diff options
-rw-r--r-- | engines/hopkins/anim.cpp | 8 | ||||
-rw-r--r-- | engines/hopkins/computer.cpp | 59 | ||||
-rw-r--r-- | engines/hopkins/dialogs.cpp | 30 | ||||
-rw-r--r-- | engines/hopkins/font.cpp | 2 | ||||
-rw-r--r-- | engines/hopkins/globals.cpp | 20 | ||||
-rw-r--r-- | engines/hopkins/globals.h | 25 | ||||
-rw-r--r-- | engines/hopkins/graphics.cpp | 8 | ||||
-rw-r--r-- | engines/hopkins/hopkins.cpp | 92 | ||||
-rw-r--r-- | engines/hopkins/hopkins.h | 4 | ||||
-rw-r--r-- | engines/hopkins/lines.cpp | 588 | ||||
-rw-r--r-- | engines/hopkins/lines.h | 20 | ||||
-rw-r--r-- | engines/hopkins/objects.cpp | 358 | ||||
-rw-r--r-- | engines/hopkins/script.cpp | 222 | ||||
-rw-r--r-- | engines/hopkins/sound.cpp | 6 | ||||
-rw-r--r-- | engines/hopkins/talk.cpp | 118 |
15 files changed, 782 insertions, 778 deletions
diff --git a/engines/hopkins/anim.cpp b/engines/hopkins/anim.cpp index 2186967922..38f02c3fda 100644 --- a/engines/hopkins/anim.cpp +++ b/engines/hopkins/anim.cpp @@ -532,10 +532,10 @@ int AnimationManager::loadSpriteBank(int idx, const Common::String &filename) { byte *ofsData = _vm->_fileManager.loadFile(ofsFilename); byte *curOfsData = ofsData; for (int objIdx = 0; objIdx < _vm->_globals.Bank[idx]._objDataIdx; ++objIdx, curOfsData += 8) { - int x1 = (int16)READ_LE_UINT16(curOfsData); - int y1 = (int16)READ_LE_UINT16(curOfsData + 2); - int x2 = (int16)READ_LE_UINT16(curOfsData + 4); - int y2 = (int16)READ_LE_UINT16(curOfsData + 6); + int x1 = READ_LE_INT16(curOfsData); + int y1 = READ_LE_INT16(curOfsData + 2); + int x2 = READ_LE_INT16(curOfsData + 4); + int y2 = READ_LE_INT16(curOfsData + 6); _vm->_objectsManager.setOffsetXY(_vm->_globals.Bank[idx]._data, objIdx, x1, y1, 0); if (_vm->_globals.Bank[idx]._fileHeader == 2) diff --git a/engines/hopkins/computer.cpp b/engines/hopkins/computer.cpp index 7d664acee9..d101a67278 100644 --- a/engines/hopkins/computer.cpp +++ b/engines/hopkins/computer.cpp @@ -659,36 +659,46 @@ void ComputerManager::displayBricks() { _breakoutBrickNbr = 0; _breakoutSpeed = 1; int16 *level = _breakoutLevel; - int levelIdx = 0; int cellLeft; int cellTop; int cellType; - do { + for (int levelIdx = 0; ; levelIdx += 6) { cellLeft = level[levelIdx]; + if (cellLeft == -1) + break; cellTop = level[levelIdx + 1]; cellType = level[levelIdx + 4]; - if (cellLeft != -1) { - if (cellType <= 6) - ++_breakoutBrickNbr; - - if (cellType == 3) - _vm->_graphicsManager.AFFICHE_SPEEDVGA(_breakoutSpr, cellLeft, cellTop, 17); - else if (cellType == 6) - _vm->_graphicsManager.AFFICHE_SPEEDVGA(_breakoutSpr, cellLeft, cellTop, 18); - else if (cellType == 5) - _vm->_graphicsManager.AFFICHE_SPEEDVGA(_breakoutSpr, cellLeft, cellTop, 19); - else if (cellType == 4) - _vm->_graphicsManager.AFFICHE_SPEEDVGA(_breakoutSpr, cellLeft, cellTop, 20); - else if (cellType == 1) - _vm->_graphicsManager.AFFICHE_SPEEDVGA(_breakoutSpr, cellLeft, cellTop, 21); - else if (cellType == 2) - _vm->_graphicsManager.AFFICHE_SPEEDVGA(_breakoutSpr, cellLeft, cellTop, 22); - else if (cellType == 31) - _vm->_graphicsManager.AFFICHE_SPEEDVGA(_breakoutSpr, cellLeft, cellTop, 23); + + if (cellType <= 6) + ++_breakoutBrickNbr; + + switch (cellType) { + case 1: + _vm->_graphicsManager.AFFICHE_SPEEDVGA(_breakoutSpr, cellLeft, cellTop, 21); + break; + case 2: + _vm->_graphicsManager.AFFICHE_SPEEDVGA(_breakoutSpr, cellLeft, cellTop, 22); + break; + case 3: + _vm->_graphicsManager.AFFICHE_SPEEDVGA(_breakoutSpr, cellLeft, cellTop, 17); + break; + case 4: + _vm->_graphicsManager.AFFICHE_SPEEDVGA(_breakoutSpr, cellLeft, cellTop, 20); + break; + case 5: + _vm->_graphicsManager.AFFICHE_SPEEDVGA(_breakoutSpr, cellLeft, cellTop, 19); + break; + case 6: + _vm->_graphicsManager.AFFICHE_SPEEDVGA(_breakoutSpr, cellLeft, cellTop, 18); + break; + case 31: + _vm->_graphicsManager.AFFICHE_SPEEDVGA(_breakoutSpr, cellLeft, cellTop, 23); + break; } + levelIdx += 6; - } while (cellLeft != -1); + } displayScore(); } @@ -1042,18 +1052,17 @@ int ComputerManager::moveBall() { _vm->_soundManager.playSample(2, 6); _ballPosition.x = randVal + 6; _ballRightFl = !_ballRightFl; - } - if (_ballPosition.x > 307) { + } else if (_ballPosition.x > 307) { _vm->_soundManager.playSample(2, 6); _ballPosition.x = 307 - randVal; _ballRightFl = !_ballRightFl; } + if (_ballPosition.y <= 6) { _vm->_soundManager.playSample(2, 6); _ballPosition.y = randVal + 7; _ballUpFl = !_ballUpFl; - } - if (_ballPosition.y >= 186 && _ballPosition.y <= 194) { + } else if (_ballPosition.y >= 186 && _ballPosition.y <= 194) { _vm->_soundManager.playSample(2, 6); int ballPosXRight = _ballPosition.x + 6; if ((_ballPosition.x > _padPositionX - 2) && (ballPosXRight < _padPositionX + 36)) { diff --git a/engines/hopkins/dialogs.cpp b/engines/hopkins/dialogs.cpp index 574100e9df..93f86598bc 100644 --- a/engines/hopkins/dialogs.cpp +++ b/engines/hopkins/dialogs.cpp @@ -320,7 +320,7 @@ void DialogsManager::showInventory() { _vm->_eventsManager.getMouseY(); _vm->_eventsManager.VBL(); } - _vm->_dialogsManager._inventWin1 = g_PTRNUL; + _inventWin1 = g_PTRNUL; bool loopFl; do { @@ -352,18 +352,18 @@ void DialogsManager::showInventory() { error("Error opening file - %s", filename.c_str()); size_t filesize = f.size(); - _vm->_dialogsManager._inventWin1 = _vm->_globals.allocMemory(filesize); - _vm->_fileManager.readStream(f, _vm->_dialogsManager._inventWin1, filesize); + _inventWin1 = _vm->_globals.allocMemory(filesize); + _vm->_fileManager.readStream(f, _inventWin1, filesize); f.close(); _inventBuf2 = _vm->_fileManager.loadFile("INVENT2.SPR"); _inventX = _vm->_graphicsManager._scrollOffset + 152; _inventY = 114; - _inventWidth = _vm->_objectsManager.getWidth(_vm->_dialogsManager._inventWin1, 0); - _inventHeight = _vm->_objectsManager.getHeight(_vm->_dialogsManager._inventWin1, 0); + _inventWidth = _vm->_objectsManager.getWidth(_inventWin1, 0); + _inventHeight = _vm->_objectsManager.getHeight(_inventWin1, 0); - _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager._vesaBuffer, _vm->_dialogsManager._inventWin1, _inventX + 300, 414, 0, 0, 0, false); + _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager._vesaBuffer, _inventWin1, _inventX + 300, 414, 0, 0, 0, false); int curPosY = 0; int inventCount = 0; for (int inventLine = 1; inventLine <= 5; inventLine++) { @@ -382,7 +382,7 @@ void DialogsManager::showInventory() { }; curPosY += 38; } - _vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager._vesaBuffer, _vm->_dialogsManager._inventWin1, _inventX, _inventY, _inventWidth, _inventHeight); + _vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager._vesaBuffer, _inventWin1, _inventX, _inventY, _inventWidth, _inventHeight); _vm->_eventsManager._curMouseButton = 0; int newInventoryItem = 0; @@ -433,7 +433,7 @@ void DialogsManager::showInventory() { _vm->_globals._exitId = 0; _inventBuf2 = _vm->_globals.freeMemory(_inventBuf2); - _vm->_dialogsManager._inventWin1 = _vm->_globals.freeMemory(_vm->_dialogsManager._inventWin1); + _inventWin1 = _vm->_globals.freeMemory(_inventWin1); loopFl = true; break; } else @@ -455,15 +455,15 @@ void DialogsManager::showInventory() { _vm->_objectsManager.BOBTOUS = true; } - _vm->_dialogsManager._inventWin1 = _vm->_globals.freeMemory(_vm->_dialogsManager._inventWin1); + _inventWin1 = _vm->_globals.freeMemory(_inventWin1); _inventBuf2 = _vm->_globals.freeMemory(_inventBuf2); if (_vm->_eventsManager._mouseCursorId == 1) showOptionsDialog(); else if (_vm->_eventsManager._mouseCursorId == 3) - _vm->_dialogsManager.showLoadGame(); + showLoadGame(); else if (_vm->_eventsManager._mouseCursorId == 2) - _vm->_dialogsManager.showSaveGame(); + showSaveGame(); _vm->_eventsManager._mouseCursorId = 4; _vm->_eventsManager.changeMouseCursor(4); @@ -535,21 +535,21 @@ void DialogsManager::testDialogOpening() { switch (key) { case KEY_INVENTORY: - _vm->_dialogsManager.showInventory(); + showInventory(); break; case KEY_OPTIONS: _vm->_graphicsManager._scrollStatus = 1; - _vm->_dialogsManager.showOptionsDialog(); + showOptionsDialog(); _vm->_graphicsManager._scrollStatus = 0; break; case KEY_LOAD: _vm->_graphicsManager._scrollStatus = 1; - _vm->_dialogsManager.showLoadGame(); + showLoadGame(); _vm->_graphicsManager._scrollStatus = 0; break; case KEY_SAVE: _vm->_graphicsManager._scrollStatus = 1; - _vm->_dialogsManager.showSaveGame(); + showSaveGame(); _vm->_graphicsManager._scrollStatus = 0; break; default: diff --git a/engines/hopkins/font.cpp b/engines/hopkins/font.cpp index 3343c2fd10..844bcb930d 100644 --- a/engines/hopkins/font.cpp +++ b/engines/hopkins/font.cpp @@ -210,7 +210,7 @@ void FontManager::box(int idx, int messageId, const Common::String &filename, in _tempText = _vm->_globals.allocMemory(110); Common::fill(&_tempText[0], &_tempText[110], 0); memcpy(_tempText, _vm->_globals.BUF_ZONE + _index[messageId], 96); - WRITE_LE_UINT16((uint16 *)_tempText + 48, (int16)READ_LE_UINT16(_vm->_globals.BUF_ZONE + _index[messageId] + 96)); + WRITE_LE_UINT16((uint16 *)_tempText + 48, READ_LE_INT16(_vm->_globals.BUF_ZONE + _index[messageId] + 96)); } byte *curTempTextPtr = _tempText; for (int i = 0; i < bufSize; i++) { diff --git a/engines/hopkins/globals.cpp b/engines/hopkins/globals.cpp index 06807b3940..633f222092 100644 --- a/engines/hopkins/globals.cpp +++ b/engines/hopkins/globals.cpp @@ -103,9 +103,9 @@ Globals::Globals() { _linuxEndDemoFl = false; _speed = 1; _oldFrameIndex = 0; - _oldDirection = 0; + _oldDirection = DIR_NONE; _oldDirectionSpriteIdx = 59; - _lastDirection = 0; + _lastDirection = DIR_NONE; NUM_FICHIER_OBJ = 0; nbrligne = 0; _boxWidth = 0; @@ -130,8 +130,7 @@ Globals::Globals() { PERSO_TYPE = 0; GOACTION = false; Compteur = 0; - _actionDirection = 0; - _actionDirection = 0; + _actionDirection = DIR_NONE; Credit_bx = -1; Credit_bx1 = -1; @@ -142,7 +141,7 @@ Globals::Globals() { memset(_creditsItem, 0, 12000); _creditsStep = 0; - _oceanDirection = 0; + _oceanDirection = DIR_NONE; // Initialize pointers BUF_ZONE = NULL; @@ -177,7 +176,6 @@ Globals::Globals() { _oldMouseY = 0; compteur_71 = 0; _forceHideText = false; - j_104 = 0; } Globals::~Globals() { @@ -284,7 +282,7 @@ void Globals::loadCharacterData() { } _oldFrameIndex = -1; - _oldDirection = -1; + _oldDirection = DIR_NONE; } void Globals::INIT_ANIM() { @@ -414,10 +412,10 @@ void Globals::loadCache(const Common::String &file) { CACHE_BANQUE[1] = spriteData; int curBufIdx = 60; for (int i = 0; i <= 21; i++) { - Cache[i]._spriteIndex = (int16)READ_LE_UINT16((uint16 *)ptr + curBufIdx); - Cache[i]._x = (int16)READ_LE_UINT16((uint16 *)ptr + curBufIdx + 1); - Cache[i]._y = (int16)READ_LE_UINT16((uint16 *)ptr + curBufIdx + 2); - Cache[i].field14 = (int16)READ_LE_UINT16((uint16 *)ptr + curBufIdx + 4); + Cache[i]._spriteIndex = READ_LE_INT16((uint16 *)ptr + curBufIdx); + Cache[i]._x = READ_LE_INT16((uint16 *)ptr + curBufIdx + 1); + Cache[i]._y = READ_LE_INT16((uint16 *)ptr + curBufIdx + 2); + Cache[i].field14 = READ_LE_INT16((uint16 *)ptr + curBufIdx + 4); if (spriteData == g_PTRNUL) { Cache[i]._useCount = 0; } else { diff --git a/engines/hopkins/globals.h b/engines/hopkins/globals.h index 0eed175462..bfd5d01307 100644 --- a/engines/hopkins/globals.h +++ b/engines/hopkins/globals.h @@ -192,8 +192,6 @@ enum SauvegardeOffset { , svField401 = 401 }; -enum PlayerCharacter { CHARACTER_HOPKINS = 0, CHARACTER_HOPKINS_CLONE = 1, CHARACTER_SAMANTHA = 2 }; - // TODO: Sauvegrade1 fields should really be mapped into data array struct Sauvegarde { byte _data[2050]; @@ -215,6 +213,21 @@ struct CreditItem { enum Language { LANG_EN = 0, LANG_FR = 1, LANG_SP = 2}; +enum PlayerCharacter { CHARACTER_HOPKINS = 0, CHARACTER_HOPKINS_CLONE = 1, CHARACTER_SAMANTHA = 2 }; + +enum Directions { + DIR_NONE = -1, + DIR_UP = 1, + DIR_UP_RIGHT = 2, + DIR_RIGHT = 3, + DIR_DOWN_RIGHT = 4, + DIR_DOWN = 5, + DIR_DOWN_LEFT = 6, + DIR_LEFT = 7, + DIR_UP_LEFT = 8 +}; + + class HopkinsEngine; /** @@ -238,10 +251,11 @@ public: bool _cacheFl; bool _forceHideText; int _exitId; - int _oceanDirection; - int _oldDirection, _oldDirectionSpriteIdx; + Directions _oceanDirection; + Directions _oldDirection; + int _oldDirectionSpriteIdx; int _actionDirection; - int _lastDirection; + Directions _lastDirection; int _oldFrameIndex; int _hotspotTextColor; int _inventory[36]; @@ -312,7 +326,6 @@ public: int compteur_71; Common::String FICH_ZONE; bool GOACTION; - int j_104; Common::String FICH_TEXTE; Globals(); diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 61af620769..0e2df5e04a 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1246,9 +1246,9 @@ void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp spriteStartP += READ_LE_UINT32(spriteStartP) + 16; const byte *spriteSizeP = spriteStartP + 4; - int spriteWidth = (int16)READ_LE_UINT16(spriteSizeP); + int spriteWidth = READ_LE_INT16(spriteSizeP); spriteSizeP += 2; - int spriteHeight2 = (int16)READ_LE_UINT16(spriteSizeP); + int spriteHeight2 = READ_LE_INT16(spriteSizeP); int spriteHeight1 = spriteHeight2; const byte *spritePixelsP = spriteSizeP + 10; _posXClipped = 0; @@ -1639,9 +1639,9 @@ void GraphicsManager::displayFont(byte *surface, const byte *spriteData, int xp, int spriteWidth = 0; int spriteHeight = 0; const byte *spriteSizeP = spriteDataP + 4; - spriteWidth = (int16)READ_LE_UINT16(spriteSizeP); + spriteWidth = READ_LE_INT16(spriteSizeP); spriteSizeP += 2; - spriteHeight = (int16)READ_LE_UINT16(spriteSizeP); + spriteHeight = READ_LE_INT16(spriteSizeP); const byte *spritePixelsP = spriteSizeP + 10; byte *destP = surface + xp + _lineNbr2 * yp; _width = spriteWidth; diff --git a/engines/hopkins/hopkins.cpp b/engines/hopkins/hopkins.cpp index c7bea38e03..880d2b6cd2 100644 --- a/engines/hopkins/hopkins.cpp +++ b/engines/hopkins/hopkins.cpp @@ -1285,55 +1285,55 @@ bool HopkinsEngine::runFull() { break; case 77: - OCEAN(77, "OCEAN01", 3, 0, 84, 0, 0, 25); + OCEAN(77, "OCEAN01", DIR_RIGHT, 0, 84, 0, 0, 25); break; case 78: - OCEAN(78, "OCEAN02", 1, 0, 91, 84, 0, 25); + OCEAN(78, "OCEAN02", DIR_UP, 0, 91, 84, 0, 25); break; case 79: - OCEAN(79, "OCEAN03", 7, 87, 0, 0, 83, 25); + OCEAN(79, "OCEAN03", DIR_LEFT, 87, 0, 0, 83, 25); break; case 80: - OCEAN(80, "OCEAN04", 1, 86, 88, 0, 81, 25); + OCEAN(80, "OCEAN04", DIR_UP, 86, 88, 0, 81, 25); break; case 81: - OCEAN(81, "OCEAN05", 1, 91, 82, 80, 85, 25); + OCEAN(81, "OCEAN05", DIR_UP, 91, 82, 80, 85, 25); break; case 82: - OCEAN(82, "OCEAN06", 7, 81, 0, 88, 0, 25); + OCEAN(82, "OCEAN06", DIR_LEFT, 81, 0, 88, 0, 25); break; case 83: - OCEAN(83, "OCEAN07", 1, 89, 0, 79, 88, 25); + OCEAN(83, "OCEAN07", DIR_UP, 89, 0, 79, 88, 25); break; case 84: - OCEAN(84, "OCEAN08", 1, 77, 0, 0, 78, 25); + OCEAN(84, "OCEAN08", DIR_UP, 77, 0, 0, 78, 25); break; case 85: - OCEAN(85, "OCEAN09", 1, 0, 0, 81, 0, 25); + OCEAN(85, "OCEAN09", DIR_UP, 0, 0, 81, 0, 25); break; case 86: - OCEAN(86, "OCEAN10", 1, 0, 80, 0, 91, 25); + OCEAN(86, "OCEAN10", DIR_UP, 0, 80, 0, 91, 25); break; case 87: - OCEAN(87, "OCEAN11", 3, 0, 79, 90, 0, 25); + OCEAN(87, "OCEAN11", DIR_RIGHT, 0, 79, 90, 0, 25); break; case 88: - OCEAN(88, "OCEAN12", 1, 80, 0, 83, 82, 25); + OCEAN(88, "OCEAN12", DIR_UP, 80, 0, 83, 82, 25); break; case 89: - OCEAN(89, "OCEAN13", 3, 0, 83, 0, 0, 25); + OCEAN(89, "OCEAN13", DIR_RIGHT, 0, 83, 0, 0, 25); break; case 90: @@ -1341,7 +1341,7 @@ bool HopkinsEngine::runFull() { break; case 91: - OCEAN(91, "OCEAN15", 3, 78, 81, 86, 0, 25); + OCEAN(91, "OCEAN15", DIR_RIGHT, 78, 81, 86, 0, 25); break; case 93: @@ -2540,18 +2540,18 @@ void HopkinsEngine::BTOCEAN() { switch (_objectsManager._zoneNum) { case 1: switch (_globals._oceanDirection) { - case 1: - _objectsManager.SPACTION(_globals.PERSO, "27,26,25,24,23,22,21,20,19,18,-1,", 0, 0, 6, false); - break; - case 3: + case DIR_UP: + _objectsManager.SPACTION(_globals.PERSO, "27,26,25,24,23,22,21,20,19,18,-1,", 0, 0, 6, false); + break; + case DIR_RIGHT: _objectsManager.SPACTION(_globals.PERSO, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,-1,", 0, 0, 6, false); break; - case 5: + case DIR_DOWN: _objectsManager.SPACTION(_globals.PERSO, "9,10,11,12,13,14,15,16,17,18,-1,", 0, 0, 6, false); break; } - _globals._oceanDirection = 7; + _globals._oceanDirection = DIR_LEFT; _globals._exitId = 1; oldX = _objectsManager.getSpriteX(0); for (;;) { @@ -2575,17 +2575,17 @@ void HopkinsEngine::BTOCEAN() { break; case 2: switch (_globals._oceanDirection) { - case 1: + case DIR_UP: _objectsManager.SPACTION(_globals.PERSO, "27,28,29,30,31,32,33,34,35,36,-1,", 0, 0, 6, false); break; - case 5: + case DIR_DOWN: _objectsManager.SPACTION(_globals.PERSO, "9,8,7,6,5,4,3,2,1,0,-1,", 0, 0, 6, false); break; - case 7: + case DIR_LEFT: _objectsManager.SPACTION(_globals.PERSO, "18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,-1,", 0, 0, 6, false); break; } - _globals._oceanDirection = 3; + _globals._oceanDirection = DIR_RIGHT; _globals._exitId = 2; oldX = _objectsManager.getSpriteX(0); for (;;) { @@ -2608,7 +2608,7 @@ void HopkinsEngine::BTOCEAN() { break; case 3: switch (_globals._oceanDirection) { - case 3: + case DIR_RIGHT: oldX = _objectsManager.getSpriteX(0); do { if (_globals._speed == 1) @@ -2628,10 +2628,10 @@ void HopkinsEngine::BTOCEAN() { if (!displAnim) _objectsManager.SPACTION(_globals.PERSO, "36,35,34,33,32,31,30,29,28,27,-1,", 0, 0, 6, false); break; - case 5: + case DIR_DOWN: _objectsManager.SPACTION(_globals.PERSO, "9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,-1,", 0, 0, 6, false); break; - case 7: + case DIR_LEFT: oldX = _objectsManager.getSpriteX(0); do { if (_globals._speed == 1) @@ -2652,15 +2652,15 @@ void HopkinsEngine::BTOCEAN() { _objectsManager.SPACTION(_globals.PERSO, "18,19,20,21,22,23,24,25,26,27,-1,", 0, 0, 6, false); break; } - _globals._oceanDirection = 1; + _globals._oceanDirection = DIR_UP; _globals._exitId = 3; break; case 4: switch (_globals._oceanDirection) { - case 1: + case DIR_UP: _objectsManager.SPACTION(_globals.PERSO, "27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,-1,", 0, 0, 6, false); break; - case 3: + case DIR_RIGHT: oldX = _objectsManager.getSpriteX(0); do { if (_globals._speed == 1) @@ -2680,7 +2680,7 @@ void HopkinsEngine::BTOCEAN() { if (!displAnim) _objectsManager.SPACTION(_globals.PERSO, "0,1,2,3,4,5,6,7,8,9,-1,", 0, 0, 6, false); break; - case 7: + case DIR_LEFT: oldX = _objectsManager.getSpriteX(0); for (;;) { if (_globals._speed == 1) @@ -2703,24 +2703,30 @@ void HopkinsEngine::BTOCEAN() { } break; } - _globals._oceanDirection = 5; + _globals._oceanDirection = DIR_DOWN; _globals._exitId = 4; break; } } void HopkinsEngine::OCEAN_HOME() { - if (_globals._oceanDirection == 3) - _objectsManager.setSpriteIndex(0, 0); - else if (_globals._oceanDirection == 7) - _objectsManager.setSpriteIndex(0, 18); - else if (_globals._oceanDirection == 1) + switch (_globals._oceanDirection) { + case DIR_UP: _objectsManager.setSpriteIndex(0, 27); - else if (_globals._oceanDirection == 5) + break; + case DIR_RIGHT: + _objectsManager.setSpriteIndex(0, 0); + break; + case DIR_DOWN: _objectsManager.setSpriteIndex(0, 9); + break; + case DIR_LEFT: + _objectsManager.setSpriteIndex(0, 18); + break; + } } -void HopkinsEngine::OCEAN(int16 curExitId, Common::String backgroundFilename, int16 defaultDirection, int16 exit1, int16 exit2, int16 exit3, int16 exit4, int16 soundId) { +void HopkinsEngine::OCEAN(int16 curExitId, Common::String backgroundFilename, Directions defaultDirection, int16 exit1, int16 exit2, int16 exit3, int16 exit4, int16 soundId) { _globals._cityMapEnabledFl = false; _graphicsManager._noFadingFl = false; _globals.NOMARCHE = false; @@ -2753,19 +2759,19 @@ void HopkinsEngine::OCEAN(int16 curExitId, Common::String backgroundFilename, in _globals._oceanDirection = defaultDirection; switch (_globals._oceanDirection) { - case 1: + case DIR_UP: _objectsManager._characterPos.x = 236; _objectsManager._startSpriteIndex = 27; break; - case 3: + case DIR_RIGHT: _objectsManager._characterPos.x = -20; _objectsManager._startSpriteIndex = 0; break; - case 5: + case DIR_DOWN: _objectsManager._characterPos.x = 236; _objectsManager._startSpriteIndex = 9; break; - case 7: + case DIR_LEFT: _objectsManager._characterPos.x = 415; _objectsManager._startSpriteIndex = 18; break; diff --git a/engines/hopkins/hopkins.h b/engines/hopkins/hopkins.h index d3e735df10..0fd683375f 100644 --- a/engines/hopkins/hopkins.h +++ b/engines/hopkins/hopkins.h @@ -82,6 +82,8 @@ enum { */ #define MKTAG24(a0,a1,a2) ((uint32)((a2) | (a1) << 8 | ((a0) << 16))) +#define READ_LE_INT16(x) (int16) READ_LE_UINT16(x) + struct HopkinsGameDescription; class HopkinsEngine : public Engine { @@ -120,7 +122,7 @@ private: void BTOCEAN(); void OCEAN_HOME(); - void OCEAN(int16 curExitId, Common::String backgroundFilename, int16 defaultDirection, int16 exit1, int16 exit2, int16 exit3, int16 exit4, int16 soundId); + void OCEAN(int16 curExitId, Common::String backgroundFilename, Directions defaultDirection, int16 exit1, int16 exit2, int16 exit3, int16 exit4, int16 soundId); void loadCredits(); void displayCredits(int startPosY, byte *buffer, char colour); void displayCredits(); diff --git a/engines/hopkins/lines.cpp b/engines/hopkins/lines.cpp index 3334a76757..6870d1a0c1 100644 --- a/engines/hopkins/lines.cpp +++ b/engines/hopkins/lines.cpp @@ -59,7 +59,7 @@ LinesManager::LinesManager() { Common::fill((byte *)&_smoothRoute[i], (byte *)&_smoothRoute[i] + sizeof(SmoothItem), 0); for (int i = 0; i < 8001; ++i) - super_parcours[i].set(0, 0, 0); + super_parcours[i].set(0, 0, DIR_NONE); for (int i = 0; i < 101; ++i) { Common::fill((byte *)&_segment[i], (byte *)&_segment[i] + sizeof(SegmentItem), 0); @@ -80,7 +80,7 @@ LinesManager::LinesManager() { NV_POSI = 0; NVPX = 0; NVPY = 0; - _smoothMoveDirection = 0; + _smoothMoveDirection = DIR_NONE; _lastLine = 0; _maxLineIdx = 0; _pathFindingMaxDepth = 0; @@ -109,13 +109,13 @@ void LinesManager::loadLines(const Common::String &file) { _linesNumb = 0; _lastLine = 0; byte *ptr = _vm->_fileManager.loadFile(file); - for (int idx = 0; (int16)READ_LE_UINT16((uint16 *)ptr + (idx * 5)) != -1; idx++) { + for (int idx = 0; READ_LE_INT16((uint16 *)ptr + (idx * 5)) != -1; idx++) { addLine(idx, - (int16)READ_LE_UINT16((uint16 *)ptr + (idx * 5)), - (int16)READ_LE_UINT16((uint16 *)ptr + (idx * 5) + 1), - (int16)READ_LE_UINT16((uint16 *)ptr + (idx * 5) + 2), - (int16)READ_LE_UINT16((uint16 *)ptr + (idx * 5) + 3), - (int16)READ_LE_UINT16((uint16 *)ptr + (idx * 5) + 4)); + (Directions)READ_LE_INT16((uint16 *)ptr + (idx * 5)), + READ_LE_INT16((uint16 *)ptr + (idx * 5) + 1), + READ_LE_INT16((uint16 *)ptr + (idx * 5) + 2), + READ_LE_INT16((uint16 *)ptr + (idx * 5) + 3), + READ_LE_INT16((uint16 *)ptr + (idx * 5) + 4)); } initRoute(); _vm->_globals.freeMemory(ptr); @@ -237,18 +237,16 @@ void LinesManager::addZoneLine(int idx, int a2, int a3, int a4, int a5, int bobZ /** * Add Line */ -void LinesManager::addLine(int idx, int direction, int a3, int a4, int a5, int a6) { +void LinesManager::addLine(int idx, Directions direction, int a3, int a4, int a5, int a6) { assert (idx <= MAX_LINES); if (_linesNumb < idx) _linesNumb = idx; Ligne[idx]._lineData = (int16 *)_vm->_globals.freeMemory((byte *)Ligne[idx]._lineData); - int v7 = abs(a3 - a5); - int v8 = v7 + 1; - int v9 = abs(a4 - a6); - int v34 = v9 + 1; - int v33 = v9 + 1; + int v8 = abs(a3 - a5) + 1; + int v34 = abs(a4 - a6) + 1; + int v33 = v34; if (v8 > v34) v34 = v8; @@ -270,60 +268,60 @@ void LinesManager::addLine(int idx, int direction, int a3, int a4, int a5, int a int v12 = (int)v37 / 1000; if (!v11) { if (v12 == -1) { - Ligne[idx].field6 = 1; - Ligne[idx].field8 = 5; + Ligne[idx].field6 = DIR_UP; + Ligne[idx].field8 = DIR_DOWN; } if (v12 == 1) { - Ligne[idx].field6 = 5; - Ligne[idx].field8 = 1; + Ligne[idx].field6 = DIR_DOWN; + Ligne[idx].field8 = DIR_UP; } } if (v11 == 1) { if (v12 == -1) { - Ligne[idx].field6 = 2; - Ligne[idx].field8 = 6; + Ligne[idx].field6 = DIR_UP_RIGHT; + Ligne[idx].field8 = DIR_DOWN_LEFT; } if (!v12) { - Ligne[idx].field6 = 3; - Ligne[idx].field8 = 7; + Ligne[idx].field6 = DIR_RIGHT; + Ligne[idx].field8 = DIR_LEFT; } if (v12 == 1) { - Ligne[idx].field6 = 4; - Ligne[idx].field8 = 8; + Ligne[idx].field6 = DIR_DOWN_RIGHT; + Ligne[idx].field8 = DIR_UP_LEFT; } } if (v11 == -1) { if (v12 == 1) { - Ligne[idx].field6 = 6; - Ligne[idx].field8 = 2; + Ligne[idx].field6 = DIR_DOWN_LEFT; + Ligne[idx].field8 = DIR_UP_RIGHT; } if (!v12) { - Ligne[idx].field6 = 7; - Ligne[idx].field8 = 3; + Ligne[idx].field6 = DIR_LEFT; + Ligne[idx].field8 = DIR_RIGHT; } if (v12 == -1) { - Ligne[idx].field6 = 8; - Ligne[idx].field8 = 4; + Ligne[idx].field6 = DIR_UP_LEFT; + Ligne[idx].field8 = DIR_DOWN_RIGHT; } } if (v11 == 1 && v37 > 250 && v37 <= 999) { - Ligne[idx].field6 = 4; - Ligne[idx].field8 = 8; + Ligne[idx].field6 = DIR_DOWN_RIGHT; + Ligne[idx].field8 = DIR_UP_LEFT; } if (v11 == -1 && v37 > 250 && v37 <= 999) { - Ligne[idx].field6 = 6; - Ligne[idx].field8 = 2; + Ligne[idx].field6 = DIR_DOWN_LEFT; + Ligne[idx].field8 = DIR_UP_RIGHT; } if (v11 == 1 && v37 < -250 && v37 > -1000) { - Ligne[idx].field6 = 2; - Ligne[idx].field8 = 6; + Ligne[idx].field6 = DIR_UP_RIGHT; + Ligne[idx].field8 = DIR_DOWN_LEFT; } // This condition is impossible to meet! // Code present in the Linux and BeOS executables // CHECKME: maybe it should be checking negative values? if (v11 == -1 && v37 <= 249 && v37 > 1000) { - Ligne[idx].field6 = 8; - Ligne[idx].field8 = 4; + Ligne[idx].field6 = DIR_UP_LEFT; + Ligne[idx].field8 = DIR_DOWN_RIGHT; } int v40 = v36 / v34; int v38 = 1000 * v33 / v34; @@ -528,34 +526,9 @@ int LinesManager::CONTOURNE1(int a1, int a2, int a3, int a4, int a5, RouteItem * return v40; } -bool LinesManager::MIRACLE(int a1, int a2, int a3, int a4, int a5) { - int v5; - int v6; - int v7; - int v9; - int v10; - int i; - int v12; - int v13; - int j; - int v15; - int v16; - int k; - int v18; - int v19; - int l; - int v21; - int v23; - int v26; - int v29; - int v32; +bool LinesManager::MIRACLE(int fromX, int fromY, int a3, int a4, int a5) { int v35 = 0; int v36 = 0; - int v37; - int v38; - int v39; - int v40; - int v41; int v42 = 0; int v43 = 0; int v44 = 0; @@ -564,50 +537,49 @@ bool LinesManager::MIRACLE(int a1, int a2, int a3, int a4, int a5) { int v47 = 0; int v48 = 0; int v49 = 0; - int v50; - int v51; - v5 = a1; - v6 = a2; - v50 = a3; - v7 = a5; - if (checkCollisionLine(a1, a2, &v51, &v50, 0, _linesNumb)) { + int curX = fromX; + int curY = fromY; + int v50 = a3; + int v7 = a5; + int v51; + if (checkCollisionLine(fromX, fromY, &v51, &v50, 0, _linesNumb)) { switch (Ligne[v50]._direction) { - case 1: - v6 = a2 - 2; + case DIR_UP: + curY -= 2; break; - case 2: - v6 -= 2; - v5 = a1 + 2; + case DIR_UP_RIGHT: + curY -= 2; + curX += 2; break; - case 3: - v5 += 2; + case DIR_RIGHT: + curX += 2; break; - case 4: - v6 += 2; - v5 += 2; + case DIR_DOWN_RIGHT: + curY += 2; + curX += 2; break; - case 5: - v6 += 2; + case DIR_DOWN: + curY += 2; break; - case 6: - v6 += 2; - v5 -= 2; + case DIR_DOWN_LEFT: + curY += 2; + curX -= 2; break; - case 7: - v5 -= 2; + case DIR_LEFT: + curX -= 2; break; - case 8: - v6 -= 2; - v5 -= 2; + case DIR_UP_LEFT: + curY -= 2; + curX -= 2; break; } } - v41 = v5; - v40 = v6; - v9 = 0; - v10 = v40; - for (i = v40; v40 + 200 > v10; i = v10) { + int v41 = curX; + int v40 = curY; + int v9 = 0; + int v10 = v40; + for (int i = v40; v40 + 200 > v10; i = v10) { if (checkCollisionLine(v41, i, &v49, &v48, 0, _lastLine) == 1 && v48 <= _lastLine) break; v49 = 0; @@ -615,10 +587,10 @@ bool LinesManager::MIRACLE(int a1, int a2, int a3, int a4, int a5) { ++v9; ++v10; } - v37 = v9; - v12 = 0; - v13 = v40; - for (j = v40; v40 - 200 < v13; j = v13) { + int v37 = v9; + int v12 = 0; + int v13 = v40; + for (int j = v40; v40 - 200 < v13; j = v13) { if (checkCollisionLine(v41, j, &v47, &v46, 0, _lastLine) == 1 && v46 <= _lastLine) break; v47 = 0; @@ -626,10 +598,10 @@ bool LinesManager::MIRACLE(int a1, int a2, int a3, int a4, int a5) { ++v12; --v13; } - v39 = v12; - v15 = 0; - v16 = v41; - for (k = v41; v41 + 200 > v16; k = v16) { + int v39 = v12; + int v15 = 0; + int v16 = v41; + for (int k = v41; v41 + 200 > v16; k = v16) { if (checkCollisionLine(k, v40, &v45, &v44, 0, _lastLine) == 1 && v44 <= _lastLine) break; v45 = 0; @@ -637,10 +609,10 @@ bool LinesManager::MIRACLE(int a1, int a2, int a3, int a4, int a5) { ++v15; ++v16; } - v38 = v15; - v18 = 0; - v19 = v41; - for (l = v41; v41 - 200 < v19; l = v19) { + int v38 = v15; + int v18 = 0; + int v19 = v41; + for (int l = v41; v41 - 200 < v19; l = v19) { if (checkCollisionLine(l, v40, &v43, &v42, 0, _lastLine) == 1 && v42 <= _lastLine) break; v43 = 0; @@ -665,8 +637,7 @@ bool LinesManager::MIRACLE(int a1, int a2, int a3, int a4, int a5) { v48 = -1; if (v42 != -1 && a4 < v42) v42 = -1; - } - if (a4 < v50) { + } else if (a4 < v50) { if (v46 != -1 && v46 >= v50) v46 = -1; if (v44 != -1 && v50 <= v44) @@ -685,18 +656,17 @@ bool LinesManager::MIRACLE(int a1, int a2, int a3, int a4, int a5) { v42 = -1; } if (v46 != -1 || v44 != -1 || v48 != -1 || v42 != -1) { - v21 = 0; + Directions newDir = DIR_NONE; if (a4 > v50) { if (v48 <= v46 && v44 <= v46 && v42 <= v46 && v46 > v50) - v21 = 1; + newDir = DIR_UP; if (v48 <= v44 && v46 <= v44 && v42 <= v44 && v50 < v44) - v21 = 3; + newDir = DIR_RIGHT; if (v46 <= v48 && v44 <= v48 && v42 <= v48 && v50 < v48) - v21 = 5; + newDir = DIR_DOWN; if (v48 <= v42 && v44 <= v42 && v46 <= v42 && v50 < v42) - v21 = 7; - } - if (a4 < v50) { + newDir = DIR_LEFT; + } else if (a4 < v50) { if (v46 == -1) v46 = 1300; if (v44 == -1) @@ -706,103 +676,96 @@ bool LinesManager::MIRACLE(int a1, int a2, int a3, int a4, int a5) { if (v42 == -1) v42 = 1300; if (v46 != 1300 && v48 >= v46 && v44 >= v46 && v42 >= v46 && v46 < v50) - v21 = 1; + newDir = DIR_UP; if (v44 != 1300 && v48 >= v44 && v46 >= v44 && v42 >= v44 && v50 > v44) - v21 = 3; + newDir = DIR_RIGHT; if (v48 != 1300 && v46 >= v48 && v44 >= v48 && v42 >= v48 && v50 > v48) - v21 = 5; + newDir = DIR_DOWN; if (v42 != 1300 && v48 >= v42 && v44 >= v42 && v46 >= v42 && v50 > v42) - v21 = 7; - } - if (v21) { - if (v21 == 1) { - v36 = v46; - v35 = v47; - } - if (v21 == 3) { - v36 = v44; - v35 = v45; - } - if (v21 == 5) { - v36 = v48; - v35 = v49; - } - if (v21 == 7) { - v36 = v42; - v35 = v43; - } - if (v21 == 1) { - for (int v22 = 0; v22 < v39; v22++) { - if (checkCollisionLine(v41, v40 - v22, &v47, &v46, _lastLine + 1, _linesNumb) && _lastLine < v46) { - v23 = GENIAL(v46, v47, v41, v40 - v22, v41, v40 - v39, v7, &super_parcours[0]); - if (v23 == -1) - return false; - v7 = v23; - if (NVPY != -1) - v22 = NVPY - v40; - } - super_parcours[v7].set(v41, v40 - v22, 1); - v7++; + newDir = DIR_LEFT; + } + + switch(newDir) { + case DIR_UP: + v36 = v46; + v35 = v47; + for (int v22 = 0; v22 < v39; v22++) { + if (checkCollisionLine(v41, v40 - v22, &v47, &v46, _lastLine + 1, _linesNumb) && _lastLine < v46) { + int v23 = GENIAL(v46, v47, v41, v40 - v22, v41, v40 - v39, v7, &super_parcours[0]); + if (v23 == -1) + return false; + v7 = v23; + if (NVPY != -1) + v22 = NVPY - v40; } - NV_LIGNEDEP = v36; - NV_LIGNEOFS = v35; - NV_POSI = v7; - return true; + super_parcours[v7].set(v41, v40 - v22, DIR_UP); + v7++; } - if (v21 == 5) { - for (int v25 = 0; v25 < v37; v25++) { - if (checkCollisionLine(v41, v25 + v40, &v47, &v46, _lastLine + 1, _linesNumb) && _lastLine < v46) { - v26 = GENIAL(v46, v47, v41, v25 + v40, v41, v37 + v40, v7, &super_parcours[0]); - if (v26 == -1) - return false; - v7 = v26; - if (NVPY != -1) - v25 = v40 - NVPY; - } - super_parcours[v7].set(v41, v25 + v40, 5); - v7++; + NV_LIGNEDEP = v36; + NV_LIGNEOFS = v35; + NV_POSI = v7; + return true; + break; + case DIR_RIGHT: + v36 = v44; + v35 = v45; + for (int v31 = 0; v31 < v38; v31++) { + if (checkCollisionLine(v31 + v41, v40, &v47, &v46, _lastLine + 1, _linesNumb) && _lastLine < v46) { + int v32 = GENIAL(v46, v47, v31 + v41, v40, v38 + v41, v40, v7, &super_parcours[0]); + if (v32 == -1) + return false; + v7 = v32; + if (NVPX != -1) + v31 = NVPX - v41; } - NV_LIGNEDEP = v36; - NV_LIGNEOFS = v35; - NV_POSI = v7; - return true; + super_parcours[v7].set(v31 + v41, v40, DIR_RIGHT); + v7++; } - if (v21 == 7) { - for (int v28 = 0; v28 < v18; v28++) { - if (checkCollisionLine(v41 - v28, v40, &v47, &v46, _lastLine + 1, _linesNumb) && _lastLine < v46) { - v29 = GENIAL(v46, v47, v41 - v28, v40, v41 - v18, v40, v7, &super_parcours[0]); - if (v29 == -1) - return false; - v7 = v29; - if (NVPX != -1) - v28 = v41 - NVPX; - } - super_parcours[v7].set(v41 - v28, v40, 7); - v7++; + NV_LIGNEDEP = v36; + NV_LIGNEOFS = v35; + NV_POSI = v7; + return true; + break; + case DIR_DOWN: + v36 = v48; + v35 = v49; + for (int v25 = 0; v25 < v37; v25++) { + if (checkCollisionLine(v41, v25 + v40, &v47, &v46, _lastLine + 1, _linesNumb) && _lastLine < v46) { + int v26 = GENIAL(v46, v47, v41, v25 + v40, v41, v37 + v40, v7, &super_parcours[0]); + if (v26 == -1) + return false; + v7 = v26; + if (NVPY != -1) + v25 = v40 - NVPY; } - NV_LIGNEDEP = v36; - NV_LIGNEOFS = v35; - NV_POSI = v7; - return true; + super_parcours[v7].set(v41, v25 + v40, DIR_DOWN); + v7++; } - if (v21 == 3) { - for (int v31 = 0; v31 < v38; v31++) { - if (checkCollisionLine(v31 + v41, v40, &v47, &v46, _lastLine + 1, _linesNumb) && _lastLine < v46) { - v32 = GENIAL(v46, v47, v31 + v41, v40, v38 + v41, v40, v7, &super_parcours[0]); - if (v32 == -1) - return false; - v7 = v32; - if (NVPX != -1) - v31 = NVPX - v41; - } - super_parcours[v7].set(v31 + v41, v40, 3); - v7++; + NV_LIGNEDEP = v36; + NV_LIGNEOFS = v35; + NV_POSI = v7; + return true; + break; + case DIR_LEFT: + v36 = v42; + v35 = v43; + for (int v28 = 0; v28 < v18; v28++) { + if (checkCollisionLine(v41 - v28, v40, &v47, &v46, _lastLine + 1, _linesNumb) && _lastLine < v46) { + int v29 = GENIAL(v46, v47, v41 - v28, v40, v41 - v18, v40, v7, &super_parcours[0]); + if (v29 == -1) + return false; + v7 = v29; + if (NVPX != -1) + v28 = v41 - NVPX; } - NV_LIGNEDEP = v36; - NV_LIGNEOFS = v35; - NV_POSI = v7; - return true; + super_parcours[v7].set(v41 - v28, v40, DIR_LEFT); + v7++; } + NV_LIGNEDEP = v36; + NV_LIGNEOFS = v35; + NV_POSI = v7; + return true; + break; } } return false; @@ -1081,31 +1044,31 @@ int LinesManager::GENIAL(int lineIdx, int dataIdx, int a3, int a4, int a5, int a break; switch (Ligne[foundLineIdx]._direction) { - case 1: + case DIR_UP: --NVPY; break; - case 2: + case DIR_UP_RIGHT: --NVPY; ++NVPX; break; - case 3: + case DIR_RIGHT: ++NVPX; break; - case 4: + case DIR_DOWN_RIGHT: ++NVPY; ++NVPX; break; - case 5: + case DIR_DOWN: ++NVPY; break; - case 6: + case DIR_DOWN_LEFT: ++NVPY; --NVPX; break; - case 7: + case DIR_LEFT: --NVPX; break; - case 8: + case DIR_UP_LEFT: --NVPY; --NVPX; break; @@ -1135,7 +1098,7 @@ RouteItem *LinesManager::PARCOURS2(int fromX, int fromY, int destX, int destY) { int v120 = 0; int v115 = 0; int v114 = 0; - int v113 = 0; + Directions newDir = DIR_NONE; int v111 = 0; if (destY <= 24) clipDestY = 25; @@ -1333,22 +1296,22 @@ RouteItem *LinesManager::PARCOURS2(int fromX, int fromY, int destX, int destY) { if (v141[1] != -1 && v126[3] >= v126[1] && v126[5] >= v126[1] && v126[7] >= v126[1]) { v115 = v141[1]; v111 = v131[1]; - v113 = 1; + newDir = DIR_UP; v114 = v136[1]; } else if (v141[5] != -1 && v126[3] >= v126[5] && v126[1] >= v126[5] && v126[7] >= v126[5]) { v115 = v141[5]; v111 = v131[5]; - v113 = 5; + newDir = DIR_DOWN; v114 = v136[5]; } else if (v141[3] != -1 && v126[1] >= v126[3] && v126[5] >= v126[3] && v126[7] >= v126[3]) { v115 = v141[3]; v111 = v131[3]; - v113 = 3; + newDir = DIR_RIGHT; v114 = v136[3]; } else if (v141[7] != -1 && v126[1] >= v126[7] && v126[5] >= v126[7] && v126[3] >= v126[7]) { v115 = v141[7]; v111 = v131[7]; - v113 = 7; + newDir = DIR_LEFT; v114 = v136[7]; } @@ -1362,7 +1325,7 @@ RouteItem *LinesManager::PARCOURS2(int fromX, int fromY, int destX, int destY) { v114 = NV_LIGNEOFS; v112 = NV_POSI; } else { - if (v113 == 1) { + if (newDir == DIR_UP) { for (int deltaY = 0; deltaY < v111; deltaY++) { if (checkCollisionLine(fromX, fromY - deltaY, &foundDataIdx, &foundLineIdx, _lastLine + 1, _linesNumb) && _lastLine < foundLineIdx) { int v58 = GENIAL(foundLineIdx, foundDataIdx, fromX, fromY - deltaY, fromX, fromY - v111, v112, super_parcours); @@ -1374,11 +1337,11 @@ RouteItem *LinesManager::PARCOURS2(int fromX, int fromY, int destX, int destY) { if (NVPY != -1) deltaY = fromY - NVPY; } - super_parcours[v112].set(fromX, fromY - deltaY, 1); + super_parcours[v112].set(fromX, fromY - deltaY, DIR_UP); v112++; } } - if (v113 == 5) { + if (newDir == DIR_DOWN) { for (int deltaY = 0; deltaY < v111; deltaY++) { if (checkCollisionLine(fromX, deltaY + fromY, &foundDataIdx, &foundLineIdx, _lastLine + 1, _linesNumb) && _lastLine < foundLineIdx) { @@ -1391,11 +1354,11 @@ RouteItem *LinesManager::PARCOURS2(int fromX, int fromY, int destX, int destY) { if (NVPY != -1) deltaY = NVPY - fromY; } - super_parcours[v112].set(fromX, fromY + deltaY, 5); + super_parcours[v112].set(fromX, fromY + deltaY, DIR_DOWN); v112++; } } - if (v113 == 7) { + if (newDir == DIR_LEFT) { for (int deltaX = 0; deltaX < v111; deltaX++) { if (checkCollisionLine(fromX - deltaX, fromY, &foundDataIdx, &foundLineIdx, _lastLine + 1, _linesNumb) && _lastLine < foundLineIdx) { int v64 = GENIAL(foundLineIdx, foundDataIdx, fromX - deltaX, fromY, fromX - v111, fromY, v112, &super_parcours[0]); @@ -1407,11 +1370,11 @@ RouteItem *LinesManager::PARCOURS2(int fromX, int fromY, int destX, int destY) { if (NVPX != -1) deltaX = fromX - NVPX; } - super_parcours[v112].set(fromX - deltaX, fromY, 7); + super_parcours[v112].set(fromX - deltaX, fromY, DIR_LEFT); v112++; } } - if (v113 == 3) { + if (newDir == DIR_RIGHT) { for (int deltaX = 0; deltaX < v111; deltaX++) { if (checkCollisionLine(deltaX + fromX, fromY, &foundDataIdx, &foundLineIdx, _lastLine + 1, _linesNumb) && _lastLine < foundLineIdx) { int v67 = GENIAL(foundLineIdx, foundDataIdx, deltaX + fromX, fromY, v111 + fromX, fromY, v112, &super_parcours[0]); @@ -1423,7 +1386,7 @@ RouteItem *LinesManager::PARCOURS2(int fromX, int fromY, int destX, int destY) { if (NVPX != -1) deltaX = NVPX - fromX; } - super_parcours[v112].set(fromX + deltaX, fromY, 3); + super_parcours[v112].set(fromX + deltaX, fromY, DIR_RIGHT); v112++; } } @@ -1558,7 +1521,7 @@ int LinesManager::PARC_PERS(int fromX, int fromY, int destX, int destY, int a5, bool v45; int v54; int v55; - int newDirection; + Directions newDirection; int v92; int v93; int v94; @@ -1599,30 +1562,30 @@ int LinesManager::PARC_PERS(int fromX, int fromY, int destX, int destY, int a5, int foundLineIdx = a5; if (checkCollisionLine(fromX, fromY, &foundDataIdx, &foundLineIdx, 0, _linesNumb)) { switch (Ligne[foundLineIdx]._direction) { - case 1: + case DIR_UP: curY -= 2; break; - case 2: + case DIR_UP_RIGHT: curY -= 2; curX += 2; break; - case 3: + case DIR_RIGHT: curX += 2; break; - case 4: + case DIR_DOWN_RIGHT: curY += 2; curX += 2; - case 5: + case DIR_DOWN: curY += 2; break; - case 6: + case DIR_DOWN_LEFT: curY += 2; curX -= 2; break; - case 7: + case DIR_LEFT: curX -= 2; break; - case 8: + case DIR_UP_LEFT: curY -= 2; curX -= 2; break; @@ -1660,19 +1623,19 @@ int LinesManager::PARC_PERS(int fromX, int fromY, int destX, int destY, int a5, v99 = -v99; v13 = (int16)v101 / 1000; v94 = (int16)v99 / 1000; - newDirection = -1; + newDirection = DIR_NONE; if (v94 == -1 && (v101 >= 0 && v101 <= 150)) - newDirection = 1; + newDirection = DIR_UP; if (v13 == 1 && (v99 >= -1 && v99 <= 150)) - newDirection = 3; + newDirection = DIR_RIGHT; if (v94 == 1 && (v101 >= -150 && v101 <= 150)) - newDirection = 5; + newDirection = DIR_DOWN; if (v13 == -1 && (v99 >= -150 && v99 <= 150)) - newDirection = 7; + newDirection = DIR_LEFT; if (v94 == -1 && (v101 >= -150 && v101 <= 0)) - newDirection = 1; + newDirection = DIR_UP; - if (newDirection == -1 && !checkSmoothMove(curX, v109, destX, destY) && !makeSmoothMove(curX, v109, destX, destY)) { + if (newDirection == DIR_NONE && !checkSmoothMove(curX, v109, destX, destY) && !makeSmoothMove(curX, v109, destX, destY)) { newDirection = _smoothMoveDirection; v14 = 0; for (v14 = 0; _smoothRoute[v14]._posX != -1 && _smoothRoute[v14]._posY != -1; ++v14) { @@ -1723,71 +1686,71 @@ int LinesManager::PARC_PERS(int fromX, int fromY, int destX, int destY, int a5, v104 = 1000 * v111 / 1000; v103 = v105 / 1000; if (!(v102 / 1000) && v96 == -1) - newDirection = 1; + newDirection = DIR_UP; if (v22 == 1) { if (v96 == -1) - newDirection = 2; + newDirection = DIR_UP_RIGHT; if (!v96) - newDirection = 3; + newDirection = DIR_RIGHT; if (v96 == 1) - newDirection = 4; + newDirection = DIR_DOWN_RIGHT; } if (!v22 && v96 == 1) - newDirection = 5; + newDirection = DIR_DOWN; if ((v22 != -1) && (v96 == -1)) { if (v102 >= 0 && v102 < 510) - newDirection = 1; + newDirection = DIR_UP; else if (v102 >= 510 && v102 <= 1000) - newDirection = 2; + newDirection = DIR_UP_RIGHT; } else { if (v96 == 1) - newDirection = 6; + newDirection = DIR_DOWN_LEFT; else if (!v96) - newDirection = 7; + newDirection = DIR_LEFT; else if (v96 == -1) { if (v102 >= 0 && v102 < 510) - newDirection = 1; + newDirection = DIR_UP; else if (v102 >= 510 && v102 <= 1000) - newDirection = 2; + newDirection = DIR_UP_RIGHT; else - newDirection = 8; + newDirection = DIR_UP_LEFT; } } if (v22 == 1) { if (v100 >= -1000 && v100 <= -510) - newDirection = 2; + newDirection = DIR_UP_RIGHT; if (v100 >= -510 && v100 <= 0) - newDirection = 3; + newDirection = DIR_RIGHT; if (v100 >= 0 && v100 <= 510) - newDirection = 3; + newDirection = DIR_RIGHT; if (v100 >= 510 && v100 <= 1000) - newDirection = 4; + newDirection = DIR_DOWN_RIGHT; } if (v96 == 1) { if (v102 >= 510 && v102 <= 1000) - newDirection = 4; + newDirection = DIR_DOWN_RIGHT; if (v102 >= 0 && v102 <= 510) - newDirection = 5; + newDirection = DIR_DOWN; if (v102 >= -510 && v102 <= 0) - newDirection = 5; + newDirection = DIR_DOWN; if (v102 >= -1000 && v102 <= -510) - newDirection = 6; + newDirection = DIR_DOWN_LEFT; } if (v22 == -1) { if (v100 >= 510 && v100 <= 1000) - newDirection = 6; + newDirection = DIR_DOWN_LEFT; if (v100 >= 0 && v100 <= 510) - newDirection = 7; + newDirection = DIR_LEFT; if (v100 >= -510 && v100 <= 0) - newDirection = 7; + newDirection = DIR_LEFT; if (v100 >= -1000 && v100 <= -510) - newDirection = 8; + newDirection = DIR_UP_LEFT; } if (v96 == -1) { if (v102 >= -1000 && v102 <= -510) - newDirection = 8; + newDirection = DIR_UP_LEFT; if (v102 >= -510 && v102 <= 0) - newDirection = 1; + newDirection = DIR_UP; } v23 = 0; if (v108 + 1 <= 0) { @@ -1841,9 +1804,9 @@ int LinesManager::PARC_PERS(int fromX, int fromY, int destX, int destY, int a5, } if (v33 < destX) - essai1[v117++].set(v33++, v92, 3); + essai1[v117++].set(v33++, v92, DIR_RIGHT); else - essai1[v117++].set(v33--, v92, 7); + essai1[v117++].set(v33--, v92, DIR_LEFT); } if (v33 != destX) break; @@ -1863,9 +1826,9 @@ int LinesManager::PARC_PERS(int fromX, int fromY, int destX, int destY, int a5, } if (v43 < destY) - essai1[v117++].set(destX, v43++, 5); + essai1[v117++].set(destX, v43++, DIR_DOWN); else - essai1[v117++].set(destX, v43--, 1); + essai1[v117++].set(destX, v43--, DIR_UP); } if (v43 == destY) { essai1[v117].invalidate(); @@ -1901,9 +1864,9 @@ int LinesManager::PARC_PERS(int fromX, int fromY, int destX, int destY, int a5, } if (v55 < destY) - essai2[v117++].set(v114, v55++, 5); + essai2[v117++].set(v114, v55++, DIR_DOWN); else - essai2[v117++].set(v114, v55--, 1); + essai2[v117++].set(v114, v55--, DIR_UP); } if (v55 != destY) break; @@ -1925,9 +1888,9 @@ int LinesManager::PARC_PERS(int fromX, int fromY, int destX, int destY, int a5, } if (v61 < destX) - essai2[v117++].set(v61++, destY, 3); + essai2[v117++].set(v61++, destY, DIR_RIGHT); else - essai2[v117++].set(v61--, destY, 7); + essai2[v117++].set(v61--, destY, DIR_LEFT); } if (v61 == destX) { collLineIdx = -1; @@ -2168,7 +2131,7 @@ RouteItem *LinesManager::cityMapCarRoute(int x1, int y1, int x2, int y2) { for (;;) { v28 = essai2[v27]._X; int v29 = essai2[v27]._Y; - int v66 = essai2[v27]._dir; + Directions v66 = essai2[v27]._dir; v27++; if (checkCollisionLine(v28, v29, &arrDataIdx[1], &arrLineIdx[1], 0, _lastLine)) @@ -2323,7 +2286,7 @@ bool LinesManager::makeSmoothMove(int fromX, int fromY, int destX, int destY) { if (stepCount > 5) { _smoothRoute[smoothIdx]._posX = -1; _smoothRoute[smoothIdx]._posY = -1; - _smoothMoveDirection = 6; + _smoothMoveDirection = DIR_DOWN_LEFT; return false; } } else if (fromX < destX && destY > fromY) { @@ -2357,7 +2320,7 @@ bool LinesManager::makeSmoothMove(int fromX, int fromY, int destX, int destY) { if (stepCount > 5) { _smoothRoute[smoothIdx]._posX = -1; _smoothRoute[smoothIdx]._posY = -1; - _smoothMoveDirection = 4; + _smoothMoveDirection = DIR_DOWN_RIGHT; return false; } } else if (fromX > destX && destY < fromY) { @@ -2384,7 +2347,7 @@ bool LinesManager::makeSmoothMove(int fromX, int fromY, int destX, int destY) { if (stepCount > 5) { _smoothRoute[smoothIdx]._posX = -1; _smoothRoute[smoothIdx]._posY = -1; - _smoothMoveDirection = 8; + _smoothMoveDirection = DIR_UP_LEFT; return false; } } else if (fromX < destX && destY < fromY) { @@ -2412,7 +2375,7 @@ bool LinesManager::makeSmoothMove(int fromX, int fromY, int destX, int destY) { if (stepCount > 5) { _smoothRoute[smoothIdx]._posX = -1; _smoothRoute[smoothIdx]._posY = -1; - _smoothMoveDirection = 2; + _smoothMoveDirection = DIR_UP_RIGHT; return false; } } @@ -2531,9 +2494,9 @@ int LinesManager::TEST_LIGNE(int paramX, int paramY, int *a3, int *foundLineIdx, *a3 = 1; int posX = lineData[2 * (lineDataEndIdx - 1)]; int posY = lineData[2 * (lineDataEndIdx - 1) + 1]; - if (Ligne[idx].field6 == 5 || Ligne[idx].field6 == 1) + if (Ligne[idx].field6 == DIR_DOWN || Ligne[idx].field6 == DIR_UP) posY += 2; - if (Ligne[idx].field6 == 3 || Ligne[idx].field8 == 7) + if (Ligne[idx].field6 == DIR_RIGHT || Ligne[idx].field8 == 7) posX += 2; if (!checkCollisionLine(posX, posY, &collDataIdx, &collLineIdx, 0, _lastLine)) error("Error in test line"); @@ -2545,9 +2508,9 @@ int LinesManager::TEST_LIGNE(int paramX, int paramY, int *a3, int *foundLineIdx, *a3 = 2; int posX = lineData[0]; int posY = lineData[1]; - if (Ligne[idx].field6 == 5 || Ligne[idx].field6 == 1) + if (Ligne[idx].field6 == DIR_DOWN || Ligne[idx].field6 == DIR_UP) posY -= 2; - if (Ligne[idx].field6 == 3 || Ligne[idx].field8 == 7) + if (Ligne[idx].field6 == DIR_RIGHT || Ligne[idx].field8 == 7) posX -= 2; if (!checkCollisionLine(posX, posY, &collDataIdx, &collLineIdx, 0, _lastLine)) error("Error in test line"); @@ -2589,9 +2552,9 @@ void LinesManager::PACOURS_PROPRE(RouteItem *route) { int v12; int v1 = 0; - int v14 = -1; + Directions v14 = DIR_NONE; int v2 = route[0]._Y; - int v15 = route[0]._dir; + Directions v15 = route[0]._dir; if (route[0]._X == -1 && v2 == -1) return; @@ -2738,9 +2701,9 @@ int LinesManager::colision(int xp, int yp) { int yMin = yp - 4; do { - int16 *dataP = _vm->_linesManager._zoneLine[curZoneLineIdx]._zoneData; + int16 *dataP = _zoneLine[curZoneLineIdx]._zoneData; if (dataP != (int16 *)g_PTRNUL) { - int count = _vm->_linesManager._zoneLine[curZoneLineIdx]._count; + int count = _zoneLine[curZoneLineIdx]._count; int v1 = dataP[0]; int v2 = dataP[1]; int v3 = dataP[count * 2 - 2]; @@ -2756,13 +2719,13 @@ int LinesManager::colision(int xp, int yp) { if (v2 >= v4 && (yMin > v2 || yMax < v4)) flag = false; - if (flag && _vm->_linesManager._zoneLine[curZoneLineIdx]._count > 0) { + if (flag && _zoneLine[curZoneLineIdx]._count > 0) { for (int i = 0; i < count; ++i) { int xCheck = *dataP++; int yCheck = *dataP++; if ((xp == xCheck || (xp + 1) == xCheck) && (yp == yCheck)) - return _vm->_linesManager._zoneLine[curZoneLineIdx]._bobZoneIdx; + return _zoneLine[curZoneLineIdx]._bobZoneIdx; } } } @@ -2786,18 +2749,18 @@ void LinesManager::CARRE_ZONE() { } for (int idx = 0; idx < MAX_LINES; ++idx) { - int16 *dataP = _vm->_linesManager._zoneLine[idx]._zoneData; + int16 *dataP = _zoneLine[idx]._zoneData; if (dataP == (int16 *)g_PTRNUL) continue; - int carreZoneId = _vm->_linesManager._zoneLine[idx]._bobZoneIdx; + int carreZoneId = _zoneLine[idx]._bobZoneIdx; _squareZone[carreZoneId]._enabledFl = 1; if (_squareZone[carreZoneId]._maxZoneLineIdx < idx) _squareZone[carreZoneId]._maxZoneLineIdx = idx; if (_squareZone[carreZoneId]._minZoneLineIdx > idx) _squareZone[carreZoneId]._minZoneLineIdx = idx; - for (int i = 0; i < _vm->_linesManager._zoneLine[idx]._count; i++) { + for (int i = 0; i < _zoneLine[idx]._count; i++) { int zoneX = *dataP++; int zoneY = *dataP++; @@ -2822,32 +2785,31 @@ void LinesManager::CARRE_ZONE() { void LinesManager::clearAll() { for (int idx = 0; idx < 105; ++idx) { - _vm->_linesManager.ZONEP[idx]._destX = 0; - _vm->_linesManager.ZONEP[idx]._destY = 0; - _vm->_linesManager.ZONEP[idx]._spriteIndex = 0; + ZONEP[idx]._destX = 0; + ZONEP[idx]._destY = 0; + ZONEP[idx]._spriteIndex = 0; } - _vm->_linesManager.essai0 = (RouteItem *)g_PTRNUL; - _vm->_linesManager.essai1 = (RouteItem *)g_PTRNUL; - _vm->_linesManager.essai2 = (RouteItem *)g_PTRNUL; - _vm->_linesManager.BufLig = (int16 *)g_PTRNUL; - _vm->_linesManager._route = (RouteItem *)g_PTRNUL; + essai0 = (RouteItem *)g_PTRNUL; + essai1 = (RouteItem *)g_PTRNUL; + essai2 = (RouteItem *)g_PTRNUL; + BufLig = (int16 *)g_PTRNUL; + _route = (RouteItem *)g_PTRNUL; for (int idx = 0; idx < MAX_LINES; ++idx) { - _vm->_linesManager.Ligne[idx]._lineDataEndIdx = 0; - _vm->_linesManager.Ligne[idx]._direction = 0; - _vm->_linesManager.Ligne[idx].field6 = 0; - _vm->_linesManager.Ligne[idx].field8 = 0; - _vm->_linesManager.Ligne[idx]._lineData = (int16 *)g_PTRNUL; + Ligne[idx]._lineDataEndIdx = 0; + Ligne[idx]._direction = DIR_NONE; + Ligne[idx].field6 = DIR_NONE; + Ligne[idx].field8 = DIR_NONE; + Ligne[idx]._lineData = (int16 *)g_PTRNUL; - _vm->_linesManager._zoneLine[idx]._count = 0; - _vm->_linesManager._zoneLine[idx]._bobZoneIdx = 0; - _vm->_linesManager._zoneLine[idx]._zoneData = (int16 *)g_PTRNUL; + _zoneLine[idx]._count = 0; + _zoneLine[idx]._bobZoneIdx = 0; + _zoneLine[idx]._zoneData = (int16 *)g_PTRNUL; } - for (int idx = 0; idx < 100; ++idx) { - _vm->_linesManager._squareZone[idx]._enabledFl = 0; - } + for (int idx = 0; idx < 100; ++idx) + _squareZone[idx]._enabledFl = 0; // FIXME: Delete these somewhere _vm->_linesManager.essai0 = new RouteItem[8334]; @@ -2949,11 +2911,11 @@ void LinesManager::checkZone() { if (_vm->_globals.compteur_71 <= 1) return; - if (_vm->_globals.NOMARCHE || (_vm->_linesManager._route == (RouteItem *)g_PTRNUL) || _vm->_globals.compteur_71 > 4) { + if (_vm->_globals.NOMARCHE || (_route == (RouteItem *)g_PTRNUL) || _vm->_globals.compteur_71 > 4) { _vm->_globals.compteur_71 = 0; int zoneId; if (_vm->_globals._oldMouseX != mouseX || _vm->_globals._oldMouseY != oldMouseY) { - zoneId = _vm->_linesManager.MZONE(); + zoneId = MZONE(); } else { zoneId = _vm->_globals._oldMouseZoneId; } diff --git a/engines/hopkins/lines.h b/engines/hopkins/lines.h index b8cfb7442b..5df9a59daf 100644 --- a/engines/hopkins/lines.h +++ b/engines/hopkins/lines.h @@ -23,6 +23,8 @@ #ifndef HOPKINS_LINES_H #define HOPKINS_LINES_H +#include "hopkins/globals.h" + #include "common/scummsys.h" #include "common/str.h" @@ -40,9 +42,9 @@ struct RouteItem; struct LigneItem { int _lineDataEndIdx; - int _direction; - int field6; - int field8; + Directions _direction; + Directions field6; + Directions field8; int16 *_lineData; int appendToRouteInc(int from, int to, RouteItem *route, int index); @@ -91,11 +93,11 @@ struct ZonePItem { struct RouteItem { int16 _X; int16 _Y; - int16 _dir; + Directions _dir; int16 _unk; bool isValid() const { return _X != -1 || _Y != -1; } - void invalidate() { _X = _Y = _dir = _unk = -1; } - void set(int16 X, int16 Y, int16 dir) { _X = X; _Y = Y; _dir = dir; _unk = 0; } + void invalidate() { _X = _Y = _unk = -1; _dir = DIR_NONE; } + void set(int16 X, int16 Y, Directions dir) { _X = X; _Y = Y; _dir = dir; _unk = 0; } }; @@ -110,7 +112,7 @@ private: int NV_POSI; int NVPX; int NVPY; - int _smoothMoveDirection; + Directions _smoothMoveDirection; RouteItem super_parcours[8001]; byte *BUFFERTAPE; RouteItem *essai0; @@ -135,7 +137,7 @@ private: int CALC_PROPRE(int idx); int CONTOURNE1(int a1, int a2, int a3, int a4, int a5, RouteItem *route, int a8, int a9); int CONTOURNE(int a1, int a2, int a3, int a4, int a5, RouteItem *route); - bool MIRACLE(int a1, int a2, int a3, int a4, int a5); + bool MIRACLE(int fromX, int fromY, int a3, int a4, int a5); int GENIAL(int lineIdx, int dataIdx, int a3, int a4, int a5, int a6, int a7, RouteItem *route); int PARC_PERS(int fromX, int fromY, int destX, int destY, int a5, int a6, int a7); bool PLAN_TEST(int paramX, int paramY, int a3, int a4, int a5); @@ -159,7 +161,7 @@ public: int checkInventoryHotspots(int posX, int posY); void addZoneLine(int idx, int a2, int a3, int a4, int a5, int bobZoneIdx); void loadLines(const Common::String &file); - void addLine(int idx, int direction, int a3, int a4, int a5, int a6); + void addLine(int idx, Directions direction, int a3, int a4, int a5, int a6); void initRoute(); RouteItem *cityMapCarRoute(int x1, int y1, int x2, int y2); void clearAllZones(); diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp index 3abb8d6634..b1be7c1abd 100644 --- a/engines/hopkins/objects.cpp +++ b/engines/hopkins/objects.cpp @@ -193,9 +193,9 @@ int ObjectsManager::getOffsetX(const byte *spriteData, int spriteIndex, bool isS v3 += READ_LE_UINT32(v3) + 16; const byte *v5 = v3 + 8; - int result = (int16)READ_LE_UINT16(v5); + int result = READ_LE_INT16(v5); if (isSize) - result = (int16)READ_LE_UINT16(v5 + 4); + result = READ_LE_INT16(v5 + 4); return result; } @@ -206,9 +206,9 @@ int ObjectsManager::getOffsetY(const byte *spriteData, int spriteIndex, bool isS v3 += READ_LE_UINT32(v3) + 16; const byte *v5 = v3 + 10; - int result = (int16)READ_LE_UINT16(v5); + int result = READ_LE_INT16(v5); if (isSize) - result = (int16)READ_LE_UINT16(v5 + 4); + result = READ_LE_INT16(v5 + 4); return result; } @@ -221,7 +221,7 @@ int ObjectsManager::getWidth(const byte *objectData, int idx) { for (int i = idx; i; --i) rectP += READ_LE_UINT32(rectP) + 16; - return (int16)READ_LE_UINT16(rectP + 4); + return READ_LE_INT16(rectP + 4); } /** @@ -232,7 +232,7 @@ int ObjectsManager::getHeight(const byte *objectData, int idx) { for (int i = idx; i; --i) rectP += READ_LE_UINT32(rectP) + 16; - return (int16)READ_LE_UINT16(rectP + 6); + return READ_LE_INT16(rectP + 6); } void ObjectsManager::sprite_alone(const byte *objectData, byte *sprite, int objIndex) { @@ -242,7 +242,7 @@ void ObjectsManager::sprite_alone(const byte *objectData, byte *sprite, int objI } objP += 4; - int result = (int16)READ_LE_UINT16(objP) * (int16)READ_LE_UINT16(objP + 2); + int result = READ_LE_INT16(objP) * READ_LE_INT16(objP + 2); memcpy(sprite + 3, objP - 4, result + 16); } @@ -254,7 +254,7 @@ void ObjectsManager::capture_mem_sprite(const byte *objectData, byte *sprite, in } objP += 4; - int result = (int16)READ_LE_UINT16(objP) * (int16)READ_LE_UINT16(objP + 2); + int result = READ_LE_INT16(objP) * READ_LE_INT16(objP + 2); memcpy(sprite, objP + 12, result); } @@ -582,17 +582,17 @@ void ObjectsManager::BOB_VISU(int idx) { resetBob(idx); const byte *data = _vm->_globals.Bqe_Anim[idx]._data; - int bankIdx = (int16)READ_LE_UINT16(data); + int bankIdx = READ_LE_INT16(data); if (!bankIdx) return; if ((!_vm->_globals.Bank[bankIdx]._loadedFl) || (!READ_LE_UINT16(data + 24))) return; - int16 v9 = (int16)READ_LE_UINT16(data + 2); - int16 v8 = (int16)READ_LE_UINT16(data + 4); - int16 offsetY = (int16)READ_LE_UINT16(data + 6); - int16 v6 = (int16)READ_LE_UINT16(data + 8); + int16 v9 = READ_LE_INT16(data + 2); + int16 v8 = READ_LE_INT16(data + 4); + int16 offsetY = READ_LE_INT16(data + 6); + int16 v6 = READ_LE_INT16(data + 8); if (!v9) v9 = 1; @@ -949,15 +949,15 @@ void ObjectsManager::displayBobAnim() { byte *dataPtr = _bob[idx]._animData + 20; int dataIdx = _bob[idx]._animDataIdx; - _bob[idx]._xp = (int16)READ_LE_UINT16(dataPtr + 2 * dataIdx); + _bob[idx]._xp = READ_LE_INT16(dataPtr + 2 * dataIdx); if (_vm->_globals._lockedAnims[idx]._enableFl) _bob[idx]._xp = _vm->_globals._lockedAnims[idx]._posX; if ( PERSO_ON && idx > 20 ) _bob[idx]._xp += _vm->_eventsManager._startPos.x; - _bob[idx]._yp = (int16)READ_LE_UINT16(dataPtr + 2 * dataIdx + 2); - _bob[idx].field12 = (int16)READ_LE_UINT16(dataPtr + 2 * dataIdx + 4); - _bob[idx]._zoomFactor = (int16)READ_LE_UINT16(dataPtr + 2 * dataIdx + 6); + _bob[idx]._yp = READ_LE_INT16(dataPtr + 2 * dataIdx + 2); + _bob[idx].field12 = READ_LE_INT16(dataPtr + 2 * dataIdx + 4); + _bob[idx]._zoomFactor = READ_LE_INT16(dataPtr + 2 * dataIdx + 6); _bob[idx]._frameIndex = dataPtr[2 * dataIdx + 8]; _bob[idx]._flipFl = (dataPtr[2 * dataIdx + 9] != 0); _bob[idx]._animDataIdx += 5; @@ -983,16 +983,16 @@ void ObjectsManager::displayBobAnim() { } else { _bob[idx]._animDataIdx = 0; byte *v21 = _bob[idx]._animData + 20; - _bob[idx]._xp = (int16)READ_LE_UINT16(v21); + _bob[idx]._xp = READ_LE_INT16(v21); if (_vm->_globals._lockedAnims[idx]._enableFl) _bob[idx]._xp = _vm->_globals._lockedAnims[idx]._posX; if (PERSO_ON && idx > 20) _bob[idx]._xp += _vm->_eventsManager._startPos.x; - _bob[idx]._yp = (int16)READ_LE_UINT16(v21 + 2); - _bob[idx].field12 = (int16)READ_LE_UINT16(v21 + 4); - _bob[idx]._zoomFactor = (int16)READ_LE_UINT16(v21 + 6); + _bob[idx]._yp = READ_LE_INT16(v21 + 2); + _bob[idx].field12 = READ_LE_INT16(v21 + 4); + _bob[idx]._zoomFactor = READ_LE_INT16(v21 + 6); _bob[idx]._frameIndex = v21[8]; _bob[idx]._flipFl = (v21[9] != 0); _bob[idx]._animDataIdx += 5; @@ -1274,10 +1274,6 @@ void ObjectsManager::setFlipSprite(int idx, bool flipFl) { } void ObjectsManager::GOHOME() { - int v0 = 0; - int v58 = 0; - int v1 = 0; - if (_vm->_linesManager._route == (RouteItem *)g_PTRNUL) return; @@ -1288,10 +1284,13 @@ void ObjectsManager::GOHOME() { int newPosX; int newPosY; - int newDirection; + Directions newDirection; + int oldPosX = 0; + int oldPosY = 0; + int oldFrameIdx = 0; _vm->_globals.Compteur = 0; - if (_vm->_globals._oldDirection == -1) { + if (_vm->_globals._oldDirection == DIR_NONE) { computeAndSetSpriteSize(); newPosX = _vm->_linesManager._route->_X; newPosY = _vm->_linesManager._route->_Y; @@ -1306,7 +1305,7 @@ void ObjectsManager::GOHOME() { _oldCharacterPosY = newPosY; } else { setSpriteIndex(0, _vm->_globals._oldDirection + 59); - _vm->_globals._actionDirection = 0; + _vm->_globals._actionDirection = DIR_NONE; int zoneId; if (_vm->_globals.GOACTION) zoneId = _vm->_globals._saveData->_data[svField2]; @@ -1317,7 +1316,7 @@ void ObjectsManager::GOHOME() { setFlipSprite(0, false); _vm->_globals.Compteur = 0; _vm->_linesManager._route = (RouteItem *)g_PTRNUL; - _vm->_globals._oldDirection = -1; + _vm->_globals._oldDirection = DIR_NONE; if (zoneId > 0) { if (_vm->_linesManager.ZONEP[zoneId]._destX && _vm->_linesManager.ZONEP[zoneId]._destY && _vm->_linesManager.ZONEP[zoneId]._destY != 31) { if (_vm->_linesManager.ZONEP[zoneId]._spriteIndex == -1) { @@ -1334,11 +1333,11 @@ void ObjectsManager::GOHOME() { _vm->_globals.Compteur = 0; return; } - if (_vm->_globals._oldDirection == 3) { + if (_vm->_globals._oldDirection == DIR_RIGHT) { if (_vm->_globals._oldFrameIndex < 24 || _vm->_globals._oldFrameIndex > 35) { - v0 = _oldCharacterPosX; - v58 = _oldCharacterPosY; - v1 = 24; + oldPosX = _oldCharacterPosX; + oldPosY = _oldCharacterPosY; + oldFrameIdx = 24; } else { int deltaX = _vm->_globals.Hopkins[_vm->_globals._oldFrameIndex].field0; int deltaY = _vm->_globals.Hopkins[_vm->_globals._oldFrameIndex].field2; @@ -1350,19 +1349,19 @@ void ObjectsManager::GOHOME() { deltaX = _vm->_graphicsManager.zoomIn(deltaX, _sprite[0]._zoomFactor); deltaY = _vm->_graphicsManager.zoomIn(deltaY, _sprite[0]._zoomFactor); } - v0 = _oldCharacterPosX + deltaX; - v58 = _oldCharacterPosY + deltaY; - v1 = _vm->_globals._oldFrameIndex + 1; - if (v1 > 35) - v1 = 24; + oldPosX = _oldCharacterPosX + deltaX; + oldPosY = _oldCharacterPosY + deltaY; + oldFrameIdx = _vm->_globals._oldFrameIndex + 1; + if (oldFrameIdx > 35) + oldFrameIdx = 24; } _vm->_globals.Compteur = 5 / _vm->_globals._speed; } - if (_vm->_globals._oldDirection == 7) { + if (_vm->_globals._oldDirection == DIR_LEFT) { if (_vm->_globals._oldFrameIndex < 24 || _vm->_globals._oldFrameIndex > 35) { - v0 = _oldCharacterPosX; - v58 = _oldCharacterPosY; - v1 = 24; + oldPosX = _oldCharacterPosX; + oldPosY = _oldCharacterPosY; + oldFrameIdx = 24; } else { int deltaX = _vm->_globals.Hopkins[_vm->_globals._oldFrameIndex].field0; int deltaY = _vm->_globals.Hopkins[_vm->_globals._oldFrameIndex].field2; @@ -1373,19 +1372,19 @@ void ObjectsManager::GOHOME() { deltaX = _vm->_graphicsManager.zoomIn(deltaX, _sprite[0]._zoomFactor); deltaY = _vm->_graphicsManager.zoomIn(deltaY, _sprite[0]._zoomFactor); } - v0 = _oldCharacterPosX - deltaX; - v58 = _oldCharacterPosY - deltaY; - v1 = _vm->_globals._oldFrameIndex + 1; - if (v1 > 35) - v1 = 24; + oldPosX = _oldCharacterPosX - deltaX; + oldPosY = _oldCharacterPosY - deltaY; + oldFrameIdx = _vm->_globals._oldFrameIndex + 1; + if (oldFrameIdx > 35) + oldFrameIdx = 24; } _vm->_globals.Compteur = 5 / _vm->_globals._speed; } - if (_vm->_globals._oldDirection == 1) { + if (_vm->_globals._oldDirection == DIR_UP) { if (_vm->_globals._oldFrameIndex > 11) { - v0 = _oldCharacterPosX; - v58 = _oldCharacterPosY; - v1 = 0; + oldPosX = _oldCharacterPosX; + oldPosY = _oldCharacterPosY; + oldFrameIdx = 0; } else { int deltaY = abs(_vm->_globals.Hopkins[_vm->_globals._oldFrameIndex].field2); if (_sprite[0]._zoomFactor < 0) { @@ -1393,20 +1392,20 @@ void ObjectsManager::GOHOME() { } else if (_sprite[0]._zoomFactor > 0) { deltaY = _vm->_graphicsManager.zoomIn(deltaY, _sprite[0]._zoomFactor); } - v0 = _oldCharacterPosX; - v58 = _oldCharacterPosY - deltaY; - v1 = _vm->_globals._oldFrameIndex + 1; - if (v1 > 11) - v1 = 0; + oldPosX = _oldCharacterPosX; + oldPosY = _oldCharacterPosY - deltaY; + oldFrameIdx = _vm->_globals._oldFrameIndex + 1; + if (oldFrameIdx > 11) + oldFrameIdx = 0; } _vm->_globals.Compteur = 4 / _vm->_globals._speed; } - if (_vm->_globals._oldDirection == 5) { + if (_vm->_globals._oldDirection == DIR_DOWN) { if (_vm->_globals._oldFrameIndex < 48 || _vm->_globals._oldFrameIndex > 59) { - v0 = _oldCharacterPosX; - v58 = _oldCharacterPosY; - v1 = 48; + oldPosX = _oldCharacterPosX; + oldPosY = _oldCharacterPosY; + oldFrameIdx = 48; } else { int deltaY = abs(_vm->_globals.Hopkins[_vm->_globals._oldFrameIndex].field2); if (_sprite[0]._zoomFactor < 0) { @@ -1414,19 +1413,19 @@ void ObjectsManager::GOHOME() { } else if (_sprite[0]._zoomFactor > 0) { deltaY = _vm->_graphicsManager.zoomIn(deltaY, _sprite[0]._zoomFactor); } - v0 = _oldCharacterPosX; - v58 = deltaY + _oldCharacterPosY; - v1 = _vm->_globals._oldFrameIndex + 1; - if (v1 > 59) - v1 = 48; + oldPosX = _oldCharacterPosX; + oldPosY = deltaY + _oldCharacterPosY; + oldFrameIdx = _vm->_globals._oldFrameIndex + 1; + if (oldFrameIdx > 59) + oldFrameIdx = 48; } _vm->_globals.Compteur = 4 / _vm->_globals._speed; } - if (_vm->_globals._oldDirection == 2) { + if (_vm->_globals._oldDirection == DIR_UP_RIGHT) { if (_vm->_globals._oldFrameIndex < 12 || _vm->_globals._oldFrameIndex > 23) { - v0 = _oldCharacterPosX; - v58 = _oldCharacterPosY; - v1 = 12; + oldPosX = _oldCharacterPosX; + oldPosY = _oldCharacterPosY; + oldFrameIdx = 12; } else { int deltaX = _vm->_globals.Hopkins[_vm->_globals._oldFrameIndex].field0; int deltaY = _vm->_globals.Hopkins[_vm->_globals._oldFrameIndex].field2; @@ -1438,19 +1437,19 @@ void ObjectsManager::GOHOME() { deltaX = _vm->_graphicsManager.zoomIn(deltaX, _sprite[0]._zoomFactor); deltaY = _vm->_graphicsManager.zoomIn(deltaY, _sprite[0]._zoomFactor); } - v0 = deltaX + _oldCharacterPosX; - v58 = _oldCharacterPosY + deltaY; - v1 = _vm->_globals._oldFrameIndex + 1; - if (v1 > 23) - v1 = 12; + oldPosX = deltaX + _oldCharacterPosX; + oldPosY = _oldCharacterPosY + deltaY; + oldFrameIdx = _vm->_globals._oldFrameIndex + 1; + if (oldFrameIdx > 23) + oldFrameIdx = 12; } _vm->_globals.Compteur = 5 / _vm->_globals._speed; } - if (_vm->_globals._oldDirection == 8) { + if (_vm->_globals._oldDirection == DIR_UP_LEFT) { if (_vm->_globals._oldFrameIndex < 12 || _vm->_globals._oldFrameIndex > 23) { - v0 = _oldCharacterPosX; - v58 = _oldCharacterPosY; - v1 = 12; + oldPosX = _oldCharacterPosX; + oldPosY = _oldCharacterPosY; + oldFrameIdx = 12; } else { int deltaX = _vm->_globals.Hopkins[_vm->_globals._oldFrameIndex].field0; int deltaY = _vm->_globals.Hopkins[_vm->_globals._oldFrameIndex].field2; @@ -1461,19 +1460,19 @@ void ObjectsManager::GOHOME() { deltaX = _vm->_graphicsManager.zoomIn(deltaX, _sprite[0]._zoomFactor); deltaY = _vm->_graphicsManager.zoomIn(deltaY, _sprite[0]._zoomFactor); } - v0 = _oldCharacterPosX - deltaX; - v58 = _oldCharacterPosY + deltaY; - v1 = _vm->_globals._oldFrameIndex + 1; - if (v1 > 23) - v1 = 12; + oldPosX = _oldCharacterPosX - deltaX; + oldPosY = _oldCharacterPosY + deltaY; + oldFrameIdx = _vm->_globals._oldFrameIndex + 1; + if (oldFrameIdx > 23) + oldFrameIdx = 12; } _vm->_globals.Compteur = 5 / _vm->_globals._speed; } - if (_vm->_globals._oldDirection == 4) { + if (_vm->_globals._oldDirection == DIR_DOWN_RIGHT) { if (_vm->_globals._oldFrameIndex < 36 || _vm->_globals._oldFrameIndex > 47) { - v0 = _oldCharacterPosX; - v58 = _oldCharacterPosY; - v1 = 36; + oldPosX = _oldCharacterPosX; + oldPosY = _oldCharacterPosY; + oldFrameIdx = 36; } else { int deltaX = _vm->_globals.Hopkins[_vm->_globals._oldFrameIndex].field0; int deltaY = _vm->_globals.Hopkins[_vm->_globals._oldFrameIndex].field2; @@ -1485,19 +1484,19 @@ void ObjectsManager::GOHOME() { deltaX = _vm->_graphicsManager.zoomIn(deltaX, _sprite[0]._zoomFactor); deltaY = _vm->_graphicsManager.zoomIn(deltaY, _sprite[0]._zoomFactor); } - v0 = deltaX + _oldCharacterPosX; - v58 = _oldCharacterPosY + deltaY; - v1 = _vm->_globals._oldFrameIndex + 1; - if (v1 > 47) - v1 = 36; + oldPosX = deltaX + _oldCharacterPosX; + oldPosY = _oldCharacterPosY + deltaY; + oldFrameIdx = _vm->_globals._oldFrameIndex + 1; + if (oldFrameIdx > 47) + oldFrameIdx = 36; } _vm->_globals.Compteur = 5 / _vm->_globals._speed; } - if (_vm->_globals._oldDirection == 6) { + if (_vm->_globals._oldDirection == DIR_DOWN_LEFT) { if (_vm->_globals._oldFrameIndex < 36 || _vm->_globals._oldFrameIndex > 47) { - v0 = _oldCharacterPosX; - v58 = _oldCharacterPosY; - v1 = 36; + oldPosX = _oldCharacterPosX; + oldPosY = _oldCharacterPosY; + oldFrameIdx = 36; } else { int deltaX = _vm->_globals.Hopkins[_vm->_globals._oldFrameIndex].field0; int deltaY = _vm->_globals.Hopkins[_vm->_globals._oldFrameIndex].field2; @@ -1509,11 +1508,11 @@ void ObjectsManager::GOHOME() { deltaX = _vm->_graphicsManager.zoomIn(deltaX, _sprite[0]._zoomFactor); deltaY = _vm->_graphicsManager.zoomIn(deltaY, _sprite[0]._zoomFactor); } - v0 = _oldCharacterPosX - deltaX; - v58 = _oldCharacterPosY + deltaY; - v1 = _vm->_globals._oldFrameIndex + 1; - if (v1 > 47) - v1 = 36; + oldPosX = _oldCharacterPosX - deltaX; + oldPosY = _oldCharacterPosY + deltaY; + oldFrameIdx = _vm->_globals._oldFrameIndex + 1; + if (oldFrameIdx > 47) + oldFrameIdx = 36; } _vm->_globals.Compteur = 5 / _vm->_globals._speed; } @@ -1521,7 +1520,7 @@ void ObjectsManager::GOHOME() { do { newPosX = _vm->_linesManager._route->_X; newPosY = _vm->_linesManager._route->_Y; - newDirection = _vm->_linesManager._route->_dir; + newDirection = (Directions)_vm->_linesManager._route->_dir; _vm->_linesManager._route++; if (newPosX == -1 && newPosY == -1) { @@ -1531,12 +1530,12 @@ void ObjectsManager::GOHOME() { else zoneId = _zoneNum; setSpriteIndex(0, _vm->_globals._oldDirection + 59); - _vm->_globals._actionDirection = 0; + _vm->_globals._actionDirection = DIR_NONE; _vm->_linesManager._route = (RouteItem *)g_PTRNUL; computeAndSetSpriteSize(); setFlipSprite(0, false); _vm->_globals.Compteur = 0; - _vm->_globals._oldDirection = -1; + _vm->_globals._oldDirection = DIR_NONE; _oldCharacterPosX = getSpriteX(0); _oldCharacterPosY = getSpriteY(0); @@ -1557,36 +1556,36 @@ void ObjectsManager::GOHOME() { } if (_vm->_globals._oldDirection != newDirection) break; - if ((newDirection == 3 && newPosX >= v0) || (_vm->_globals._oldDirection == 7 && newPosX <= v0) || - (_vm->_globals._oldDirection == 1 && newPosY <= v58) || (_vm->_globals._oldDirection == 5 && newPosY >= v58) || - (_vm->_globals._oldDirection == 2 && newPosX >= v0) || (_vm->_globals._oldDirection == 8 && newPosX <= v0) || - (_vm->_globals._oldDirection == 4 && newPosX >= v0) || (_vm->_globals._oldDirection == 6 && newPosX <= v0)) + if ((newDirection == DIR_RIGHT && newPosX >= oldPosX) || (_vm->_globals._oldDirection == DIR_LEFT && newPosX <= oldPosX) || + (_vm->_globals._oldDirection == DIR_UP && newPosY <= oldPosY) || (_vm->_globals._oldDirection == DIR_DOWN && newPosY >= oldPosY) || + (_vm->_globals._oldDirection == DIR_UP_RIGHT && newPosX >= oldPosX) || (_vm->_globals._oldDirection == DIR_UP_LEFT && newPosX <= oldPosX) || + (_vm->_globals._oldDirection == DIR_DOWN_RIGHT && newPosX >= oldPosX) || (_vm->_globals._oldDirection == DIR_DOWN_LEFT && newPosX <= oldPosX)) loopCond = true; } while (!loopCond); if (loopCond) { computeAndSetSpriteSize(); - if ((_vm->_globals._oldDirection == 6) || (_vm->_globals._oldDirection == 7) || (_vm->_globals._oldDirection == 8)) + if ((_vm->_globals._oldDirection == DIR_DOWN_LEFT) || (_vm->_globals._oldDirection == DIR_LEFT) || (_vm->_globals._oldDirection == DIR_UP_LEFT)) setFlipSprite(0, true); - if ((_vm->_globals._oldDirection == 1) || (_vm->_globals._oldDirection == 2) || (_vm->_globals._oldDirection == 3) || - (_vm->_globals._oldDirection == 4) || (_vm->_globals._oldDirection == 5)) + if ((_vm->_globals._oldDirection == DIR_UP) || (_vm->_globals._oldDirection == DIR_UP_RIGHT) || (_vm->_globals._oldDirection == DIR_RIGHT) || + (_vm->_globals._oldDirection == DIR_DOWN_RIGHT) || (_vm->_globals._oldDirection == DIR_DOWN)) setFlipSprite(0, false); setSpriteX(0, newPosX); setSpriteY(0, newPosY); - setSpriteIndex(0, v1); + setSpriteIndex(0, oldFrameIdx); } else { - if ((_vm->_globals._oldDirection == 6) || (_vm->_globals._oldDirection == 7) || (_vm->_globals._oldDirection == 8)) + if ((_vm->_globals._oldDirection == DIR_DOWN_LEFT) || (_vm->_globals._oldDirection == DIR_LEFT) || (_vm->_globals._oldDirection == DIR_UP_LEFT)) setFlipSprite(0, true); - if ((_vm->_globals._oldDirection == 1) || (_vm->_globals._oldDirection == 2) || (_vm->_globals._oldDirection == 3) || - (_vm->_globals._oldDirection == 4) || (_vm->_globals._oldDirection == 5)) + if ((_vm->_globals._oldDirection == DIR_UP) || (_vm->_globals._oldDirection == DIR_UP_RIGHT) || (_vm->_globals._oldDirection == DIR_RIGHT) || + (_vm->_globals._oldDirection == DIR_DOWN_RIGHT) || (_vm->_globals._oldDirection == DIR_DOWN)) setFlipSprite(0, false); _vm->_globals.Compteur = 0; } _vm->_globals._oldDirection = newDirection; _vm->_globals._oldDirectionSpriteIdx = newDirection + 59; - _vm->_globals._oldFrameIndex = v1; + _vm->_globals._oldFrameIndex = oldFrameIdx; _oldCharacterPosX = newPosX; _oldCharacterPosY = newPosY; } @@ -1595,48 +1594,61 @@ void ObjectsManager::GOHOME2() { if (_vm->_linesManager._route == (RouteItem *)g_PTRNUL) return; - int v0 = 2; + int realSpeed = 2; if (_vm->_globals._speed == 2) - v0 = 4; + realSpeed = 4; else if (_vm->_globals._speed == 3) - v0 = 6; + realSpeed = 6; - _vm->_globals.j_104 = 0; + int countColisionPixel = 0; for (;;) { int nexPosX = _vm->_linesManager._route->_X; int newPosY = _vm->_linesManager._route->_Y; - int newDirection = _vm->_linesManager._route->_dir; + Directions newDirection = (Directions)_vm->_linesManager._route->_dir; _vm->_linesManager._route++; if ((nexPosX == -1) && (newPosY == -1)) break; - ++_vm->_globals.j_104; - if (_vm->_globals.j_104 >= v0) { + ++countColisionPixel; + if (countColisionPixel >= realSpeed) { _vm->_globals._lastDirection = newDirection; setSpriteX(0, nexPosX); setSpriteY(0, newPosY); - if (_vm->_globals._lastDirection == 1) + switch (_vm->_globals._lastDirection) { + case DIR_UP: setSpriteIndex(0, 4); - else if (_vm->_globals._lastDirection == 3) + break; + case DIR_RIGHT: setSpriteIndex(0, 5); - else if (_vm->_globals._lastDirection == 5) + break; + case DIR_DOWN: setSpriteIndex(0, 6); - else if (_vm->_globals._lastDirection == 7) + break; + case DIR_LEFT: setSpriteIndex(0, 7); + break; + } return; } } - if (_vm->_globals._lastDirection == 1) + + switch (_vm->_globals._lastDirection) { + case DIR_UP: setSpriteIndex(0, 0); - else if (_vm->_globals._lastDirection == 3) + break; + case DIR_RIGHT: setSpriteIndex(0, 1); - else if (_vm->_globals._lastDirection == 5) + break; + case DIR_DOWN: setSpriteIndex(0, 2); - else if (_vm->_globals._lastDirection == 7) + break; + case DIR_LEFT: setSpriteIndex(0, 3); + break; + } _vm->_linesManager._route = (RouteItem *)g_PTRNUL; } @@ -1672,7 +1684,7 @@ void ObjectsManager::loadZone(const Common::String &file) { int zoneLineIdx = 0; int bobZoneIdx; do { - bobZoneIdx = (int16)READ_LE_UINT16((uint16 *)ptr + bufId); + bobZoneIdx = READ_LE_INT16((uint16 *)ptr + bufId); if (bobZoneIdx != -1) { _vm->_linesManager.addZoneLine( zoneLineIdx, @@ -1688,9 +1700,9 @@ void ObjectsManager::loadZone(const Common::String &file) { } while (bobZoneIdx != -1); for (int i = 1; i <= 100; i++) { - _vm->_linesManager.ZONEP[i]._destX = (int16)READ_LE_UINT16((uint16 *)ptr + bufId); - _vm->_linesManager.ZONEP[i]._destY = (int16)READ_LE_UINT16((uint16 *)ptr + bufId + 1); - _vm->_linesManager.ZONEP[i]._spriteIndex = (int16)READ_LE_UINT16((uint16 *)ptr + bufId + 2); + _vm->_linesManager.ZONEP[i]._destX = READ_LE_INT16((uint16 *)ptr + bufId); + _vm->_linesManager.ZONEP[i]._destY = READ_LE_INT16((uint16 *)ptr + bufId + 1); + _vm->_linesManager.ZONEP[i]._spriteIndex = READ_LE_INT16((uint16 *)ptr + bufId + 2); bufId += 3; } @@ -1894,12 +1906,12 @@ void ObjectsManager::handleLeftButton() { if (getSpriteY(0) > 374 && getSpriteY(0) <= 410) { _vm->_linesManager._route = (RouteItem *)g_PTRNUL; setSpriteIndex(0, _vm->_globals._oldDirectionSpriteIdx); - _vm->_globals._actionDirection = 0; + _vm->_globals._actionDirection = DIR_NONE; _vm->_linesManager._route = (RouteItem *)g_PTRNUL; computeAndSetSpriteSize(); setFlipSprite(0, false); _vm->_globals.Compteur = 0; - _vm->_globals._oldDirection = -1; + _vm->_globals._oldDirection = DIR_NONE; } else { _vm->_linesManager._route = _vm->_linesManager.PARCOURS2(getSpriteX(0), getSpriteY(0), getSpriteX(0), 390); if (_vm->_linesManager._route != (RouteItem *)g_PTRNUL) @@ -1908,7 +1920,7 @@ void ObjectsManager::handleLeftButton() { _oldCharacterPosY = getSpriteY(0); _vm->_globals.Compteur = 0; if (_vm->_linesManager._route != (RouteItem *)g_PTRNUL || oldRoute == _vm->_linesManager._route) { - _vm->_globals._oldDirection = -1; + _vm->_globals._oldDirection = DIR_NONE; } else { _vm->_linesManager._route = oldRoute; } @@ -1922,7 +1934,7 @@ void ObjectsManager::handleLeftButton() { _oldCharacterPosY = getSpriteY(0); _vm->_globals.Compteur = 0; if (_vm->_linesManager._route != (RouteItem *)g_PTRNUL || oldRoute == _vm->_linesManager._route) - _vm->_globals._oldDirection = -1; + _vm->_globals._oldDirection = DIR_NONE; else _vm->_linesManager._route = oldRoute; } @@ -2077,7 +2089,7 @@ void ObjectsManager::clearScreen() { _forceZoneFl = true; _changeVerbFl = false; _vm->_linesManager._route = (RouteItem *)g_PTRNUL; - _vm->_globals._oldDirection = -1; + _vm->_globals._oldDirection = DIR_NONE; _vm->_graphicsManager.RESET_SEGMENT_VESA(); } @@ -2423,16 +2435,16 @@ void ObjectsManager::initBorder(int zoneIdx) { if (!zoneIdx) _vm->_eventsManager._mouseCursorId = 0; - else if (zoneIdx == 32) - _vm->_eventsManager._mouseCursorId = 16; - else if (zoneIdx == 30) - _vm->_eventsManager._mouseCursorId = 2; - else if (zoneIdx == 31) - _vm->_eventsManager._mouseCursorId = 3; else if (zoneIdx >= 1 && zoneIdx <= 28) _vm->_eventsManager._mouseCursorId = 8; else if (zoneIdx == 29) _vm->_eventsManager._mouseCursorId = 1; + else if (zoneIdx == 30) + _vm->_eventsManager._mouseCursorId = 2; + else if (zoneIdx == 31) + _vm->_eventsManager._mouseCursorId = 3; + else if (zoneIdx == 32) + _vm->_eventsManager._mouseCursorId = 16; if (zoneIdx >= 1 && zoneIdx <= 28 && !_vm->_globals._inventory[zoneIdx]) { _vm->_eventsManager._mouseCursorId = 0; @@ -2554,7 +2566,7 @@ void ObjectsManager::OPTI_OBJET() { if (opcodeType == 1 || opcodeType == 4) ++lastOpcodeResult; - if (!opcodeType || opcodeType == 5) + else if (!opcodeType || opcodeType == 5) break; } @@ -2695,8 +2707,8 @@ void ObjectsManager::BOB_VIVANT(int idx) { if (!READ_LE_UINT16(_vm->_talkManager._characterAnim + startPos + 4)) return; - int xp = (int16)READ_LE_UINT16(_vm->_talkManager._characterAnim + startPos); - int yp = (int16)READ_LE_UINT16(_vm->_talkManager._characterAnim + startPos + 2); + int xp = READ_LE_INT16(_vm->_talkManager._characterAnim + startPos); + int yp = READ_LE_INT16(_vm->_talkManager._characterAnim + startPos + 2); int spriteIndex = _vm->_talkManager._characterAnim[startPos + 8]; _vm->_graphicsManager.fastDisplay(_vm->_talkManager._characterSprite, xp, yp, spriteIndex); @@ -3054,7 +3066,7 @@ void ObjectsManager::INILINK(const Common::String &file) { } if (!OBSSEUL) { for (int idx = 0; idx < 500; ++idx) - _vm->_globals._spriteSize[idx] = (int16)READ_LE_UINT16((uint16 *)ptr + idx); + _vm->_globals._spriteSize[idx] = READ_LE_INT16((uint16 *)ptr + idx); _vm->_globals.resetCache(); @@ -3071,11 +3083,11 @@ void ObjectsManager::INILINK(const Common::String &file) { int curDataCacheId = 60; byte *curDataPtr = ptr + 1000; for (int cacheIdx = 0; cacheIdx <= 21; cacheIdx++) { - int curSpriteId = (int16)READ_LE_UINT16(curDataPtr + 2 * curDataCacheId); + int curSpriteId = READ_LE_INT16(curDataPtr + 2 * curDataCacheId); _vm->_globals.Cache[cacheIdx]._spriteIndex = curSpriteId; - _vm->_globals.Cache[cacheIdx]._x = (int16)READ_LE_UINT16(curDataPtr + 2 * curDataCacheId + 2); - _vm->_globals.Cache[cacheIdx]._y = (int16)READ_LE_UINT16(curDataPtr + 2 * curDataCacheId + 4); - _vm->_globals.Cache[cacheIdx].field14 = (int16)READ_LE_UINT16(curDataPtr + 2 * curDataCacheId + 8); + _vm->_globals.Cache[cacheIdx]._x = READ_LE_INT16(curDataPtr + 2 * curDataCacheId + 2); + _vm->_globals.Cache[cacheIdx]._y = READ_LE_INT16(curDataPtr + 2 * curDataCacheId + 4); + _vm->_globals.Cache[cacheIdx].field14 = READ_LE_INT16(curDataPtr + 2 * curDataCacheId + 8); if (!_vm->_globals.CACHE_BANQUE[1]) { _vm->_globals.Cache[cacheIdx]._useCount = 0; @@ -3102,21 +3114,21 @@ void ObjectsManager::INILINK(const Common::String &file) { int lineDataIdx = 0; int curLineIdx = 0; _vm->_linesManager.resetLinesNumb(); - int curDirection; + Directions curDirection; do { - curDirection = (int16)READ_LE_UINT16(curDataPtr + 2 * lineDataIdx); - if (curDirection != -1) { + curDirection = (Directions)READ_LE_INT16(curDataPtr + 2 * lineDataIdx); + if (curDirection != DIR_NONE) { _vm->_linesManager.addLine( curLineIdx, curDirection, - (int16)READ_LE_UINT16(curDataPtr + 2 * lineDataIdx + 2), - (int16)READ_LE_UINT16(curDataPtr + 2 * lineDataIdx + 4), - (int16)READ_LE_UINT16(curDataPtr + 2 * lineDataIdx + 6), - (int16)READ_LE_UINT16(curDataPtr + 2 * lineDataIdx + 8)); + READ_LE_INT16(curDataPtr + 2 * lineDataIdx + 2), + READ_LE_INT16(curDataPtr + 2 * lineDataIdx + 4), + READ_LE_INT16(curDataPtr + 2 * lineDataIdx + 6), + READ_LE_INT16(curDataPtr + 2 * lineDataIdx + 8)); } lineDataIdx += 5; ++curLineIdx; - } while (curDirection != -1); + } while (curDirection != DIR_NONE); _vm->_linesManager.initRoute(); } } @@ -3146,14 +3158,14 @@ void ObjectsManager::INILINK(const Common::String &file) { int curLineIdx = 0; int v28; do { - v28 = (int16)READ_LE_UINT16(curDataPtr + 2 * curDataIdx); + v28 = READ_LE_INT16(curDataPtr + 2 * curDataIdx); if (v28 != -1) { _vm->_linesManager.addZoneLine( curLineIdx, - (int16)READ_LE_UINT16(curDataPtr + 2 * curDataIdx + 2), - (int16)READ_LE_UINT16(curDataPtr + 2 * curDataIdx + 4), - (int16)READ_LE_UINT16(curDataPtr + 2 * curDataIdx + 6), - (int16)READ_LE_UINT16(curDataPtr + 2 * curDataIdx + 8), + READ_LE_INT16(curDataPtr + 2 * curDataIdx + 2), + READ_LE_INT16(curDataPtr + 2 * curDataIdx + 4), + READ_LE_INT16(curDataPtr + 2 * curDataIdx + 6), + READ_LE_INT16(curDataPtr + 2 * curDataIdx + 8), v28); _vm->_linesManager.ZONEP[v28]._enabledFl = true; } @@ -3161,9 +3173,9 @@ void ObjectsManager::INILINK(const Common::String &file) { ++curLineIdx; } while (v28 != -1); for (int i = 1; i <= 100; i++) { - _vm->_linesManager.ZONEP[i]._destX = (int16)READ_LE_UINT16(curDataPtr + 2 * curDataIdx); - _vm->_linesManager.ZONEP[i]._destY = (int16)READ_LE_UINT16(curDataPtr + 2 * curDataIdx + 2); - _vm->_linesManager.ZONEP[i]._spriteIndex = (int16)READ_LE_UINT16(curDataPtr + 2 * curDataIdx + 4); + _vm->_linesManager.ZONEP[i]._destX = READ_LE_INT16(curDataPtr + 2 * curDataIdx); + _vm->_linesManager.ZONEP[i]._destY = READ_LE_INT16(curDataPtr + 2 * curDataIdx + 2); + _vm->_linesManager.ZONEP[i]._spriteIndex = READ_LE_INT16(curDataPtr + 2 * curDataIdx + 4); curDataIdx += 3; } @@ -3183,7 +3195,7 @@ void ObjectsManager::INILINK(const Common::String &file) { } int dep = 1010; for (int i = 1; i <= 100; i++) { - _vm->_linesManager.ZONEP[i].field12 = (int16)READ_LE_UINT16(v22 + dep); + _vm->_linesManager.ZONEP[i].field12 = READ_LE_INT16(v22 + dep); dep += 2; } _vm->_linesManager.CARRE_ZONE(); @@ -3706,7 +3718,7 @@ void ObjectsManager::PERSONAGE(const Common::String &backgroundFile, const Commo stopBobAnimation(3); _vm->_globals.NOT_VERIF = true; _oldCharacterPosX = getSpriteX(0); - _vm->_globals._oldDirection = -1; + _vm->_globals._oldDirection = DIR_NONE; _vm->_globals.Compteur = 0; _vm->_linesManager._route = (RouteItem *)g_PTRNUL; _vm->_linesManager._route = _vm->_linesManager.PARCOURS2(getSpriteX(0), getSpriteY(0), 330, 345); @@ -3823,7 +3835,7 @@ void ObjectsManager::PERSONAGE2(const Common::String &backgroundFile, const Comm _vm->_eventsManager._mouseSpriteId = 4; _oldCharacterPosX = _characterPos.x; _oldCharacterPosY = _characterPos.y; - _vm->_globals._oldDirection = -1; + _vm->_globals._oldDirection = DIR_NONE; _vm->_globals.Compteur = 0; for (int idx = 0; idx < 5; ++idx) diff --git a/engines/hopkins/script.cpp b/engines/hopkins/script.cpp index 33876f8293..64f5fe2a57 100644 --- a/engines/hopkins/script.cpp +++ b/engines/hopkins/script.cpp @@ -54,7 +54,7 @@ int ScriptManager::handleOpcode(byte *dataP) { switch (signature24) { case MKTAG24('T', 'X', 'T'): { vbobFrameIndex = dataP[6]; - int mesgId = (int16)READ_LE_UINT16(dataP + 13); + int mesgId = READ_LE_INT16(dataP + 13); opcodeType = 1; if (!TRAVAILOBJET) { if (_vm->_globals._saveData->_data[svField356] == 1) { @@ -133,8 +133,8 @@ int ScriptManager::handleOpcode(byte *dataP) { } while (_vm->_soundManager._soundFl); } if (!_vm->_soundManager._textOffFl) { - int textPosX = (int16)READ_LE_UINT16(dataP + 9); - int textPosY = (int16)READ_LE_UINT16(dataP + 11); + int textPosX = READ_LE_INT16(dataP + 9); + int textPosY = READ_LE_INT16(dataP + 11); _vm->_fontManager.initTextBuffers(9, mesgId, _vm->_globals.FICH_TEXTE, 2 * textPosX, 2 * textPosY + 40, 6, dataP[7], 253); if (!_vm->_soundManager._textOffFl) _vm->_fontManager.showText(9); @@ -149,7 +149,7 @@ int ScriptManager::handleOpcode(byte *dataP) { if (!_vm->_soundManager._voiceOffFl) _vm->_soundManager.mixVoice(635, 4); } else { - int textPosX = (int16)READ_LE_UINT16(dataP + 9); + int textPosX = READ_LE_INT16(dataP + 9); if (_vm->_globals._language == LANG_FR && !_vm->_soundManager._textOffFl) _vm->_fontManager.initTextBuffers(9, mesgId, "OBJET1.TXT", 2 * textPosX, 60, 6, dataP[7], 253); else if (_vm->_globals._language == LANG_EN && !_vm->_soundManager._textOffFl) @@ -172,10 +172,10 @@ int ScriptManager::handleOpcode(byte *dataP) { int vbobIdx = dataP[5]; vbobFrameIndex = dataP[6]; int v4 = dataP[7]; - int vbobPosX = (int16)READ_LE_UINT16(dataP + 8); - int vbobPosY = (int16)READ_LE_UINT16(dataP + 10); + int vbobPosX = READ_LE_INT16(dataP + 8); + int vbobPosY = READ_LE_INT16(dataP + 10); if (vbobIdx == 52) { - _vm->_graphicsManager.fastDisplay(_vm->_globals.SPRITE_ECRAN, vbobPosX, (int16)READ_LE_UINT16(dataP + 10), vbobFrameIndex); + _vm->_graphicsManager.fastDisplay(_vm->_globals.SPRITE_ECRAN, vbobPosX, READ_LE_INT16(dataP + 10), vbobFrameIndex); } else if (vbobIdx == 51) { _vm->_objectsManager.BOB_VIVANT(vbobFrameIndex); } else if (vbobIdx != 50) { @@ -198,8 +198,8 @@ int ScriptManager::handleOpcode(byte *dataP) { case MKTAG24('S', 'T', 'P'): if (!_vm->_objectsManager._disableFl) { _vm->_objectsManager._twoCharactersFl = false; - _vm->_objectsManager._characterPos.x = (int16)READ_LE_UINT16(dataP + 6); - _vm->_objectsManager._characterPos.y = (int16)READ_LE_UINT16(dataP + 8); + _vm->_objectsManager._characterPos.x = READ_LE_INT16(dataP + 6); + _vm->_objectsManager._characterPos.y = READ_LE_INT16(dataP + 8); _vm->_objectsManager._startSpriteIndex = dataP[5]; if (_vm->_objectsManager._changeHeadFl) { if (_vm->_globals._saveData->_data[svField354] == 1 @@ -266,183 +266,183 @@ int ScriptManager::handleOpcode(byte *dataP) { break; case MKTAG24('B', 'O', 'F'): if (!_vm->_objectsManager._disableFl) - _vm->_objectsManager.VBOB_OFF((int16)READ_LE_UINT16(dataP + 5)); + _vm->_objectsManager.VBOB_OFF(READ_LE_INT16(dataP + 5)); opcodeType = 1; break; case MKTAG24('P', 'E', 'R'): { - int specialOpcode = (int16)READ_LE_UINT16(dataP + 5); + int specialOpcode = READ_LE_INT16(dataP + 5); if (!_vm->_globals._saveData->_data[svField122] && !_vm->_globals._saveData->_data[svField356]) { vbobFrameIndex = 0; switch (specialOpcode) { case 1: case 14: - if (_vm->_globals._actionDirection == 1) + if (_vm->_globals._actionDirection == DIR_UP) _vm->_objectsManager.doActionBack(4); - if (_vm->_globals._actionDirection == 3) + if (_vm->_globals._actionDirection == DIR_RIGHT) _vm->_objectsManager.doActionRight(4); - if (_vm->_globals._actionDirection == 2) + if (_vm->_globals._actionDirection == DIR_UP_RIGHT) _vm->_objectsManager.doActionDiagRight(4); - if (_vm->_globals._actionDirection == 5) + if (_vm->_globals._actionDirection == DIR_DOWN) _vm->_objectsManager.doActionFront(4); - if (_vm->_globals._actionDirection == 8) + if (_vm->_globals._actionDirection == DIR_UP_LEFT) _vm->_objectsManager.doActionDiagLeft(4); - if (_vm->_globals._actionDirection == 7) + if (_vm->_globals._actionDirection == DIR_LEFT) _vm->_objectsManager.doActionLeft(4); break; case 2: - if (_vm->_globals._actionDirection == 1) + if (_vm->_globals._actionDirection == DIR_UP) _vm->_objectsManager.doActionBack(7); - if (_vm->_globals._actionDirection == 3) + if (_vm->_globals._actionDirection == DIR_RIGHT) _vm->_objectsManager.doActionRight(7); - if (_vm->_globals._actionDirection == 2) + if (_vm->_globals._actionDirection == DIR_UP_RIGHT) _vm->_objectsManager.doActionDiagRight(7); - if (_vm->_globals._actionDirection == 5) + if (_vm->_globals._actionDirection == DIR_DOWN) _vm->_objectsManager.doActionFront(7); - if (_vm->_globals._actionDirection == 8) + if (_vm->_globals._actionDirection == DIR_UP_LEFT) _vm->_objectsManager.doActionDiagLeft(7); - if (_vm->_globals._actionDirection == 7) + if (_vm->_globals._actionDirection == DIR_LEFT) _vm->_objectsManager.doActionLeft(7); - if (_vm->_globals._actionDirection == 1) + if (_vm->_globals._actionDirection == DIR_UP) _vm->_objectsManager.doActionBack(8); - if (_vm->_globals._actionDirection == 3) + if (_vm->_globals._actionDirection == DIR_RIGHT) _vm->_objectsManager.doActionRight(8); - if (_vm->_globals._actionDirection == 2) + if (_vm->_globals._actionDirection == DIR_UP_RIGHT) _vm->_objectsManager.doActionDiagRight(8); - if (_vm->_globals._actionDirection == 5) + if (_vm->_globals._actionDirection == DIR_DOWN) _vm->_objectsManager.doActionFront(8); - if (_vm->_globals._actionDirection == 8) + if (_vm->_globals._actionDirection == DIR_UP_LEFT) _vm->_objectsManager.doActionDiagLeft(8); - if (_vm->_globals._actionDirection == 7) + if (_vm->_globals._actionDirection == DIR_LEFT) _vm->_objectsManager.doActionLeft(8); break; case 19: case 4: - if (_vm->_globals._actionDirection == 1) + if (_vm->_globals._actionDirection == DIR_UP) _vm->_objectsManager.doActionBack(1); - if (_vm->_globals._actionDirection == 3) + if (_vm->_globals._actionDirection == DIR_RIGHT) _vm->_objectsManager.doActionRight(1); - if (_vm->_globals._actionDirection == 2) + if (_vm->_globals._actionDirection == DIR_UP_RIGHT) _vm->_objectsManager.doActionDiagRight(1); - if (_vm->_globals._actionDirection == 5) + if (_vm->_globals._actionDirection == DIR_DOWN) _vm->_objectsManager.doActionFront(1); - if (_vm->_globals._actionDirection == 8) + if (_vm->_globals._actionDirection == DIR_UP_LEFT) _vm->_objectsManager.doActionDiagLeft(1); - if (_vm->_globals._actionDirection == 7) + if (_vm->_globals._actionDirection == DIR_LEFT) _vm->_objectsManager.doActionLeft(1); break; case 5: - if (_vm->_globals._actionDirection == 1) + if (_vm->_globals._actionDirection == DIR_UP) _vm->_objectsManager.doActionBack(5); - if (_vm->_globals._actionDirection == 3) + if (_vm->_globals._actionDirection == DIR_RIGHT) _vm->_objectsManager.doActionRight(5); - if (_vm->_globals._actionDirection == 2) + if (_vm->_globals._actionDirection == DIR_UP_RIGHT) _vm->_objectsManager.doActionDiagRight(5); - if (_vm->_globals._actionDirection == 5) + if (_vm->_globals._actionDirection == DIR_DOWN) _vm->_objectsManager.doActionFront(5); - if (_vm->_globals._actionDirection == 8) + if (_vm->_globals._actionDirection == DIR_UP_LEFT) _vm->_objectsManager.doActionDiagLeft(5); - if (_vm->_globals._actionDirection == 7) + if (_vm->_globals._actionDirection == DIR_LEFT) _vm->_objectsManager.doActionLeft(5); - if (_vm->_globals._actionDirection == 1) + if (_vm->_globals._actionDirection == DIR_UP) _vm->_objectsManager.doActionBack(6); - if (_vm->_globals._actionDirection == 3) + if (_vm->_globals._actionDirection == DIR_RIGHT) _vm->_objectsManager.doActionRight(6); - if (_vm->_globals._actionDirection == 2) + if (_vm->_globals._actionDirection == DIR_UP_RIGHT) _vm->_objectsManager.doActionDiagRight(6); - if (_vm->_globals._actionDirection == 5) + if (_vm->_globals._actionDirection == DIR_DOWN) _vm->_objectsManager.doActionFront(6); - if (_vm->_globals._actionDirection == 8) + if (_vm->_globals._actionDirection == DIR_UP_LEFT) _vm->_objectsManager.doActionDiagLeft(6); - if (_vm->_globals._actionDirection == 7) + if (_vm->_globals._actionDirection == DIR_LEFT) _vm->_objectsManager.doActionLeft(6); break; case 17: case 7: - if (_vm->_globals._actionDirection == 1) + if (_vm->_globals._actionDirection == DIR_UP) _vm->_objectsManager.doActionBack(2); - if (_vm->_globals._actionDirection == 3) + if (_vm->_globals._actionDirection == DIR_RIGHT) _vm->_objectsManager.doActionRight(2); - if (_vm->_globals._actionDirection == 2) + if (_vm->_globals._actionDirection == DIR_UP_RIGHT) _vm->_objectsManager.doActionDiagRight(2); - if (_vm->_globals._actionDirection == 5) + if (_vm->_globals._actionDirection == DIR_DOWN) _vm->_objectsManager.doActionFront(2); - if (_vm->_globals._actionDirection == 8) + if (_vm->_globals._actionDirection == DIR_UP_LEFT) _vm->_objectsManager.doActionDiagLeft(2); - if (_vm->_globals._actionDirection == 7) + if (_vm->_globals._actionDirection == DIR_LEFT) _vm->_objectsManager.doActionLeft(2); break; case 18: case 8: - if (_vm->_globals._actionDirection == 1) + if (_vm->_globals._actionDirection == DIR_UP) _vm->_objectsManager.doActionBack(3); - if (_vm->_globals._actionDirection == 3) + if (_vm->_globals._actionDirection == DIR_RIGHT) _vm->_objectsManager.doActionRight(3); - if (_vm->_globals._actionDirection == 2) + if (_vm->_globals._actionDirection == DIR_UP_RIGHT) _vm->_objectsManager.doActionDiagRight(3); - if (_vm->_globals._actionDirection == 5) + if (_vm->_globals._actionDirection == DIR_DOWN) _vm->_objectsManager.doActionFront(3); - if (_vm->_globals._actionDirection == 8) + if (_vm->_globals._actionDirection == DIR_UP_LEFT) _vm->_objectsManager.doActionDiagLeft(3); - if (_vm->_globals._actionDirection == 7) + if (_vm->_globals._actionDirection == DIR_LEFT) _vm->_objectsManager.doActionLeft(3); break; case 9: - if (_vm->_globals._actionDirection == 1) + if (_vm->_globals._actionDirection == DIR_UP) _vm->_objectsManager.doActionBack(5); - if (_vm->_globals._actionDirection == 3) + if (_vm->_globals._actionDirection == DIR_RIGHT) _vm->_objectsManager.doActionRight(5); - if (_vm->_globals._actionDirection == 2) + if (_vm->_globals._actionDirection == DIR_UP_RIGHT) _vm->_objectsManager.doActionDiagRight(5); - if (_vm->_globals._actionDirection == 5) + if (_vm->_globals._actionDirection == DIR_DOWN) _vm->_objectsManager.doActionFront(5); - if (_vm->_globals._actionDirection == 8) + if (_vm->_globals._actionDirection == DIR_UP_LEFT) _vm->_objectsManager.doActionDiagLeft(5); - if (_vm->_globals._actionDirection == 7) + if (_vm->_globals._actionDirection == DIR_LEFT) _vm->_objectsManager.doActionLeft(5); break; case 10: - if (_vm->_globals._actionDirection == 1) + if (_vm->_globals._actionDirection == DIR_UP) _vm->_objectsManager.doActionBack(6); - if (_vm->_globals._actionDirection == 3) + if (_vm->_globals._actionDirection == DIR_RIGHT) _vm->_objectsManager.doActionRight(6); - if (_vm->_globals._actionDirection == 2) + if (_vm->_globals._actionDirection == DIR_UP_RIGHT) _vm->_objectsManager.doActionDiagRight(6); - if (_vm->_globals._actionDirection == 5) + if (_vm->_globals._actionDirection == DIR_DOWN) _vm->_objectsManager.doActionFront(6); - if (_vm->_globals._actionDirection == 8) + if (_vm->_globals._actionDirection == DIR_UP_LEFT) _vm->_objectsManager.doActionDiagLeft(6); - if (_vm->_globals._actionDirection == 7) + if (_vm->_globals._actionDirection == DIR_LEFT) _vm->_objectsManager.doActionLeft(6); break; case 15: case 11: - if (_vm->_globals._actionDirection == 1) + if (_vm->_globals._actionDirection == DIR_UP) _vm->_objectsManager.doActionBack(7); - if (_vm->_globals._actionDirection == 3) + if (_vm->_globals._actionDirection == DIR_RIGHT) _vm->_objectsManager.doActionRight(7); - if (_vm->_globals._actionDirection == 2) + if (_vm->_globals._actionDirection == DIR_UP_RIGHT) _vm->_objectsManager.doActionDiagRight(7); - if (_vm->_globals._actionDirection == 5) + if (_vm->_globals._actionDirection == DIR_DOWN) _vm->_objectsManager.doActionFront(7); - if (_vm->_globals._actionDirection == 8) + if (_vm->_globals._actionDirection == DIR_UP_LEFT) _vm->_objectsManager.doActionDiagLeft(7); - if (_vm->_globals._actionDirection == 7) + if (_vm->_globals._actionDirection == DIR_LEFT) _vm->_objectsManager.doActionLeft(7); break; case 16: case 12: - if (_vm->_globals._actionDirection == 1) + if (_vm->_globals._actionDirection == DIR_UP) _vm->_objectsManager.doActionBack(8); - if (_vm->_globals._actionDirection == 3) + if (_vm->_globals._actionDirection == DIR_RIGHT) _vm->_objectsManager.doActionRight(8); - if (_vm->_globals._actionDirection == 2) + if (_vm->_globals._actionDirection == DIR_UP_RIGHT) _vm->_objectsManager.doActionDiagRight(8); - if (_vm->_globals._actionDirection == 5) + if (_vm->_globals._actionDirection == DIR_DOWN) _vm->_objectsManager.doActionFront(8); - if (_vm->_globals._actionDirection == 8) + if (_vm->_globals._actionDirection == DIR_UP_LEFT) _vm->_objectsManager.doActionDiagLeft(8); - if (_vm->_globals._actionDirection == 7) + if (_vm->_globals._actionDirection == DIR_LEFT) _vm->_objectsManager.doActionLeft(8); break; } @@ -468,36 +468,36 @@ int ScriptManager::handleOpcode(byte *dataP) { } case MKTAG24('O', 'B', 'P'): opcodeType = 1; - _vm->_objectsManager.addObject((int16)READ_LE_UINT16(dataP + 5)); + _vm->_objectsManager.addObject(READ_LE_INT16(dataP + 5)); break; case MKTAG24('O', 'B', 'M'): opcodeType = 1; - _vm->_objectsManager.removeObject((int16)READ_LE_UINT16(dataP + 5)); + _vm->_objectsManager.removeObject(READ_LE_INT16(dataP + 5)); break; case MKTAG24('G', 'O', 'T'): opcodeType = 2; break; case MKTAG24('Z', 'O', 'N'): - _vm->_linesManager.enableZone((int16)READ_LE_UINT16(dataP + 5)); + _vm->_linesManager.enableZone(READ_LE_INT16(dataP + 5)); opcodeType = 1; break; case MKTAG24('Z', 'O', 'F'): - _vm->_linesManager.disableZone((int16)READ_LE_UINT16(dataP + 5)); + _vm->_linesManager.disableZone(READ_LE_INT16(dataP + 5)); opcodeType = 1; break; case MKTAG24('E', 'X', 'I'): opcodeType = 5; break; case MKTAG24('S', 'O', 'R'): - _vm->_globals._exitId = (int16)READ_LE_UINT16(dataP + 5); + _vm->_globals._exitId = READ_LE_INT16(dataP + 5); opcodeType = 5; break; case MKTAG24('B', 'C', 'A'): - _vm->_globals.B_CACHE_OFF((int16)READ_LE_UINT16(dataP + 5)); + _vm->_globals.B_CACHE_OFF(READ_LE_INT16(dataP + 5)); opcodeType = 1; break; case MKTAG24('A', 'N', 'I'): { - int animId = (int16)READ_LE_UINT16(dataP + 5); + int animId = READ_LE_INT16(dataP + 5); if (animId <= 100) _vm->_objectsManager.setBobAnimation(animId); else @@ -506,7 +506,7 @@ int ScriptManager::handleOpcode(byte *dataP) { break; } case MKTAG24('S', 'P', 'E'): - switch ((int16)READ_LE_UINT16(dataP + 5)) { + switch (READ_LE_INT16(dataP + 5)) { case 6: _vm->_objectsManager.removeSprite(0); _vm->_objectsManager.OPTI_ONE(20, 0, 14, 4); @@ -955,7 +955,7 @@ int ScriptManager::handleOpcode(byte *dataP) { case 59: { _vm->_globals.NOT_VERIF = true; _vm->_objectsManager._oldCharacterPosX = _vm->_objectsManager.getSpriteX(0); - _vm->_globals._oldDirection = -1; + _vm->_globals._oldDirection = DIR_NONE; _vm->_globals.Compteur = 0; _vm->_linesManager._route = (RouteItem *)g_PTRNUL; _vm->_linesManager._route = _vm->_linesManager.PARCOURS2(_vm->_objectsManager.getSpriteX(0), _vm->_objectsManager.getSpriteY(0), 445, 332); @@ -1055,7 +1055,7 @@ int ScriptManager::handleOpcode(byte *dataP) { case 81: { _vm->_globals.NOT_VERIF = true; _vm->_objectsManager._oldCharacterPosX = _vm->_objectsManager.getSpriteX(0); - _vm->_globals._oldDirection = -1; + _vm->_globals._oldDirection = DIR_NONE; _vm->_globals.Compteur = 0; _vm->_linesManager._route = (RouteItem *)g_PTRNUL; _vm->_linesManager._route = _vm->_linesManager.PARCOURS2(_vm->_objectsManager.getSpriteX(0), _vm->_objectsManager.getSpriteY(0), 119, 268); @@ -1372,7 +1372,7 @@ int ScriptManager::handleOpcode(byte *dataP) { case 105: _vm->_globals.NOT_VERIF = true; _vm->_objectsManager._oldCharacterPosX = _vm->_objectsManager.getSpriteX(0); - _vm->_globals._oldDirection = -1; + _vm->_globals._oldDirection = DIR_NONE; _vm->_globals.Compteur = 0; _vm->_linesManager._route = (RouteItem *)g_PTRNUL; if (_vm->_globals._saveData->_data[svField253] == 1) { @@ -1619,7 +1619,7 @@ int ScriptManager::handleOpcode(byte *dataP) { _vm->_globals._introSpeechOffFl = false; _vm->_globals.NOT_VERIF = true; _vm->_objectsManager._oldCharacterPosX = _vm->_objectsManager.getSpriteX(0); - _vm->_globals._oldDirection = -1; + _vm->_globals._oldDirection = DIR_NONE; _vm->_globals.Compteur = 0; _vm->_globals.NOT_VERIF = true; _vm->_linesManager._route = (RouteItem *)g_PTRNUL; @@ -1647,7 +1647,7 @@ int ScriptManager::handleOpcode(byte *dataP) { _vm->_globals._introSpeechOffFl = false; _vm->_globals.NOT_VERIF = true; _vm->_objectsManager._oldCharacterPosX = _vm->_objectsManager.getSpriteX(0); - _vm->_globals._oldDirection = -1; + _vm->_globals._oldDirection = DIR_NONE; _vm->_globals.Compteur = 0; _vm->_globals.NOT_VERIF = true; _vm->_linesManager._route = (RouteItem *)g_PTRNUL; @@ -1949,7 +1949,7 @@ int ScriptManager::handleOpcode(byte *dataP) { _vm->_globals.CACHE_ON(); _vm->_globals.NOT_VERIF = true; _vm->_objectsManager._oldCharacterPosX = _vm->_objectsManager.getSpriteX(0); - _vm->_globals._oldDirection = -1; + _vm->_globals._oldDirection = DIR_NONE; _vm->_globals.Compteur = 0; _vm->_globals.NOT_VERIF = true; _vm->_linesManager._route = (RouteItem *)g_PTRNUL; @@ -2373,34 +2373,34 @@ int ScriptManager::handleOpcode(byte *dataP) { break; case MKTAG24('V', 'A', 'L'): { opcodeType = 1; - int idx = (int16)READ_LE_UINT16(dataP + 5); + int idx = READ_LE_INT16(dataP + 5); assert(idx >= 0 && idx < 2050); _vm->_globals._saveData->_data[idx] = dataP[7]; break; } case MKTAG24('A', 'D', 'D'): opcodeType = 1; - _vm->_globals._saveData->_data[(int16)READ_LE_UINT16(dataP + 5)] += dataP[7]; + _vm->_globals._saveData->_data[READ_LE_INT16(dataP + 5)] += dataP[7]; break; case MKTAG24('B', 'O', 'S'): opcodeType = 1; - _vm->_objectsManager.BOB_OFFSET((int16)READ_LE_UINT16(dataP + 5), (int16)READ_LE_UINT16(dataP + 7)); + _vm->_objectsManager.BOB_OFFSET(READ_LE_INT16(dataP + 5), READ_LE_INT16(dataP + 7)); break; case MKTAG24('V', 'O', 'N'): - _vm->_objectsManager.enableVerb((int16)READ_LE_UINT16(dataP + 5), (int16)READ_LE_UINT16(dataP + 7)); + _vm->_objectsManager.enableVerb(READ_LE_INT16(dataP + 5), READ_LE_INT16(dataP + 7)); opcodeType = 1; break; case MKTAG24('Z', 'C', 'H'): - _vm->_linesManager.ZONEP[(int16)READ_LE_UINT16(dataP + 5)].field12 = (int16)READ_LE_UINT16(dataP + 7); + _vm->_linesManager.ZONEP[READ_LE_INT16(dataP + 5)].field12 = READ_LE_INT16(dataP + 7); opcodeType = 1; break; case MKTAG24('J', 'U', 'M'): - _vm->_objectsManager._jumpZone = (int16)READ_LE_UINT16(dataP + 5); - _vm->_objectsManager._jumpVerb = (int16)READ_LE_UINT16(dataP + 7); + _vm->_objectsManager._jumpZone = READ_LE_INT16(dataP + 5); + _vm->_objectsManager._jumpVerb = READ_LE_INT16(dataP + 7); opcodeType = 6; break; case MKTAG24('S', 'O', 'U'): { - int soundNum = (int16)READ_LE_UINT16(dataP + 5); + int soundNum = READ_LE_INT16(dataP + 5); Common::String file = Common::String::format("SOUND%d.WAV", soundNum); _vm->_soundManager.playSound(file); @@ -2408,7 +2408,7 @@ int ScriptManager::handleOpcode(byte *dataP) { break; } case MKTAG24('V', 'O', 'F'): - _vm->_objectsManager.disableVerb((int16)READ_LE_UINT16(dataP + 5), (int16)READ_LE_UINT16(dataP + 7)); + _vm->_objectsManager.disableVerb(READ_LE_INT16(dataP + 5), READ_LE_INT16(dataP + 7)); opcodeType = 1; break; case MKTAG24('I', 'I', 'F'): @@ -2424,7 +2424,7 @@ int ScriptManager::handleOpcode(byte *dataP) { int ScriptManager::handleGoto(const byte *dataP) { - return (int16)READ_LE_UINT16(dataP + 5); + return READ_LE_INT16(dataP + 5); } int ScriptManager::handleIf(const byte *dataP, int a2) { @@ -2468,8 +2468,8 @@ int ScriptManager::handleIf(const byte *dataP, int a2) { byte oper = buf[13]; byte oper2 = buf[14]; byte operType = buf[15]; - int saveDataIdx1 = (int16)READ_LE_UINT16(buf + 5); - int compVal1 = (int16)READ_LE_UINT16(buf + 7); + int saveDataIdx1 = READ_LE_INT16(buf + 5); + int compVal1 = READ_LE_INT16(buf + 7); bool check1Fl = false; if ((oper == 1 && _vm->_globals._saveData->_data[saveDataIdx1] == compVal1) || (oper == 2 && _vm->_globals._saveData->_data[saveDataIdx1] != compVal1) || @@ -2481,8 +2481,8 @@ int ScriptManager::handleIf(const byte *dataP, int a2) { bool check2Fl = false; if (operType != 3) { - int saveDataIdx2 = (int16)READ_LE_UINT16(buf + 9); - int compVal2 = (int16)READ_LE_UINT16(buf + 11); + int saveDataIdx2 = READ_LE_INT16(buf + 9); + int compVal2 = READ_LE_INT16(buf + 11); if ((oper2 == 1 && compVal2 == _vm->_globals._saveData->_data[saveDataIdx2]) || (oper2 == 2 && compVal2 != _vm->_globals._saveData->_data[saveDataIdx2]) || (oper2 == 3 && compVal2 >= _vm->_globals._saveData->_data[saveDataIdx2]) || diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 87943872d4..5d0442aaa5 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -361,7 +361,7 @@ void SoundManager::WSOUND_OFF() { stopVoice(0); stopVoice(1); stopVoice(2); - if (_vm->_soundManager._soundFl) + if (_soundFl) delWav(_currentSoundIndex); for (int i = 1; i <= 48; ++i) @@ -583,7 +583,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { oldMusicVol = _musicVolume; if (!_musicOffFl && _musicVolume > 2) { _musicVolume = (signed int)((long double)_musicVolume - (long double)_musicVolume / 100.0 * 45.0); - _vm->_soundManager.MODSetMusicVolume(_vm->_soundManager._musicVolume); + MODSetMusicVolume(_musicVolume); } playVoice(); @@ -611,7 +611,7 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode) { // Speech is over, set the music volume back to normal _musicVolume = oldMusicVol; if (!_musicOffFl && _musicVolume > 2) { - _vm->_soundManager.MODSetMusicVolume(_vm->_soundManager._musicVolume); + MODSetMusicVolume(_musicVolume); } _vm->_eventsManager._escKeyFl = false; _skipRefreshFl = false; diff --git a/engines/hopkins/talk.cpp b/engines/hopkins/talk.cpp index 61ea1b6438..f22aa679e1 100644 --- a/engines/hopkins/talk.cpp +++ b/engines/hopkins/talk.cpp @@ -75,8 +75,8 @@ void TalkManager::PARLER_PERSO(const Common::String &filename) { } else if (_vm->_globals._language == LANG_SP) { _answersFilename = _questionsFilename = "RUEES.TXT"; } - _dialogueMesgId1 = (int16)READ_LE_UINT16((uint16 *)_characterBuffer + 40); - _paletteBufferIdx = 20 * (int16)READ_LE_UINT16((uint16 *)_characterBuffer + 42) + 110; + _dialogueMesgId1 = READ_LE_INT16((uint16 *)_characterBuffer + 40); + _paletteBufferIdx = 20 * READ_LE_INT16((uint16 *)_characterBuffer + 42) + 110; _characterSprite = _vm->_fileManager.searchCat(spriteFilename, 7); if (_characterSprite) { _characterSprite = _vm->_objectsManager.loadSprite(spriteFilename); @@ -182,8 +182,8 @@ void TalkManager::PARLER_PERSO2(const Common::String &filename) { break; } - _dialogueMesgId1 = (int16)READ_LE_UINT16((uint16 *)_characterBuffer + 40); - _paletteBufferIdx = 20 * (int16)READ_LE_UINT16((uint16 *)_characterBuffer + 42) + 110; + _dialogueMesgId1 = READ_LE_INT16((uint16 *)_characterBuffer + 40); + _paletteBufferIdx = 20 * READ_LE_INT16((uint16 *)_characterBuffer + 42) + 110; searchCharacterPalette(_paletteBufferIdx, false); _dialogueMesgId2 = _dialogueMesgId1 + 1; _dialogueMesgId3 = _dialogueMesgId1 + 2; @@ -228,17 +228,17 @@ void TalkManager::getStringFromBuffer(int srcStart, Common::String &dest, const int TalkManager::dialogQuestion(bool animatedFl) { if (animatedFl) { uint16 *bufPtr = (uint16 *)_characterBuffer + 48; - int curVal = (int16)READ_LE_UINT16(bufPtr); + int curVal = READ_LE_INT16(bufPtr); if (curVal != 0) _vm->_objectsManager.setBobAnimation(curVal); if (curVal != 1) - _vm->_objectsManager.setBobAnimation((int16)READ_LE_UINT16(bufPtr + 1)); + _vm->_objectsManager.setBobAnimation(READ_LE_INT16(bufPtr + 1)); if (curVal != 2) - _vm->_objectsManager.setBobAnimation((int16)READ_LE_UINT16(bufPtr + 2)); + _vm->_objectsManager.setBobAnimation(READ_LE_INT16(bufPtr + 2)); if (curVal != 3) - _vm->_objectsManager.setBobAnimation((int16)READ_LE_UINT16(bufPtr + 3)); + _vm->_objectsManager.setBobAnimation(READ_LE_INT16(bufPtr + 3)); if (curVal != 4) - _vm->_objectsManager.setBobAnimation((int16)READ_LE_UINT16(bufPtr + 4)); + _vm->_objectsManager.setBobAnimation(READ_LE_INT16(bufPtr + 4)); } else { dialogWait(); } @@ -299,23 +299,23 @@ int TalkManager::dialogQuestion(bool animatedFl) { if (animatedFl) { uint16 *bufPtr = (uint16 *)_characterBuffer + 48; - int curVal = (int16)READ_LE_UINT16(bufPtr); + int curVal = READ_LE_INT16(bufPtr); if (curVal != 0) _vm->_objectsManager.stopBobAnimation(curVal); - curVal = (int16)READ_LE_UINT16(bufPtr + 1); + curVal = READ_LE_INT16(bufPtr + 1); if (curVal != 1) _vm->_objectsManager.stopBobAnimation(curVal); - curVal = (int16)READ_LE_UINT16(bufPtr + 2); + curVal = READ_LE_INT16(bufPtr + 2); if (curVal != 2) _vm->_objectsManager.stopBobAnimation(curVal); - curVal = (int16)READ_LE_UINT16(bufPtr + 3); + curVal = READ_LE_INT16(bufPtr + 3); if (curVal != 3) _vm->_objectsManager.stopBobAnimation(curVal); - curVal = (int16)READ_LE_UINT16(bufPtr + 4); + curVal = READ_LE_INT16(bufPtr + 4); if (curVal != 4) _vm->_objectsManager.stopBobAnimation(curVal); } else { @@ -329,21 +329,21 @@ int TalkManager::dialogQuestion(bool animatedFl) { int TalkManager::dialogAnswer(int idx, bool animatedFl) { int charIdx; byte *charBuf; - for (charBuf = _characterBuffer + 110, charIdx = 0; (int16)READ_LE_UINT16(charBuf) != idx; charBuf += 20) { + for (charBuf = _characterBuffer + 110, charIdx = 0; READ_LE_INT16(charBuf) != idx; charBuf += 20) { ++charIdx; - if ((int16)READ_LE_UINT16((uint16 *)_characterBuffer + 42) < charIdx) + if (READ_LE_INT16((uint16 *)_characterBuffer + 42) < charIdx) return -1; } - int mesgId = (int16)READ_LE_UINT16((uint16 *)charBuf + 1); - int mesgPosX = (int16)READ_LE_UINT16((uint16 *)charBuf + 2); - int mesgPosY = (int16)READ_LE_UINT16((uint16 *)charBuf + 3); - int mesgLength = (int16)READ_LE_UINT16((uint16 *)charBuf + 4); - _dialogueMesgId1 = (int16)READ_LE_UINT16((uint16 *)charBuf + 5); - _dialogueMesgId2 = (int16)READ_LE_UINT16((uint16 *)charBuf + 6); - _dialogueMesgId3 = (int16)READ_LE_UINT16((uint16 *)charBuf + 7); - int v6 = (int16)READ_LE_UINT16((uint16 *)charBuf + 8); - int v7 = (int16)READ_LE_UINT16((uint16 *)charBuf + 9); + int mesgId = READ_LE_INT16((uint16 *)charBuf + 1); + int mesgPosX = READ_LE_INT16((uint16 *)charBuf + 2); + int mesgPosY = READ_LE_INT16((uint16 *)charBuf + 3); + int mesgLength = READ_LE_INT16((uint16 *)charBuf + 4); + _dialogueMesgId1 = READ_LE_INT16((uint16 *)charBuf + 5); + _dialogueMesgId2 = READ_LE_INT16((uint16 *)charBuf + 6); + _dialogueMesgId3 = READ_LE_INT16((uint16 *)charBuf + 7); + int v6 = READ_LE_INT16((uint16 *)charBuf + 8); + int v7 = READ_LE_INT16((uint16 *)charBuf + 9); if (v7) _vm->_globals._saveData->_data[svField4] = v7; @@ -352,23 +352,23 @@ int TalkManager::dialogAnswer(int idx, bool animatedFl) { v6 = 10; if (animatedFl) { uint16 *bufPtr = (uint16 *)_characterBuffer + 43; - int curVal = (int16)READ_LE_UINT16(bufPtr); + int curVal = READ_LE_INT16(bufPtr); if (curVal) _vm->_objectsManager.stopBobAnimation(curVal); - curVal = (int16)READ_LE_UINT16(bufPtr + 1); + curVal = READ_LE_INT16(bufPtr + 1); if (curVal) _vm->_objectsManager.stopBobAnimation(curVal); - curVal = (int16)READ_LE_UINT16(bufPtr + 2); + curVal = READ_LE_INT16(bufPtr + 2); if (curVal) _vm->_objectsManager.stopBobAnimation(curVal); - curVal = (int16)READ_LE_UINT16(bufPtr + 3); + curVal = READ_LE_INT16(bufPtr + 3); if (curVal) _vm->_objectsManager.stopBobAnimation(curVal); - curVal = (int16)READ_LE_UINT16(bufPtr + 4); + curVal = READ_LE_INT16(bufPtr + 4); if (curVal) _vm->_objectsManager.stopBobAnimation(curVal); } else { @@ -402,23 +402,23 @@ int TalkManager::dialogAnswer(int idx, bool animatedFl) { _vm->_fontManager.hideText(9); if (animatedFl) { uint16 *bufPtr = (uint16 *)_characterBuffer + 43; - int curVal = (int16)READ_LE_UINT16(bufPtr); + int curVal = READ_LE_INT16(bufPtr); if (curVal) _vm->_objectsManager.stopBobAnimation(curVal); - curVal = (int16)READ_LE_UINT16(bufPtr + 1); + curVal = READ_LE_INT16(bufPtr + 1); if (curVal) _vm->_objectsManager.stopBobAnimation(curVal); - curVal = (int16)READ_LE_UINT16(bufPtr + 2); + curVal = READ_LE_INT16(bufPtr + 2); if (curVal) _vm->_objectsManager.stopBobAnimation(curVal); - curVal = (int16)READ_LE_UINT16(bufPtr + 3); + curVal = READ_LE_INT16(bufPtr + 3); if (curVal) _vm->_objectsManager.stopBobAnimation(curVal); - curVal = (int16)READ_LE_UINT16(bufPtr + 4); + curVal = READ_LE_INT16(bufPtr + 4); if (curVal) _vm->_objectsManager.stopBobAnimation(curVal); } else { @@ -600,10 +600,10 @@ void TalkManager::BOB_VISU_PARLE(int idx) { if (!_vm->_objectsManager._bob[idx].field0) { _vm->_objectsManager.resetBob(idx); byte *v5 = _vm->_globals.Bqe_Anim[idx]._data; - int v4 = (int16)READ_LE_UINT16(v5 + 2); + int v4 = READ_LE_INT16(v5 + 2); if (!v4) v4 = 1; - if ((int16)READ_LE_UINT16(v5 + 24)) { + if (READ_LE_INT16(v5 + 24)) { _vm->_objectsManager._bob[idx]._isSpriteFl = true; _vm->_objectsManager._bob[idx]._zoomFactor = 0; _vm->_objectsManager._bob[idx]._flipFl = false; @@ -636,10 +636,10 @@ void TalkManager::startCharacterAnim0(int startIdx, bool readOnlyFl) { int idx = 0; int v7; do { - v7 = (int16)READ_LE_UINT16(&_characterAnim[2 * idx + 4]); + v7 = READ_LE_INT16(&_characterAnim[2 * idx + 4]); if (v7 && _vm->_globals._speed != 501) - _vm->_graphicsManager.fastDisplay(_characterSprite, _vm->_eventsManager._startPos.x + (int16)READ_LE_UINT16(&_characterAnim[2 * idx]), - (int16)READ_LE_UINT16(&_characterAnim[2 * idx + 2]), _characterAnim[2 * idx + 8]); + _vm->_graphicsManager.fastDisplay(_characterSprite, _vm->_eventsManager._startPos.x + READ_LE_INT16(&_characterAnim[2 * idx]), + READ_LE_INT16(&_characterAnim[2 * idx + 2]), _characterAnim[2 * idx + 8]); idx += 5; } while (_vm->_globals._speed != 501 && v7); } @@ -651,43 +651,43 @@ void TalkManager::startCharacterAnim0(int startIdx, bool readOnlyFl) { void TalkManager::initCharacterAnim() { uint16 *bufPtr = (uint16 *)_characterBuffer + 43; byte *animPtr = _characterBuffer + 110; - int curVal = (int16)READ_LE_UINT16(bufPtr); + int curVal = READ_LE_INT16(bufPtr); if (curVal) searchCharacterAnim(21, animPtr, curVal, _characterSize); - curVal = (int16)READ_LE_UINT16(bufPtr + 1); + curVal = READ_LE_INT16(bufPtr + 1); if (curVal) searchCharacterAnim(22, animPtr, curVal, _characterSize); - curVal = (int16)READ_LE_UINT16(bufPtr + 2); + curVal = READ_LE_INT16(bufPtr + 2); if (curVal) searchCharacterAnim(23, animPtr, curVal, _characterSize); - curVal = (int16)READ_LE_UINT16(bufPtr + 3); + curVal = READ_LE_INT16(bufPtr + 3); if (curVal) searchCharacterAnim(24, animPtr, curVal, _characterSize); - curVal = (int16)READ_LE_UINT16(bufPtr + 4); + curVal = READ_LE_INT16(bufPtr + 4); if (curVal) searchCharacterAnim(25, animPtr, curVal, _characterSize); - curVal = (int16)READ_LE_UINT16(bufPtr + 5); + curVal = READ_LE_INT16(bufPtr + 5); if (curVal) searchCharacterAnim(26, animPtr, curVal, _characterSize); - curVal = (int16)READ_LE_UINT16(bufPtr + 6); + curVal = READ_LE_INT16(bufPtr + 6); if (curVal) searchCharacterAnim(27, animPtr, curVal, _characterSize); - curVal = (int16)READ_LE_UINT16(bufPtr + 7); + curVal = READ_LE_INT16(bufPtr + 7); if (curVal) searchCharacterAnim(28, animPtr, curVal, _characterSize); - curVal = (int16)READ_LE_UINT16(bufPtr + 8); + curVal = READ_LE_INT16(bufPtr + 8); if (curVal) searchCharacterAnim(29, animPtr, curVal, _characterSize); - curVal = (int16)READ_LE_UINT16(bufPtr + 9); + curVal = READ_LE_INT16(bufPtr + 9); if (curVal) searchCharacterAnim(30, animPtr, curVal, _characterSize); } @@ -723,11 +723,11 @@ bool TalkManager::searchCharacterAnim(int idx, const byte *bufPerso, int animId, _vm->_globals.Bqe_Anim[idx]._data = _vm->_globals.allocMemory(animLength + 50); _vm->_globals.Bqe_Anim[idx]._enabledFl = true; memcpy(_vm->_globals.Bqe_Anim[idx]._data, (const byte *)(bufPerso + bufPos + 5), 20); - int v23 = (int16)READ_LE_UINT16(bufPos + bufPerso + 29); - WRITE_LE_UINT16(_vm->_globals.Bqe_Anim[idx]._data + 20, (int16)READ_LE_UINT16(bufPos + bufPerso + 25)); - WRITE_LE_UINT16(_vm->_globals.Bqe_Anim[idx]._data + 22, (int16)READ_LE_UINT16(bufPos + bufPerso + 27)); + int v23 = READ_LE_INT16(bufPos + bufPerso + 29); + WRITE_LE_UINT16(_vm->_globals.Bqe_Anim[idx]._data + 20, READ_LE_INT16(bufPos + bufPerso + 25)); + WRITE_LE_UINT16(_vm->_globals.Bqe_Anim[idx]._data + 22, READ_LE_INT16(bufPos + bufPerso + 27)); WRITE_LE_UINT16(_vm->_globals.Bqe_Anim[idx]._data + 24, v23); - WRITE_LE_UINT16(_vm->_globals.Bqe_Anim[idx]._data + 26, (int16)READ_LE_UINT16(bufPos + bufPerso + 31)); + WRITE_LE_UINT16(_vm->_globals.Bqe_Anim[idx]._data + 26, READ_LE_INT16(bufPos + bufPerso + 31)); _vm->_globals.Bqe_Anim[idx]._data[28] = bufPerso[bufPos + 33]; _vm->_globals.Bqe_Anim[idx]._data[29] = bufPerso[bufPos + 34]; byte *bqeCurData = _vm->_globals.Bqe_Anim[idx]._data + 20; @@ -737,11 +737,11 @@ bool TalkManager::searchCharacterAnim(int idx, const byte *bufPerso, int animId, curBufPerso += 10; if (!v23) break; - v23 = (int16)READ_LE_UINT16(curBufPerso + 4); - WRITE_LE_UINT16(bqeCurData, (int16)READ_LE_UINT16(curBufPerso)); - WRITE_LE_UINT16(bqeCurData + 2, (int16)READ_LE_UINT16(curBufPerso + 2)); + v23 = READ_LE_INT16(curBufPerso + 4); + WRITE_LE_UINT16(bqeCurData, READ_LE_INT16(curBufPerso)); + WRITE_LE_UINT16(bqeCurData + 2, READ_LE_INT16(curBufPerso + 2)); WRITE_LE_UINT16(bqeCurData + 4, v23); - WRITE_LE_UINT16(bqeCurData + 6, (int16)READ_LE_UINT16(curBufPerso + 6)); + WRITE_LE_UINT16(bqeCurData + 6, READ_LE_INT16(curBufPerso + 6)); bqeCurData[8] = curBufPerso[8]; bqeCurData[9] = curBufPerso[9]; } @@ -1004,7 +1004,7 @@ void TalkManager::OBJET_VIVANT(const Common::String &a2) { if (!_vm->_graphicsManager._lineNbr) _vm->_graphicsManager._scrollOffset = 0; _vm->_graphicsManager.NB_SCREEN(true); - _paletteBufferIdx = 20 * (int16)READ_LE_UINT16((uint16 *)_characterBuffer + 42) + 110; + _paletteBufferIdx = 20 * READ_LE_INT16((uint16 *)_characterBuffer + 42) + 110; _vm->_graphicsManager.NB_SCREEN(true); _vm->_objectsManager.PERSO_ON = true; searchCharacterPalette(_paletteBufferIdx, true); |