diff options
author | Strangerke | 2012-05-06 22:32:23 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2018-03-28 17:36:57 +0200 |
commit | 7153a4b38aca78c7d9c5222c0f17d8d6342ebf2d (patch) | |
tree | fc6ffbf045fd2266884bdc390073eeddfc890ebf /engines | |
parent | 98ac7cf0eb7dacfa8a63c6af6b4554f53d2cec9b (diff) | |
download | scummvm-rg350-7153a4b38aca78c7d9c5222c0f17d8d6342ebf2d.tar.gz scummvm-rg350-7153a4b38aca78c7d9c5222c0f17d8d6342ebf2d.tar.bz2 scummvm-rg350-7153a4b38aca78c7d9c5222c0f17d8d6342ebf2d.zip |
LILLIPUT: More renaming, fix a bug in sub16799, move several unsigned to signed
Diffstat (limited to 'engines')
-rw-r--r-- | engines/lilliput/lilliput.cpp | 158 | ||||
-rw-r--r-- | engines/lilliput/lilliput.h | 32 | ||||
-rw-r--r-- | engines/lilliput/script.cpp | 69 | ||||
-rw-r--r-- | engines/lilliput/script.h | 12 |
4 files changed, 136 insertions, 135 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp index 100aa02726..63736814a9 100644 --- a/engines/lilliput/lilliput.cpp +++ b/engines/lilliput/lilliput.cpp @@ -180,18 +180,18 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd) _array10999PosX[i] = 0; _array109C1PosY[i] = 0; _charactersToDisplay[i] = 0; - _characterRelativePositionX[i] = 0xFF; - _characterRelativePositionY[i] = 0xFF; + _characterRelativePositionX[i] = -1; + _characterRelativePositionY[i] = -1; _characterDisplayX[i] = 0; _characterDisplayY[i] = 0; _array12299[i] = 0xFF; - _array109E9[i] = 0xFF; - _array10A11[i] = 0xFF; + _array109E9PosX[i] = -1; + _array10A11PosY[i] = -1; _array16E94[i] = 0; _array11D49[i] = 0xFFFF; - _characterPositionX[i] = 0xFFFF; - _characterPositionY[i] = 0xFFFF; + _characterPositionX[i] = -1; + _characterPositionY[i] = -1; _characterPositionAltitude[i] = 0; _characterFrameArray[i] = 0; _rulesBuffer2_5[i] = 0xFF; @@ -666,9 +666,9 @@ void LilliputEngine::displayCharactersOnMap() { byte *buf = (byte *)_mainSurface->getPixels(); for (int index = _numCharacters - 1; index >=0; index--) { - if (((_rulesBuffer2_11[index] & 2) == 0) && (_scriptHandler->_array1614B[index] != -1)) { - int y = (3 * _scriptHandler->_array1614B[index]) + 1; - int x = (_scriptHandler->_array16123[index] * 4) + 1; + if (((_rulesBuffer2_11[index] & 2) == 0) && (_scriptHandler->_array1614BPosY[index] != -1)) { + int y = (3 * _scriptHandler->_array1614BPosY[index]) + 1; + int x = (_scriptHandler->_array16123PosX[index] * 4) + 1; _word15E5D[index] = y * 320 + x; _byte15E35[index] = buf[y * 320 + x]; @@ -713,8 +713,8 @@ void LilliputEngine::sub16217() { _characterPositionY[i] = var4; } - _scriptHandler->_array16123[i] = _characterPositionX[i] >> 3; - _scriptHandler->_array1614B[i] = _characterPositionY[i] >> 3; + _scriptHandler->_array16123PosX[i] = _characterPositionX[i] >> 3; + _scriptHandler->_array1614BPosY[i] = _characterPositionY[i] >> 3; _characterRelativePositionX[i] = 0xFF; _characterRelativePositionY[i] = 0xFF; _characterDisplayX[i] = 0xFF; @@ -980,8 +980,8 @@ void LilliputEngine::sub16CA0() { if (_rulesBuffer2_11[index] & 1) continue; - int c1 = _scriptHandler->_array16123[index]; - int c2 = _scriptHandler->_array1614B[index]; + int c1 = _scriptHandler->_array16123PosX[index]; + int c2 = _scriptHandler->_array1614BPosY[index]; for (int index2 = _numCharacters - 1; index2 >= 0; index2--) { _byte16C9F = 0; @@ -989,8 +989,8 @@ void LilliputEngine::sub16CA0() { (_rulesBuffer2_5[index] != index2) && (_rulesBuffer2_5[index2] != index) && (_rulesBuffer2_11[index2] & 2) == 0) { - int d1 = _scriptHandler->_array16123[index2]; - int d2 = _scriptHandler->_array1614B[index2]; + int d1 = _scriptHandler->_array16123PosX[index2]; + int d2 = _scriptHandler->_array1614BPosY[index2]; if (d1 != 0xFF) { int x = c1 - d1; @@ -1352,26 +1352,24 @@ void LilliputEngine::sub189DE() { } } -// TODO rename to determine direction parameter from/to -int LilliputEngine::sub16B0C(Common::Point param1, Common::Point param2) { - debugC(2, kDebugEngine, "sub16B0C(%d - %d, %d - %d)", param1.x, param1.y, param2.x, param2.y); +int LilliputEngine::getDirection(Common::Point param1, Common::Point param2) { + debugC(2, kDebugEngine, "getDirection(%d - %d, %d - %d)", param1.x, param1.y, param2.x, param2.y); - static const char _array16B04[8] = {0, 2, 0, 1, 3, 2, 3, 1}; + static const char _directionsArray[8] = {0, 2, 0, 1, 3, 2, 3, 1}; Common::Point var1 = param2; Common::Point var2 = param1; int8 var1h = var1.x - var2.x; int8 var1l = var1.y - var2.y; - int8 var2h = 0; int8 var2l = 0; - if (var1h < var2h) { + if (var1h < 0) { var2l |= 4; var1h = -var1h; } - if (var1l < var2h) { + if (var1l < 0) { var2l |= 2; var1l = -var1l; } @@ -1379,32 +1377,31 @@ int LilliputEngine::sub16B0C(Common::Point param1, Common::Point param2) { if (var1h < var1l) var2l |= 1; - return _array16B04[var2l]; + return _directionsArray[var2l]; } byte LilliputEngine::sub16799(int index, int param1) { debugC(2, kDebugEngine, "sub16799(%d, %d)", index, param1); - byte var3h = _array109E9[index]; - byte var3l = _array10A11[index]; + Common::Point var3 = Common::Point(_array109E9PosX[index], _array10A11PosY[index]); - if (var3h != 0xFF) { - if ((var3h != _scriptHandler->_array16123[index]) || (var3l != _scriptHandler->_array1614B[index])) { + if (var3.x != -1) { + if ((var3.x != _scriptHandler->_array16123PosX[index]) || (var3.y != _scriptHandler->_array1614BPosY[index])) { sub1693A(index); _scriptHandler->_array12811[index] -= (param1 >> 8) & 0x0F; return 3; } - if ((var3h == _scriptHandler->_array12811[index]) && (var3l == _array109C1PosY[index])) + if ((var3.x == _array10999PosX[index]) && (var3.y == _array109C1PosY[index])) return 2; } sub167EF(index); - Common::Point pos1 = Common::Point(_scriptHandler->_array16123[index], _scriptHandler->_array1614B[index]); - Common::Point pos2 = Common::Point(_array109E9[index], _array10A11[index]); + Common::Point pos1 = Common::Point(_scriptHandler->_array16123PosX[index], _scriptHandler->_array1614BPosY[index]); + Common::Point pos2 = Common::Point(_array109E9PosX[index], _array10A11PosY[index]); - _characterDirectionArray[index] = sub16B0C(pos1, pos2); + _characterDirectionArray[index] = getDirection(pos1, pos2); sub1693A(index); _scriptHandler->_array12811[index] -= (param1 >> 8) & 0x0F; @@ -1416,19 +1413,19 @@ byte LilliputEngine::sub16799(int index, int param1) { void LilliputEngine::sub167EF(int index) { debugC(2, kDebugEngine, "sub167EF(%d)", index); - int word167EB = sub168DA(Common::Point(_scriptHandler->_array16123[index], _scriptHandler->_array1614B[index])); + int word167EB = sub168DA(Common::Point(_scriptHandler->_array16123PosX[index], _scriptHandler->_array1614BPosY[index])); int word167ED = sub168DA(Common::Point(_array10999PosX[index], _array109C1PosY[index])); if (word167EB == word167ED) { - _array109E9[index] = _array10999PosX[index]; - _array10A11[index] = _array109C1PosY[index]; + _array109E9PosX[index] = _array10999PosX[index]; + _array10A11PosY[index] = _array109C1PosY[index]; return; } if (word167EB = 0xFFFF) { int tmpVal = sub16901(_array10999PosX[index], _array109C1PosY[index]); - _array109E9[index] = (_rulesBuffer12_4[tmpVal] >> 8); - _array10A11[index] = (_rulesBuffer12_4[tmpVal] & 0xFF); + _array109E9PosX[index] = _rulesBuffer12Pos[tmpVal].x; + _array10A11PosY[index] = _rulesBuffer12Pos[tmpVal].y; return; } @@ -1437,24 +1434,24 @@ void LilliputEngine::sub167EF(int index) { (_array10999PosX[index] <= (_rectXMinMax[word167EB] & 0xFF)) && (_array109C1PosY[index] >= (_rectYMinMax[word167EB] >> 8)) && (_array109C1PosY[index] <= (_rectYMinMax[word167EB] & 0xFF)) ) { - _array109E9[index] = (_rulesBuffer12_4[word167ED] >> 8); - _array10A11[index] = (_rulesBuffer12_4[word167ED] & 0xFF); + _array109E9PosX[index] = _rulesBuffer12Pos[word167ED].x; + _array10A11PosY[index] = _rulesBuffer12Pos[word167ED].y; return; } - _array109E9[index] = (_rulesBuffer12_4[word167EB] >> 8); - _array10A11[index] = (_rulesBuffer12_4[word167EB] & 0xFF); + _array109E9PosX[index] = _rulesBuffer12Pos[word167EB].x; + _array10A11PosY[index] = _rulesBuffer12Pos[word167EB].y; int var4h = (_rectXMinMax[index] >> 8); int var4l = (_rectXMinMax[index] & 0xFF); if (var4h != var4l) { - if (_array109E9[index] == var4h) { - --_array109E9[index]; + if (_array109E9PosX[index] == var4h) { + --_array109E9PosX[index]; return; } - if (_array109E9[index] == var4l) { - ++_array109E9[index]; + if (_array109E9PosX[index] == var4l) { + ++_array109E9PosX[index]; return; } @@ -1462,25 +1459,25 @@ void LilliputEngine::sub167EF(int index) { int var4l = (_rectYMinMax[index] & 0xFF); if (var4h != var4l) { - if (_array10A11[index] == var4h) - --_array10A11[index]; + if (_array10A11PosY[index] == var4h) + --_array10A11PosY[index]; else - ++_array10A11[index]; + ++_array10A11PosY[index]; return; } } // var4h == var4l - int mapIndex = (((_array10A11[index] >> 2) + _array109E9[index]) << 2); + int mapIndex = (((_array10A11PosY[index] >> 2) + _array109E9PosX[index]) << 2); int tmpVal = _bufferIsoMap[mapIndex + 3]; if ((tmpVal & 8) != 0) - ++_array109E9[index]; + ++_array109E9PosX[index]; else if ((tmpVal & 4) != 0) - --_array10A11[index]; + --_array10A11PosY[index]; else if ((tmpVal & 2) != 0) - ++_array10A11[index]; + ++_array10A11PosY[index]; else - --_array109E9[index]; + --_array109E9PosX[index]; return; } @@ -1490,8 +1487,8 @@ void LilliputEngine::sub1693A(int index) { static const uint16 _array1692F[4] = {4, 0xFF00, 0x100, 0xFFFC}; - byte var1h = _scriptHandler->_array16123[index]; - byte var1l = _scriptHandler->_array1614B[index]; + int var1h = _scriptHandler->_array16123PosX[index]; + int var1l = _scriptHandler->_array1614BPosY[index]; _word16937 = (var1h << 8) + var1l; sub16A08(index); @@ -1557,8 +1554,8 @@ byte LilliputEngine::sub16A76(int indexb, int indexs) { if ((var1h >= (_rectXMinMax[var2] >> 8)) && (var1h <= (_rectXMinMax[var2] & 0xFF)) && (var1l >= (_rectYMinMax[var2] >> 8)) && (var1l <= (_rectYMinMax[var2] & 0xFF))) return 0; - var1h = _array109E9[indexs]; - var1l = _array10A11[indexs]; + var1h = _array109E9PosX[indexs]; + var1l = _array10A11PosY[indexs]; if ((var1h >= (_rectXMinMax[var2] >> 8)) && (var1h <= (_rectXMinMax[var2] & 0xFF)) && (var1l >= (_rectYMinMax[var2] >> 8)) && (var1l <= (_rectYMinMax[var2] & 0xFF))) return 0; @@ -1596,8 +1593,8 @@ void LilliputEngine::sub16A08(int index) { int _array16A00[4]; for (int i = 3; i >= 0; i--) { - byte var1h = (_word16937 >> 8) + _array169F8[i] - _array109E9[index]; - byte var1l = (_word16937 & 0xFF) + _array169FC[i] - _array10A11[index]; + byte var1h = (_word16937 >> 8) + _array169F8[i] - _array109E9PosX[index]; + byte var1l = (_word16937 & 0xFF) + _array169FC[i] - _array10A11PosY[index]; _array16A00[i] = (var1l * var1l) + (var1h * var1h); } _array1692B[0] = 0; @@ -1701,7 +1698,7 @@ void LilliputEngine::sub16626() { result = sub16722(index, var1); break; case 14: - result = sub166F7(index, var1, tmpVal); + result = sub166F7(index, Common::Point(var1 >> 8, var1 && 0xFF), tmpVal); break; case 15: result = sub166EA(index); @@ -1722,30 +1719,29 @@ void LilliputEngine::sub16626() { } byte LilliputEngine::sub166EA(int index) { - debugC(2, kDebugEngine, "sub166EA(%d, %d)", index); + debugC(2, kDebugEngine, "sub166EA(%d)", index); _scriptHandler->_array12811[index] = 0x10; _scriptHandler->_characterScriptEnabled[index] = 1; return 1; } -byte LilliputEngine::sub166F7(int index, int var1, int tmpVal) { - debugC(2, kDebugEngine, "sub166F7(%d, %d, %d)", index, var1, tmpVal); +byte LilliputEngine::sub166F7(int index, Common::Point var1, int tmpVal) { + debugC(2, kDebugEngine, "sub166F7(%d, %d - %d, %d)", index, var1.x, var1.y, tmpVal); - byte a1 = (var1 >> 8); - byte a2 = (var1 & 0xFF); + byte a2 = var1.y; if (a2 != 0) { if ((a2 & 0xF0) == 0) a2 |= (a2 << 4); a2 -= 16; - _scriptHandler->_array12311[tmpVal] = (a1 << 8) + a2; + _scriptHandler->_array12311[tmpVal] = (var1.x << 8) + var1.y; - if ((a2 & 0xF0) == 0) + if ((var1.y & 0xF0) == 0) return 2; } - _scriptHandler->_array12811[index] -= ((var1 >> 8) & 0x0F); + _scriptHandler->_array12811[index] -= (var1.x & 0x0F); return 3; } @@ -1768,25 +1764,25 @@ byte LilliputEngine::sub16729(int index) { debugC(2, kDebugEngine, "sub16729(%d)", index); int arg1 = index | 0xFF00; - int pos1 = (_scriptHandler->_array16123[index] << 8) | (_scriptHandler->_array1614B[index] & 0xFF); - int pos2 = (_scriptHandler->_viewportPos.x << 8) | (_scriptHandler->_viewportPos.y & 0xFF); + Common::Point pos1 = Common::Point(_scriptHandler->_array16123PosX[index], _scriptHandler->_array1614BPosY[index]); + Common::Point pos2 = _scriptHandler->_viewportPos; _soundHandler->contentFct2(); // TODO: add arg pos1 and pos2 return 2; } byte LilliputEngine::sub1675D(int index, int var1) { - debugC(2, kDebugEngine, "sub1675D(%d, %d)", index, var1); + debugC(2, kDebugEngine, "sub1675D(%d)", index); int var2 = _scriptHandler->_array10A39[index]; - int var1h = _scriptHandler->_array16123[var2]; - int var1l = _scriptHandler->_array1614B[var2]; - int var3 = _array109E9[index]; + int var1h = _scriptHandler->_array16123PosX[var2]; + int var1l = _scriptHandler->_array1614BPosY[var2]; + int var3 = _array109E9PosX[index]; if ((var3 != 0xFF) && (var3 == _array10999PosX[index])) { - var3 = _array10A11[index]; + var3 = _array10A11PosY[index]; if (var3 == _array109C1PosY[index]) { - _array109E9[index] = var1h; - _array10A11[index] = var1l; + _array109E9PosX[index] = var1h; + _array10A11PosY[index] = var1l; } } @@ -1802,7 +1798,7 @@ void LilliputEngine::sub16EBC() { int index2 = 3; for (int index1 = _numCharacters - 1; index1 >= 0; index1--) { - int var2 = (_scriptHandler->_array1614B[index1] << 8) + (_scriptHandler->_array16123[index1] << 2); + int var2 = (_scriptHandler->_array1614BPosY[index1] << 8) + (_scriptHandler->_array16123PosX[index1] << 2); int var1 = (_bufferIsoMap[index2 + var2] & 0x40); if (var1 == _array16E94[index1]) @@ -2121,7 +2117,7 @@ void LilliputEngine::sub16B8F(int index, int x, int y, int flag) { debugC(2, kDebugEngine, "sub16B8F(%d, %d, %d)", index, x, y); int diffX = x >> 3; - if (((diffX & 0xFF) == _scriptHandler->_array16123[index]) && ((y >> 3) == _scriptHandler->_array1614B[index])) { + if (((diffX & 0xFF) == _scriptHandler->_array16123PosX[index]) && ((y >> 3) == _scriptHandler->_array1614BPosY[index])) { _characterPositionX[index] = x; _characterPositionY[index] = y; } @@ -2129,7 +2125,7 @@ void LilliputEngine::sub16B8F(int index, int x, int y, int flag) { if ((x < 0) || (x >= 512) || (y < 0) || (y >= 512)) return; - int mapIndex = (_scriptHandler->_array1614B[index] << 6) + _scriptHandler->_array16123[index]; + int mapIndex = (_scriptHandler->_array1614BPosY[index] << 6) + _scriptHandler->_array16123PosX[index]; mapIndex <<= 2; if ((_bufferIsoMap[mapIndex + 3] & _array16C58[flag]) == 0) @@ -2509,12 +2505,14 @@ void LilliputEngine::loadRules() { // Chunk 12 _rulesChunk12_size = f.readUint16LE(); assert(_rulesChunk12_size <= 40); + uint16 tmpVal; for (int i = 0; i < _rulesChunk12_size; i++) { _rectXMinMax[i] = f.readUint16LE(); _rectYMinMax[i] = f.readUint16LE(); _rulesBuffer12_3[i] = f.readUint16LE(); - _rulesBuffer12_4[i] = f.readUint16LE(); + tmpVal = f.readUint16LE(); + _rulesBuffer12Pos[i] = Common::Point(tmpVal >> 8, tmpVal & 0xFF); } // Chunk 13 diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h index 0caf627f71..f2b38cad53 100644 --- a/engines/lilliput/lilliput.h +++ b/engines/lilliput/lilliput.h @@ -152,9 +152,9 @@ public: byte *_rulesChunk1; int _currentScriptCharacter; - int _characterPositionX[40]; - int _characterPositionY[40]; - byte _characterPositionAltitude[40]; + int16 _characterPositionX[40]; + int16 _characterPositionY[40]; + char _characterPositionAltitude[40]; int _characterFrameArray[40]; byte _rulesBuffer2_5[40]; byte _rulesBuffer2_6[40]; @@ -184,26 +184,26 @@ public: int *_rulesChunk10; byte *_rulesChunk11; int _rulesChunk12_size; - uint16 _rectXMinMax[40]; - uint16 _rectYMinMax[40]; + int16 _rectXMinMax[40]; + int16 _rectYMinMax[40]; int _rulesBuffer12_3[40]; - int _rulesBuffer12_4[40]; + Common::Point _rulesBuffer12Pos[40]; int _word12F68_ERULES; byte _rulesBuffer13_1[20]; int _interfaceHotspotsX[20]; int _interfaceHotspotsY[20]; byte _rulesBuffer13_4[20]; - byte _array10999PosX[40]; - byte _array109C1PosY[40]; + int16 _array10999PosX[40]; + int16 _array109C1PosY[40]; byte _array15AC8[256]; byte _charactersToDisplay[40]; - byte _characterRelativePositionX[40]; - byte _characterRelativePositionY[40]; - byte _characterDisplayX[40]; - byte _characterDisplayY[40]; + int16 _characterRelativePositionX[40]; + int16 _characterRelativePositionY[40]; + int16 _characterDisplayX[40]; + int16 _characterDisplayY[40]; byte _array12299[40]; - byte _array109E9[40]; - byte _array10A11[40]; + int16 _array109E9PosX[40]; + int16 _array10A11PosY[40]; byte _array16E94[40]; byte _array16C54[4]; byte _array16C58[4]; @@ -266,7 +266,7 @@ public: void renderCharacters(byte *buf, byte x, byte y); byte sub16799(int param1, int index); - int sub16B0C(Common::Point param1, Common::Point param2); + int getDirection(Common::Point param1, Common::Point param2); void addCharToBuf(byte character); void prepareGoldAmount(int param1); void sub12F37(); @@ -305,7 +305,7 @@ public: void sub16B8F(int index, int x, int y, int flag); byte sub1675D(int index, int var1); byte sub16729(int index); - byte sub166F7(int index, int var1, int tmpVal); + byte sub166F7(int index, Common::Point var1, int tmpVal); void sub1693A(int index); void initGame(const LilliputGameDescription *gd); diff --git a/engines/lilliput/script.cpp b/engines/lilliput/script.cpp index 7b267ab230..c38bc8f947 100644 --- a/engines/lilliput/script.cpp +++ b/engines/lilliput/script.cpp @@ -65,8 +65,8 @@ LilliputScript::LilliputScript(LilliputEngine *vm) : _vm(vm), _currScript(NULL) _array10AB1[i] = 0; _array12811[i] = 16; _array12839[i] = 0xFF; - _array16123[i] = 0; - _array1614B[i] = 0; + _array16123PosX[i] = 0; + _array1614BPosY[i] = 0; _array122C1[i] = 0; } @@ -307,7 +307,7 @@ void LilliputScript::handleOpcodeType2(int curWord) { OC_sub17BF2(); break; case 0x16: - OC_sub17ACC(); + OC_setCurrentScriptCharacterPos(); break; case 0x17: OC_resetByte16F04(); @@ -370,7 +370,7 @@ void LilliputScript::handleOpcodeType2(int curWord) { OC_sub17EC5(); break; case 0x2B: - OC_sub17EF4(); + OC_setCharacterDirectionTowardsPos(); break; case 0x2C: OC_sub17F08(); @@ -382,7 +382,7 @@ void LilliputScript::handleOpcodeType2(int curWord) { OC_sub17F68(); break; case 0x2F: - OC_getNextVal(); + OC_skipNextVal(); break; case 0x30: OC_sub17FD2(); @@ -629,7 +629,7 @@ static const OpCode opCodes2[] = { /* 0x13 */ { "OC_setByte18823", 2, kGetValue1, kImmediateValue, kNone, kNone, kNone }, /* 0x14 */ { "OC_callScript", 2, kImmediateValue, kGetValue1, kNone, kNone, kNone }, // run script /* 0x15 */ { "OC_sub17BF2", 2, kImmediateValue, kGetValue1, kNone, kNone, kNone }, // run script then stop -/* 0x16 */ { "OC_sub17ACC", 1, kgetPosFromScript, kNone, kNone, kNone, kNone }, +/* 0x16 */ { "OC_setCurrentScriptCharacterPos", 1, kgetPosFromScript, kNone, kNone, kNone, kNone }, /* 0x17 */ { "OC_resetByte16F04", 0, kNone, kNone, kNone, kNone, kNone }, /* 0x18 */ { "OC_sub17AE1", 1, kImmediateValue, kNone, kNone, kNone, kNone }, /* 0x19 */ { "OC_sub17AEE", 1, kImmediateValue, kNone, kNone, kNone, kNone }, @@ -650,11 +650,11 @@ static const OpCode opCodes2[] = { /* 0x28 */ { "OC_sub17E7E", 2, kImmediateValue, kImmediateValue, kNone, kNone, kNone }, /* 0x29 */ { "OC_sub17E99", 4, kImmediateValue, kImmediateValue, kImmediateValue, kImmediateValue, kNone }, /* 0x2a */ { "OC_sub17EC5", 4, kImmediateValue, kImmediateValue, kImmediateValue, kImmediateValue, kNone }, -/* 0x2b */ { "OC_sub17EF4", 1, kgetPosFromScript, kNone, kNone, kNone, kNone }, +/* 0x2b */ { "OC_setCharacterDirectionTowardsPos", 1, kgetPosFromScript, kNone, kNone, kNone, kNone }, /* 0x2c */ { "OC_sub17F08", 1, kGetValue1, kNone, kNone, kNone, kNone }, /* 0x2d */ { "OC_sub17F4F", 1, kGetValue1, kNone, kNone, kNone, kNone }, /* 0x2e */ { "OC_sub17F68", 0, kNone, kNone, kNone, kNone, kNone }, -/* 0x2f */ { "OC_getNextVal", 1, kImmediateValue, kNone, kNone, kNone, kNone }, +/* 0x2f */ { "OC_skipNextVal", 1, kImmediateValue, kNone, kNone, kNone, kNone }, /* 0x30 */ { "OC_sub17FD2", 1, kGetValue1, kNone, kNone, kNone, kNone }, /* 0x31 */ { "OC_sub17FDD", 1, kImmediateValue, kNone, kNone, kNone, kNone }, /* 0x32 */ { "OC_setByte10B29", 1, kGetValue1, kNone, kNone, kNone, kNone }, @@ -1386,8 +1386,8 @@ byte LilliputScript::OC_comparePos() { debugC(2, kDebugScript, "OC_comparePos()"); int index = getValue1(); - byte d1 = _array16123[index]; - byte d2 = _array1614B[index]; + byte d1 = _array16123PosX[index]; + byte d2 = _array1614BPosY[index]; Common::Point var1 = getPosFromScript(); if (var1 == Common::Point(d1, d2)) @@ -1559,7 +1559,7 @@ byte LilliputScript::OC_compareCoords_2() { debugC(1, kDebugScript, "OC_compareCoords_2()"); int index = getValue1(); - Common::Point var1 = Common::Point(_array16123[index], _array1614B[index]); + Common::Point var1 = Common::Point(_array16123PosX[index], _array1614BPosY[index]); uint16 var2 = _currScript->readUint16LE(); uint16 var3 = _vm->_rectXMinMax[var2]; uint16 var4 = _vm->_rectYMinMax[var2]; @@ -2274,8 +2274,8 @@ void LilliputScript::OC_sub17A8D() { if (tmpVal == _vm->_word10804) _viewportCharacterTarget = 0xFFFF; - _vm->_characterPositionX[tmpVal] = 0xFFFF; - _vm->_characterPositionY[tmpVal] = 0xFFFF; + _vm->_characterPositionX[tmpVal] = -1; + _vm->_characterPositionY[tmpVal] = -1; } void LilliputScript::OC_saveAndQuit() { @@ -2360,14 +2360,13 @@ void LilliputScript::OC_sub17BF2() { sub17B6C(0); } -// TODO: rename arrays -void LilliputScript::OC_sub17ACC() { - debugC(1, kDebugScript, "OC_sub17ACC()"); +void LilliputScript::OC_setCurrentScriptCharacterPos() { + debugC(1, kDebugScript, "OC_setCurrentScriptCharacterPos()"); - Common::Point var = getPosFromScript(); - _vm->_array10999PosX[_vm->_currentScriptCharacter] = var.x; - _vm->_array109C1PosY[_vm->_currentScriptCharacter] = var.y; - _vm->_array109E9[_vm->_currentScriptCharacter] = 0xFF; + Common::Point pos = getPosFromScript(); + _vm->_array10999PosX[_vm->_currentScriptCharacter] = pos.x; + _vm->_array109C1PosY[_vm->_currentScriptCharacter] = pos.y; + _vm->_array109E9PosX[_vm->_currentScriptCharacter] = -1; } void LilliputScript::OC_resetByte16F04() { @@ -2583,17 +2582,18 @@ void LilliputScript::OC_sub17EC5() { computeOperation(compBuf, oper, var3);*/ } -Common::Point LilliputScript::sub17285(int index) { +Common::Point LilliputScript::getCharacterTilePos(int index) { + debugC(2, kDebugScript, "getCharacterTilePos(%d)", index); + return Common::Point(_vm->_characterPositionX[index] >> 3, _vm->_characterPositionY[index] >> 3); } -// TODO rename to set direction -void LilliputScript::OC_sub17EF4() { - debugC(1, kDebugScript, "OC_sub17EF4()"); +void LilliputScript::OC_setCharacterDirectionTowardsPos() { + debugC(1, kDebugScript, "OC_setCharacterDirectionTowardsPos()"); Common::Point pos1 = getPosFromScript(); - Common::Point tilePos = sub17285(_vm->_currentScriptCharacter); - int dir = _vm->sub16B0C(tilePos, pos1); + Common::Point tilePos = getCharacterTilePos(_vm->_currentScriptCharacter); + int dir = _vm->getDirection(tilePos, pos1); _vm->_characterDirectionArray[_vm->_currentScriptCharacter] = dir; } @@ -2627,8 +2627,8 @@ void LilliputScript::OC_sub17F4F() { debugC(1, kDebugScript, "OC_sub17F4F()"); int var = getValue1(); - _array10A39[_vm->_currentScriptCharacter] = var; - _vm->_array109E9[_vm->_currentScriptCharacter] = 0xFF; + _array10A39[_vm->_currentScriptCharacter] = var & 0xFF; + _vm->_array109E9PosX[_vm->_currentScriptCharacter] = -1; } void LilliputScript::OC_sub17F68() { @@ -2643,7 +2643,7 @@ void LilliputScript::OC_sub17F68() { int cx = _byte17F60[_vm->_characterDirectionArray[_vm->_currentScriptCharacter]]; int cy = _byte17F64[_vm->_characterDirectionArray[_vm->_currentScriptCharacter]]; - Common::Point pos = sub17285(_vm->_currentScriptCharacter); + Common::Point pos = getCharacterTilePos(_vm->_currentScriptCharacter); int newPosX = pos.x + cx; int newPosY = pos.y + cy; @@ -2665,10 +2665,13 @@ void LilliputScript::OC_sub17F68() { _byte12A09 = 0; } -void LilliputScript::OC_getNextVal() { - debugC(1, kDebugScript, "OC_getNextVal()"); + +void LilliputScript::OC_skipNextVal() { + debugC(1, kDebugScript, "OC_skipNextVal()"); + _currScript->readUint16LE(); } + void LilliputScript::OC_sub17FD2() { debugC(1, kDebugScript, "OC_sub17FD2()"); @@ -3178,8 +3181,8 @@ void LilliputScript::OC_sub186E5_snd() { byte var4h = 0xFF; byte var4l = (index & 0xFF); - byte var3h = _array16123[index]; - byte var3l = _array1614B[index]; + byte var3h = _array16123PosX[index]; + byte var3l = _array1614BPosY[index]; byte var2h = (_viewportPos.x & 0xFF); byte var2l = (_viewportPos.y & 0xFF); int var1 = _currScript->readUint16LE(); diff --git a/engines/lilliput/script.h b/engines/lilliput/script.h index 00163121a8..2e62c1f9b5 100644 --- a/engines/lilliput/script.h +++ b/engines/lilliput/script.h @@ -61,8 +61,8 @@ public: byte _characterScriptEnabled[40]; byte _array122E9[20]; - byte _array16123[40]; - byte _array1614B[40]; + char _array16123PosX[40]; + char _array1614BPosY[40]; byte _array12811[40]; byte _array10AB1[40]; byte _array122FD[20]; @@ -136,7 +136,7 @@ private: void sub18B7C(int var1, int var3); void sub189B8(); void sub189F5(); - Common::Point sub17285(int index); + Common::Point getCharacterTilePos(int index); int sub18BB7(int index); int16 getValue1(); @@ -221,7 +221,7 @@ private: void OC_setByte18823(); void OC_callScript(); void OC_sub17BF2(); - void OC_sub17ACC(); + void OC_setCurrentScriptCharacterPos(); void OC_resetByte16F04(); void OC_sub17AE1(); void OC_sub17AEE(); @@ -242,11 +242,11 @@ private: void OC_changeCurrentCharacterSprite(); void OC_sub17E99(); void OC_sub17EC5(); - void OC_sub17EF4(); + void OC_setCharacterDirectionTowardsPos(); void OC_sub17F08(); void OC_sub17F4F(); void OC_sub17F68(); - void OC_getNextVal(); + void OC_skipNextVal(); void OC_sub17FD2(); void OC_sub17FDD(); void OC_setByte10B29(); |