aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2013-02-06 21:59:13 +0100
committerStrangerke2013-02-06 21:59:13 +0100
commitf35c410493e5af0751955fb8fbfefe4a44fe2f71 (patch)
tree463fe7eca9b3faa84ac069b25f44198eebcb589e
parent2e47d8fe7a1978078b2ccd54982401bb3add9f13 (diff)
downloadscummvm-rg350-f35c410493e5af0751955fb8fbfefe4a44fe2f71.tar.gz
scummvm-rg350-f35c410493e5af0751955fb8fbfefe4a44fe2f71.tar.bz2
scummvm-rg350-f35c410493e5af0751955fb8fbfefe4a44fe2f71.zip
HOPKINS: Remove the last GOTO from TalkManager
-rw-r--r--engines/hopkins/talk.cpp169
1 files changed, 87 insertions, 82 deletions
diff --git a/engines/hopkins/talk.cpp b/engines/hopkins/talk.cpp
index 12ad4d85f0..fea3bcc235 100644
--- a/engines/hopkins/talk.cpp
+++ b/engines/hopkins/talk.cpp
@@ -776,96 +776,101 @@ void TalkManager::REPONSE(int zone, int verb) {
int lastOpcodeResult;
bool tagFound;
bool v16;
- bool loopCond;
+ bool innerLoopCond;
byte *ptr;
byte zoneObj = zone;
byte verbObj = verb;
-LABEL_2:
- tagFound = false;
- if (_vm->_globals._answerBuffer == g_PTRNUL)
- return;
-
- byte *curAnswerBuf = _vm->_globals._answerBuffer;
- for (;;) {
- if (READ_BE_UINT24(curAnswerBuf) == MKTAG24('F', 'I', 'N'))
- return;
- if (READ_BE_UINT24(curAnswerBuf) == MKTAG24('C', 'O', 'D')) {
- if (curAnswerBuf[3] == zoneObj && curAnswerBuf[4] == verbObj)
- tagFound = true;
- }
- if (!tagFound)
- curAnswerBuf++;
- else
- break;
- }
-
- // 'COD' tag found
- curAnswerBuf += 5;
- ptr = _vm->_globals.allocMemory(620);
- assert(ptr != g_PTRNUL);
- memset(ptr, 0, 620);
- v7 = 0;
- v12 = 0;
- loopCond = false;
- do {
- v16 = false;
- if (READ_BE_UINT16(&curAnswerBuf[v7]) == MKTAG16('F', 'C')) {
- ++v12;
- assert(v12 < (620 / 20));
-
- v8 = (ptr + 20 * v12);
- v11 = 0;
- do {
- assert(v11 < 20);
- v8[v11++] = curAnswerBuf[v7++];
- if (READ_BE_UINT16(&curAnswerBuf[v7]) == MKTAG16('F', 'F')) {
- v16 = true;
- v8[v11] = 'F';
- v8[v11 + 1] = 'F';
- ++v7;
- }
- } while (!v16);
- }
- if (!v16) {
- uint32 signature24 = READ_BE_UINT24(&curAnswerBuf[v7]);
- if (signature24 == MKTAG24('C', 'O', 'D') || signature24 == MKTAG24('F', 'I', 'N'))
- loopCond = true;
- }
- curAnswerBuf += v7 + 1;
- v7 = 0;
- } while (!loopCond);
- loopCond = false;
- lastOpcodeResult = 1;
+
+ bool outerLoopFl;
do {
- opcodeType = _vm->_scriptManager.handleOpcode(ptr + 20 * lastOpcodeResult);
- if (_vm->shouldQuit())
+ outerLoopFl = false;
+ tagFound = false;
+ if (_vm->_globals._answerBuffer == g_PTRNUL)
return;
- if (opcodeType == 2)
- // GOTO
- lastOpcodeResult = _vm->_scriptManager.handleGoto(ptr + 20 * lastOpcodeResult);
- else if (opcodeType == 3)
- // IF
- lastOpcodeResult = _vm->_scriptManager.handleIf(ptr, lastOpcodeResult);
-
- if (lastOpcodeResult == -1)
- error("Invalid IFF function");
-
- if (opcodeType == 1 || opcodeType == 4)
- // Already handled opcode or END IF
- ++lastOpcodeResult;
- else if (!opcodeType || opcodeType == 5)
- // EXIT
- loopCond = true;
- else if (opcodeType == 6) {
- // JUMP
- _vm->_globals.freeMemory(ptr);
- zoneObj = _vm->_objectsManager._jumpZone;
- verbObj = _vm->_objectsManager._jumpVerb;
- goto LABEL_2;
+ byte *curAnswerBuf = _vm->_globals._answerBuffer;
+ for (;;) {
+ if (READ_BE_UINT24(curAnswerBuf) == MKTAG24('F', 'I', 'N'))
+ return;
+ if (READ_BE_UINT24(curAnswerBuf) == MKTAG24('C', 'O', 'D')) {
+ if (curAnswerBuf[3] == zoneObj && curAnswerBuf[4] == verbObj)
+ tagFound = true;
+ }
+ if (!tagFound)
+ curAnswerBuf++;
+ else
+ break;
}
- } while (!loopCond);
+
+ // 'COD' tag found
+ curAnswerBuf += 5;
+ ptr = _vm->_globals.allocMemory(620);
+ assert(ptr != g_PTRNUL);
+ memset(ptr, 0, 620);
+ v7 = 0;
+ v12 = 0;
+ innerLoopCond = false;
+ do {
+ v16 = false;
+ if (READ_BE_UINT16(&curAnswerBuf[v7]) == MKTAG16('F', 'C')) {
+ ++v12;
+ assert(v12 < (620 / 20));
+
+ v8 = (ptr + 20 * v12);
+ v11 = 0;
+ do {
+ assert(v11 < 20);
+ v8[v11++] = curAnswerBuf[v7++];
+ if (READ_BE_UINT16(&curAnswerBuf[v7]) == MKTAG16('F', 'F')) {
+ v16 = true;
+ v8[v11] = 'F';
+ v8[v11 + 1] = 'F';
+ ++v7;
+ }
+ } while (!v16);
+ }
+ if (!v16) {
+ uint32 signature24 = READ_BE_UINT24(&curAnswerBuf[v7]);
+ if (signature24 == MKTAG24('C', 'O', 'D') || signature24 == MKTAG24('F', 'I', 'N'))
+ innerLoopCond = true;
+ }
+ curAnswerBuf += v7 + 1;
+ v7 = 0;
+ } while (!innerLoopCond);
+ innerLoopCond = false;
+ lastOpcodeResult = 1;
+ do {
+ opcodeType = _vm->_scriptManager.handleOpcode(ptr + 20 * lastOpcodeResult);
+ if (_vm->shouldQuit())
+ return;
+
+ if (opcodeType == 2)
+ // GOTO
+ lastOpcodeResult = _vm->_scriptManager.handleGoto(ptr + 20 * lastOpcodeResult);
+ else if (opcodeType == 3)
+ // IF
+ lastOpcodeResult = _vm->_scriptManager.handleIf(ptr, lastOpcodeResult);
+
+ if (lastOpcodeResult == -1)
+ error("Invalid IFF function");
+
+ if (opcodeType == 1 || opcodeType == 4)
+ // Already handled opcode or END IF
+ ++lastOpcodeResult;
+ else if (!opcodeType || opcodeType == 5)
+ // EXIT
+ innerLoopCond = true;
+ else if (opcodeType == 6) {
+ // JUMP
+ _vm->_globals.freeMemory(ptr);
+ zoneObj = _vm->_objectsManager._jumpZone;
+ verbObj = _vm->_objectsManager._jumpVerb;
+ outerLoopFl = true;
+ break;
+ }
+ } while (!innerLoopCond);
+ } while (outerLoopFl);
_vm->_globals.freeMemory(ptr);
_vm->_globals._saveData->_data[svField2] = 0;
return;