diff options
Diffstat (limited to 'engines/hopkins')
-rw-r--r-- | engines/hopkins/script.cpp | 67 | ||||
-rw-r--r-- | engines/hopkins/talk.cpp | 26 |
2 files changed, 46 insertions, 47 deletions
diff --git a/engines/hopkins/script.cpp b/engines/hopkins/script.cpp index a4d768023a..cf4f296fff 100644 --- a/engines/hopkins/script.cpp +++ b/engines/hopkins/script.cpp @@ -2429,42 +2429,41 @@ int ScriptManager::handleGoto(const byte *dataP) { } int ScriptManager::handleIf(const byte *dataP, int a2) { - int v2; - int v3; - int v4; - int v6; - bool v7; int v20; - - v2 = a2; -LABEL_2: - v3 = v2; - do { - if (_vm->shouldQuit()) - return 0; // Exiting game - - ++v3; - v4 = checkOpcode(dataP + 20 * v3); - if (v3 > 400) - error("Control if failed"); - } while (v4 != 4); // EIF - v20 = v3; - v6 = v2; - v7 = false; + int v2 = a2; + bool loopFl; do { - if (_vm->shouldQuit()) - return 0; // Exiting game - - ++v6; - if (checkOpcode(dataP + 20 * v6) == 3) // IIF - v7 = true; - if (v6 > 400) - error("Control if failed "); - if (v7) { - v2 = v20; - goto LABEL_2; - } - } while (v20 != v6); + loopFl = false; + int v3 = v2; + int opcodeType; + do { + if (_vm->shouldQuit()) + return 0; // Exiting game + + ++v3; + opcodeType = checkOpcode(dataP + 20 * v3); + if (v3 > 400) + error("Control if failed"); + } while (opcodeType != 4); // EIF + v20 = v3; + int v6 = v2; + bool v7 = false; + do { + if (_vm->shouldQuit()) + return 0; // Exiting game + + ++v6; + if (checkOpcode(dataP + 20 * v6) == 3) // IIF + v7 = true; + if (v6 > 400) + error("Control if failed "); + if (v7) { + v2 = v20; + loopFl = true; + break; + } + } while (v20 != v6); + } while (loopFl); const byte *buf = dataP + 20 * a2; byte oper = buf[13]; diff --git a/engines/hopkins/talk.cpp b/engines/hopkins/talk.cpp index 29679fe547..12ad4d85f0 100644 --- a/engines/hopkins/talk.cpp +++ b/engines/hopkins/talk.cpp @@ -770,10 +770,10 @@ bool TalkManager::searchCharacterAnim(int idx, const byte *bufPerso, int animId, void TalkManager::REPONSE(int zone, int verb) { uint16 v7; byte *v8; - int v10; + int opcodeType; uint16 v11; int v12; - int v13; + int lastOpcodeResult; bool tagFound; bool v16; bool loopCond; @@ -836,29 +836,29 @@ LABEL_2: v7 = 0; } while (!loopCond); loopCond = false; - v13 = 1; + lastOpcodeResult = 1; do { - v10 = _vm->_scriptManager.handleOpcode(ptr + 20 * v13); + opcodeType = _vm->_scriptManager.handleOpcode(ptr + 20 * lastOpcodeResult); if (_vm->shouldQuit()) return; - if (v10 == 2) + if (opcodeType == 2) // GOTO - v13 = _vm->_scriptManager.handleGoto(ptr + 20 * v13); - else if (v10 == 3) + lastOpcodeResult = _vm->_scriptManager.handleGoto(ptr + 20 * lastOpcodeResult); + else if (opcodeType == 3) // IF - v13 = _vm->_scriptManager.handleIf(ptr, v13); + lastOpcodeResult = _vm->_scriptManager.handleIf(ptr, lastOpcodeResult); - if (v13 == -1) + if (lastOpcodeResult == -1) error("Invalid IFF function"); - if (v10 == 1 || v10 == 4) + if (opcodeType == 1 || opcodeType == 4) // Already handled opcode or END IF - ++v13; - else if (!v10 || v10 == 5) + ++lastOpcodeResult; + else if (!opcodeType || opcodeType == 5) // EXIT loopCond = true; - else if (v10 == 6) { + else if (opcodeType == 6) { // JUMP _vm->_globals.freeMemory(ptr); zoneObj = _vm->_objectsManager._jumpZone; |