diff --git a/engines/cge/bitmaps.cpp b/engines/cge/bitmaps.cpp index 8e1b7ce5e90..77012c0488b 100644 --- a/engines/cge/bitmaps.cpp +++ b/engines/cge/bitmaps.cpp @@ -225,35 +225,35 @@ static uint8 MEDesign[][9] = { { R R R R R R R R R }, // 0 namespace CGE { #ifdef DEBUG -BMP_PTR MB[] = { - new BITMAP("BRICK"), - NULL +BMP_PTR MB[] = { + new BITMAP("BRICK"), + NULL }; -BMP_PTR HL[] = { - new BITMAP("HLINE"), - NULL +BMP_PTR HL[] = { + new BITMAP("HLINE"), + NULL }; #endif -BMP_PTR MC[] = { +BMP_PTR MC[] = { new BITMAP("MOUSE"), new BITMAP("DUMMY"), NULL }; -BMP_PTR PR[] = { - new BITMAP("PRESS"), - NULL +BMP_PTR PR[] = { + new BITMAP("PRESS"), + NULL }; -BMP_PTR SP[] = { +BMP_PTR SP[] = { new BITMAP("SPK_L"), new BITMAP("SPK_R"), NULL }; -BMP_PTR LI[] = { +BMP_PTR LI[] = { new BITMAP("LITE0"), new BITMAP("LITE1"), new BITMAP("LITE2"), diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index 7c4f689e309..4fb0988d381 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -55,9 +55,9 @@ IOBUF::IOBUF(const char *name, IOMODE mode, CRYPT *crpt) } IOBUF::~IOBUF(void) { - if (Mode > REA) + if (Mode > REA) WriteBuff(); - if (Buff) + if (Buff) free(Buff); } @@ -81,18 +81,18 @@ void IOBUF::WriteBuff(void) { uint16 IOBUF::Read(void *buf, uint16 len) { uint16 total = 0; while (len) { - if (Ptr >= Lim) + if (Ptr >= Lim) ReadBuff(); uint16 n = Lim - Ptr; if (n) { - if (len < n) + if (len < n) n = len; memcpy(buf, Buff + Ptr, n); buf = (uint8 *)buf + n; len -= n; total += n; Ptr += n; - } else + } else break; } return total; @@ -103,40 +103,40 @@ uint16 IOBUF::Read(uint8 *buf) { uint16 total = 0; while (total < LINE_MAX - 2) { - if (Ptr >= Lim) + if (Ptr >= Lim) ReadBuff(); uint8 *p = Buff + Ptr; uint16 n = Lim - Ptr; if (n) { - if (total + n >= LINE_MAX - 2) + if (total + n >= LINE_MAX - 2) n = LINE_MAX - 2 - total; uint8 *eol = (uint8 *) memchr(p, '\r', n); - if (eol) + if (eol) n = (uint16)(eol - p); uint8 *eof = (uint8 *) memchr(p, '\32', n); if (eof) { // end-of-file n = (uint16)(eof - p); Ptr = (uint16)(eof - Buff); } - if (n) + if (n) memcpy(buf, p, n); buf += n; total += n; - if (eof) + if (eof) break; Ptr += n; if (eol) { ++ Ptr; * (buf ++) = '\n'; ++ total; - if (Ptr >= Lim) + if (Ptr >= Lim) ReadBuff(); - if (Ptr < Lim) - if (Buff[Ptr] == '\n') + if (Ptr < Lim) + if (Buff[Ptr] == '\n') ++Ptr; break; } - } else + } else break; } *buf = '\0'; @@ -148,7 +148,7 @@ uint16 IOBUF::Write(void *buf, uint16 len) { uint16 tot = 0; while (len) { uint16 n = IOBUF_SIZE - Lim; - if (n > len) + if (n > len) n = len; if (n) { memcpy(Buff + Lim, buf, n); @@ -156,7 +156,7 @@ uint16 IOBUF::Write(void *buf, uint16 len) { len -= n; buf = (uint8 *)buf + n; tot += n; - } else + } else WriteBuff(); } return tot; @@ -167,8 +167,8 @@ uint16 IOBUF::Write(uint8 *buf) { uint16 len = 0; if (buf) { len = strlen((const char *) buf); - if (len) - if (buf[len - 1] == '\n') + if (len) + if (buf[len - 1] == '\n') --len; len = Write(buf, len); if (len) { @@ -184,7 +184,7 @@ uint16 IOBUF::Write(uint8 *buf) { int IOBUF::Read(void) { if (Ptr >= Lim) { ReadBuff(); - if (Lim == 0) + if (Lim == 0) return -1; } return Buff[Ptr ++]; @@ -211,9 +211,9 @@ CFILE::~CFILE(void) { void CFILE::Flush(void) { - if (Mode > REA) + if (Mode > REA) WriteBuff(); - else + else Lim = 0; /* @@ -250,11 +250,11 @@ void CFILE::Append(CFILE &f) { Seek(Size()); if (f.Error == 0) { while (true) { - if ((Lim = f.IOHAND::Read(Buff, IOBUF_SIZE)) == IOBUF_SIZE) + if ((Lim = f.IOHAND::Read(Buff, IOBUF_SIZE)) == IOBUF_SIZE) WriteBuff(); - else + else break; - if ((Error = f.Error) != 0) + if ((Error = f.Error) != 0) break; } } diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 62936e8c9c8..24964da0fcc 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -1322,19 +1322,19 @@ void SPRITE::Touch(uint16 mask, int x, int y) { if (Flags.Kept || Hero->Distance(this) < MAX_DISTANCE) { if (Works(ps)) { FeedSnail(ps, TAKE); - } else + } else OffUse(); SelectPocket(-1); - } else + } else TooFar(); } else { - if (Flags.Kept) + if (Flags.Kept) mask |= L_UP; else { if (Hero->Distance(this) < MAX_DISTANCE) { /// if (Flags.Port) { - if (FindPocket(NULL) < 0) + if (FindPocket(NULL) < 0) PocFul(); else { SNPOST(SNREACH, -1, -1, this); @@ -1343,15 +1343,15 @@ void SPRITE::Touch(uint16 mask, int x, int y) { } } else { if (TakePtr != NO_PTR) { - if (SnList(TAKE)[TakePtr].Com == SNNEXT) + if (SnList(TAKE)[TakePtr].Com == SNNEXT) OffUse(); - else + else FeedSnail(this, TAKE); - } else + } else OffUse(); } }/// - else + else TooFar(); } } @@ -1365,7 +1365,7 @@ void SPRITE::Touch(uint16 mask, int x, int y) { break; } } - } else + } else SNPOST(SNWALK, -1, -1, this); // Hero->FindWay(this); } } @@ -1400,9 +1400,9 @@ static void LoadSprite(const char *fname, int ref, int cav, int col = 0, int row while ((len = sprf.Read((uint8 *)line)) != 0) { ++ lcnt; - if (len && line[len - 1] == '\n') + if (len && line[len - 1] == '\n') line[-- len] = '\0'; - if (len == 0 || *line == '.') + if (len == 0 || *line == '.') continue; if ((i = TakeEnum(Comd, strtok(line, " =\t"))) < 0) @@ -1531,42 +1531,42 @@ static void LoadScript(const char *fname) { int lcnt = 0; bool ok = true; - if (scrf.Error) + if (scrf.Error) return; while (scrf.Read((uint8 *)line) != 0) { char *p; ++lcnt; - if (*line == 0 || *line == '\n' || *line == '.') + if (*line == 0 || *line == '\n' || *line == '.') continue; ok = false; // not OK if break // sprite ident number - if ((p = strtok(line, " \t\n")) == NULL) + if ((p = strtok(line, " \t\n")) == NULL) break; SpI = atoi(p); // sprite file name - if ((SpN = strtok(NULL, " ,;/\t\n")) == NULL) + if ((SpN = strtok(NULL, " ,;/\t\n")) == NULL) break; // sprite cave - if ((p = strtok(NULL, " ,;/\t\n")) == NULL) + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; SpA = atoi(p); // sprite column - if ((p = strtok(NULL, " ,;/\t\n")) == NULL) + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; SpX = atoi(p); // sprite row - if ((p = strtok(NULL, " ,;/\t\n")) == NULL) + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; SpY = atoi(p); // sprite Z pos - if ((p = strtok(NULL, " ,;/\t\n")) == NULL) + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; SpZ = atoi(p); // sprite life - if ((p = strtok(NULL, " ,;/\t\n")) == NULL) + if ((p = strtok(NULL, " ,;/\t\n")) == NULL) break; BkG = atoi(p) == 0; @@ -1574,7 +1574,7 @@ static void LoadScript(const char *fname) { Sprite = NULL; LoadSprite(SpN, SpI, SpA, SpX, SpY, SpZ); - if (Sprite && BkG) + if (Sprite && BkG) Sprite->Flags.Back = true; } if (! ok) @@ -1688,10 +1688,10 @@ static void RunGame(void) { if ((Sprite = VGA::SpareQ.Locate(121)) != NULL) SNPOST_(SNSEQ, -1, VGA::Mono, Sprite); - if ((Sprite = VGA::SpareQ.Locate(122)) != NULL) + if ((Sprite = VGA::SpareQ.Locate(122)) != NULL) Sprite->Step(Music); SNPOST_(SNSEQ, -1, Music, Sprite); - if (! Music) + if (! Music) KillMIDI(); if (Mini && INI_FILE::Exist("MINI.SPR")) { @@ -1738,7 +1738,7 @@ static void RunGame(void) { #endif Mouse.Busy = VGA::SpareQ.Locate(BUSY_REF); - if (Mouse.Busy) + if (Mouse.Busy) ExpandSprite(Mouse.Busy); Startup = 0; @@ -1820,14 +1820,14 @@ bool ShowTitle(const char *name) { VGA::ShowQ.Append(&Mouse); HEART::Enable = true; Mouse.On(); - for (SelectSound(); ! Snail.Idle() || VMENU::Addr;) + for (SelectSound(); ! Snail.Idle() || VMENU::Addr;) MainLoop(); Mouse.Off(); HEART::Enable = false; VGA::ShowQ.Clear(); VGA::CopyPage(0, 2); STARTUP::SoundOk = 2; - if (Music) + if (Music) LoadMIDI(0); } @@ -1857,12 +1857,12 @@ bool ShowTitle(const char *name) { VGA::ShowQ.Append(&Mouse); //Mouse.On(); HEART::Enable = true; - for (TakeName(); GET_TEXT::Ptr;) + for (TakeName(); GET_TEXT::Ptr;) MainLoop(); HEART::Enable = false; - if (KEYBOARD::Last() == Enter && *UsrFnam) + if (KEYBOARD::Last() == Enter && *UsrFnam) usr_ok = true; - if (usr_ok) + if (usr_ok) strcat(UsrFnam, SVG_EXT); //Mouse.Off(); VGA::ShowQ.Clear(); @@ -1879,12 +1879,12 @@ bool ShowTitle(const char *name) { ++ STARTUP::Mode; FINIS = false; } - } else + } else ++STARTUP::Mode; } } - if (STARTUP::Mode < 2) + if (STARTUP::Mode < 2) Movie("X01"); // wink VGA::CopyPage(0, 2); @@ -1918,7 +1918,7 @@ void cge_main(void) { if (! Mouse.Exist) error("%s", Text[NO_MOUSE_TEXT]); - if (! SVG0FILE::Exist(SVG0NAME)) + if (! SVG0FILE::Exist(SVG0NAME)) STARTUP::Mode = 2; Debug(DebugLine.Flags.Hide = true;) @@ -1927,9 +1927,9 @@ void cge_main(void) { //srand((uint16) Timer()); Sys = new SYSTEM; - if (Music && STARTUP::SoundOk) + if (Music && STARTUP::SoundOk) LoadMIDI(0); - if (STARTUP::Mode < 2) + if (STARTUP::Mode < 2) Movie(LGO_EXT); if (ShowTitle("WELCOME")) { #ifndef DEMO @@ -1937,9 +1937,9 @@ void cge_main(void) { #endif RunGame(); Startup = 2; - if (FINIS) + if (FINIS) Movie("X03"); - } else + } else Vga.Sunset(); error("%s", Text[EXIT_OK_TEXT + FINIS]); } diff --git a/engines/cge/cge_main.h b/engines/cge/cge_main.h index a67cd290000..fa27274803e 100644 --- a/engines/cge/cge_main.h +++ b/engines/cge/cge_main.h @@ -39,7 +39,6 @@ namespace CGE { #define NO_WAY (TSEQ+5) #define POC_FUL (TSEQ+5) #define OFF_USE (TSEQ+6) - #define EXIT_OK_TEXT 40 #define NOMUSIC_TEXT 98 #define BADSVG_TEXT 99 @@ -49,19 +48,15 @@ namespace CGE { #define TOO_FAR_TEXT 681 #define POC_FUL_TEXT 691 #define A_C_D_TEXT 777 - #define GETNAME_PROMPT 50 #define GETNAME_TITLE 51 - #define QUIT_TITLE 200 #define QUIT_TEXT 201 #define NOQUIT_TEXT 202 #define DEMO_TEXT 300 #define NOSOUND_TEXT 310 - #define PAN_HIG 40 #define WORLD_HIG (SCR_HIG-PAN_HIG) - #define INFO_X 177 #define INFO_Y 164 #define INFO_W 140 @@ -75,7 +70,7 @@ namespace CGE { #define CAVE_DY 29 #define CAVE_NX 3 #define CAVE_NY 1 -#else +#else #define CAVE_X 4 #define CAVE_Y 166 #define CAVE_SX 0 @@ -92,19 +87,14 @@ namespace CGE { #define BUTTON_DY 11 #define BUTTON_NX 1 #define BUTTON_NY 3 - #define MINI_X 86 #define MINI_Y 162 - -//#define MAP_XCNT 16 -//#define MAP_ZCNT 4 #define MAP_XCNT 40 #define MAP_ZCNT 20 #define MAP_TOP 80 #define MAP_HIG 80 #define MAP_XGRID (SCR_WID / MAP_XCNT) #define MAP_ZGRID (MAP_HIG / MAP_ZCNT) - #define LINE_MAX 512 #define USER_MAX 100 #define SHP_MAX 1024 @@ -113,16 +103,12 @@ namespace CGE { #define CAVE_MAX (CAVE_NX*CAVE_NY) #define MAX_FIND_LEVEL 3 #define MAX_DISTANCE 3 - #define INI_EXT ".INI" #define IN0_EXT ".IN0" #define LGO_EXT ".LGO" #define SVG_EXT ".SVG" - #define WALKSIDE 10 - #define BUSY_REF 500 - #define SYSTIMERATE 6 // 12 Hz #define HEROFUN0 (40*12) #define HEROFUN1 ( 2*12) diff --git a/engines/cge/config.cpp b/engines/cge/config.cpp index c1e9ae4762b..19000935209 100644 --- a/engines/cge/config.cpp +++ b/engines/cge/config.cpp @@ -72,12 +72,12 @@ static void SetIRQ(void); static void SetDMA(void); -static int DevName[] = { +static int DevName[] = { NONE_TEXT, SB_TEXT, SBM_TEXT, GUS_TEXT, GUSM_TEXT, MIDI_TEXT, AUTO_TEXT }; -static CHOICE DevMenu[] = { +static CHOICE DevMenu[] = { { NULL, NONE }, { NULL, SB }, { NULL, SBM }, @@ -89,7 +89,7 @@ static CHOICE DevMenu[] = { }; -static CHOICE DigiPorts[] = { +static CHOICE DigiPorts[] = { { " 210h", SetPortD }, { " 220h", SetPortD }, { " 230h", SetPortD }, @@ -100,7 +100,7 @@ static CHOICE DigiPorts[] = { { NULL, NULL } }; -static CHOICE MIDIPorts[] = { +static CHOICE MIDIPorts[] = { { " 220h", SetPortM }, { " 230h", SetPortM }, { " 240h", SetPortM }, @@ -115,7 +115,7 @@ static CHOICE MIDIPorts[] = { { NULL, NULL } }; -static CHOICE BlsterIRQ[] = { +static CHOICE BlsterIRQ[] = { { "IRQ 2", SetIRQ }, { "IRQ 5", SetIRQ }, { "IRQ 7", SetIRQ }, @@ -124,7 +124,7 @@ static CHOICE BlsterIRQ[] = { { NULL, NULL } }; -static CHOICE GravisIRQ[] = { +static CHOICE GravisIRQ[] = { { "IRQ 2", SetIRQ }, { "IRQ 5", SetIRQ }, { "IRQ 7", SetIRQ }, @@ -135,7 +135,7 @@ static CHOICE GravisIRQ[] = { { NULL, NULL } }; -static CHOICE GravisDMA[] = { +static CHOICE GravisDMA[] = { { "DMA 1", SetDMA }, { "DMA 3", SetDMA }, { "DMA 5", SetDMA }, @@ -145,7 +145,7 @@ static CHOICE GravisDMA[] = { { NULL, NULL } }; -static CHOICE BlsterDMA[] = { +static CHOICE BlsterDMA[] = { { "DMA 0", SetDMA }, { "DMA 1", SetDMA }, { "DMA 3", SetDMA }, @@ -157,7 +157,7 @@ static CHOICE BlsterDMA[] = { void SelectSound(void) { int i; Sound.Close(); - if (VMENU::Addr) + if (VMENU::Addr) SNPOST_(SNKILL, -1, 0, VMENU::Addr); Inf(Text[STYPE_TEXT]); Talk->Goto(Talk->X, FONT_HIG / 2); @@ -173,11 +173,11 @@ static void Reset(void) { static uint16 deco(const char *str, uint16(*dco)(const char *)) { - while (*str && ! IsDigit(*str)) + while (*str && ! IsDigit(*str)) ++str; - if (*str) + if (*str) return dco(str); - else + else return DETECT; } @@ -286,9 +286,9 @@ static void SetIRQ(void) { static void SetDMA(void) { SNDDrvInfo.DDMA = ddeco(((SNDDrvInfo.DDEV == DEV_SB) ? BlsterDMA : GravisDMA)[VMENU::Recent].Text); - if (SNDDrvInfo.MDEV != SNDDrvInfo.DDEV) + if (SNDDrvInfo.MDEV != SNDDrvInfo.DDEV) Select(MIDIPorts, MPORT_TEXT); - else + else Sound.Open(); } diff --git a/engines/cge/ems.cpp b/engines/cge/ems.cpp index b6540005538..7b0697cd8a0 100644 --- a/engines/cge/ems.cpp +++ b/engines/cge/ems.cpp @@ -34,7 +34,7 @@ namespace CGE { #define SIZ(n) ((n) ? ((long)n) : (0x10000L)) -enum EMM_FUN { +enum EMM_FUN { GET_STATUS = 0x40, GET_FRAME, GET_SIZE, OPEN_HANDLE, MAP_PAGE, CLOSE_HANDLE, GET_VER, SAVE_CONTEXT, REST_CONTEXT, GET_PAGES = 0x4B, GET_HANDLES, GET_INFO, CONTROL diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp index 25af315d988..4102e080b61 100644 --- a/engines/cge/game.cpp +++ b/engines/cge/game.cpp @@ -83,9 +83,9 @@ void FLY::Tick(void) { Tx = new_random(3) - 1; Ty = new_random(3) - 1; } - if (X + Tx < L || X + Tx + W > R) + if (X + Tx < L || X + Tx + W > R) Tx = -Tx; - if (Y + Ty < T || Y + Ty + H > B) + if (Y + Ty < T || Y + Ty + H > B) Ty = -Ty; Goto(X + Tx, Y + Ty); } diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 3a0114c672e..e68533d0b2c 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -187,7 +187,7 @@ char *wtom(uint16 val, char *str, int radix, int len) { char *dwtom(uint32 val, char *str, int radix, int len) { while (--len >= 0) { uint16 w = (uint16) (val % radix); - if (w > 9) + if (w > 9) w += ('A' - ('9' + 1)); str[len] = '0' + w; val /= radix; diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp index 78cc0356a1c..4399a30916e 100644 --- a/engines/cge/gettext.cpp +++ b/engines/cge/gettext.cpp @@ -75,7 +75,7 @@ void GET_TEXT::Touch(uint16 mask, int x, int y) { char *p; if (mask & KEYB) { - if (Click) + if (Click) Click(); switch (x) { case Enter : @@ -83,7 +83,7 @@ void GET_TEXT::Touch(uint16 mask, int x, int y) { strcpy(Text, Buff); for (p = Text; *p; p ++) { char *q = strchr(ogon, *p); - if (q) + if (q) *p = bezo[q - ogon]; } case Esc : @@ -103,7 +103,7 @@ void GET_TEXT::Touch(uint16 mask, int x, int y) { } else { if (KEYBOARD::Key[ALT]) { p = strchr(bezo, x); - if (p) + if (p) x = ogon[p - bezo]; } if (Len < Size && 2 * TEXT_HM + Font.Width(Buff) + Font.Wid[x] <= W) { @@ -114,7 +114,7 @@ void GET_TEXT::Touch(uint16 mask, int x, int y) { } break; } - } else + } else SPRITE::Touch(mask, x, y); } diff --git a/engines/cge/keybd.cpp b/engines/cge/keybd.cpp index a4590f49804..35e6c72c112 100644 --- a/engines/cge/keybd.cpp +++ b/engines/cge/keybd.cpp @@ -34,26 +34,26 @@ namespace CGE { SPRITE *KEYBOARD::Client = NULL; uint8 KEYBOARD::Key[0x60] = { 0 }; uint16 KEYBOARD::Current = 0; -uint16 KEYBOARD::Code[0x60] = { - 0, Esc, '1', '2', '3', - '4', '5', '6', '7', '8', - '9', '0', '-', '+', BSp, - Tab, 'Q', 'W', 'E', 'R', - 'T', 'Y', 'U', 'I', 'O', - 'P', '[', ']', Enter, 0/*Ctrl*/, - 'A', 'S', 'D', 'F', 'G', - 'H', 'J', 'K', 'L', ';', - '\'', '`', 0/*LShift*/, '\\', 'Z', - 'X', 'C', 'V', 'B', 'N', - 'M', ',', '.', '/', 0/*RShift*/, - '*', 0/*Alt*/, ' ', 0/*Caps*/, F1, - F2, F3, F4, F5, F6, - F7, F8, F9, F10, 0/*NumLock*/, - 0/*ScrollLock*/, Home, Up, PgUp, '-', - Left, Ctr, Right, '+', End, - Down, PgDn, Ins, Del, 0 * 0x54, - 0 * 0x55, 0 * 0x56, F11, F12, 0 * 0x59, - 0 * 0x5A, 0 * 0x5B, 0 * 0x5C, 0 * 0x5D, 0 * 0x5E, +uint16 KEYBOARD::Code[0x60] = { + 0, Esc, '1', '2', '3', + '4', '5', '6', '7', '8', + '9', '0', '-', '+', BSp, + Tab, 'Q', 'W', 'E', 'R', + 'T', 'Y', 'U', 'I', 'O', + 'P', '[', ']', Enter, 0/*Ctrl*/, + 'A', 'S', 'D', 'F', 'G', + 'H', 'J', 'K', 'L', ';', + '\'', '`', 0/*LShift*/, '\\', 'Z', + 'X', 'C', 'V', 'B', 'N', + 'M', ',', '.', '/', 0/*RShift*/, + '*', 0/*Alt*/, ' ', 0/*Caps*/, F1, + F2, F3, F4, F5, F6, + F7, F8, F9, F10, 0/*NumLock*/, + 0/*ScrollLock*/, Home, Up, PgUp, '-', + Left, Ctr, Right, '+', End, + Down, PgDn, Ins, Del, 0 * 0x54, + 0 * 0x55, 0 * 0x56, F11, F12, 0 * 0x59, + 0 * 0x5A, 0 * 0x5B, 0 * 0x5C, 0 * 0x5D, 0 * 0x5E, 0 * 0x5F }; diff --git a/engines/cge/mixer.cpp b/engines/cge/mixer.cpp index 47a6e17fc9a..83d9cd1be56 100644 --- a/engines/cge/mixer.cpp +++ b/engines/cge/mixer.cpp @@ -76,7 +76,7 @@ MIXER::MIXER(int x, int y) : SPRITE(NULL), Fall(MIX_FALL) { Led[ArrayCount(Led) - 1]->Flags.BDel = true; VGA::ShowQ.Insert(this); - for (i = 0; i < ArrayCount(Led); i ++) + for (i = 0; i < ArrayCount(Led); i ++) VGA::ShowQ.Insert(Led[i]); //--- reset balance @@ -101,10 +101,10 @@ void MIXER::Touch(uint16 mask, int x, int y) { if (mask & L_UP) { uint8 *vol = (&SNDDrvInfo.VOL2.D) + (x < W / 2); if (y < MIX_BHIG) { - if (*vol < 0xFF) + if (*vol < 0xFF) *vol += 0x11; } else if (y >= H - MIX_BHIG) { - if (*vol > 0x00) + if (*vol > 0x00) *vol -= 0x11; } Update(); @@ -116,10 +116,10 @@ void MIXER::Tick(void) { int x = Mouse.X, y = Mouse.Y; if (SpriteAt(x, y) == this) { Fall = MIX_FALL; - if (Flags.Hold) + if (Flags.Hold) Touch(L_UP, x - X, y - Y); } else { - if (Fall) + if (Fall) --Fall; else { for (int i = 0; i < ArrayCount(Led); i ++) diff --git a/engines/cge/mouse.cpp b/engines/cge/mouse.cpp index d97a7eca7f4..9bb9626deb4 100644 --- a/engines/cge/mouse.cpp +++ b/engines/cge/mouse.cpp @@ -40,9 +40,9 @@ uint16 MOUSE::OldMouseMask = 0; MOUSE::MOUSE(BITMAP **shpl) : SPRITE(shpl), Busy(NULL), Hold(NULL), hx(0) { - static SEQ ms[] = { - { 0, 0, 0, 0, 1 }, - { 1, 1, 0, 0, 1 } + static SEQ ms[] = { + { 0, 0, 0, 0, 1 }, + { 1, 1, 0, 0, 1 } }; SetSeq(ms); @@ -135,9 +135,9 @@ void MOUSE::ClrEvt(SPRITE *spr) { if (spr) { uint16 e; for (e = EvtTail; e != EvtHead; e = (e + 1) % EVT_MAX) - if (Evt[e].Ptr == spr) + if (Evt[e].Ptr == spr) Evt[e].Msk = 0; - } else + } else EvtTail = EvtHead; } @@ -156,11 +156,11 @@ void MOUSE::Tick(void) { // activate current touched SPRITE if (e.Ptr) { - if (e.Msk & KEYB) + if (e.Msk & KEYB) e.Ptr->Touch(e.Msk, e.X, e.Y); - else + else e.Ptr->Touch(e.Msk, e.X - e.Ptr->X, e.Y - e.Ptr->Y); - } else if (Sys) + } else if (Sys) Sys->Touch(e.Msk, e.X, e.Y); if (e.Msk & L_DN) { @@ -186,7 +186,7 @@ void MOUSE::Tick(void) { ///Touched = e.Ptr; // discard Text if button released - if (e.Msk & (L_UP | R_UP)) + if (e.Msk & (L_UP | R_UP)) KillText(); } EvtTail = (EvtTail + 1) % EVT_MAX; diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index 952e0322222..cc52ec63dc9 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -88,7 +88,7 @@ static void SNGame(SPRITE *spr, int num) { if (Game) { // continue game int i = new_random(3), hand = (dup[0]->ShpCnt == 6); ++ Stage; - if (hand && Stage > DRESSED) + if (hand && Stage > DRESSED) ++hand; if (Debug(i >= 0 ||) dup[i] == spr && new_random(3) == 0) { @@ -138,8 +138,8 @@ static void SNGame(SPRITE *spr, int num) { SNPOST(SNSEQ, -1, 2, dup[1]); // no SNPOST(SNSEQ, -1, 2, dup[2]); // no SNPOST(SNPAUSE, -1, 72, NULL); // 1 sec - } - } + } + } SNPOST(SNWALK, 198, 134, NULL); // na miejsce SNPOST(SNWAIT, 1, -1, NULL); // stoi SNPOST(SNCOVER, 1, 16101, NULL); // ch’op do bicia @@ -152,7 +152,7 @@ static void SNGame(SPRITE *spr, int num) { SNPOST(SNSEQ, 16040, 0, NULL); // schowaj plask SNPOST(SNWAIT, 16101, -1, NULL); // stoi SNPOST(SNUNCOVER, 1, 16101, NULL); // SDS - if (! Game) { + if (! Game) { SNPOST(SNSAY, buref, 16008, NULL); // zgadnij! Game = true; } @@ -200,13 +200,13 @@ static void SNGame(SPRITE *spr, int num) { SNPOST(SNKEEP, 20007, 0, NULL); // do kieszeni SNPOST(SNSEND, 20006, 20, NULL); // bilon SNPOST(SNSOUND, 20006, 20002, NULL); // bilon! - SNPOST(SNSAY, 20002, 20004, NULL); + SNPOST(SNSAY, 20002, 20004, NULL); SNPOST(SNSEND, 20010, 20, NULL); // papier SNPOST(SNSOUND, 20010, 20003, NULL); // papier! SNPOST(SNSAY, 20001, 20005, NULL); Game = false; return; - } else + } else k3->Step(new_random(5)); } if (count < 100) { @@ -237,7 +237,7 @@ static void SNGame(SPRITE *spr, int num) { SNPOST(SNWAIT, 20007, -1, NULL); // koniec SNPOST(SNGAME, 20001, 2, NULL); // again! break; - case 20001 : + case 20001: SNPOST(SNSAY, 20002, 20012, NULL); // zapro SNPOST(SNSEQ, 20002, 1, NULL); // rzu SNPOST(SNWAIT, 20002, 3, NULL); // czekaj @@ -249,8 +249,8 @@ static void SNGame(SPRITE *spr, int num) { SNPOST(SNSOUND, 20007, 20001, NULL); // grzech SNPOST(SNWAIT, 20007, -1, NULL); // koniec SNPOST(SNGAME, 20002, 2, NULL); // again! - break; - case 20002 : + break; + case 20002: SNPOST(SNSAY, 20002, 20010, NULL); // zapro SNPOST(SNWALK, 20005, -1, NULL); // do stol SNPOST(SNWAIT, 1, -1, NULL); // stoi @@ -276,19 +276,19 @@ static void SNGame(SPRITE *spr, int num) { void ExpandSprite(SPRITE *spr) { - if (spr) + if (spr) VGA::ShowQ.Insert(VGA::SpareQ.Remove(spr)); } void ContractSprite(SPRITE *spr) { - if (spr) + if (spr) VGA::SpareQ.Append(VGA::ShowQ.Remove(spr)); } int FindPocket(SPRITE *spr) { - for (int i = 0; i < POCKET_NX; i ++) - if (Pocket[i] == spr) + for (int i = 0; i < POCKET_NX; i ++) + if (Pocket[i] == spr) return i; return -1; } @@ -298,7 +298,7 @@ void SelectPocket(int n) { if (n < 0 || (PocLight.SeqPtr && PocPtr == n)) { PocLight.Step(0); n = FindPocket(NULL); - if (n >= 0) + if (n >= 0) PocPtr = n; } else { if (Pocket[n] != NULL) { @@ -335,7 +335,7 @@ void SNGhost(BITMAP *bmp) { void FeedSnail(SPRITE *spr, SNLIST snq) { - if (spr) + if (spr) if (spr->Active()) { uint8 ptr = (snq == TAKE) ? spr->TakePtr : spr->NearPtr; @@ -350,13 +350,13 @@ void FeedSnail(SPRITE *spr, SNLIST snq) { PocFul(); return; } - if (p->Ptr) + if (p->Ptr) break; } } while (true) { if (c->Com == SNTALK) { - if ((Snail.TalkEnable = (c->Val != 0)) == false) + if ((Snail.TalkEnable = (c->Val != 0)) == false) KillText(); } if (c->Com == SNNEXT) { @@ -379,27 +379,27 @@ void FeedSnail(SPRITE *spr, SNLIST snq) { v = c->Val; break; } - if (v >= 0) + if (v >= 0) *idx = v; } } - if (s == spr) + if (s == spr) break; } if (c->Com == SNIF) { SPRITE *s = (c->Ref < 0) ? spr : Locate(c->Ref); if (s) { // sprite extsts - if (! s->SeqTest(-1)) + if (! s->SeqTest(-1)) c = comtab + c->Val; // not parked - else + else ++c; - } else + } else ++c; } else { SNPOST(c->Com, c->Ref, c->Val, spr); - if (c->Ptr) + if (c->Ptr) break; - else + else ++c; } } @@ -408,17 +408,17 @@ void FeedSnail(SPRITE *spr, SNLIST snq) { } -const char *SNAIL::ComTxt[] = { - "LABEL", "PAUSE", "WAIT", "LEVEL", "HIDE", - "SAY", "INF", "TIME", "CAVE", "KILL", - "RSEQ", "SEQ", "SEND", "SWAP", "KEEP", - "GIVE", "IF", "GAME", "SETX0", "SETY0", +const char *SNAIL::ComTxt[] = { + "LABEL", "PAUSE", "WAIT", "LEVEL", "HIDE", + "SAY", "INF", "TIME", "CAVE", "KILL", + "RSEQ", "SEQ", "SEND", "SWAP", "KEEP", + "GIVE", "IF", "GAME", "SETX0", "SETY0", "SLAVE", "SETXY", "RELX", "RELY", "RELZ", "SETX", "SETY", "SETZ", "TRANS", "PORT", "NEXT", "NNEXT", "TNEXT", "RNNEXT", "RTNEXT", - "RMNEAR", "RMTAKE", "FLAG", "SETREF", "BACKPT", - "FLASH", "LIGHT", "SETHB", "SETVB", "WALK", - "REACH", "COVER", "UNCOVER", "CLEAR", "TALK", + "RMNEAR", "RMTAKE", "FLAG", "SETREF", "BACKPT", + "FLASH", "LIGHT", "SETHB", "SETVB", "WALK", + "REACH", "COVER", "UNCOVER", "CLEAR", "TALK", "MOUSE", "SOUND", "COUNT", NULL }; @@ -431,7 +431,7 @@ SNAIL::SNAIL(bool turbo) SNAIL::~SNAIL(void) { - if (SNList) + if (SNList) free(SNList); } @@ -459,7 +459,7 @@ void SNAIL::InsCom(SNCOM com, int ref, int val, void *ptr) { if (Busy) { SNList[(Tail - 1) & 0xFF] = SNList[Tail]; snc = &SNList[Tail]; - } else + } else snc = &SNList[(Tail - 1) & 0xFF]; --Tail; snc->Com = com; @@ -476,35 +476,35 @@ void SNAIL::InsCom(SNCOM com, int ref, int val, void *ptr) { static void SNNNext(SPRITE *sprel, int p) { - if (sprel) - if (sprel->NearPtr != NO_PTR) + if (sprel) + if (sprel->NearPtr != NO_PTR) sprel->NearPtr = p; } static void SNTNext(SPRITE *sprel, int p) { - if (sprel) - if (sprel->TakePtr != NO_PTR) + if (sprel) + if (sprel->TakePtr != NO_PTR) sprel->TakePtr = p; } static void SNRNNext(SPRITE *sprel, int p) { - if (sprel) - if (sprel->NearPtr != NO_PTR) + if (sprel) + if (sprel->NearPtr != NO_PTR) sprel->NearPtr += p; } static void SNRTNext(SPRITE *sprel, int p) { - if (sprel) - if (sprel->TakePtr != NO_PTR) + if (sprel) + if (sprel->TakePtr != NO_PTR) sprel->TakePtr += p; } static void SNZTrim(SPRITE *spr) { - if (spr) + if (spr) if (spr->Active()) { bool en = HEART::Enable; SPRITE *s; @@ -523,36 +523,36 @@ static void SNZTrim(SPRITE *spr) { static void SNHide(SPRITE *spr, int val) { if (spr) { spr->Flags.Hide = (val >= 0) ? (val != 0) : (! spr->Flags.Hide); - if (spr->Flags.Shad) + if (spr->Flags.Shad) spr->Prev->Flags.Hide = spr->Flags.Hide; } } static void SNRmNear(SPRITE *spr) { - if (spr) + if (spr) spr->NearPtr = NO_PTR; } static void SNRmTake(SPRITE *spr) { - if (spr) + if (spr) spr->TakePtr = NO_PTR; } void SNSeq(SPRITE *spr, int val) { if (spr) { - if (spr == Hero && val == 0) + if (spr == Hero && val == 0) Hero->Park(); - else + else spr->Step(val); } } void SNRSeq(SPRITE *spr, int val) { - if (spr) + if (spr) SNSeq(spr, spr->SeqPtr + val); } @@ -567,18 +567,18 @@ void SNSend(SPRITE *spr, int val) { if (was1) { if (spr->Flags.Kept) { int n = FindPocket(spr); - if (n >= 0) + if (n >= 0) Pocket[n] = NULL; } Hide1(spr); ContractSprite(spr); spr->Flags.Slav = false; } else { - if (spr->Ref % 1000 == 0) + if (spr->Ref % 1000 == 0) BITMAP::Pal = SysPal; - if (spr->Flags.Back) + if (spr->Flags.Back) spr->BackShow(true); - else + else ExpandSprite(spr); BITMAP::Pal = NULL; } @@ -601,7 +601,7 @@ void SNSwap(SPRITE *spr, int xref) { Swap(spr->Z, xspr->Z); if (spr->Flags.Kept) { int n = FindPocket(spr); - if (n >= 0) + if (n >= 0) Pocket[n] = xspr; xspr->Flags.Kept = true; xspr->Flags.Port = false; @@ -610,12 +610,12 @@ void SNSwap(SPRITE *spr, int xref) { if (was1) { Hide1(spr); ContractSprite(spr); - } else + } else ExpandSprite(spr); if (xwas1) { Hide1(xspr); ContractSprite(xspr); - } else + } else ExpandSprite(xspr); } } @@ -650,7 +650,7 @@ void SNUncover(SPRITE *spr, SPRITE *xspr) { } spr->Z = xspr->Z; SNSend(xspr, -1); - if (spr->Time == 0) + if (spr->Time == 0) ++spr->Time; } } @@ -742,21 +742,21 @@ void SNKill(SPRITE *spr) { if (spr) { if (spr->Flags.Kept) { int n = FindPocket(spr); - if (n >= 0) + if (n >= 0) Pocket[n] = NULL; } SPRITE *nx = spr->Next; Hide1(spr); VGA::ShowQ.Remove(spr); MOUSE::ClrEvt(spr); - if (spr->Flags.Kill) + if (spr->Flags.Kill) delete spr; else { spr->Cave = -1; VGA::SpareQ.Append(spr); } - if (nx) - if (nx->Flags.Slav) + if (nx) + if (nx->Flags.Slav) SNKill(nx); } } @@ -764,7 +764,7 @@ void SNKill(SPRITE *spr) { static void SNSound(SPRITE *spr, int wav, int cnt) { if (SNDDrvInfo.DDEV) { - if (wav == -1) + if (wav == -1) Sound.Stop(); else Sound.Play(Fx[wav], (spr) ? ((spr->X + spr->W / 2) / (SCR_WID / 16)) : 8, cnt); @@ -781,7 +781,7 @@ void SNKeep(SPRITE *spr, int stp) { spr->Flags.Kept = true; spr->Goto(POCKET_X + POCKET_DX * PocPtr + POCKET_DX / 2 - spr->W / 2, POCKET_Y + POCKET_DY / 2 - spr->H / 2); - if (stp >= 0) + if (stp >= 0) spr->Step(stp); } SelectPocket(-1); @@ -795,7 +795,7 @@ void SNGive(SPRITE *spr, int stp) { Pocket[p] = NULL; spr->Cave = Now; spr->Flags.Kept = false; - if (stp >= 0) + if (stp >= 0) spr->Step(stp); } } @@ -805,7 +805,7 @@ void SNGive(SPRITE *spr, int stp) { static void SNBackPt(SPRITE *spr, int stp) { if (spr) { - if (stp >= 0) + if (stp >= 0) spr->Step(stp); spr->BackShow(true); } @@ -828,7 +828,7 @@ static void SNLevel(SPRITE *spr, int lev) { } } MaxCave = maxcav[Lev]; - if (spr) + if (spr) spr->Flags.Hide = false; } @@ -860,14 +860,14 @@ void SNFlash(bool on) { } VGA::SetColors(pal, 64); } - } else + } else VGA::SetColors(SysPal, 64); Dark = false; } static void SNLight(bool in) { - if (in) + if (in) VGA::Sunrise(SysPal); else VGA::Sunset(); @@ -882,16 +882,16 @@ static void SNBarrier(int cav, int bar, bool horz) { static void SNWalk(SPRITE *spr, int x, int y) { if (Hero) { - if (spr && y < 0) + if (spr && y < 0) Hero->FindWay(spr); - else + else Hero->FindWay(XZ(x, y)); } } static void SNReach(SPRITE *spr, int mode) { - if (Hero) + if (Hero) Hero->Reach(spr, mode); } @@ -914,7 +914,7 @@ void SNAIL::RunCom(void) { COM *snc = &SNList[Tail]; if (! Turbo) { // only for the slower one - if (Pause) + if (Pause) break; else { if (TextDelay) { @@ -922,7 +922,7 @@ void SNAIL::RunCom(void) { TextDelay = false; } } - if (Talk && snc->Com != SNPAUSE) + if (Talk && snc->Com != SNPAUSE) break; } @@ -932,7 +932,7 @@ void SNAIL::RunCom(void) { break; case SNPAUSE : HEART::SetXTimer(&Pause, snc->Val); - if (Talk) + if (Talk) TextDelay = true; break; case SNWAIT : @@ -940,7 +940,7 @@ void SNAIL::RunCom(void) { if (sprel->SeqTest(snc->Val) && (snc->Val >= 0 || sprel != Hero || Hero->TracePtr < 0)) { HEART::SetXTimer(&Pause, sprel->Time); - } else + } else goto xit; } break; @@ -1116,7 +1116,7 @@ void SNAIL::RunCom(void) { break; } ++Tail; - if (!Turbo) + if (!Turbo) break; } xit: diff --git a/engines/cge/snail.h b/engines/cge/snail.h index f9b969a5545..4255ea4e616 100644 --- a/engines/cge/snail.h +++ b/engines/cge/snail.h @@ -61,16 +61,16 @@ struct SCB { enum SNCOM { SNLABEL, SNPAUSE, SNWAIT, SNLEVEL, SNHIDE, - SNSAY, SNINF, SNTIME, SNCAVE, SNKILL, - SNRSEQ, SNSEQ, SNSEND, SNSWAP, SNKEEP, - SNGIVE, SNIF, SNGAME, SNSETX0, SNSETY0, + SNSAY, SNINF, SNTIME, SNCAVE, SNKILL, + SNRSEQ, SNSEQ, SNSEND, SNSWAP, SNKEEP, + SNGIVE, SNIF, SNGAME, SNSETX0, SNSETY0, SNSLAVE, SNSETXY, SNRELX, SNRELY, SNRELZ, SNSETX, SNSETY, SNSETZ, SNTRANS, SNPORT, SNNEXT, SNNNEXT, SNTNEXT, SNRNNEXT, SNRTNEXT, - SNRMNEAR, SNRMTAKE, SNFLAG, SNSETREF, SNBACKPT, - SNFLASH, SNLIGHT, SNSETHB, SNSETVB, SNWALK, - SNREACH, SNCOVER, SNUNCOVER, SNCLEAR, SNTALK, - SNMOUSE, SNSOUND, SNCOUNT, SNEXEC, SNSTEP, + SNRMNEAR, SNRMTAKE, SNFLAG, SNSETREF, SNBACKPT, + SNFLASH, SNLIGHT, SNSETHB, SNSETVB, SNWALK, + SNREACH, SNCOVER, SNUNCOVER, SNCLEAR, SNTALK, + SNMOUSE, SNSOUND, SNCOUNT, SNEXEC, SNSTEP, SNZTRIM, SNGHOST }; diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index 397684849a0..04e5d9464a3 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -41,7 +41,7 @@ SOUND Sound; SOUND::SOUND(void) { - if (STARTUP::SoundOk) + if (STARTUP::SoundOk) Open(); } @@ -115,7 +115,7 @@ int FX::Find(int ref) { for (p = Cache, q = p + Size; p < q; p ++) { if (p->Ref == ref) break; - else + else ++i; } return i; @@ -133,7 +133,7 @@ void FX::Preload(int ref0) { DATACK *wav = LoadWave(&file, &Emm); if (wav) { HAN *p = &Cache[Find(0)]; - if (p >= CacheLim) + if (p >= CacheLim) break; p->Wav = wav; p->Ref = ref; @@ -159,7 +159,7 @@ DATACK *FX::Load(int idx, int ref) { DATACK *FX::operator [](int ref) { int i; - if ((i = Find(ref)) < Size) + if ((i = Find(ref)) < Size) Current = Cache[i].Wav; else { if ((i = Find(0)) >= Size) { @@ -195,7 +195,7 @@ void LoadMIDI(int ref) { midi = new uint8[siz]; if (midi) { mid.Read(midi, siz); - if (mid.Error) + if (mid.Error) KillMIDI(); else SNDMIDIStart(midi); diff --git a/engines/cge/startup.cpp b/engines/cge/startup.cpp index 2bed51af971..24aaf3e042a 100644 --- a/engines/cge/startup.cpp +++ b/engines/cge/startup.cpp @@ -160,25 +160,25 @@ const char *UsrPath(const char *nam) { int i = strlen(key); while (ini.Read(buf) && !ok) { int j = strlen(buf); - if (j) - if (buf[--j] == '\n') + if (j) + if (buf[--j] == '\n') buf[j] = '\0'; - if (memicmp(buf, key, i) == 0) + if (memicmp(buf, key, i) == 0) ok = true; } if (ok) { strcpy(buf, buf + i); p = buf + strlen(buf); - if (*(p - 1) != '\\') + if (*(p - 1) != '\\') *(p++) = '\\'; strcpy(p, "NUL"); - if (_dos_open(buf, 0, &i) == 0) + if (_dos_open(buf, 0, &i) == 0) _dos_close(i); - else + else ok = false; } } - if (!ok) + if (!ok) quit_now(BADCD_TEXT); } #endif diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index 1dbcbad98da..e707e4e7056 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -79,8 +79,8 @@ void FONT::Load(void) { uint16 FONT::Width(const char *text) { uint16 w = 0; - if (text) - while (* text) + if (text) + while (* text) w += Wid[*(text ++)]; return w; } @@ -141,13 +141,13 @@ void TALK::Update(const char *tx) { for (p = tx; *p; p ++) { if (*p == '|' || *p == '\n') { mh += FONT_HIG + TEXT_LS; - if (k > mw) + if (k > mw) mw = k; k = 2 * hmarg; - } else + } else k += Font.Wid[*p]; } - if (k > mw) + if (k > mw) mw = k; TS[0] = Box(mw, mh); } @@ -165,7 +165,7 @@ void TALK::Update(const char *tx) { uint16 n; register uint16 b = *(f++); for (n = 0; n < FONT_HIG; n++) { - if (b & 1) + if (b & 1) *p = TEXT_FG; b >>= 1; p += mw; @@ -186,9 +186,9 @@ BITMAP *TALK::Box(uint16 w, uint16 h) { uint8 *b, * p, * q; uint16 n, r = (Mode == ROUND) ? TEXT_RD : 0; - if (w < 8) + if (w < 8) w = 8; - if (h < 8) + if (h < 8) h = 8; b = farnew(uint8, n = w * h); if (! b) @@ -263,13 +263,13 @@ void TALK::PutLine(int line, const char *text) { register uint16 b = fp[i]; uint16 n; for (n = 0; n < FONT_HIG; n ++) { - if (b & 1) + if (b & 1) *p = TEXT_FG; b >>= 1; p += lsiz; } p = p - rsiz + psiz; - if (p >= q) + if (p >= q) p = p - size + 1; } ++text; @@ -310,12 +310,12 @@ void INFO_LINE::Update(const char *tx) { for (uint16 i = 0; i < cw; i++) { register uint16 b = fp[i]; for (uint16 n = 0; n < FONT_HIG; n ++) { - if (b & 1) + if (b & 1) *p = TEXT_FG; b >>= 1; p += lsiz; } - if (p >= q) + if (p >= q) p = p - size + 1; } ++tx; diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 71f4f156d53..92951196c7b 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -79,7 +79,7 @@ int TEXT::Find(int ref) { for (p = Cache, q = p + Size; p < q; p ++) { if (p->Ref == ref) break; - else + else ++i; } return i; @@ -111,14 +111,14 @@ void TEXT::Preload(int from, int upto) { if (p < CacheLim) { delete[] p->Txt; p->Txt = NULL; - } else + } else p = &Cache[Find(0)]; - if (p >= CacheLim) + if (p >= CacheLim) break; s += strlen(s); - if (s < line + n) + if (s < line + n) ++s; - if ((p->Txt = new char[strlen(s) + 1]) == NULL) + if ((p->Txt = new char[strlen(s) + 1]) == NULL) break; p->Ref = ref; strcpy(p->Txt, s); @@ -138,24 +138,24 @@ char *TEXT::Load(int idx, int ref) { while ((n = tf.Read((uint8 *)line)) != 0) { char *s; - if (line[n - 1] == '\n') + if (line[n - 1] == '\n') line[-- n] = '\0'; - if ((s = strtok(line, " =,;/\t\n")) == NULL) + if ((s = strtok(line, " =,;/\t\n")) == NULL) continue; - if (! IsDigit(*s)) + if (! IsDigit(*s)) continue; int r = atoi(s); - if (r < ref) + if (r < ref) continue; - if (r > ref) + if (r > ref) break; // (r == ref) s += strlen(s); - if (s < line + n) + if (s < line + n) ++s; p->Ref = ref; - if ((p->Txt = new char[strlen(s) + 1]) == NULL) + if ((p->Txt = new char[strlen(s) + 1]) == NULL) return NULL; return strcpy(p->Txt, s); } @@ -166,7 +166,7 @@ char *TEXT::Load(int idx, int ref) { char *TEXT::operator [](int ref) { int i; - if ((i = Find(ref)) < Size) + if ((i = Find(ref)) < Size) return Cache[i].Txt; if ((i = Find(0)) >= Size) { @@ -191,14 +191,14 @@ void Say(const char *txt, SPRITE *spr) { uint16 sw = spike->W; if (east) { - if (x + sw + TEXT_RD + 5 >= SCR_WID) + if (x + sw + TEXT_RD + 5 >= SCR_WID) east = false; } else { - if (x <= 5 + TEXT_RD + sw) + if (x <= 5 + TEXT_RD + sw) east = true; } x = (east) ? (spr->X + spr->W - 2) : (spr->X + 2 - sw); - if (spr->Ref == 1) + if (spr->Ref == 1) x += (east) ? -10 : 10; // Hero Talk->Flags.Kill = true; diff --git a/engines/cge/text.h b/engines/cge/text.h index fe740ffacdd..7cf3922c5ac 100644 --- a/engines/cge/text.h +++ b/engines/cge/text.h @@ -34,10 +34,10 @@ namespace CGE { #ifndef SYSTXT_MAX -#define SYSTXT_MAX 1000 +#define SYSTXT_MAX 1000 #endif -#define SAY_EXT ".SAY" +#define SAY_EXT ".SAY" #define NOT_VGA_TEXT 90 #define BAD_CHIP_TEXT 91 @@ -45,11 +45,8 @@ namespace CGE { #define NO_CORE_TEXT 93 #define BAD_MIPS_TEXT 94 #define NO_MOUSE_TEXT 95 - - #define INF_NAME 101 #define SAY_NAME 102 - #define INF_REF 301 #define SAY_REF 302 diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index e7ed6d0402e..3f303e7f29f 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -88,7 +88,7 @@ extern "C" void SNDMIDIPlay(void); char *NumStr(char *str, int num) { char *p = strchr(str, '#'); - if (p) + if (p) wtom(num, p, 10, 5); return str; } @@ -345,7 +345,7 @@ void ENGINE::NewTimer(...) { void HEART::SetXTimer(uint16 *ptr) { - if (XTimer && ptr != XTimer) + if (XTimer && ptr != XTimer) *XTimer = 0; XTimer = ptr; } @@ -374,7 +374,7 @@ SPRITE::~SPRITE(void) { BMP_PTR SPRITE::Shp(void) { register SPREXT *e = Ext; - if (e) + if (e) if (e->Seq) { int i = e->Seq[SeqPtr].Now; #ifdef DEBUG @@ -403,15 +403,15 @@ BMP_PTR *SPRITE::SetShapeList(BMP_PTR *shp) { BMP_PTR *p; for (p = shp; *p; p++) { BMP_PTR b = (*p); // ->Code(); - if (b->W > W) + if (b->W > W) W = b->W; - if (b->H > H) + if (b->H > H) H = b->H; ++ShpCnt; } Expand(); Ext->ShpList = shp; - if (! Ext->Seq) + if (! Ext->Seq) SetSeq((ShpCnt < 2) ? Seq1 : Seq2); } return r; @@ -427,7 +427,7 @@ void SPRITE::MoveShapes(uint8 *buf) { bool SPRITE::Works(SPRITE *spr) { - if (spr) + if (spr) if (spr->Ext) { SNAIL::COM *c = spr->Ext->Take; if (c != NULL) { @@ -445,18 +445,18 @@ SEQ *SPRITE::SetSeq(SEQ *seq) { Expand(); register SEQ *s = Ext->Seq; Ext->Seq = seq; - if (SeqPtr == NO_SEQ) + if (SeqPtr == NO_SEQ) Step(0); - else if (Time == 0) + else if (Time == 0) Step(SeqPtr); return s; } bool SPRITE::SeqTest(int n) { - if (n >= 0) + if (n >= 0) return (SeqPtr == n); - if (Ext) + if (Ext) return (Ext->Seq[SeqPtr].Next == SeqPtr); return true; } @@ -464,7 +464,7 @@ bool SPRITE::SeqTest(int n) { SNAIL::COM *SPRITE::SnList(SNLIST type) { register SPREXT *e = Ext; - if (e) + if (e) return (type == NEAR) ? e->Near : e->Take; return NULL; } @@ -477,7 +477,7 @@ void SPRITE::SetName(char *n) { Ext->Name = NULL; } if (n) { - if ((Ext->Name = new char[strlen(n) + 1]) != NULL) + if ((Ext->Name = new char[strlen(n) + 1]) != NULL) strcpy(Ext->Name, n); else error("No core [%s]", n); @@ -516,9 +516,9 @@ SPRITE *SPRITE::Expand(void) { while ((len = sprf.Read((uint8 *)line)) != 0) { ++ lcnt; - if (len && line[len - 1] == '\n') + if (len && line[len - 1] == '\n') line[-- len] = '\0'; - if (len == 0 || *line == '.') + if (len == 0 || *line == '.') continue; switch (TakeEnum(Comd, strtok(line, " =\t"))) { @@ -536,7 +536,7 @@ SPRITE *SPRITE::Expand(void) { error("No core [%s]", fname); SEQ *s = &seq[seqcnt ++]; s->Now = atoi(strtok(NULL, " \t,;/")); - if (s->Now > maxnow) + if (s->Now > maxnow) maxnow = s->Now; s->Next = atoi(strtok(NULL, " \t,;/")); switch (s->Next) { @@ -547,7 +547,7 @@ SPRITE *SPRITE::Expand(void) { s->Next = seqcnt - 1; break; } - if (s->Next > maxnxt) + if (s->Next > maxnxt) maxnxt = s->Next; s->Dx = atoi(strtok(NULL, " \t,;/")); s->Dy = atoi(strtok(NULL, " \t,;/")); @@ -598,19 +598,19 @@ SPRITE *SPRITE::Expand(void) { if (maxnxt >= seqcnt) error("Bad JUMP in SEQ [%s]", fname); SetSeq(seq); - } else + } else SetSeq((ShpCnt == 1) ? Seq1 : Seq2); //disable(); // disable interupt SetShapeList(shplist); //enable(); // enable interupt - if (nea) + if (nea) nea[neacnt - 1].Ptr = Ext->Near = nea; - else + else NearPtr = NO_PTR; - if (tak) + if (tak) tak[takcnt - 1].Ptr = Ext->Take = tak; - else + else TakePtr = NO_PTR; } HEART::Enable = enbl; @@ -622,20 +622,20 @@ SPRITE *SPRITE::Expand(void) { SPRITE *SPRITE::Contract(void) { register SPREXT *e = Ext; if (e) { - if (e->Name) + if (e->Name) delete[] e->Name; if (Flags.BDel && e->ShpList) { int i; - for (i = 0; e->ShpList[i]; i ++) + for (i = 0; e->ShpList[i]; i ++) delete e->ShpList[i]; - if (MemType(e->ShpList) == NEAR_MEM) + if (MemType(e->ShpList) == NEAR_MEM) delete[] e->ShpList; } - if (MemType(e->Seq) == NEAR_MEM) + if (MemType(e->Seq) == NEAR_MEM) free(e->Seq); - if (e->Near) + if (e->Near) free(e->Near); - if (e->Take) + if (e->Take) free(e->Take); delete e; Ext = NULL; @@ -648,7 +648,7 @@ SPRITE *SPRITE::BackShow(bool fast) { Expand(); Show(2); Show(1); - if (fast) + if (fast) Show(0); Contract(); return this; @@ -656,11 +656,11 @@ SPRITE *SPRITE::BackShow(bool fast) { void SPRITE::Step(int nr) { - if (nr >= 0) + if (nr >= 0) SeqPtr = nr; if (Ext) { SEQ *seq; - if (nr < 0) + if (nr < 0) SeqPtr = Ext->Seq[SeqPtr].Next; seq = Ext->Seq + SeqPtr; if (seq->Dly >= 0) { @@ -680,7 +680,7 @@ void SPRITE::MakeXlat(uint8 *x) { if (Ext) { BMP_PTR *b; - if (Flags.Xlat) + if (Flags.Xlat) KillXlat(); for (b = Ext->ShpList; *b; b ++) (*b)->M = x; @@ -712,23 +712,23 @@ void SPRITE::KillXlat(void) { void SPRITE::Goto(int x, int y) { int xo = X, yo = Y; if (W < SCR_WID) { - if (x < 0) + if (x < 0) x = 0; - if (x + W > SCR_WID) + if (x + W > SCR_WID) x = (SCR_WID - W); X = x; } if (H < SCR_HIG) { - if (y < 0) + if (y < 0) y = 0; - if (y + H > SCR_HIG) + if (y + H > SCR_HIG) y = (SCR_HIG - H); Y = y; } - if (Next) - if (Next->Flags.Slav) + if (Next) + if (Next->Flags.Slav) Next->Goto(Next->X - xo + X, Next->Y - yo + Y); - if (Flags.Shad) + if (Flags.Shad) Prev->Goto(Prev->X - xo + X, Prev->Y - yo + Y); } @@ -766,7 +766,7 @@ void SPRITE::Show(uint16 pg) { void SPRITE::Hide(void) { register SPREXT *e = Ext; - if (e->b0) + if (e->b0) e->b0->Hide(e->x0, e->y0); } @@ -815,7 +815,7 @@ QUEUE::~QUEUE(void) { void QUEUE::Clear(void) { while (Head) { SPRITE *s = Remove(Head); - if (s->Flags.Kill) + if (s->Flags.Kill) delete s; } } @@ -835,12 +835,12 @@ void QUEUE::Append(SPRITE *spr) { if (Tail) { spr->Prev = Tail; Tail->Next = spr; - } else + } else Head = spr; Tail = spr; - if (Show) + if (Show) spr->Expand(); - else + else spr->Contract(); } @@ -849,19 +849,19 @@ void QUEUE::Insert(SPRITE *spr, SPRITE *nxt) { if (nxt == Head) { spr->Next = Head; Head = spr; - if (! Tail) + if (! Tail) Tail = spr; } else { spr->Next = nxt; spr->Prev = nxt->Prev; - if (spr->Prev) + if (spr->Prev) spr->Prev->Next = spr; } - if (spr->Next) + if (spr->Next) spr->Next->Prev = spr; - if (Show) + if (Show) spr->Expand(); - else + else spr->Contract(); } @@ -871,25 +871,25 @@ void QUEUE::Insert(SPRITE *spr) { for (s = Head; s; s = s->Next) if (s->Z > spr->Z) break; - if (s) + if (s) Insert(spr, s); - else + else Append(spr); - if (Show) + if (Show) spr->Expand(); - else + else spr->Contract(); } SPRITE *QUEUE::Remove(SPRITE *spr) { - if (spr == Head) + if (spr == Head) Head = spr->Next; - if (spr == Tail) + if (spr == Tail) Tail = spr->Prev; - if (spr->Next) + if (spr->Next) spr->Next->Prev = spr->Prev; - if (spr->Prev) + if (spr->Prev) spr->Prev->Next = spr->Next; spr->Prev = NULL; spr->Next = NULL; @@ -899,8 +899,8 @@ SPRITE *QUEUE::Remove(SPRITE *spr) { SPRITE *QUEUE::Locate(int ref) { SPRITE *spr; - for (spr = Head; spr; spr = spr->Next) - if (spr->Ref == ref) + for (spr = Head; spr; spr = spr->Next) + if (spr->Ref == ref) return spr; return NULL; } @@ -948,7 +948,7 @@ VGA::VGA(int mode) warning("TODO: Fix Copr"); SetStatAdr(); - if (StatAdr != VGAST1_) + if (StatAdr != VGAST1_) ++Mono; if (IsVga()) { OldColors = farnew(DAC, 256); @@ -1194,10 +1194,10 @@ void VGA::Sunset(void) { void VGA::Show(void) { SPRITE *spr = ShowQ.First(); - for (spr = ShowQ.First(); spr; spr = spr->Next) + for (spr = ShowQ.First(); spr; spr = spr->Next) spr->Show(); Update(); - for (spr = ShowQ.First(); spr; spr = spr->Next) + for (spr = ShowQ.First(); spr; spr = spr->Next) spr->Hide(); ++ FrmCnt; diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h index 810e781808f..b7622689569 100644 --- a/engines/cge/vga13h.h +++ b/engines/cge/vga13h.h @@ -287,12 +287,12 @@ uint8 Closest(CBLK *pal, CBLK x) { #define f(col, lum) ((((uint16)(col)) << 8) / lum) uint16 i, dif = 0xFFFF, found = 0; uint16 L = x.R + x.G + x.B; - if (!L) + if (!L) ++L; uint16 R = f(x.R, L), G = f(x.G, L), B = f(x.B, L); for (i = 0; i < 256; i ++) { uint16 l = pal[i].R + pal[i].G + pal[i].B; - if (! l) + if (! l) ++l; int r = f(pal[i].R, l), g = f(pal[i].G, l), b = f(pal[i].B, l); uint16 D = ((r > R) ? (r - R) : (R - r)) + @@ -303,7 +303,7 @@ uint8 Closest(CBLK *pal, CBLK x) { if (D < dif) { found = i; dif = D; - if (D == 0) + if (D == 0) break; // exact! } } diff --git a/engines/cge/vmenu.cpp b/engines/cge/vmenu.cpp index a8da163b331..4287c12d638 100644 --- a/engines/cge/vmenu.cpp +++ b/engines/cge/vmenu.cpp @@ -83,7 +83,7 @@ char *VMGather(CHOICE *list) { if (vmgt) { *vmgt = '\0'; for (cp = list; cp->Text; cp ++) { - if (*vmgt) + if (*vmgt) strcat(vmgt, "|"); strcat(vmgt, cp->Text); ++ h; @@ -104,13 +104,13 @@ VMENU::VMENU(CHOICE *list, int x, int y) Addr = this; delete[] vmgt; Items = 0; - for (cp = list; cp->Text; cp ++) + for (cp = list; cp->Text; cp ++) ++Items; Flags.BDel = true; Flags.Kill = true; - if (x < 0 || y < 0) + if (x < 0 || y < 0) Center(); - else + else Goto(x - W / 2, y - (TEXT_VM + FONT_HIG / 2)); VGA::ShowQ.Insert(this, VGA::ShowQ.Last()); Bar = new MENU_BAR(W - 2 * TEXT_HM); @@ -136,9 +136,9 @@ void VMENU::Touch(uint16 mask, int x, int y) { //if if (y >= 0) { n = y / h; - if (n < Items) + if (n < Items) ok = (x >= TEXT_HM && x < W - TEXT_HM/* && y % h < FONT_HIG*/); - else + else n = Items - 1; } diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 46282d2bbe6..9b6489afab3 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -56,7 +56,7 @@ VFILE::VFILE(const char *name, IOMODE mode) EndMark = (BufMark = BegMark = kp->Mark) + kp->Size; } #ifdef VOL_UPD - else + else Make(name); #endif } @@ -80,7 +80,7 @@ void VFILE::ReadBuff(void) { } BufMark = Dat.File.Mark(); long n = EndMark - BufMark; - if (n > IOBUF_SIZE) + if (n > IOBUF_SIZE) n = IOBUF_SIZE; Lim = Dat.File.Read(Buff, (uint16) n); Ptr = 0;