diff options
Diffstat (limited to 'engines/lab')
-rw-r--r-- | engines/lab/allocroom.cpp | 24 | ||||
-rw-r--r-- | engines/lab/engine.cpp | 71 | ||||
-rw-r--r-- | engines/lab/graphics.cpp | 26 | ||||
-rw-r--r-- | engines/lab/intro.cpp | 34 | ||||
-rw-r--r-- | engines/lab/labfile.cpp | 16 | ||||
-rw-r--r-- | engines/lab/map.cpp | 69 | ||||
-rw-r--r-- | engines/lab/mouse.cpp | 7 | ||||
-rw-r--r-- | engines/lab/processroom.cpp | 5 | ||||
-rw-r--r-- | engines/lab/special.cpp | 58 | ||||
-rw-r--r-- | engines/lab/text.cpp | 23 | ||||
-rw-r--r-- | engines/lab/undiff.cpp | 9 |
11 files changed, 143 insertions, 199 deletions
diff --git a/engines/lab/allocroom.cpp b/engines/lab/allocroom.cpp index 22dfae6181..2b80967032 100644 --- a/engines/lab/allocroom.cpp +++ b/engines/lab/allocroom.cpp @@ -56,25 +56,20 @@ static int32 MemLeftInBuffer = 0L; /* Allocates the memory for the room buffers. */ /*****************************************************************************/ bool initRoomBuffer() { - uint16 counter; - CurMarker = 0; if ((RoomBuffer = calloc(ROOMBUFFERSIZE, 1))) { MemPlace = RoomBuffer; MemLeftInBuffer = ROOMBUFFERSIZE; - for (counter = 0; counter < MAXMARKERS; counter++) - RoomMarkers[counter].RoomNum = EMPTYROOM; + for (uint16 i = 0; i < MAXMARKERS; i++) + RoomMarkers[i].RoomNum = EMPTYROOM; return true; } else return false; } - - - /*****************************************************************************/ /* Frees the memory for the room buffers. */ /*****************************************************************************/ @@ -83,7 +78,6 @@ void freeRoomBuffer() { free(RoomBuffer); } - /*****************************************************************************/ /* Frees a room's resources. */ /*****************************************************************************/ @@ -132,12 +126,12 @@ static void *getCurMem(uint16 Size) { if (MemPlace > NextMemPlace) { NextMemPlace = NULL; - for (uint16 counter = 0; counter < MAXMARKERS; counter++) { - if (RoomMarkers[counter].RoomNum != EMPTYROOM) { - void *Start0 = RoomMarkers[counter].Start0; - void *Start1 = RoomMarkers[counter].Start1; - void *End0 = RoomMarkers[counter].End0; - void *End1 = RoomMarkers[counter].End1; + for (uint16 i = 0; i < MAXMARKERS; i++) { + if (RoomMarkers[i].RoomNum != EMPTYROOM) { + void *Start0 = RoomMarkers[i].Start0; + void *Start1 = RoomMarkers[i].Start1; + void *End0 = RoomMarkers[i].End0; + void *End1 = RoomMarkers[i].End1; if (((Start0 >= Ptr) && (Start0 < MemPlace)) || ((End0 >= Ptr) && (End0 < MemPlace)) || @@ -146,7 +140,7 @@ static void *getCurMem(uint16 Size) { ((Start1 >= Ptr) && (Start1 < MemPlace)) || ((End1 >= Ptr) && (End1 < MemPlace)) || ((Ptr >= Start1) && (Ptr <= End1))) { - freeRoom(counter); + freeRoom(i); } else { if (Start0 >= MemPlace) if ((NextMemPlace == NULL) || (Start0 < NextMemPlace)) diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp index 2c56f5fa72..2d85dda3db 100644 --- a/engines/lab/engine.cpp +++ b/engines/lab/engine.cpp @@ -219,7 +219,6 @@ static void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) { /* Sets up the Labyrinth screens, and opens up the initial windows. */ /******************************************************************************/ bool LabEngine::setUpScreens() { - uint16 counter; byte *buffer; byte *MovePanelBuffer, *InvPanelBuffer; Gadget *curgad; @@ -242,8 +241,8 @@ bool LabEngine::setUpScreens() { buffer = MovePanelBuffer; - for (counter = 0; counter < 20; counter++) - readImage(&buffer, &(MoveImages[counter])); + for (uint16 i = 0; i < 20; i++) + readImage(&buffer, &(MoveImages[i])); /* Creates the gadgets for the movement control panel */ y = VGAScaleY(173) - SVGACord(2); @@ -303,8 +302,8 @@ bool LabEngine::setUpScreens() { buffer = InvPanelBuffer; if (g_lab->getPlatform() == Common::kPlatformWindows) { - for (counter = 0; counter < 10; counter++) - readImage(&buffer, &(InvImages[counter])); + for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++) + readImage(&buffer, &(InvImages[imgIdx])); InvGadgetList = createButton(24, y, 0, 'm', InvImages[0], InvImages[1]); curgad = InvGadgetList; @@ -323,8 +322,8 @@ bool LabEngine::setUpScreens() { curgad->NextGadget = createButton(266, y, 7, 'f', InvImages[8], InvImages[9]); curgad = curgad->NextGadget; } else { - for (counter = 0; counter < 6; counter++) - readImage(&buffer, &(InvImages[counter])); + for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++) + readImage(&buffer, &(InvImages[imgIdx])); InvGadgetList = createButton(58, y, 0, 0, InvImages[0], InvImages[1]); curgad = InvGadgetList; @@ -639,7 +638,7 @@ void LabEngine::mainGameLoop() { IntuiMessage *Msg; uint32 Class; - uint16 Code = 0, Qualifier, MouseX, MouseY, ActionMode = 4; + uint16 Qualifier, MouseX, MouseY, ActionMode = 4; uint16 CurInv = MAPNUM, LastInv = MAPNUM, Old; bool ForceDraw = false, doit, GotMessage = true; @@ -673,6 +672,7 @@ void LabEngine::mainGameLoop() { /* Set up initial picture. */ + uint16 code = 0; while (1) { WSDL_ProcessInput(1); @@ -762,11 +762,11 @@ void LabEngine::mainGameLoop() { MouseY = y; if (result == VKEY_UPARROW) { - Code = GadID = 7; + code = GadID = 7; } else if (result == VKEY_LTARROW) { - Code = GadID = 6; + code = GadID = 6; } else if (result == VKEY_RTARROW) { - Code = GadID = 8; + code = GadID = 8; } GotMessage = true; @@ -782,7 +782,7 @@ void LabEngine::mainGameLoop() { GotMessage = true; Class = Msg->msgClass; - Code = Msg->code; + code = Msg->code; Qualifier = Msg->qualifier; MouseX = Msg->mouseX; MouseY = Msg->mouseY; @@ -794,23 +794,23 @@ from_crumbs: DoBlack = false; if ((Class == RAWKEY) && (!LongWinInFront)) { - if (Code == 13) { /* The return key */ + if (code == 13) { /* The return key */ Class = MOUSEBUTTONS; Qualifier = IEQUALIFIER_LEFTBUTTON; mouseXY(&MouseX, &MouseY); } else if (g_lab->getPlatform() == Common::kPlatformWindows && - (Code == 'b' || Code == 'B')) { /* Start bread crumbs */ + (code == 'b' || code == 'B')) { /* Start bread crumbs */ BreadCrumbs[0].RoomNum = 0; NumCrumbs = 0; DroppingCrumbs = true; mayShowCrumbIndicator(); WSDL_UpdateScreen(); - } else if (Code == 'f' || Code == 'F' || - Code == 'r' || Code == 'R') { /* Follow bread crumbs */ + } else if (code == 'f' || code == 'F' || + code == 'r' || code == 'R') { /* Follow bread crumbs */ if (DroppingCrumbs) { if (NumCrumbs > 0) { FollowingCrumbs = true; - FollowCrumbsFast = (Code == 'r' || Code == 'R'); + FollowCrumbsFast = (code == 'r' || code == 'R'); IsCrumbTurning = false; IsCrumbWaiting = false; g_lab->getTime(&CrumbSecs, &CrumbMicros); @@ -836,8 +836,8 @@ from_crumbs: WSDL_UpdateScreen(); } } - } else if ((Code == 315) || (Code == 'x') || (Code == 'X') - || (Code == 'q') || (Code == 'Q')) { /* Quit? */ + } else if ((code == 315) || (code == 'x') || (code == 'X') + || (code == 'q') || (code == 'Q')) { /* Quit? */ DoNotDrawMessage = false; drawMessage("Do you want to quit? (Y/N)"); doit = false; @@ -872,9 +872,9 @@ from_crumbs: ForceDraw = true; interfaceOn(); } - } else if (Code == 9) { /* TAB key */ + } else if (code == 9) { /* TAB key */ Class = DELTAMOVE; - } else if (Code == 27) { /* ESC key */ + } else if (code == 27) { /* ESC key */ CPtr = NULL; } @@ -1015,11 +1015,9 @@ from_crumbs: BreadCrumbs[0].RoomNum = 0; } else { bool intersect = false; - int i; - - for (i = 0; i < NumCrumbs; i++) { - if (BreadCrumbs[i].RoomNum == RoomNum) { - NumCrumbs = i + 1; + for (int idx = 0; idx < NumCrumbs; idx++) { + if (BreadCrumbs[idx].RoomNum == RoomNum) { + NumCrumbs = idx + 1; BreadCrumbs[NumCrumbs].RoomNum = 0; intersect = true; } @@ -1293,21 +1291,19 @@ from_crumbs: free(Rooms); if (Inventory) { - for (Code = 1; Code <= NumInv; Code++) { - if (Inventory[Code].name) - free(Inventory[Code].name); + for (code = 1; code <= NumInv; code++) { + if (Inventory[code].name) + free(Inventory[code].name); - if (Inventory[Code].BInvName) - free(Inventory[Code].BInvName); + if (Inventory[code].BInvName) + free(Inventory[code].BInvName); } free(Inventory); } } - void LabEngine::go() { - uint16 counter; bool dointro = true; IsHiRes = ((getFeatures() & GF_LOWRES) == 0); @@ -1359,7 +1355,7 @@ void LabEngine::go() { blackAllScreen(); readPict("P:End/L2In.1", true); - for (counter = 0; counter < 120; counter++) { + for (uint16 i = 0; i < 120; i++) { g_music->updateMusic(); waitTOF(); } @@ -1395,9 +1391,6 @@ int followCrumbs() { { VKEY_RTARROW, VKEY_LTARROW, VKEY_RTARROW, VKEY_UPARROW } }; - int ExitDir; - int MoveDir; - if (IsCrumbWaiting) { uint32 Secs; uint32 Micros; @@ -1422,6 +1415,8 @@ int followCrumbs() { return 0; } + int ExitDir; + // which direction is last crumb if (BreadCrumbs[NumCrumbs].Direction == EAST) ExitDir = WEST; @@ -1432,7 +1427,7 @@ int followCrumbs() { else ExitDir = NORTH; - MoveDir = movement[Direction][ExitDir]; + int MoveDir = movement[Direction][ExitDir]; if (NumCrumbs == 0) { IsCrumbTurning = false; diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp index b21c4f6e33..fbf8c45809 100644 --- a/engines/lab/graphics.cpp +++ b/engines/lab/graphics.cpp @@ -608,18 +608,18 @@ static void doScrollBounce() { g_music->updateMusic(); int startline = headerdata.y - height - 1; - for (int counter = 0; counter < 5; counter++) { + for (int i = 0; i < 5; i++) { g_music->updateMusic(); - startline -= newby[counter]; + startline -= newby[i]; copyPage(width, height, 0, startline, mem); g_lab->WSDL_UpdateScreen(); g_lab->waitTOF(); } - for (int counter = 8; counter > 0; counter--) { + for (int i = 8; i > 0; i--) { g_music->updateMusic(); - startline += newby1[counter - 1]; + startline += newby1[i - 1]; copyPage(width, height, 0, startline, mem); g_lab->WSDL_UpdateScreen(); @@ -636,7 +636,7 @@ static void doScrollBounce() { /* Does the transporter wipe. */ /*****************************************************************************/ static void doTransWipe(CloseDataPtr *CPtr, char *filename) { - uint16 LastY, CurY, counter, linesdone = 0, lineslast; + uint16 LastY, CurY, linesdone = 0, lineslast; Image ImSource, ImDest; if (IsHiRes) { @@ -647,8 +647,8 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) { LastY = 148; } - for (counter = 0; counter < 2; counter++) { - CurY = counter * 2; + for (uint16 i = 0; i < 2; i++) { + CurY = i * 2; while (CurY < LastY) { if (linesdone >= lineslast) { @@ -665,8 +665,8 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) { g_lab->setAPen(0); - for (counter = 0; counter < 2; counter++) { - CurY = counter * 2; + for (uint16 i = 0; i < 2; i++) { + CurY = i * 2; while (CurY <= LastY) { if (linesdone >= lineslast) { @@ -700,8 +700,8 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) { ImDest.Height = g_lab->_screenHeight; ImDest.ImageData = g_lab->getVGABaseAddr(); - for (counter = 0; counter < 2; counter++) { - CurY = counter * 2; + for (uint16 i = 0; i < 2; i++) { + CurY = i * 2; while (CurY < LastY) { if (linesdone >= lineslast) { @@ -719,8 +719,8 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) { } } - for (counter = 0; counter < 2; counter++) { - CurY = counter * 2; + for (uint16 i = 0; i < 2; i++) { + CurY = i * 2; while (CurY <= LastY) { if (linesdone >= lineslast) { diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp index feb4905824..b3a5ccd6da 100644 --- a/engines/lab/intro.cpp +++ b/engines/lab/intro.cpp @@ -217,14 +217,12 @@ void Intro::doPictText(const char *filename, bool isscreen) { /* Does a one second delay, but checks the music while doing it. */ /*****************************************************************************/ void Intro::musicDelay() { - int16 counter; - g_music->updateMusic(); if (_quitIntro) return; - for (counter = 0; counter < 20; counter++) { + for (uint16 i = 0; i < 20; i++) { g_music->updateMusic(); g_lab->waitTOF(); g_lab->waitTOF(); @@ -253,8 +251,6 @@ void Intro::nReadPict(const char *filename, bool playOnce) { /* Does the introduction sequence for Labyrinth. */ /*****************************************************************************/ void Intro::introSequence() { - uint16 counter, counter1; - uint16 palette[16] = { 0x0000, 0x0855, 0x0FF9, 0x0EE7, 0x0ED5, 0x0DB4, 0x0CA2, 0x0C91, @@ -272,7 +268,7 @@ void Intro::introSequence() { } else { nReadPict("WYRMKEEP", true); // Wait 4 seconds - for (counter = 0; counter < 4 * 1000 / 10; counter++) { + for (uint16 i = 0; i < 4 * 1000 / 10; i++) { introEatMessages(); if (_quitIntro) break; @@ -293,13 +289,13 @@ void Intro::introSequence() { FadePalette = palette; - for (counter = 0; counter < 16; counter++) { + for (uint16 i = 0; i < 16; i++) { if (_quitIntro) break; - palette[counter] = ((diffcmap[counter * 3] >> 2) << 8) + - ((diffcmap[counter * 3 + 1] >> 2) << 4) + - (diffcmap[counter * 3 + 2] >> 2); + palette[i] = ((diffcmap[i * 3] >> 2) << 8) + + ((diffcmap[i * 3 + 1] >> 2) << 4) + + (diffcmap[i * 3 + 2] >> 2); } g_music->updateMusic(); @@ -312,8 +308,8 @@ void Intro::introSequence() { g_music->updateMusic(); uint16 temp = palette[2]; - for (counter = 2; counter < 15; counter++) - palette[counter] = palette[counter + 1]; + for (uint16 i = 2; i < 15; i++) + palette[i] = palette[i + 1]; palette[15] = temp; @@ -358,10 +354,10 @@ void Intro::introSequence() { nReadPict("Intro.1", true); nopalchange = false; - for (counter = 0; counter < 16; counter++) { - palette[counter] = ((diffcmap[counter * 3] >> 2) << 8) + - ((diffcmap[counter * 3 + 1] >> 2) << 4) + - (diffcmap[counter * 3 + 2] >> 2); + for (uint16 i = 0; i < 16; i++) { + palette[i] = ((diffcmap[i * 3] >> 2) << 8) + + ((diffcmap[i * 3 + 1] >> 2) << 4) + + (diffcmap[i * 3 + 2] >> 2); } doPictText("i.1", true); @@ -399,9 +395,9 @@ void Intro::introSequence() { doPictText("i.11", false); if (!_quitIntro) - for (counter = 0; counter < 50; counter++) { - for (counter1 = (8 * 3); counter1 < (255 * 3); counter1++) - diffcmap[counter1] = 255 - diffcmap[counter1]; + for (uint16 i = 0; i < 50; i++) { + for (uint16 idx = (8 * 3); idx < (255 * 3); idx++) + diffcmap[idx] = 255 - diffcmap[idx]; g_music->updateMusic(); g_lab->waitTOF(); diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp index 231c63ab67..fb6b17e759 100644 --- a/engines/lab/labfile.cpp +++ b/engines/lab/labfile.cpp @@ -86,16 +86,12 @@ static void *getCurMemLabFile(uint32 size) { ptr = MemPlace; MemPlace = (char *)MemPlace + size; - for (int counter = 0; counter < MAXMARKERS; counter++) { - if (FileMarkers[counter].name[0]) { - if (((FileMarkers[counter].Start >= ptr) && - (FileMarkers[counter].Start < MemPlace)) || - ((FileMarkers[counter].End >= ptr) && - (FileMarkers[counter].End < MemPlace)) || - ((ptr >= FileMarkers[counter].Start) && - (ptr <= FileMarkers[counter].End))) - - freeFile(counter); + for (int i = 0; i < MAXMARKERS; i++) { + if (FileMarkers[i].name[0]) { + if ( ((FileMarkers[i].Start >= ptr) && (FileMarkers[i].Start < MemPlace)) + || ((FileMarkers[i].End >= ptr) && (FileMarkers[i].End < MemPlace)) + || ((ptr >= FileMarkers[i].Start) && (ptr <= FileMarkers[i].End))) + freeFile(i); } } diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp index fdec095f1a..50a551473f 100644 --- a/engines/lab/map.cpp +++ b/engines/lab/map.cpp @@ -63,10 +63,10 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) { if (numcolors > 16) numcolors = 16; - for (uint16 counter = 0; counter < numcolors; counter++) { - vgapal[vgacount++] = (byte)(((pal[counter] & 0xf00) >> 8) << 2); - vgapal[vgacount++] = (byte)(((pal[counter] & 0x0f0) >> 4) << 2); - vgapal[vgacount++] = (byte)(((pal[counter] & 0x00f)) << 2); + for (uint16 i = 0; i < numcolors; i++) { + vgapal[vgacount++] = (byte)(((pal[i] & 0xf00) >> 8) << 2); + vgapal[vgacount++] = (byte)(((pal[i] & 0x0f0) >> 4) << 2); + vgapal[vgacount++] = (byte)(((pal[i] & 0x00f)) << 2); } g_lab->writeColorRegsSmooth(vgapal, 0, 16); @@ -294,18 +294,18 @@ static uint16 fadeNumOut(uint16 num, uint16 res, uint16 counter) { /* Does the fading of the Palette on the screen. */ /*****************************************************************************/ void fade(bool fadein, uint16 res) { - uint16 pennum, counter, newpal[16]; + uint16 newpal[16]; - for (counter = 0; counter < 16; counter++) { - for (pennum = 0; pennum < 16; pennum++) { + for (uint16 i = 0; i < 16; i++) { + for (uint16 palIdx = 0; palIdx < 16; palIdx++) { if (fadein) - newpal[pennum] = (0x00F & fadeNumIn(0x00F & FadePalette[pennum], 0x00F & res, counter)) + - (0x0F0 & fadeNumIn(0x0F0 & FadePalette[pennum], 0x0F0 & res, counter)) + - (0xF00 & fadeNumIn(0xF00 & FadePalette[pennum], 0xF00 & res, counter)); + newpal[palIdx] = (0x00F & fadeNumIn(0x00F & FadePalette[palIdx], 0x00F & res, i)) + + (0x0F0 & fadeNumIn(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) + + (0xF00 & fadeNumIn(0xF00 & FadePalette[palIdx], 0xF00 & res, i)); else - newpal[pennum] = (0x00F & fadeNumOut(0x00F & FadePalette[pennum], 0x00F & res, counter)) + - (0x0F0 & fadeNumOut(0x0F0 & FadePalette[pennum], 0x0F0 & res, counter)) + - (0xF00 & fadeNumOut(0xF00 & FadePalette[pennum], 0xF00 & res, counter)); + newpal[palIdx] = (0x00F & fadeNumOut(0x00F & FadePalette[palIdx], 0x00F & res, i)) + + (0x0F0 & fadeNumOut(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) + + (0xF00 & fadeNumOut(0xF00 & FadePalette[palIdx], 0xF00 & res, i)); } setAmigaPal(newpal, 16); @@ -314,8 +314,6 @@ void fade(bool fadein, uint16 res) { } } - - /*****************************************************************************/ /* Figures out what a room's coordinates should be. */ /*****************************************************************************/ @@ -350,10 +348,6 @@ static void roomCords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 } } - - - - /*****************************************************************************/ /* Draws a room to the bitmap. */ /*****************************************************************************/ @@ -489,28 +483,18 @@ static void drawRoom(uint16 CurRoom, bool drawx) { g_lab->drawImage(XMark, xx, xy); } - - /*****************************************************************************/ /* Checks if a floor has been visitted. */ /*****************************************************************************/ static bool onFloor(uint16 Floor) { - uint16 drawroom; - - for (drawroom = 1; drawroom <= MaxRooms; drawroom++) { - if ((Maps[drawroom].PageNumber == Floor) - && g_lab->_roomsFound->in(drawroom) - && Maps[drawroom].x) { + for (uint16 i = 1; i <= MaxRooms; i++) { + if ((Maps[i].PageNumber == Floor) && g_lab->_roomsFound->in(i) && Maps[i].x) return true; - } } return false; } - - - /*****************************************************************************/ /* Figures out which floor, if any, should be gone to if the up arrow is hit */ /*****************************************************************************/ @@ -570,7 +554,6 @@ static void getDownFloor(uint16 *Floor, bool *isfloor) { /* Draws the map */ /*****************************************************************************/ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) { - uint16 drawroom; char *sptr; uint16 tempfloor; @@ -587,11 +570,9 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b g_lab->drawImage(Map, 0, 0); drawGadgetList(MapGadgetList); - for (drawroom = 1; drawroom <= MaxRooms; drawroom++) { - if ((Maps[drawroom].PageNumber == Floor) - && g_lab->_roomsFound->in(drawroom) - && Maps[drawroom].x) { - drawRoom(drawroom, (bool)(drawroom == CurRoom)); + for (uint16 i = 1; i <= MaxRooms; i++) { + if ((Maps[i].PageNumber == Floor) && g_lab->_roomsFound->in(i) && Maps[i].x) { + drawRoom(i, (bool)(i == CurRoom)); g_music->updateMusic(); } } @@ -674,14 +655,12 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b mouseShow(); } - - /*****************************************************************************/ /* Processes the map. */ /*****************************************************************************/ void processMap(uint16 CurRoom) { uint32 Class, place = 1; - uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, drawroom, x1, y1, x2, y2; + uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, x1, y1, x2, y2; char *sptr; byte newcolor[3]; bool drawmap; @@ -804,14 +783,14 @@ void processMap(uint16 CurRoom) { else if (MouseX > mapScaleX(314)) { OldMsg = CurMsg; - for (drawroom = 1; drawroom <= MaxRooms; drawroom++) { - roomCords(drawroom, &x1, &y1, &x2, &y2); + for (uint16 i = 1; i <= MaxRooms; i++) { + roomCords(i, &x1, &y1, &x2, &y2); - if ((Maps[drawroom].PageNumber == CurFloor) - && g_lab->_roomsFound->in(drawroom) + if ((Maps[i].PageNumber == CurFloor) + && g_lab->_roomsFound->in(i) && (MouseX >= x1) && (MouseX <= x2) && (MouseY >= y1) && (MouseY <= y2)) { - CurMsg = drawroom; + CurMsg = i; } } diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp index ef483f7e2d..bdfb3fc235 100644 --- a/engines/lab/mouse.cpp +++ b/engines/lab/mouse.cpp @@ -70,8 +70,6 @@ static Gadget *hitgad = NULL; /* of gadgets. */ /*****************************************************************************/ static Gadget *checkGadgetHit(Gadget *gadlist, uint16 x, uint16 y) { - uint16 counter; - while (gadlist != NULL) { if ((x >= gadlist->x) && (y >= gadlist->y) && (x <= (gadlist->x + gadlist->Im->Width)) && @@ -84,7 +82,7 @@ static Gadget *checkGadgetHit(Gadget *gadlist, uint16 x, uint16 y) { g_lab->drawImage(gadlist->ImAlt, gadlist->x, gadlist->y); mouseShow(); - for (counter = 0; counter < 3; counter++) + for (uint16 i = 0; i < 3; i++) g_lab->waitTOF(); mouseHide(); @@ -133,7 +131,6 @@ void mouseHandler(int32 flag, int32 mouseX, int32 mouseY) { } void updateMouse() { - uint16 counter; bool doUpdateDisplay = false; if (!MouseHidden) @@ -144,7 +141,7 @@ void updateMouse() { g_lab->drawImage(hitgad->ImAlt, hitgad->x, hitgad->y); mouseShow(); - for (counter = 0; counter < 3; counter++) + for (uint16 i = 0; i < 3; i++) g_lab->waitTOF(); mouseHide(); diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp index fd5ec73670..ccce27adf3 100644 --- a/engines/lab/processroom.cpp +++ b/engines/lab/processroom.cpp @@ -330,7 +330,6 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) { CloseDataPtr TLCPtr; bool FirstLoaded = true; char **str, *Test; - uint16 counter; uint32 StartSecs, StartMicros, CurSecs, CurMicros; while (APtr) { @@ -563,8 +562,8 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) { else if (APtr->Param1 == 2) DoBlack = (CPtr != NULL); else if (APtr->Param1 == 5) { /* inverse the palette */ - for (counter = (8 * 3); counter < (255 * 3); counter++) - diffcmap[counter] = 255 - diffcmap[counter]; + for (uint16 idx = (8 * 3); idx < (255 * 3); idx++) + diffcmap[idx] = 255 - diffcmap[idx]; g_lab->waitTOF(); g_lab->VGASetPal(diffcmap, 256); diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp index 1ee539f20b..ea9df4fc13 100644 --- a/engines/lab/special.cpp +++ b/engines/lab/special.cpp @@ -110,7 +110,6 @@ extern uint16 RoomNum, Direction; static byte *loadBackPict(const char *fileName, bool tomem) { - uint16 counter; byte *res = NULL; FadePalette = hipal; @@ -121,10 +120,10 @@ static byte *loadBackPict(const char *fileName, bool tomem) { else readPict(fileName, true); - for (counter = 0; counter < 16; counter++) { - hipal[counter] = ((diffcmap[counter * 3] >> 2) << 8) + - ((diffcmap[counter * 3 + 1] >> 2) << 4) + - ((diffcmap[counter * 3 + 2] >> 2)); + for (uint16 i = 0; i < 16; i++) { + hipal[i] = ((diffcmap[i * 3] >> 2) << 8) + + ((diffcmap[i * 3 + 1] >> 2) << 4) + + ((diffcmap[i * 3 + 2] >> 2)); } nopalchange = false; @@ -136,17 +135,14 @@ static byte *loadBackPict(const char *fileName, bool tomem) { /* Draws the images of the combination lock to the display bitmap. */ /*****************************************************************************/ static void doCombination() { - uint16 counter; - - for (counter = 0; counter <= 5; counter++) - g_lab->drawImage(Images[combination[counter]], VGAScaleX(combx[counter]), VGAScaleY(65)); + for (uint16 i = 0; i <= 5; i++) + g_lab->drawImage(Images[combination[i]], VGAScaleX(combx[i]), VGAScaleY(65)); } /*****************************************************************************/ /* Reads in a backdrop picture. */ /*****************************************************************************/ void showCombination(const char *filename) { - uint16 CurBit; byte **buffer; resetBuffer(); @@ -159,7 +155,7 @@ void showCombination(const char *filename) { buffer = g_music->newOpen("P:Numbers"); - for (CurBit = 0; CurBit < 10; CurBit++) + for (uint16 CurBit = 0; CurBit < 10; CurBit++) readImage(buffer, &(Images[CurBit])); allocFile((void **)&g_lab->_tempScrollData, Images[0]->Width * Images[0]->Height * 2L, "tempdata"); @@ -176,7 +172,7 @@ void showCombination(const char *filename) { /*****************************************************************************/ static void changeCombination(uint16 number) { Image display; - uint16 counter, combnum; + uint16 combnum; bool unlocked = true; if (combination[number] < 9) @@ -190,9 +186,9 @@ static void changeCombination(uint16 number) { display.Width = g_lab->_screenWidth; display.Height = g_lab->_screenHeight; - for (counter = 1; counter <= (Images[combnum]->Height / 2); counter++) { + for (uint16 i = 1; i <= (Images[combnum]->Height / 2); i++) { if (IsHiRes) { - if (counter & 1) + if (i & 1) g_lab->waitTOF(); } else g_lab->waitTOF(); @@ -201,11 +197,11 @@ static void changeCombination(uint16 number) { g_lab->scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->Width - 1, VGAScaleY(65) + (Images[combnum])->Height); - g_lab->bltBitMap(Images[combnum], 0, (Images[combnum])->Height - (2 * counter), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->Width, 2); + g_lab->bltBitMap(Images[combnum], 0, (Images[combnum])->Height - (2 * i), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->Width, 2); } - for (counter = 0; counter < 6; counter++) - unlocked = (combination[counter] == solution[counter]) && unlocked; + for (uint16 i = 0; i < 6; i++) + unlocked = (combination[i] == solution[i]) && unlocked; if (unlocked) g_lab->_conditions->inclElement(COMBINATIONUNLOCKED); @@ -289,7 +285,7 @@ static void doTile(bool showsolution) { /* Reads in a backdrop picture. */ /*****************************************************************************/ void showTile(const char *filename, bool showsolution) { - uint16 CurBit, start; + uint16 start; byte **buffer; resetBuffer(); @@ -310,8 +306,8 @@ void showTile(const char *filename, bool showsolution) { if (!buffer) return; - for (CurBit = start; CurBit < 16; CurBit++) - readImage(buffer, &(Tiles[CurBit])); + for (uint16 curBit = start; curBit < 16; curBit++) + readImage(buffer, &(Tiles[curBit])); allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->Width * Tiles[1]->Height * 2L, "tempdata"); @@ -334,7 +330,6 @@ static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, ui static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) { int16 dX = 0, dY = 0, dx = 0, dy = 0, sx = 0, sy = 0; uint16 last = 0, x1, y1; - uint16 counter; if (scrolltype == LEFTSCROLL) { dX = VGAScaleX(5); @@ -361,7 +356,7 @@ static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) { x1 = VGAScaleX(100) + (col * VGAScaleX(30)) + dx; y1 = VGAScaleY(25) + (row * VGAScaleY(25)) + dy; - for (counter = 0; counter < last; counter++) { + for (uint16 i = 0; i < last; i++) { g_lab->waitTOF(); scrollRaster(dX, dY, x1, y1, x1 + VGAScaleX(28) + sx, y1 + VGAScaleY(23) + sy); x1 += dX; @@ -549,7 +544,6 @@ static bool loadJournalData() { byte **buffer; char filename[20]; Gadget *TopGadget = &BackG; - uint16 counter; bool bridge, dirty, news, clean; BigMsgFont = &bmfont; @@ -607,7 +601,7 @@ static bool loadJournalData() { BackG.KeyEquiv = VKEY_LTARROW; ForwardG.KeyEquiv = VKEY_RTARROW; - counter = 0; + uint16 counter = 0; while (TopGadget) { TopGadget->x = VGAScaleX(JGadX[counter]); @@ -667,21 +661,19 @@ static void drawJournalText() { /* Does the turn page wipe. */ /*****************************************************************************/ static void turnPage(bool FromLeft) { - uint16 counter; - if (FromLeft) { - for (counter = 0; counter < g_lab->_screenWidth; counter += 8) { + for (int i = 0; i < g_lab->_screenWidth; i += 8) { g_music->updateMusic(); g_lab->waitTOF(); ScreenImage.ImageData = g_lab->getVGABaseAddr(); - g_lab->bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight); + g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight); } } else { - for (counter = (g_lab->_screenWidth - 8); counter > 0; counter -= 8) { + for (int i = (g_lab->_screenWidth - 8); i > 0; i -= 8) { g_music->updateMusic(); g_lab->waitTOF(); ScreenImage.ImageData = g_lab->getVGABaseAddr(); - g_lab->bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight); + g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight); } } } @@ -878,7 +870,7 @@ static void getMonImages() { /* Draws the text for the monitor. */ /*****************************************************************************/ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) { - uint16 DrawingToPage = 0, yspacing = 0, numlines, fheight, counter; + uint16 DrawingToPage = 0, yspacing = 0, numlines, fheight; int32 CharsDrawn = 0L; char *CurText = text; @@ -903,8 +895,8 @@ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, g_lab->setAPen(0); g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, y2); - for (counter = 0; counter < numlines; counter++) - g_lab->drawImage(MonButton, 0, counter * MonGadHeight); + for (uint16 i = 0; i < numlines; i++) + g_lab->drawImage(MonButton, 0, i * MonGadHeight); } else if (isinteractive) { g_lab->setAPen(0); g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, y2); diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp index cf920d3f43..10e4ac8326 100644 --- a/engines/lab/text.cpp +++ b/engines/lab/text.cpp @@ -51,19 +51,18 @@ void closeFont(struct TextFont *tf) { /* Returns the length of a text in the specified font. */ /*****************************************************************************/ uint16 textLength(struct TextFont *tf, const char *text, uint16 numchars) { - uint16 counter, length = 0; + uint16 length = 0; - if (tf) - for (counter = 0; counter < numchars; counter++) { + if (tf) { + for (uint16 i = 0; i < numchars; i++) { length += tf->Widths[(uint)*text]; text++; } + } return length; } - - /*****************************************************************************/ /* Returns the height of a specified font. */ /*****************************************************************************/ @@ -78,11 +77,11 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex byte *VGATop, *VGACur, *VGATemp, *VGATempLine, *cdata; uint32 RealOffset, SegmentOffset; int32 templeft, LeftInSegment; - uint16 counter, counterb, bwidth, mask, curpage, rows, cols, data; + uint16 bwidth, mask, curpage, data; VGATop = g_lab->getVGABaseAddr(); - for (counter = 0; counter < numchars; counter++) { + for (uint16 i = 0; i < numchars; i++) { RealOffset = (g_lab->_screenWidth * y) + x; curpage = RealOffset / g_lab->_screenBytesPerPage; SegmentOffset = RealOffset - (curpage * g_lab->_screenBytesPerPage); @@ -95,16 +94,16 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex VGATemp = VGACur; VGATempLine = VGACur; - for (rows = 0; rows < tf->Height; rows++) { + for (uint16 rows = 0; rows < tf->Height; rows++) { VGATemp = VGATempLine; templeft = LeftInSegment; - for (cols = 0; cols < bwidth; cols++) { + for (uint16 cols = 0; cols < bwidth; cols++) { data = *cdata++; if (data && (templeft >= 8)) { - for (int i = 7; i >= 0; i--) { - if ((1 << i) & data) + for (int j = 7; j >= 0; j--) { + if ((1 << j) & data) *VGATemp = color; VGATemp++; } @@ -114,7 +113,7 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex mask = 0x80; templeft = LeftInSegment; - for (counterb = 0; counterb < 8; counterb++) { + for (uint16 counterb = 0; counterb < 8; counterb++) { if (templeft <= 0) { curpage++; VGATemp = (byte *)(VGATop - templeft); diff --git a/engines/lab/undiff.cpp b/engines/lab/undiff.cpp index f7610d99ce..2b22496011 100644 --- a/engines/lab/undiff.cpp +++ b/engines/lab/undiff.cpp @@ -371,14 +371,11 @@ void runLengthDecode(byte *Dest, byte *Source) { void VRunLengthDecode(byte *Dest, byte *Source, uint16 bytesperrow) { int8 num; int16 count; - uint16 Counter; - byte *Top; + byte *Top = Dest; - Top = Dest; - - for (Counter = 0; Counter < DataBytesPerRow; Counter++) { + for (uint16 i = 0; i < DataBytesPerRow; i++) { Dest = Top; - Dest += Counter; + Dest += i; num = (int8)*Source; Source++; |