diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/lilliput/lilliput.cpp | 244 | ||||
-rw-r--r-- | engines/lilliput/lilliput.h | 28 | ||||
-rw-r--r-- | engines/lilliput/script.cpp | 18 | ||||
-rw-r--r-- | engines/lilliput/script.h | 18 |
4 files changed, 285 insertions, 23 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp index b645c513df..06edcba19d 100644 --- a/engines/lilliput/lilliput.cpp +++ b/engines/lilliput/lilliput.cpp @@ -128,6 +128,9 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd) _byte1714E = 0; _byte12FCE = 0; _byte129A0 = 0xFF; + _byte160FA = 0; + _byte16529 = 0; + _byte1652A = 0; _rulesBuffer2PrevIndx = 0; _word16EFA = 0; @@ -138,14 +141,36 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd) _word15BC8 = 0; _word15BCA = 0; _word15AC2 = 0; + _word16213 = 0; + _word16215 = 0; _saveFlag = false; _byte16F07_menuId = 0; for (int i = 0; i < 40; i++) { - _byte10999[i] = 0; - _byte109C1[i] = 0; + _array10999[i] = 0; + _array109C1[i] = 0; + _array160FB[i] = 0; + _array16173[i] = 0xFF; + _array1619B[i] = 0xFF; + _array161C3[i] = 0; + _array161EB[i] = 0; + _array11D49[i] = 0xFFFF; + _rulesBuffer2_1[i] = 0xFFFF; + _rulesBuffer2_2[i] = 0xFFFF; + _rulesBuffer2_3[i] = 0; + _rulesBuffer2_4[i] = 0; + _rulesBuffer2_5[i] = 0xFF; + _rulesBuffer2_6[i] = 4; + _rulesBuffer2_7[i] = 0; + _rulesBuffer2_8[i] = 20; + _rulesBuffer2_9[i] = 0; + _rulesBuffer2_10[i] = 0; + _rulesBuffer2_11[i] = 0; + _rulesBuffer2_12[i] = 0; + _rulesBuffer2_13[i] = 0; + _rulesBuffer2_14[i] = 0; } for (int i = 0; i < 256; i++) @@ -187,6 +212,7 @@ Common::Platform LilliputEngine::getPlatform() const { return _platform; } +// display mouse cursor, if any void LilliputEngine::displayFunction1(byte *buf, int var1, int var2, int var4) { debugC(2, kDebugEngine, "displayFunction1(buf, %d, %d, %d)", var1, var2, var4); @@ -243,6 +269,7 @@ void LilliputEngine::displayFunction1a(byte *buf, int var2, int var4) { displayFunction1(buf, 0, var2, var4); } +// save area under mouse cursor void LilliputEngine::displayFunction2(byte *buf, int var2, int var4) { debugC(2, kDebugEngine, "displayFunction2(buf, %d, %d)", var2, var4); @@ -258,6 +285,7 @@ void LilliputEngine::displayFunction2(byte *buf, int var2, int var4) { } } +// display mouse cursor void LilliputEngine::displayFunction4() { debugC(2, kDebugEngine, "displayFunction4()"); @@ -287,6 +315,7 @@ void LilliputEngine::displayFunction5() { } } +// save game area void LilliputEngine::displayFunction6() { debugC(2, kDebugEngine, "displayFunction6()"); @@ -302,6 +331,60 @@ void LilliputEngine::displayFunction6() { displayFunction4(); } +// save speech zone +void LilliputEngine::displayFunction7() { + debugC(2, kDebugEngine, "displayFunction7()"); + + displayFunction5(); + + int index = 66; + for (int i = 0; i < 16; i++) { + for (int j = 0; j < 252; j++) + _buffer10_4032[(i * 252) + j] = ((byte *)_mainSurface->getPixels())[index + j]; + index += 320; + } + + displayFunction4(); +} + +void LilliputEngine::displayFunction8() { + debugC(2, kDebugEngine, "displayFunction8()"); + + if (_scriptHandler->_byte16F08 == 1) + return; + + displayFunction5(); + + int index = 0; + int tmpVal; + for (int i = 0; i < _word12F68_ERULES; i++) { + tmpVal = ((_scriptHandler->_array122E9[index] << 2) + (_scriptHandler->_array122E9[index] << 4)) & 0xFF; + displayFunction1(_bufferIdeogram, tmpVal + index, _rulesBuffer13_2[index], _rulesBuffer13_3[index]); + } + + displayFunction4(); +} + +void LilliputEngine::displayFunction9() { + debugC(2, kDebugEngine, "displayFunction9()"); + + memcpy(_buffer2_45k, _buffer3_45k, 45056); + + int var1 = (_scriptHandler->_word12A02 >> 8) + ((_scriptHandler->_word12A02 & 0xFF) << 8) + (_scriptHandler->_word12A00 << 2); + int var2; + int index = 0; + + for (int i = 0; i < 8; i++) { + for (int j = 0; j < 8 ; j++) { + var2 = (j << 8) + i; + displayFunction13(_buffer2_45k, _bufferIsoMap[var1 + index], var2, 0); + index += 4; + } + index += 224; + } + +} + void LilliputEngine::displayFunction12() { debugC(1, kDebugEngine, "displayFunction12()"); @@ -313,16 +396,163 @@ void LilliputEngine::displayFunction12() { _system->updateScreen(); displayFunction6(); - warning("Display function 7"); - warning("Display function 8"); - warning("Display function 9"); - warning("sub_1649F()"); - warning("sub_154C5()"); + displayFunction7(); + displayFunction8(); + displayFunction9(); + displayFunction15(); + displayFunction14(); displayFunction4(); free(tmpBuf); } +void LilliputEngine::displayFunction13(byte *buf, int var1, int var2, int var3) { + debugC(1, kDebugEngine, "displayFunction13(buf, %d, %d, %d)", var1, var2, var3); + + byte tmpByte1 = ((7 + (var2 >> 8) - (var2 & 0xFF)) << 4) & 0xFF; + byte tmpByte2 = ((4 + (var2 >> 8) + (var2 & 0xFF) - (var3 >>8) - (var3 & 0xFF)) << 3) & 0xFF; + + int index = (tmpByte2 << 8) + tmpByte1; + int index2 = tmpByte1 << 8; + + for (int i = 0; i < 32; i++) { + for (int j = 0; j < 32; j++) { + if (_bufferCubegfx[index2 + j] != 0) + buf[index] = _bufferCubegfx[index2 + j]; + } + index += 256; + } +} + +void LilliputEngine::displayFunction14() { + debugC(2, kDebugEngine, "displayFunction14()"); + + if (_scriptHandler->_byte16F08 == 1) + return; + + if (_mouseDisplayX > 48) + displayFunction5(); + + int index = (16 * 320) + 64; + for (int i = 0; i < 176; i++) { + for (int j = 0; j < 256; j++) + ((byte *)_mainSurface->getPixels())[index + j] = _buffer1_45k[(i * 256) + j]; + index += 320; + } + + _system->copyRectToScreen((byte *)_mainSurface->getPixels(), 320, 0, 0, 320, 200); + _system->updateScreen(); + + displayFunction4(); +}; + +void LilliputEngine::sub16217() { + debugC(2, kDebugEngine, "sub16217()"); + + _byte160FA = 0; + int index = _word10807_ERULES - 1; + _word16213 = _scriptHandler->_word12A00 << 3; + _word16215 = _scriptHandler->_word12A02 << 3; + + for (int i = index; i >= 0; i--) { + if (_rulesBuffer2_5[i] != 0xFF) { + int index2 = _rulesBuffer2_5[i]; + _rulesBuffer2_3[i] = _rulesBuffer2_3[index2] + _rulesBuffer2_7[i]; + int tmpVal = _rulesBuffer2_6[i]; + _rulesBuffer2_9[i] = _rulesBuffer2_9[index2]; + int var3 = _rulesBuffer2_1[index2]; + int var4 = _rulesBuffer2_2[index2]; + + switch (_rulesBuffer2_9[i]) { + case 0: + var3 -= tmpVal; + break; + case 1: + var4 += tmpVal; + break; + case 2: + var4 -= tmpVal; + break; + default: + var3 += tmpVal; + break; + } + + _rulesBuffer2_1[i] = var3; + _rulesBuffer2_2[i] = var4; + } + + _scriptHandler->_array16123[i] = (_rulesBuffer2_1[i] & 0xFF); + _scriptHandler->_array1614B[i] = (_rulesBuffer2_2[i] & 0xFF); + _scriptHandler->_array16173[i] = 0xFF; + _array1619B[i] = 0xFF; + _array161C3[i] = 0xFF; + _array161EB[i] = 0xFF; + + int tmpVal2 = _rulesBuffer2_1[i] - _scriptHandler->_word12A00; + int tmpVal3 = _rulesBuffer2_2[i] - _scriptHandler->_word12A02; + if ((tmpVal2 >= 0) && (tmpVal2 <= 7) && (tmpVal3 >= 0) && (tmpVal3 <= 7)) { + _array16173[i] = tmpVal2; + _array1619B[i] = tmpVal3; + tmpVal2 = _rulesBuffer2_1[i] - _word16213; + tmpVal3 = _rulesBuffer2_2[i] - _word16213; + int tmpVal4 = _rulesBuffer2_3[i]; + _array161C3[i] = ((60 + tmpVal2 - tmpVal3) * 2) & 0xFF; + _array161EB[i] = (20 + tmpVal2 + tmpVal3 - tmpVal4) & 0xFF; + _array160FB[_byte160FA] = i; + ++_byte160FA; + } + } +} + +void LilliputEngine::sub1652B(int var1) { + debugC(2, kDebugEngine, "sub1652B(%d)", var1); + + if (_byte160FA < (var1 & 0xFF)) { + int index = _array160FB[var1 & 0xFF]; + _byte16529 = _array16173[index]; + _byte1652A = _array1619B[index]; + } else { + _byte16529 = 0xFF; + _byte1652A = 0xFF; + } +} + +void LilliputEngine::displayFunction15() { + debugC(2, kDebugEngine, "displayFunction15()"); + + sub16217(); + _word16550 = 0; + sub1652B(0); + + memcpy(_buffer1_45k, _buffer2_45k, 45056); + + int index1 = (_scriptHandler->_word12A02 >> 8) + ((_scriptHandler->_word12A02 & 0xFF) << 8) + (_scriptHandler->_word12A00 << 2); + byte *map = &_bufferIsoMap[index1]; + + for (int i = 0; i < 8; i++) { + for (int j = 0; j < 8; j++) { + int tmpVal = (i << 8) + j; + if (map[1] != 0xFF) { + int var1 = map[1]; + if (_rulesChunk9[var1] != 128) + var1 += _scriptHandler->_byte12A04; + displayFunction13(_buffer1_45k, var1, tmpVal, 1 << 8); + } + warning("sub_16553"); + + if (map[2] != 0xFF) { + int var1 = map[1]; + if (_rulesChunk9[var1] != 128) + var1 += _scriptHandler->_byte12A04; + displayFunction13(_buffer1_45k, var1, tmpVal, 2 << 8); + } + map = &map[4]; + } + map = &map[224]; + } +} + void LilliputEngine::pollEvent() { debugC(2, kDebugEngine, "pollEvent()"); diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h index a677c1b311..88c8d9c008 100644 --- a/engines/lilliput/lilliput.h +++ b/engines/lilliput/lilliput.h @@ -84,6 +84,8 @@ public: struct18560 _arr18560[4]; byte _byte1714E; byte _byte184F4; + byte _byte16529; + byte _byte1652A; byte _sound_byte16F06; byte _byte16F09; byte _keyboard_nextIndex; @@ -112,6 +114,7 @@ public: int _word15BC8; int _word15BCA; int _word15AC2; + int _word16550; int _array11D49[40]; @@ -158,11 +161,19 @@ public: int _rulesBuffer13_2[20]; int _rulesBuffer13_3[20]; byte _rulesBuffer13_4[20]; - byte _byte10999[40]; - byte _byte109C1[40]; + byte _array10999[40]; + byte _array109C1[40]; byte _array15AC8[256]; - + byte _array160FB[40]; + byte _array16173[40]; + byte _array1619B[40]; + byte _array161C3[40]; + byte _array161EB[40]; + + byte _buffer1_45k[45056]; + byte _buffer2_45k[45056]; byte _buffer3_45k[45056]; + byte _buffer10_4032[4032]; const LilliputGameDescription *_gameDescription; uint32 getFeatures() const; @@ -174,7 +185,13 @@ public: void displayFunction4(); void displayFunction5(); void displayFunction6(); + void displayFunction7(); + void displayFunction8(); + void displayFunction9(); void displayFunction12(); + void displayFunction13(byte *buf, int var1, int var2, int var3); + void displayFunction14(); + void displayFunction15(); void initGame(const LilliputGameDescription *gd); byte *loadVGA(Common::String filename, bool loadPal); @@ -208,11 +225,16 @@ public: byte _byte16F07_menuId; byte _byte12FCE; byte _byte129A0; + byte _byte160FA; int _word10804; + int _word16213; + int _word16215; void pollEvent(); void sub170EE(int index); void sub130DD(); + void sub16217(); + void sub1652B(int var1); void handleGameScripts(); // Temporary stubs diff --git a/engines/lilliput/script.cpp b/engines/lilliput/script.cpp index 396bd41c07..8eccb2630a 100644 --- a/engines/lilliput/script.cpp +++ b/engines/lilliput/script.cpp @@ -848,7 +848,7 @@ int LilliputScript::getValue2() { return (var1 << 8) + var2; } case 0xFA: - return ((_vm->_byte10999[_vm->_rulesBuffer2PrevIndx] << 8) + _vm->_byte109C1[_vm->_rulesBuffer2PrevIndx]); + return ((_vm->_array10999[_vm->_rulesBuffer2PrevIndx] << 8) + _vm->_array109C1[_vm->_rulesBuffer2PrevIndx]); case 0xF9: return ((_vm->_rulesBuffer2_15[4] << 8) + _vm->_rulesBuffer2_15[5]); case 0xF8: { @@ -1615,8 +1615,7 @@ void LilliputScript::OC_sub18099() { _array122E9[index] = (curWord & 0xFF); _array122FD[index] = (curWord >> 8); - warning("TODO: display function #8"); - + _vm->displayFunction8(); } void LilliputScript::OC_sub180C3() { warning("OC_sub180C3"); @@ -1665,8 +1664,9 @@ void LilliputScript::OC_loadAndDisplayCUBESx_GFX() { _byte10806 = curWord + 0x30; _vm->_bufferCubegfx = _vm->loadVGA(fileName, false); - warning("Display function 9"); - warning("sub_1649F()"); + _vm->displayFunction9(); + _vm->displayFunction15(); + } void LilliputScript::OC_sub1834C() { @@ -1677,12 +1677,14 @@ void LilliputScript::OC_sub1834C() { _vm->_ptr_rulesBuffer2_15[3] = curWord; } + void LilliputScript::OC_sub18359() { warning("OC_sub18359"); } void LilliputScript::OC_sub18367() { warning("OC_sub18367"); } + void LilliputScript::OC_sub17D04() { debugC(1, kDebugScript, "OC_sub17D04()"); @@ -1716,8 +1718,10 @@ void LilliputScript::OC_sub17E22() { void LilliputScript::OC_sub1844A() { warning("OC_sub1844A"); } + void LilliputScript::OC_sub1847F() { debugC(1, kDebugScript, "OC_sub1847F()"); + byte *buf215Ptr = getBuffer215Ptr(); byte tmpVal = buf215Ptr[0]; int curWord = _currScript->readUint16LE(); @@ -1745,9 +1749,11 @@ void LilliputScript::OC_displayVGAFile() { _vm->displayVGAFile(fileName); warning("TODO: unkPaletteFunction_2"); } + void LilliputScript::OC_sub184D7() { warning("OC_sub184D7"); } + void LilliputScript::OC_displayTitleScreen() { debugC(1, kDebugScript, "OC_displayTitleScreen()"); @@ -1818,9 +1824,11 @@ void LilliputScript::OC_sub18678() { _word15FFB = _currScript->readUint16LE(); _word15FFD = _currScript->readUint16LE(); } + void LilliputScript::OC_sub18690() { warning("OC_sub18690"); } + void LilliputScript::OC_setWord10802() { debugC(1, kDebugScript, "OC_setWord10802()"); diff --git a/engines/lilliput/script.h b/engines/lilliput/script.h index 07a7233b85..2d605f3fa4 100644 --- a/engines/lilliput/script.h +++ b/engines/lilliput/script.h @@ -32,7 +32,17 @@ namespace Lilliput { class LilliputEngine; class LilliputScript { public: + byte _byte16F08; + byte _array10B29[40]; + byte _array122E9[20]; + byte _array16123[40]; + byte _array1614B[40]; + byte _array16173[40]; + + int _word12A00; + int _word12A02; + byte _byte12A04; LilliputScript(LilliputEngine *vm); ~LilliputScript(); @@ -47,9 +57,7 @@ private: byte _byte16F05_ScriptHandler; byte _byte12A09; - byte _byte12A04; byte _byte129A0; - byte _byte16F08; byte _byte15FFA; byte _byte1855D; byte _byte10806; @@ -57,15 +65,11 @@ private: byte _byte16F02; byte *_savedBuffer215Ptr; - byte _array122E9[20]; byte _array122FD[20]; byte _array128EF[40]; byte _array10AB1[40]; byte _array12811[40]; byte _array12839[40]; - byte _array16123[40]; - byte _array1614B[40]; - byte _array16173[40]; byte _array10B51[40 * 40]; int _array12311[640]; @@ -76,8 +80,6 @@ private: int _word10804; int _word15FFB; int _word15FFD; - int _word12A00; - int _word12A02; int _word1855E; int _word18776; |