diff options
author | Strangerke | 2012-04-30 10:48:21 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2018-03-28 17:36:57 +0200 |
commit | 7320966cd7b8f612424cb1fa2898e9fb7c79f934 (patch) | |
tree | 551027012fa0183cec3a718134fd64c0a6173a69 /engines/lilliput | |
parent | 70afb0b9c51877abd7006a6262d85afe0ad4c844 (diff) | |
download | scummvm-rg350-7320966cd7b8f612424cb1fa2898e9fb7c79f934.tar.gz scummvm-rg350-7320966cd7b8f612424cb1fa2898e9fb7c79f934.tar.bz2 scummvm-rg350-7320966cd7b8f612424cb1fa2898e9fb7c79f934.zip |
LILLIPUT: fix (?) a couple of things in 16626, implement several core functions
Diffstat (limited to 'engines/lilliput')
-rw-r--r-- | engines/lilliput/lilliput.cpp | 190 | ||||
-rw-r--r-- | engines/lilliput/lilliput.h | 17 |
2 files changed, 189 insertions, 18 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp index 58ce4eff65..53e3f24902 100644 --- a/engines/lilliput/lilliput.cpp +++ b/engines/lilliput/lilliput.cpp @@ -168,6 +168,11 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd) _saveFlag = false; _byte16F07_menuId = 0; + _array16C54[0] = _array16C54[3] = 1; + _array16C54[1] = _array16C54[2] = 2; + _array16C54[2] = _array16C54[1] = 4; + _array16C54[3] = _array16C54[0] = 8; + for (int i = 0; i < 3; i++) _array147D1[i] = 0; @@ -290,7 +295,6 @@ Common::Platform LilliputEngine::getPlatform() const { return _platform; } - void LilliputEngine::displayFunction18(int index, int x, int y, int flags) { debugC(2, kDebugEngine, "displayFunction18(%d, %d, %d, %d)", index, x, y, flags); @@ -1422,7 +1426,7 @@ void LilliputEngine::sub16626() { if (var2 == 16) break; - var2 = (2 * var2) + (index << 5); + var2 = (2 * (var2 & 0xFF)) + (index << 5); int var1 = _scriptHandler->_array12311[var2 / 2]; int tmpVal = var2; var2 = ((var1 >> 8) >> 3); @@ -1464,11 +1468,11 @@ void LilliputEngine::sub16626() { warning("result = sub_166EA"); break; default: - error("sub16626 - unexpected value %d", var2 / 2); + warning("sub16626 - unexpected value %d", var2 / 2); break; } - if (result & 1) { + if ((result & 1) == 0) { ++_scriptHandler->_array12811[index]; if (_scriptHandler->_array12811[index] == 16) _scriptHandler->_characterScriptEnabled[index] = 1; @@ -1680,41 +1684,40 @@ int LilliputEngine::sub16685(int idx, int var1) { int LilliputEngine::sub16675(int idx, int var1) { debugC(2, kDebugEngine, "sub16675(%d, %d)", idx, var1); - warning("sub16675(%d, %d)", idx, var1); int index = sub16685(idx, var1); switch (index) { case 0: break; case 1: - warning("sub_166B1"); + sub166B1(index); break; case 2: - warning("sub_166B6"); + sub166B6(index); break; case 3: - warning("sub_166BB"); + sub166BB(index); break; case 4: - warning("sub_16B63"); + sub16B63(index); break; case 5: - warning("sub_16B76"); + sub16B76(index); break; case 6: - warning("sub_166C0"); + sub166C0(index); break; case 7: - warning("sub_166C6"); + sub166C6(index); break; case 8: - warning("sub_166CC"); + sub166CC(index); break; case 9: - warning("sub_166D2"); + sub166D2(index); break; case 10: - warning("sub_166D8"); + sub166D8(index); break; default: warning("sub16675 - Unexpected value %d", index); @@ -1723,6 +1726,159 @@ int LilliputEngine::sub16675(int idx, int var1) { return 0; } +void LilliputEngine::sub16B63(int index) { + debugC(2, kDebugEngine, "sub16B63(%d)", index); + + static const byte nextFrame[4] = {1, 3, 0, 2}; + _rulesBuffer2_9[index] = nextFrame[_rulesBuffer2_9[index]]; +} + +void LilliputEngine::sub16B76(int index) { + debugC(2, kDebugEngine, "sub16B76(%d)", index); + + static const byte nextFrame[4] = {2, 0, 3, 1}; + _rulesBuffer2_9[index] = nextFrame[_rulesBuffer2_9[index]]; +} + +void LilliputEngine::sub166C0(int index) { + debugC(2, kDebugEngine, "sub166C0(%d)", index); + + _rulesBuffer2_3[index] += 1; +} + +void LilliputEngine::sub166C6(int index) { + debugC(2, kDebugEngine, "sub166C6(%d)", index); + + _rulesBuffer2_3[index] += 2; +} + +void LilliputEngine::sub166CC(int index) { + debugC(2, kDebugEngine, "sub166CC(%d)", index); + + _rulesBuffer2_3[index] -= 1; +} + +void LilliputEngine::sub166D2(int index) { + debugC(2, kDebugEngine, "sub166D2(%d)", index); + + _rulesBuffer2_3[index] -= 2; +} + +void LilliputEngine::sub166B1(int index) { + debugC(2, kDebugEngine, "sub166B1(%d)", index); + + sub16B31(index, 2); +} + +void LilliputEngine::sub166B6(int index) { + debugC(2, kDebugEngine, "sub166B6(%d)", index); + + sub16B31(index, 4); +} + +void LilliputEngine::sub166BB(int index) { + debugC(2, kDebugEngine, "sub166BB(%d)", index); + + sub16B31(index, 0xFE); +} + +void LilliputEngine::sub166D8(int index) { + debugC(2, kDebugEngine, "sub166D8(%d)", index); + + sub16B31(index, 3); +} + +void LilliputEngine::sub16B31(int index, int val) { + debugC(2, kDebugEngine, "sub16B31(%d, %d)", index, val); + + int newX = _characterPositionX[index]; + int newY = _characterPositionY[index]; + switch (_rulesBuffer2_9[index]) { + case 0: + newX += val; + break; + case 1: + newY -= val; + break; + case 2: + newY += val; + break; + default: + newX -= val; + break; + } + sub16B8F(index, newX, newY, _rulesBuffer2_9[index]); +} + +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])) { + _characterPositionX[index] = x; + _characterPositionY[index] = y; + } + + if ((x < 0) || (x >= 512) || (y < 0) || (y >= 512)) + return; + + int mapIndex = (_scriptHandler->_array1614B[index] << 6) + _scriptHandler->_array16123[index]; + mapIndex <<= 2; + + if ((_bufferIsoMap[mapIndex + 3] & _array16C58[flag]) == 0) + return; + + mapIndex = ((y & 0xFFF8) << 3) + diffX; + mapIndex <<= 2; + + if ((_bufferIsoMap[mapIndex + 3] & _array16C54[flag]) == 0) + return; + + int var1 = _rulesBuffer2_10[index]; + var1 &= 7; + var1 ^= 7; + + if ((var1 & _rulesChunk9[_bufferIsoMap[mapIndex]]) != 0) + return; + + _characterPositionX[index] = x; + _characterPositionY[index] = y; +} + +void LilliputEngine::sub17224(int var1, int var4) { + debugC(2, kDebugEngine, "sub17224(%d, %d)", var1, var4); + + byte type = (var1 >> 8); + if (type == 0) { + sub17264(var1, var4); + return; + } + + if (type == 3) { + for (int i = _numCharacters - 1; i >= 0; i--) + sub17264(i, var4); + return; + } + + int index = var4 & 0xFF; + for (int i = 0; i < _numCharacters; i++) { + if (_scriptHandler->_array10B51[index] >= type) + sub17264(i, var4); + index += 40; + } +} + +void LilliputEngine::sub17264(int index, int var4) { + debugC(2, kDebugEngine, "sub17264(%d, %d)", index, var4); + + if (_array11D49[index] != 0xFFFF) { + _array1289F[index] = var4; + } else { + _scriptHandler->_characterScriptEnabled[index] = 1; + _array11D49[index] = var4; + } +} + void LilliputEngine::sub171CF() { debugC(2, kDebugEngine, "sub171CF()"); @@ -1742,7 +1898,7 @@ void LilliputEngine::sub171CF() { int var4 = _array12861[(3 * i) + 2]; _array12861[(3 * i) + 1] = 0xFFFF; - warning("sub_17224"); + sub17224(var1, var4); } } } @@ -2197,7 +2353,7 @@ void LilliputEngine::handleGameScripts() { assert(tmpVal < _gameScriptIndexSize); debugC(1, kDebugEngine, "================= Game Script %d ==================", i); ScriptStream script = ScriptStream(&_arrayGameScripts[_arrayGameScriptIndex[i]], _arrayGameScriptIndex[i + 1] - _arrayGameScriptIndex[i]); - _scriptHandler->disasmScript(script); +// _scriptHandler->disasmScript(script); debugC(1, kDebugEngine, "============= End Game Script %d ==================", i); } diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h index 97828f298a..54f8423298 100644 --- a/engines/lilliput/lilliput.h +++ b/engines/lilliput/lilliput.h @@ -201,7 +201,8 @@ public: byte _array109E9[40]; byte _array10A11[40]; byte _array16E94[40]; - + byte _array16C54[4]; + byte _array16C58[4]; byte _buffer1_45k[45056]; byte _buffer2_45k[45056]; byte _buffer3_45k[45056]; @@ -246,6 +247,8 @@ public: void viewportScrollTo(int var1, int var3); void sub189DE(); void sub16626(); + void sub17224(int var1, int var4); + void sub17264(int index, int var4); void renderCharacters(byte *buf, int x, int y); int sub16799(int param1, int index); @@ -274,6 +277,18 @@ public: void sub15498(byte x, byte y, int var2); void sub15A4C(int &vgaIndex, byte *srcBuf, int &bufIndex); void sub15F31(bool &forceReturnFl); + void sub16B63(int index); + void sub16B76(int index); + void sub166C0(int index); + void sub166C6(int index); + void sub166CC(int index); + void sub166D2(int index); + void sub166B1(int index); + void sub166B6(int index); + void sub166BB(int index); + void sub166D8(int index); + void sub16B31(int index, int val); + void sub16B8F(int index, int x, int y, int flag); void initGame(const LilliputGameDescription *gd); byte *loadVGA(Common::String filename, bool loadPal); |