diff options
author | Strangerke | 2012-05-06 10:04:09 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2018-03-28 17:36:57 +0200 |
commit | 98ac7cf0eb7dacfa8a63c6af6b4554f53d2cec9b (patch) | |
tree | 19501b4e306ca27659d2190c8a3817f9e8468e27 /engines | |
parent | 8aeedd1e50050f636f5f3f303b201f3cf57a3f3c (diff) | |
download | scummvm-rg350-98ac7cf0eb7dacfa8a63c6af6b4554f53d2cec9b.tar.gz scummvm-rg350-98ac7cf0eb7dacfa8a63c6af6b4554f53d2cec9b.tar.bz2 scummvm-rg350-98ac7cf0eb7dacfa8a63c6af6b4554f53d2cec9b.zip |
LILLIPUT: More renaming, fix bug in getMapPtr and sub168DA
Diffstat (limited to 'engines')
-rw-r--r-- | engines/lilliput/lilliput.cpp | 68 | ||||
-rw-r--r-- | engines/lilliput/lilliput.h | 10 | ||||
-rw-r--r-- | engines/lilliput/script.cpp | 75 | ||||
-rw-r--r-- | engines/lilliput/script.h | 8 |
4 files changed, 81 insertions, 80 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp index 8e239cda51..100aa02726 100644 --- a/engines/lilliput/lilliput.cpp +++ b/engines/lilliput/lilliput.cpp @@ -177,8 +177,8 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd) _array1692B[i] = 0; for (int i = 0; i < 40; i++) { - _array10999[i] = 0; - _array109C1[i] = 0; + _array10999PosX[i] = 0; + _array109C1PosY[i] = 0; _charactersToDisplay[i] = 0; _characterRelativePositionX[i] = 0xFF; _characterRelativePositionY[i] = 0xFF; @@ -1395,7 +1395,7 @@ byte LilliputEngine::sub16799(int index, int param1) { return 3; } - if ((var3h == _scriptHandler->_array12811[index]) && (var3l == _array109C1[index])) + if ((var3h == _scriptHandler->_array12811[index]) && (var3l == _array109C1PosY[index])) return 2; } @@ -1412,30 +1412,31 @@ byte LilliputEngine::sub16799(int index, int param1) { } +//TODO rename arrays void LilliputEngine::sub167EF(int index) { debugC(2, kDebugEngine, "sub167EF(%d)", index); - int word167EB = sub168DA(_scriptHandler->_array16123[index], _scriptHandler->_array1614B[index]); - int word167ED = sub168DA(_array10999[index], _array109C1[index]); + int word167EB = sub168DA(Common::Point(_scriptHandler->_array16123[index], _scriptHandler->_array1614B[index])); + int word167ED = sub168DA(Common::Point(_array10999PosX[index], _array109C1PosY[index])); if (word167EB == word167ED) { - _array109E9[index] = _array10999[index]; - _array10A11[index] = _array109C1[index]; + _array109E9[index] = _array10999PosX[index]; + _array10A11[index] = _array109C1PosY[index]; return; } if (word167EB = 0xFFFF) { - int tmpVal = sub16901(_array10999[index], _array109C1[index]); + int tmpVal = sub16901(_array10999PosX[index], _array109C1PosY[index]); _array109E9[index] = (_rulesBuffer12_4[tmpVal] >> 8); _array10A11[index] = (_rulesBuffer12_4[tmpVal] & 0xFF); return; } if ((word167ED != 0xFFFF) && - (_array10999[index] >= (_rulesBuffer12_1[word167EB] >> 8)) && - (_array10999[index] <= (_rulesBuffer12_1[word167EB] & 0xFF)) && - (_array109C1[index] >= (_rulesBuffer12_2[word167EB] >> 8)) && - (_array109C1[index] <= (_rulesBuffer12_2[word167EB] & 0xFF)) ) { + (_array10999PosX[index] >= (_rectXMinMax[word167EB] >> 8)) && + (_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); return; @@ -1443,8 +1444,8 @@ void LilliputEngine::sub167EF(int index) { _array109E9[index] = (_rulesBuffer12_4[word167EB] >> 8); _array10A11[index] = (_rulesBuffer12_4[word167EB] & 0xFF); - int var4h = (_rulesBuffer12_1[index] >> 8); - int var4l = (_rulesBuffer12_1[index] & 0xFF); + int var4h = (_rectXMinMax[index] >> 8); + int var4l = (_rectXMinMax[index] & 0xFF); if (var4h != var4l) { if (_array109E9[index] == var4h) { @@ -1457,8 +1458,8 @@ void LilliputEngine::sub167EF(int index) { return; } - int var4h = (_rulesBuffer12_2[index] >> 8); - int var4l = (_rulesBuffer12_2[index] & 0xFF); + int var4h = (_rectYMinMax[index] >> 8); + int var4l = (_rectYMinMax[index] & 0xFF); if (var4h != var4l) { if (_array10A11[index] == var4h) @@ -1534,16 +1535,17 @@ void LilliputEngine::sub1693A(int index) { _characterDirectionArray[index] = retVal; } +// TODO rename _word16937 byte LilliputEngine::sub16A76(int indexb, int indexs) { debugC(2, kDebugEngine, "sub16A76(%d, %d)", indexb, indexs); - static const byte _array16A6C[4] = {1, 0, 0, 0xFF}; - static const byte _array16A70[4] = {0, 0xFF, 1, 0}; + static const char _array16A6C[4] = {1, 0, 0, -1}; + static const char _array16A70[4] = {0, -1, 1, 0}; - byte var1h = (_word16937 >> 8) + _array16A6C[indexb]; - byte var1l = (_word16937 & 0xFF) + _array16A70[indexs]; + char var1h = (_word16937 >> 8) + _array16A6C[indexb]; + char var1l = (_word16937 & 0xFF) + _array16A70[indexs]; - int var2 = sub168DA(var1h, var1l); + int var2 = sub168DA(Common::Point(var1h, var1l)); if (var2 == 0xFFFF) return 1; @@ -1552,23 +1554,23 @@ byte LilliputEngine::sub16A76(int indexb, int indexs) { var1h = (_word16937 >> 8); var1l = (_word16937 & 0xFF); - if ((var1h >= (_rulesBuffer12_1[var2] >> 8)) && (var1h <= (_rulesBuffer12_1[var2] & 0xFF)) && (var1l >= (_rulesBuffer12_2[var2] >> 8)) && (var1l <= (_rulesBuffer12_2[var2] & 0xFF))) + 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]; - if ((var1h >= (_rulesBuffer12_1[var2] >> 8)) && (var1h <= (_rulesBuffer12_1[var2] & 0xFF)) && (var1l >= (_rulesBuffer12_2[var2] >> 8)) && (var1l <= (_rulesBuffer12_2[var2] & 0xFF))) + if ((var1h >= (_rectXMinMax[var2] >> 8)) && (var1h <= (_rectXMinMax[var2] & 0xFF)) && (var1l >= (_rectYMinMax[var2] >> 8)) && (var1l <= (_rectYMinMax[var2] & 0xFF))) return 0; return 1; } -uint16 LilliputEngine::sub168DA(byte var1h, byte var1l) { - debugC(2, kDebugEngine, "sub168DA(%d, %d)", var1h, var1l); +uint16 LilliputEngine::sub168DA(Common::Point pos) { + debugC(2, kDebugEngine, "sub168DA(%d, %d)", pos.x, pos.y); for (int i = 0; i < _rulesChunk12_size; i++) { - if ((var1h >= (_rulesBuffer12_1[i] >> 8)) && (var1h <= (_rulesBuffer12_1[i] & 0xFF)) && (var1h >= (_rulesBuffer12_2[i] >> 8)) && (var1h <= (_rulesBuffer12_2[i] & 0xFF))) + if ((pos.x >= (_rectXMinMax[i] >> 8)) && (pos.x <= (_rectXMinMax[i] & 0xFF)) && (pos.y >= (_rectYMinMax[i] >> 8)) && (pos.y <= (_rectYMinMax[i] & 0xFF))) return i; } return 0xFFFF; @@ -1578,7 +1580,7 @@ uint16 LilliputEngine::sub16901(byte var1h, byte var1l) { debugC(2, kDebugEngine, "sub16901(%d, %d)", var1h, var1l); for (int i = _rulesChunk12_size-1; i >= 0 ; i--) { - if ((var1h >= (_rulesBuffer12_1[i] >> 8)) && (var1h <= (_rulesBuffer12_1[i] & 0xFF)) && (var1h >= (_rulesBuffer12_2[i] >> 8)) && (var1h <= (_rulesBuffer12_2[i] & 0xFF))) + if ((var1h >= (_rectXMinMax[i] >> 8)) && (var1h <= (_rectXMinMax[i] & 0xFF)) && (var1h >= (_rectYMinMax[i] >> 8)) && (var1h <= (_rectYMinMax[i] & 0xFF))) return i; } return 0xFFFF; @@ -1780,16 +1782,16 @@ byte LilliputEngine::sub1675D(int index, int var1) { int var1l = _scriptHandler->_array1614B[var2]; int var3 = _array109E9[index]; - if ((var3 != 0xFF) && (var3 == _array10999[index])) { + if ((var3 != 0xFF) && (var3 == _array10999PosX[index])) { var3 = _array10A11[index]; - if (var3 == _array109C1[index]) { + if (var3 == _array109C1PosY[index]) { _array109E9[index] = var1h; _array10A11[index] = var1l; } } - _array10999[index] = var1h; - _array109C1[index] = var1l; + _array10999PosX[index] = var1h; + _array109C1PosY[index] = var1l; return sub16799(index, var1); } @@ -2509,8 +2511,8 @@ void LilliputEngine::loadRules() { assert(_rulesChunk12_size <= 40); for (int i = 0; i < _rulesChunk12_size; i++) { - _rulesBuffer12_1[i] = f.readUint16LE(); - _rulesBuffer12_2[i] = f.readUint16LE(); + _rectXMinMax[i] = f.readUint16LE(); + _rectYMinMax[i] = f.readUint16LE(); _rulesBuffer12_3[i] = f.readUint16LE(); _rulesBuffer12_4[i] = f.readUint16LE(); } diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h index 5d31ee498c..0caf627f71 100644 --- a/engines/lilliput/lilliput.h +++ b/engines/lilliput/lilliput.h @@ -184,8 +184,8 @@ public: int *_rulesChunk10; byte *_rulesChunk11; int _rulesChunk12_size; - int _rulesBuffer12_1[40]; - int _rulesBuffer12_2[40]; + uint16 _rectXMinMax[40]; + uint16 _rectYMinMax[40]; int _rulesBuffer12_3[40]; int _rulesBuffer12_4[40]; int _word12F68_ERULES; @@ -193,8 +193,8 @@ public: int _interfaceHotspotsX[20]; int _interfaceHotspotsY[20]; byte _rulesBuffer13_4[20]; - byte _array10999[40]; - byte _array109C1[40]; + byte _array10999PosX[40]; + byte _array109C1PosY[40]; byte _array15AC8[256]; byte _charactersToDisplay[40]; byte _characterRelativePositionX[40]; @@ -257,7 +257,7 @@ public: byte sub16A76(int indexb, int indexs); void sub17224(int var1, int var4); void sub17264(int index, int var4); - uint16 sub168DA(byte var1h, byte var1l); + uint16 sub168DA(Common::Point pos); uint16 sub16901(byte var1h, byte var1l); byte sub16722(int index, byte var1); byte sub166EA(int index); diff --git a/engines/lilliput/script.cpp b/engines/lilliput/script.cpp index b41a4457c2..7b267ab230 100644 --- a/engines/lilliput/script.cpp +++ b/engines/lilliput/script.cpp @@ -82,10 +82,10 @@ byte LilliputScript::handleOpcodeType1(int curWord) { debugC(2, kDebugScript, "handleOpcodeType1(0x%x)", curWord); switch (curWord) { case 0x0: - return OC_sub173DF(); + return OC_checkCharacterGoalPos(); break; case 0x1: - return OC_sub173F0(); + return OC_comparePos(); break; case 0x2: return OC_sub1740A(); @@ -178,10 +178,10 @@ byte LilliputScript::handleOpcodeType1(int curWord) { return OC_sub17886(); break; case 0x20: - return OC_sub178A8(); + return OC_CompareGameVariables(); break; case 0x21: - return OC_sub178BA(); + return OC_skipNextOpcode(); break; case 0x22: return OC_sub178C2(); @@ -552,11 +552,9 @@ void LilliputScript::handleOpcodeType2(int curWord) { } } - - static const OpCode opCodes1[] = { - { "OC_sub173DF", 1, kgetPosFromScript, kNone, kNone, kNone, kNone }, - { "OC_sub173F0", 2, kGetValue1, kgetPosFromScript, kNone, kNone, kNone }, + { "OC_checkCharacterGoalPos", 1, kgetPosFromScript, kNone, kNone, kNone, kNone }, + { "OC_comparePos", 2, kGetValue1, kgetPosFromScript, kNone, kNone, kNone }, { "OC_sub1740A", 1, kImmediateValue, kNone, kNone, kNone, kNone }, { "OC_sub17434", 4, kGetValue1, kImmediateValue, kCompareOperation, kImmediateValue, kNone }, { "OC_sub17468", 2, kCompareOperation, kImmediateValue, kNone, kNone, kNone }, @@ -587,8 +585,8 @@ static const OpCode opCodes1[] = { { "OC_sub17844", 1, kImmediateValue, kNone, kNone, kNone, kNone }, { "OC_sub1785C", 3, kImmediateValue, kCompareOperation, kImmediateValue, kNone, kNone }, { "OC_sub17886", 1, kgetPosFromScript, kNone, kNone, kNone, kNone }, - { "OC_sub178A8", 2, kGetValue1, kGetValue1, kNone, kNone, kNone }, - { "OC_sub178BA", 1, kImmediateValue, kNone, kNone, kNone, kNone }, + { "OC_CompareGameVariables", 2, kGetValue1, kGetValue1, kNone, kNone, kNone }, + { "OC_skipNextOpcode", 1, kImmediateValue, kNone, kNone, kNone, kNone }, { "OC_sub178C2", 0, kNone, kNone, kNone, kNone, kNone }, { "OC_sub178D2", 2, kGetValue1, kImmediateValue, kNone, kNone, kNone }, { "OC_sub178E8", 3, kGetValue1, kImmediateValue, kImmediateValue, kNone, kNone }, @@ -762,7 +760,7 @@ Common::String LilliputScript::getArgumentString(KValueType type, ScriptStream& break; } case 0xFA: - str = Common::String::format("(_array10999[currentCharacter], _array109C1[currentCharacter])"); + str = Common::String::format("(_array10999PosX[currentCharacter], _array109C1PosY[currentCharacter])"); break; case 0xF9: str = Common::String::format("(_currentCharacterVariables[4], _currentCharacterVariables[5])"); @@ -1330,7 +1328,7 @@ Common::Point LilliputScript::getPosFromScript() { return Common::Point(x, y); } case 0xFA: - return Common::Point(_vm->_array10999[_vm->_currentScriptCharacter], _vm->_array109C1[_vm->_currentScriptCharacter]); + return Common::Point(_vm->_array10999PosX[_vm->_currentScriptCharacter], _vm->_array109C1PosY[_vm->_currentScriptCharacter]); case 0xF9: return Common::Point(_vm->_currentCharacterVariables[4], _vm->_currentCharacterVariables[5]); case 0xF8: { @@ -1375,9 +1373,8 @@ byte *LilliputScript::getCharacterVariablePtr() { return _vm->getCharacterVariablesPtr(index); } -//TODO rename to "check script character pos" -byte LilliputScript::OC_sub173DF() { - debugC(2, kDebugScript, "OC_sub173F0()"); +byte LilliputScript::OC_checkCharacterGoalPos() { + debugC(2, kDebugScript, "OC_checkCharacterGoalPos()"); if (_vm->_currentScriptCharacterPos == getPosFromScript()) { return 1; @@ -1385,9 +1382,8 @@ byte LilliputScript::OC_sub173DF() { return 0; } -// TODO rename to "compare position" -byte LilliputScript::OC_sub173F0() { - debugC(2, kDebugScript, "OC_sub173F0()"); +byte LilliputScript::OC_comparePos() { + debugC(2, kDebugScript, "OC_comparePos()"); int index = getValue1(); byte d1 = _array16123[index]; @@ -1422,6 +1418,7 @@ byte LilliputScript::OC_sub1740A() { } } +// Compare field0 with value -> character id? byte LilliputScript::OC_sub17434() { debugC(1, kDebugScript, "OC_sub17434()"); @@ -1540,16 +1537,15 @@ byte LilliputScript::OC_sub1750E() { return compareValues(var1, operation, var2); } -// TODO Rename arrays to "x min/max" and "y min/max" -// TODO Rename function to "Check if point in rectangle" +// TODO Rename function to "Check if character pos in rectangle" byte LilliputScript::OC_compareCoords_1() { debugC(1, kDebugScript, "OC_compareCoords_1()"); int index = _currScript->readUint16LE(); assert(index < 40); - int var3 = _vm->_rulesBuffer12_1[index]; - int var4 = _vm->_rulesBuffer12_2[index]; + int var3 = _vm->_rectXMinMax[index]; + int var4 = _vm->_rectYMinMax[index]; Common::Point var1 = _vm->_currentScriptCharacterPos; if ((var1.x < (var3 >> 8)) || (var1.x > (var3 & 0xFF)) || (var1.y < (var4 >> 8)) || (var1.y > (var4 & 0xFF))) @@ -1558,18 +1554,21 @@ byte LilliputScript::OC_compareCoords_1() { return 1; } +// TODO Rename function to "Check if character pos in rectangle" byte LilliputScript::OC_compareCoords_2() { debugC(1, kDebugScript, "OC_compareCoords_2()"); - int var1 = getValue1(); - var1 = (_array16123[var1] << 8) + _array1614B[var1]; - int var2 = _currScript->readUint16LE(); - int var3 = _vm->_rulesBuffer12_1[var2]; - int var4 = _vm->_rulesBuffer12_2[var2]; - if (((var1 >> 8) < (var3 >> 8)) || ((var1 >> 8) > (var3 & 0xFF)) || ((var1 & 0xFF) < (var4 >> 8)) || ((var1 & 0xFF) > (var4 & 0xFF))) + int index = getValue1(); + Common::Point var1 = Common::Point(_array16123[index], _array1614B[index]); + uint16 var2 = _currScript->readUint16LE(); + uint16 var3 = _vm->_rectXMinMax[var2]; + uint16 var4 = _vm->_rectYMinMax[var2]; + + if ((var1.x < (var3 >> 8)) || (var1.x > (var3 & 0xFF)) || (var1.y < (var4 >> 8)) || (var1.y > (var4 & 0xFF))) return 0; return 1; } + byte LilliputScript::OC_sub1757C() { warning("OC_sub1757C"); return 0; @@ -1757,11 +1756,10 @@ byte LilliputScript::OC_sub17782() { return 0; } -//TODO verify "*320" byte *LilliputScript::getMapPtr(Common::Point val) { debugC(1, kDebugScript, "getMapPtr(%d %d)", val.x, val.y); - return &_vm->_bufferIsoMap[(val.y * 320 + val.x) << 2]; + return &_vm->_bufferIsoMap[(val.y * 64 + val.x) << 2]; } byte LilliputScript::OC_sub1779E() { @@ -1884,8 +1882,8 @@ byte LilliputScript::OC_sub17886() { return 0; } -byte LilliputScript::OC_sub178A8() { - debugC(1, kDebugScript, "OC_sub178A8()"); +byte LilliputScript::OC_CompareGameVariables() { + debugC(1, kDebugScript, "OC_CompareGameVariables()"); int var1 = getValue1(); int var2 = getValue1(); @@ -1894,7 +1892,9 @@ byte LilliputScript::OC_sub178A8() { return 0; } -byte LilliputScript::OC_sub178BA() { +byte LilliputScript::OC_skipNextOpcode() { + debugC(1, kDebugScript, "OC_skipNextOpcode()"); + _currScript->readUint16LE(); return 1; } @@ -2036,13 +2036,12 @@ byte LilliputScript::OC_sub179AE() { return 1; } -//TODO rename arrays byte LilliputScript::OC_sub179C2() { debugC(1, kDebugScript, "OC_sub179C2()"); Common::Point var1 = getPosFromScript(); - if ((_vm->_array10999[_vm->_currentScriptCharacter] == var1.x) - && (_vm->_array109C1[_vm->_currentScriptCharacter] == var1.y)) + if ((_vm->_array10999PosX[_vm->_currentScriptCharacter] == var1.x) + && (_vm->_array109C1PosY[_vm->_currentScriptCharacter] == var1.y)) return 1; return 0; @@ -2366,8 +2365,8 @@ void LilliputScript::OC_sub17ACC() { debugC(1, kDebugScript, "OC_sub17ACC()"); Common::Point var = getPosFromScript(); - _vm->_array10999[_vm->_currentScriptCharacter] = var.x; - _vm->_array109C1[_vm->_currentScriptCharacter] = var.y; + _vm->_array10999PosX[_vm->_currentScriptCharacter] = var.x; + _vm->_array109C1PosY[_vm->_currentScriptCharacter] = var.y; _vm->_array109E9[_vm->_currentScriptCharacter] = 0xFF; } diff --git a/engines/lilliput/script.h b/engines/lilliput/script.h index 480595bba6..00163121a8 100644 --- a/engines/lilliput/script.h +++ b/engines/lilliput/script.h @@ -147,8 +147,8 @@ private: void computeOperation(byte *bufPtr, int oper, int var2); //Opcodes Type 1 - byte OC_sub173DF(); - byte OC_sub173F0(); + byte OC_checkCharacterGoalPos(); + byte OC_comparePos(); byte OC_sub1740A(); byte OC_sub17434(); byte OC_sub17468(); @@ -179,8 +179,8 @@ private: byte OC_sub17844(); byte OC_sub1785C(); byte OC_sub17886(); - byte OC_sub178A8(); - byte OC_sub178BA(); + byte OC_CompareGameVariables(); + byte OC_skipNextOpcode(); byte OC_sub178C2(); byte OC_sub178D2(); byte OC_sub178E8(); |