diff options
author | Strangerke | 2012-05-16 17:56:46 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2018-03-28 17:36:57 +0200 |
commit | 127f73a1ec0b04640be1ecc8df987233de4e6a19 (patch) | |
tree | 0afac0a20fcb60eef3c6ce0d83327898b16f7796 /engines | |
parent | 2d88b963a94cce11f94c1de1e37aebbb190b8a11 (diff) | |
download | scummvm-rg350-127f73a1ec0b04640be1ecc8df987233de4e6a19.tar.gz scummvm-rg350-127f73a1ec0b04640be1ecc8df987233de4e6a19.tar.bz2 scummvm-rg350-127f73a1ec0b04640be1ecc8df987233de4e6a19.zip |
LILLIPUT: Some renaming, implement 3 missing opcodes
Diffstat (limited to 'engines')
-rw-r--r-- | engines/lilliput/lilliput.cpp | 49 | ||||
-rw-r--r-- | engines/lilliput/lilliput.h | 1 | ||||
-rw-r--r-- | engines/lilliput/script.cpp | 54 | ||||
-rw-r--r-- | engines/lilliput/script.h | 2 |
4 files changed, 61 insertions, 45 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp index 26143e9812..48f0271212 100644 --- a/engines/lilliput/lilliput.cpp +++ b/engines/lilliput/lilliput.cpp @@ -132,7 +132,6 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd) _scriptHandler = new LilliputScript(this); _soundHandler = new LilliputSound(this); - _byte16939 = 0; _byte1714E = 0; _byte12FCE = 0; _byte129A0 = 0xFF; @@ -1510,38 +1509,39 @@ void LilliputEngine::sub167EF(int index) { void LilliputEngine::sub1693A(int index) { debugC(2, kDebugEngineTBC, "sub1693A(%d)", index); - static const int16 _array1692F[4] = {4, -256, 256, -4}; + static const int16 mapArrayMove[4] = {4, -256, 256, -4}; _word16937Pos = Common::Point(_scriptHandler->_array16123PosX[index], _scriptHandler->_array1614BPosY[index]); sub16A08(index); int var2 = (_characterDirectionArray[index] ^ 3); + // initialized by sub16A08, values: [0, 6[ _array1692B[var2] += 0xF8; - _byte16939 = 0; + byte byte16939 = 0; int mapIndex = ((((_word16937Pos.y << 8) >> 2) + _word16937Pos.x) << 2); - int subMapIndex = 0; + int mapIndexDiff = 0; int retVal = 0; for (int i = 3; i >= 0; i--) { - subMapIndex = _array1692F[i]; - if (((_bufferIsoMap[mapIndex + subMapIndex + 3] & _array16C54[i]) != 0) && ((_bufferIsoMap[mapIndex + 3] & _array16C58[i]) != 0)) { - if ((_bufferIsoMap[mapIndex + subMapIndex + 3] & 0x80) != 0) { + mapIndexDiff = mapArrayMove[i]; + if (((_bufferIsoMap[mapIndex + mapIndexDiff + 3] & _array16C54[i]) != 0) && ((_bufferIsoMap[mapIndex + 3] & _array16C58[i]) != 0)) { + if ((_bufferIsoMap[mapIndex + mapIndexDiff + 3] & 0x80) != 0) { if (sub16A76(i, index) != 0) _array1692B[i] += 0xEC; - + int tmpVal = ((_rulesBuffer2_10[index] & 7) ^ 7); - retVal = _rulesChunk9[_bufferIsoMap[mapIndex + subMapIndex]]; + retVal = _rulesChunk9[_bufferIsoMap[mapIndex + mapIndexDiff]]; tmpVal &= retVal; if (tmpVal == 0) continue; } } _array1692B[i] = 0x9E; - ++_byte16939; + ++byte16939; } - if (_byte16939 != 0) + if (byte16939 != 0) _array1692B[_characterDirectionArray[index]] += 3; int tmpVal = 0x9D; @@ -1609,29 +1609,30 @@ int LilliputEngine::reverseFindHotspot(Common::Point pos) { void LilliputEngine::sub16A08(int index) { debugC(2, kDebugEngineTBC, "sub16A08(%d)", index); - static const char _array169F8[4] = {1, 0, 0, -1}; - static const char _array169FC[4] = {0, -1, 1, 0}; + static const char arrayMoveX[4] = {1, 0, 0, -1}; + static const char arrayMoveY[4] = {0, -1, 1, 0}; - int _array16A00[4]; + int arrayDistance[4]; for (int i = 3; i >= 0; i--) { - int16 var1h = _word16937Pos.x + _array169F8[i] - _array109E9PosX[index]; - int16 var1l = _word16937Pos.y + _array169FC[i] - _array10A11PosY[index]; - _array16A00[i] = (var1l * var1l) + (var1h * var1h); + int16 var1h = _word16937Pos.x + arrayMoveX[i] - _array109E9PosX[index]; + int16 var1l = _word16937Pos.y + arrayMoveY[i] - _array10A11PosY[index]; + arrayDistance[i] = (var1l * var1l) + (var1h * var1h); } - _array1692B[0] = 0; - _array1692B[2] = 0; + + for (int i = 0; i < 4; i++) + _array1692B[i] = 0; + int8 tmpIndex = 0; for (int i = 6; i > 0; i--) { - int tmpVal = 0x7FFF; - int tmpIndex = 0; + int16 tmpVal = 0x7FFF; for (int j = 0; j < 4; j++) { - if (tmpVal > _array16A00[j]) { - tmpVal = _array16A00[j]; + if (tmpVal > arrayDistance[j]) { + tmpVal = arrayDistance[j]; tmpIndex = j; } } - _array16A00[tmpIndex] = 0x7FFF; + arrayDistance[tmpIndex] = 0x7FFF; _array1692B[tmpIndex] = i; } } diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h index 03b2365938..cc391871d6 100644 --- a/engines/lilliput/lilliput.h +++ b/engines/lilliput/lilliput.h @@ -112,7 +112,6 @@ public: byte _byte15EAD; byte _debugFlag; // Mostly useless, as the associated functions are empty byte _byte14837; // Unused byte, set by an opcode - byte _byte16939; byte _array147D1[3]; byte _array1692B[4]; diff --git a/engines/lilliput/script.cpp b/engines/lilliput/script.cpp index 85bb07f6e0..a41fde4d68 100644 --- a/engines/lilliput/script.cpp +++ b/engines/lilliput/script.cpp @@ -131,7 +131,7 @@ byte LilliputScript::handleOpcodeType1(int curWord) { return OC_CompareDistanceFromCharacterToPositionWith(); break; case 0xF: - return OC_sub1759E(); + return OC_compareRandomCharacterId(); break; case 0x10: return OC_IsCurrentCharacterIndex(); @@ -572,7 +572,7 @@ static const OpCode opCodes1[] = { { "OC_compareCoords_1", 1, kImmediateValue, kNone, kNone, kNone, kNone }, { "OC_compareCoords_2", 2, kGetValue1, kImmediateValue, kNone, kNone, kNone }, { "OC_CompareDistanceFromCharacterToPositionWith", 3, kgetPosFromScript, kCompareOperation, kImmediateValue, kNone, kNone }, - { "OC_sub1759E", 3, kGetValue1, kCompareOperation, kImmediateValue, kNone, kNone }, + { "OC_compareRandomCharacterId", 3, kGetValue1, kCompareOperation, kImmediateValue, kNone, kNone }, { "OC_IsCurrentCharacterIndex", 1, kGetValue1, kNone, kNone, kNone, kNone }, { "OC_sub175C8", 2, kImmediateValue, kGetValue1, kNone, kNone, kNone }, { "OC_sub17640", 2, kImmediateValue, kGetValue1, kNone, kNone, kNone }, @@ -1493,13 +1493,12 @@ byte LilliputScript::OC_checkSaveFlag() { } byte LilliputScript::OC_compByte16F04() { - warning("OC_compByte16F04"); + debugC(1, kDebugScriptTBC, "OC_compByte16F04()"); - byte var1 = _byte16F04; uint16 oper = _currScript->readUint16LE(); int16 var2 = _currScript->readUint16LE(); - return compareValues(var1, oper, var2); + return compareValues(_byte16F04, oper, var2); } byte LilliputScript::OC_sub174D8() { @@ -1577,6 +1576,7 @@ byte LilliputScript::OC_compareCoords_2() { byte LilliputScript::OC_CompareDistanceFromCharacterToPositionWith() { debugC(1, kDebugScriptTBC, "OC_CompareDistanceFromCharacterToPositionWith()"); + Common::Point var1 = getPosFromScript(); Common::Point pos = _vm->_currentScriptCharacterPos; @@ -1589,13 +1589,19 @@ byte LilliputScript::OC_CompareDistanceFromCharacterToPositionWith() { int dist = dx + dy; uint16 operation = _currScript->readUint16LE(); - int16 var2 = _currScript->readUint16LE(); + int16 var2 = _currScript->readSint16LE(); return compareValues(dist, operation, var2); } -byte LilliputScript::OC_sub1759E() { - warning("OC_sub1759E"); - return 0; +byte LilliputScript::OC_compareRandomCharacterId() { + debugC(1, kDebugScriptTBC, "OC_compareRandomCharacterId()"); + + byte *tmpArr = getCharacterVariablePtr(); + _byte16F02 = _vm->_rnd->getRandomNumber(tmpArr[0] + 1); + uint16 oper = _currScript->readUint16LE(); + int16 var2 = _currScript->readSint16LE(); + + return compareValues(_byte16F02, oper, var2); } byte LilliputScript::OC_IsCurrentCharacterIndex() { @@ -2309,7 +2315,15 @@ void LilliputScript::OC_sub17B93() { } void LilliputScript::OC_sub17E37_speech4() { - warning("OC_sub17E37_speech4"); + debugC(1, kDebugScriptTBC, "OC_sub17E37_speech4()"); + + bool forceReturnFl = false; + sub17D40(forceReturnFl); + if (forceReturnFl) + return; + + _talkingCharacter = _vm->_currentScriptCharacter; + sub18B3C(5); } void LilliputScript::OC_resetByte1714E() { @@ -2588,17 +2602,19 @@ void LilliputScript::OC_sub17E99() { } void LilliputScript::OC_sub17EC5() { - //debugC(1, kDebugScriptTBC, "OC_sub17EC5()"); - warning("OC_sub17EC5"); - /*byte *compBuf = sub173D2(); - int oper = _currScript->readUint16LE(); - int index = _currScript->readUint16LE(); + debugC(1, kDebugScriptTBC, "OC_sub17EC5()"); - byte *buf = sub173D2(); - byte var1 = buf[0]; - byte var3 = _vm->_rulesChunk11[var1 + _vm->_rulesChunk10[index]]; + int indexChunk10 = _currScript->readUint16LE(); + + byte *compBuf = sub173D2(); + int indexChunk11 = _vm->_rulesChunk10[indexChunk10] + compBuf[0]; - computeOperation(compBuf, oper, var3);*/ + int oper = _currScript->readUint16LE(); + + byte *tmpBuf = sub173D2(); + int var3 = tmpBuf[0]; + + computeOperation(&_vm->_rulesChunk11[indexChunk11], oper, var3); } Common::Point LilliputScript::getCharacterTilePos(int index) { diff --git a/engines/lilliput/script.h b/engines/lilliput/script.h index b93c26d68c..4f635461a2 100644 --- a/engines/lilliput/script.h +++ b/engines/lilliput/script.h @@ -161,7 +161,7 @@ private: byte OC_compareCoords_1(); byte OC_compareCoords_2(); byte OC_CompareDistanceFromCharacterToPositionWith(); - byte OC_sub1759E(); + byte OC_compareRandomCharacterId(); byte OC_IsCurrentCharacterIndex(); byte OC_sub175C8(); byte OC_sub17640(); |