diff options
Diffstat (limited to 'engines/gob')
-rw-r--r-- | engines/gob/global.cpp | 3 | ||||
-rw-r--r-- | engines/gob/global.h | 3 | ||||
-rw-r--r-- | engines/gob/inter.cpp | 4 | ||||
-rw-r--r-- | engines/gob/inter_v1.cpp | 28 | ||||
-rw-r--r-- | engines/gob/inter_v2.cpp | 72 | ||||
-rw-r--r-- | engines/gob/inter_v4.cpp | 2 | ||||
-rw-r--r-- | engines/gob/inter_v5.cpp | 2 | ||||
-rw-r--r-- | engines/gob/inter_v6.cpp | 20 | ||||
-rw-r--r-- | engines/gob/parse.cpp | 66 | ||||
-rw-r--r-- | engines/gob/parse.h | 3 |
10 files changed, 101 insertions, 102 deletions
diff --git a/engines/gob/global.cpp b/engines/gob/global.cpp index 005d65815f..cf0364b4fa 100644 --- a/engines/gob/global.cpp +++ b/engines/gob/global.cpp @@ -115,9 +115,6 @@ Global::Global(GobEngine *vm) : _vm(vm) { _debugFlag = 0; _inVM = 0; - _inter_resStr[0] = 0; - _inter_resVal = 0; - _inter_execPtr = 0; _inter_animDataSize = 10; diff --git a/engines/gob/global.h b/engines/gob/global.h index 9f12f4ded6..5819d6b1c3 100644 --- a/engines/gob/global.h +++ b/engines/gob/global.h @@ -117,9 +117,6 @@ public: int16 _debugFlag; int16 _inVM; - char _inter_resStr[200]; - int32 _inter_resVal; - byte *_inter_execPtr; int16 _inter_animDataSize; diff --git a/engines/gob/inter.cpp b/engines/gob/inter.cpp index 9000f74e8b..f9066f7dfe 100644 --- a/engines/gob/inter.cpp +++ b/engines/gob/inter.cpp @@ -100,7 +100,7 @@ char Inter::evalExpr(int16 *pRes) { switch (type) { case TYPE_IMM_INT16: - *pRes = _vm->_global->_inter_resVal; + *pRes = _vm->_parse->_inter_resVal; break; case TYPE_IMM_STR: @@ -123,7 +123,7 @@ bool Inter::evalBoolResult() { _vm->_parse->parseExpr(99, &type); if ( (type == GOB_TRUE) || - ((type == TYPE_IMM_INT16) && _vm->_global->_inter_resVal)) + ((type == TYPE_IMM_INT16) && _vm->_parse->_inter_resVal)) return true; else return false; diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp index 1df261d7ab..7571f6d10b 100644 --- a/engines/gob/inter_v1.cpp +++ b/engines/gob/inter_v1.cpp @@ -738,7 +738,7 @@ void Inter_v1::checkSwitchTable(byte **ppExec) { if (_terminate) return; - if (_vm->_global->_inter_resVal == value) { + if (_vm->_parse->_inter_resVal == value) { found = true; notFound = false; } @@ -1079,7 +1079,7 @@ void Inter_v1::o1_loadCurLayer() { void Inter_v1::o1_playCDTrack() { evalExpr(0); _vm->_sound->adlibPlayBgMusic(); // Mac version - _vm->_sound->cdPlay(_vm->_global->_inter_resStr); // PC CD version + _vm->_sound->cdPlay(_vm->_parse->_inter_resStr); // PC CD version } void Inter_v1::o1_getCDTrackPos() { @@ -1332,7 +1332,7 @@ bool Inter_v1::o1_assign(OpFuncParams ¶ms) { switch (destType) { case TYPE_VAR_INT32: case TYPE_ARRAY_INT32: - WRITE_VAR_OFFSET(dest, _vm->_global->_inter_resVal); + WRITE_VAR_OFFSET(dest, _vm->_parse->_inter_resVal); break; case TYPE_VAR_STR: @@ -1340,7 +1340,7 @@ bool Inter_v1::o1_assign(OpFuncParams ¶ms) { if (srcType == TYPE_IMM_INT16) WRITE_VARO_UINT8(dest, result); else - WRITE_VARO_STR(dest, _vm->_global->_inter_resStr); + WRITE_VARO_STR(dest, _vm->_parse->_inter_resStr); break; } @@ -1425,7 +1425,7 @@ bool Inter_v1::o1_loadTot(OpFuncParams ¶ms) { if ((*_vm->_global->_inter_execPtr & 0x80) != 0) { _vm->_global->_inter_execPtr++; evalExpr(0); - strncpy0(buf, _vm->_global->_inter_resStr, 15); + strncpy0(buf, _vm->_parse->_inter_resStr, 15); } else { size = (int8) *_vm->_global->_inter_execPtr++; for (int i = 0; i < size; i++) @@ -2067,13 +2067,13 @@ bool Inter_v1::o1_checkData(OpFuncParams ¶ms) { evalExpr(0); varOff = _vm->_parse->parseVarIndex(); - handle = _vm->_dataIO->openData(_vm->_global->_inter_resStr); + handle = _vm->_dataIO->openData(_vm->_parse->_inter_resStr); WRITE_VAR_OFFSET(varOff, handle); if (handle >= 0) _vm->_dataIO->closeData(handle); else - warning("File \"%s\" not found", _vm->_global->_inter_resStr); + warning("File \"%s\" not found", _vm->_parse->_inter_resStr); return false; } @@ -2094,7 +2094,7 @@ bool Inter_v1::o1_insertStr(OpFuncParams ¶ms) { pos = _vm->_parse->parseValExpr(); char *str = GET_VARO_FSTR(strVar); - _vm->_util->insertStr(_vm->_global->_inter_resStr, str, pos); + _vm->_util->insertStr(_vm->_parse->_inter_resStr, str, pos); return false; } @@ -2119,7 +2119,7 @@ bool Inter_v1::o1_strstr(OpFuncParams ¶ms) { evalExpr(0); resVar = _vm->_parse->parseVarIndex(); - char *res = strstr(GET_VARO_STR(strVar), _vm->_global->_inter_resStr); + char *res = strstr(GET_VARO_STR(strVar), _vm->_parse->_inter_resStr); pos = res ? (res - (GET_VARO_STR(strVar))) : -1; WRITE_VAR_OFFSET(resVar, pos); return false; @@ -2185,7 +2185,7 @@ bool Inter_v1::o1_loadFont(OpFuncParams ¶ms) { _vm->_dataIO->closeData(_vm->_game->_extHandle); _vm->_draw->_fonts[index] = - _vm->_util->loadFont(_vm->_global->_inter_resStr); + _vm->_util->loadFont(_vm->_parse->_inter_resStr); if (_vm->_game->_extHandle >= 0) _vm->_game->_extHandle = _vm->_dataIO->openData(_vm->_game->_curExtFile); @@ -2218,7 +2218,7 @@ bool Inter_v1::o1_readData(OpFuncParams ¶ms) { _vm->_dataIO->closeData(_vm->_game->_extHandle); WRITE_VAR(1, 1); - handle = _vm->_dataIO->openData(_vm->_global->_inter_resStr); + handle = _vm->_dataIO->openData(_vm->_parse->_inter_resStr); if (handle >= 0) { DataStream *stream = _vm->_dataIO->openAsStream(handle, true); @@ -2258,7 +2258,7 @@ bool Inter_v1::o1_writeData(OpFuncParams ¶ms) { size = _vm->_parse->parseValExpr(); offset = _vm->_parse->parseValExpr(); - warning("Attempted to write to file \"%s\"", _vm->_global->_inter_resStr); + warning("Attempted to write to file \"%s\"", _vm->_parse->_inter_resStr); WRITE_VAR(1, 0); return false; @@ -2267,8 +2267,8 @@ bool Inter_v1::o1_writeData(OpFuncParams ¶ms) { bool Inter_v1::o1_manageDataFile(OpFuncParams ¶ms) { evalExpr(0); - if (_vm->_global->_inter_resStr[0] != 0) - _vm->_dataIO->openDataFile(_vm->_global->_inter_resStr); + if (_vm->_parse->_inter_resStr[0] != 0) + _vm->_dataIO->openDataFile(_vm->_parse->_inter_resStr); else _vm->_dataIO->closeDataFile(); return false; diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index e92d6ce077..293d014065 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -760,7 +760,7 @@ void Inter_v2::checkSwitchTable(byte **ppExec) { default: if (!found) { evalExpr(0); - if (value == _vm->_global->_inter_resVal) + if (value == _vm->_parse->_inter_resVal) found = true; } else _vm->_parse->skipExpr(99); @@ -1058,7 +1058,7 @@ void Inter_v2::o2_playCDTrack() { _vm->_draw->blitInvalidated(); evalExpr(0); - _vm->_sound->cdPlay(_vm->_global->_inter_resStr); + _vm->_sound->cdPlay(_vm->_parse->_inter_resStr); } void Inter_v2::o2_waitCDTrackEnd() { @@ -1076,7 +1076,7 @@ void Inter_v2::o2_readLIC() { char path[40]; evalExpr(0); - strncpy0(path, _vm->_global->_inter_resStr, 35); + strncpy0(path, _vm->_parse->_inter_resStr, 35); strcat(path, ".LIC"); _vm->_sound->cdLoadLIC(path); @@ -1124,7 +1124,7 @@ void Inter_v2::o2_totSub() { if (length & 0x80) { evalExpr(0); - strcpy(totFile, _vm->_global->_inter_resStr); + strcpy(totFile, _vm->_parse->_inter_resStr); } else { for (i = 0; i < length; i++) totFile[i] = (char) *_vm->_global->_inter_execPtr++; @@ -1168,9 +1168,9 @@ void Inter_v2::o2_pushVars() { } else { if (evalExpr(&varOff) != 20) - _vm->_global->_inter_resVal = 0; + _vm->_parse->_inter_resVal = 0; - memcpy(_varStack + _varStackPos, &_vm->_global->_inter_resVal, 4); + memcpy(_varStack + _varStackPos, &_vm->_parse->_inter_resVal, 4); _varStackPos += 4; _varStack[_varStackPos] = 4; } @@ -1507,8 +1507,8 @@ void Inter_v2::o2_playImd() { bool close; evalExpr(0); - _vm->_global->_inter_resStr[8] = 0; - strncpy0(imd, _vm->_global->_inter_resStr, 127); + _vm->_parse->_inter_resStr[8] = 0; + strncpy0(imd, _vm->_parse->_inter_resStr, 127); x = _vm->_parse->parseValExpr(); y = _vm->_parse->parseValExpr(); @@ -1521,7 +1521,7 @@ void Inter_v2::o2_playImd() { palCmd = 1 << (flags & 0x3F); debugC(1, kDebugVideo, "Playing video \"%s\" @ %d+%d, frames %d - %d, " - "paletteCmd %d (%d - %d), flags %X", _vm->_global->_inter_resStr, x, y, + "paletteCmd %d (%d - %d), flags %X", _vm->_parse->_inter_resStr, x, y, startFrame, lastFrame, palCmd, palStart, palEnd, flags); if ((imd[0] != 0) && !_vm->_vidPlayer->primaryOpen(imd, x, y, flags)) { @@ -1560,10 +1560,10 @@ void Inter_v2::o2_getImdInfo() { // WORKAROUND: The nut rolling animation in the administration center // in Woodruff is called "noixroul", but the scripts think it's "noixroule". if ((_vm->getGameType() == kGameTypeWoodruff) && - (!scumm_stricmp(_vm->_global->_inter_resStr, "noixroule"))) - strcpy(_vm->_global->_inter_resStr, "noixroul"); + (!scumm_stricmp(_vm->_parse->_inter_resStr, "noixroule"))) + strcpy(_vm->_parse->_inter_resStr, "noixroul"); - _vm->_vidPlayer->writeVideoInfo(_vm->_global->_inter_resStr, varX, varY, + _vm->_vidPlayer->writeVideoInfo(_vm->_parse->_inter_resStr, varX, varY, varFrames, varWidth, varHeight); } @@ -1571,7 +1571,7 @@ void Inter_v2::o2_openItk() { char fileName[32]; evalExpr(0); - strncpy0(fileName, _vm->_global->_inter_resStr, 27); + strncpy0(fileName, _vm->_parse->_inter_resStr, 27); if (!strchr(fileName, '.')) strcat(fileName, ".ITK"); @@ -1606,21 +1606,21 @@ bool Inter_v2::o2_assign(OpFuncParams ¶ms) { switch (destType) { case TYPE_VAR_INT8: case TYPE_ARRAY_INT8: - WRITE_VARO_UINT8(dest + i, _vm->_global->_inter_resVal); + WRITE_VARO_UINT8(dest + i, _vm->_parse->_inter_resVal); break; case TYPE_VAR_INT16: case TYPE_ARRAY_INT16: - WRITE_VARO_UINT16(dest + i * 2, _vm->_global->_inter_resVal); + WRITE_VARO_UINT16(dest + i * 2, _vm->_parse->_inter_resVal); break; case TYPE_VAR_INT32: case TYPE_ARRAY_INT32: - WRITE_VAR_OFFSET(dest + i * 4, _vm->_global->_inter_resVal); + WRITE_VAR_OFFSET(dest + i * 4, _vm->_parse->_inter_resVal); break; case TYPE_VAR_INT32_AS_INT16: - WRITE_VARO_UINT16(dest + i * 4, _vm->_global->_inter_resVal); + WRITE_VARO_UINT16(dest + i * 4, _vm->_parse->_inter_resVal); break; case TYPE_VAR_STR: @@ -1628,7 +1628,7 @@ bool Inter_v2::o2_assign(OpFuncParams ¶ms) { if (srcType == TYPE_IMM_INT16) WRITE_VARO_UINT8(dest, result); else - WRITE_VARO_STR(dest, _vm->_global->_inter_resStr); + WRITE_VARO_STR(dest, _vm->_parse->_inter_resStr); break; } } @@ -1858,17 +1858,17 @@ bool Inter_v2::o2_checkData(OpFuncParams ¶ms) { size = -1; handle = 1; - mode = _vm->_saveLoad->getSaveMode(_vm->_global->_inter_resStr); + mode = _vm->_saveLoad->getSaveMode(_vm->_parse->_inter_resStr); if (mode == SaveLoad::kSaveModeNone) { - handle = _vm->_dataIO->openData(_vm->_global->_inter_resStr); + handle = _vm->_dataIO->openData(_vm->_parse->_inter_resStr); if (handle >= 0) { _vm->_dataIO->closeData(handle); - size = _vm->_dataIO->getDataSize(_vm->_global->_inter_resStr); + size = _vm->_dataIO->getDataSize(_vm->_parse->_inter_resStr); } else - warning("File \"%s\" not found", _vm->_global->_inter_resStr); + warning("File \"%s\" not found", _vm->_parse->_inter_resStr); } else if (mode == SaveLoad::kSaveModeSave) - size = _vm->_saveLoad->getSize(_vm->_global->_inter_resStr); + size = _vm->_saveLoad->getSize(_vm->_parse->_inter_resStr); else if (mode == SaveLoad::kSaveModeExists) size = 23; @@ -1876,7 +1876,7 @@ bool Inter_v2::o2_checkData(OpFuncParams ¶ms) { handle = -1; debugC(2, kDebugFileIO, "Requested size of file \"%s\": %d", - _vm->_global->_inter_resStr, size); + _vm->_parse->_inter_resStr, size); WRITE_VAR_OFFSET(varOff, handle); WRITE_VAR(16, (uint32) size); @@ -1897,16 +1897,16 @@ bool Inter_v2::o2_readData(OpFuncParams ¶ms) { dataVar = _vm->_parse->parseVarIndex(); size = _vm->_parse->parseValExpr(); evalExpr(0); - offset = _vm->_global->_inter_resVal; + offset = _vm->_parse->_inter_resVal; retSize = 0; debugC(2, kDebugFileIO, "Read from file \"%s\" (%d, %d bytes at %d)", - _vm->_global->_inter_resStr, dataVar, size, offset); + _vm->_parse->_inter_resStr, dataVar, size, offset); - mode = _vm->_saveLoad->getSaveMode(_vm->_global->_inter_resStr); + mode = _vm->_saveLoad->getSaveMode(_vm->_parse->_inter_resStr); if (mode == SaveLoad::kSaveModeSave) { WRITE_VAR(1, 1); - if (_vm->_saveLoad->load(_vm->_global->_inter_resStr, dataVar, size, offset)) + if (_vm->_saveLoad->load(_vm->_parse->_inter_resStr, dataVar, size, offset)) WRITE_VAR(1, 0); return false; } else if (mode == SaveLoad::kSaveModeIgnore) @@ -1914,7 +1914,7 @@ bool Inter_v2::o2_readData(OpFuncParams ¶ms) { if (size < 0) { warning("Attempted to read a raw sprite from file \"%s\"", - _vm->_global->_inter_resStr); + _vm->_parse->_inter_resStr); return false ; } else if (size == 0) { dataVar = 0; @@ -1923,13 +1923,13 @@ bool Inter_v2::o2_readData(OpFuncParams ¶ms) { buf = _variables->getAddressOff8(dataVar); - if (_vm->_global->_inter_resStr[0] == 0) { + if (_vm->_parse->_inter_resStr[0] == 0) { WRITE_VAR(1, size); return false; } WRITE_VAR(1, 1); - handle = _vm->_dataIO->openData(_vm->_global->_inter_resStr); + handle = _vm->_dataIO->openData(_vm->_parse->_inter_resStr); if (handle < 0) return false; @@ -1968,19 +1968,19 @@ bool Inter_v2::o2_writeData(OpFuncParams ¶ms) { dataVar = _vm->_parse->parseVarIndex(); size = _vm->_parse->parseValExpr(); evalExpr(0); - offset = _vm->_global->_inter_resVal; + offset = _vm->_parse->_inter_resVal; debugC(2, kDebugFileIO, "Write to file \"%s\" (%d, %d bytes at %d)", - _vm->_global->_inter_resStr, dataVar, size, offset); + _vm->_parse->_inter_resStr, dataVar, size, offset); WRITE_VAR(1, 1); - mode = _vm->_saveLoad->getSaveMode(_vm->_global->_inter_resStr); + mode = _vm->_saveLoad->getSaveMode(_vm->_parse->_inter_resStr); if (mode == SaveLoad::kSaveModeSave) { - if (_vm->_saveLoad->save(_vm->_global->_inter_resStr, dataVar, size, offset)) + if (_vm->_saveLoad->save(_vm->_parse->_inter_resStr, dataVar, size, offset)) WRITE_VAR(1, 0); } else if (mode == SaveLoad::kSaveModeNone) - warning("Attempted to write to file \"%s\"", _vm->_global->_inter_resStr); + warning("Attempted to write to file \"%s\"", _vm->_parse->_inter_resStr); return false; } diff --git a/engines/gob/inter_v4.cpp b/engines/gob/inter_v4.cpp index 6ab55d70af..812ff71495 100644 --- a/engines/gob/inter_v4.cpp +++ b/engines/gob/inter_v4.cpp @@ -810,7 +810,7 @@ void Inter_v4::o4_playVmdOrMusic() { bool close; evalExpr(0); - strncpy0(fileName, _vm->_global->_inter_resStr, 127); + strncpy0(fileName, _vm->_parse->_inter_resStr, 127); // WORKAROUND: The nut rolling animation in the administration center // in Woodruff is called "noixroul", but the scripts think it's "noixroule". diff --git a/engines/gob/inter_v5.cpp b/engines/gob/inter_v5.cpp index cb5b28cb67..236af5be6e 100644 --- a/engines/gob/inter_v5.cpp +++ b/engines/gob/inter_v5.cpp @@ -675,7 +675,7 @@ const char *Inter_v5::getOpcodeGoblinDesc(int i) { void Inter_v5::o5_deleteFile() { evalExpr(0); - warning("Dynasty Stub: deleteFile \"%s\"", _vm->_global->_inter_resStr); + warning("Dynasty Stub: deleteFile \"%s\"", _vm->_parse->_inter_resStr); } void Inter_v5::o5_initScreen() { diff --git a/engines/gob/inter_v6.cpp b/engines/gob/inter_v6.cpp index 0081dfbdb8..5a8393910f 100644 --- a/engines/gob/inter_v6.cpp +++ b/engines/gob/inter_v6.cpp @@ -666,7 +666,7 @@ void Inter_v6::o6_totSub() { if (length & 0x80) { evalExpr(0); - strcpy(totFile, _vm->_global->_inter_resStr); + strcpy(totFile, _vm->_parse->_inter_resStr); } else { for (i = 0; i < length; i++) totFile[i] = (char) *_vm->_global->_inter_execPtr++; @@ -694,7 +694,7 @@ void Inter_v6::o6_playVmdOrMusic() { bool close; evalExpr(0); - strncpy0(fileName, _vm->_global->_inter_resStr, 127); + strncpy0(fileName, _vm->_parse->_inter_resStr, 127); x = _vm->_parse->parseValExpr(); y = _vm->_parse->parseValExpr(); @@ -760,7 +760,7 @@ void Inter_v6::o6_openItk() { char fileName[32]; evalExpr(0); - strncpy0(fileName, _vm->_global->_inter_resStr, 27); + strncpy0(fileName, _vm->_parse->_inter_resStr, 27); if (!strchr(fileName, '.')) strcat(fileName, ".ITK"); @@ -890,21 +890,21 @@ bool Inter_v6::o6_assign(OpFuncParams ¶ms) { switch (destType) { case TYPE_VAR_INT8: case TYPE_ARRAY_INT8: - WRITE_VARO_UINT8(dest + i, _vm->_global->_inter_resVal); + WRITE_VARO_UINT8(dest + i, _vm->_parse->_inter_resVal); break; case TYPE_VAR_INT16: case TYPE_ARRAY_INT16: - WRITE_VARO_UINT16(dest + i * 2, _vm->_global->_inter_resVal); + WRITE_VARO_UINT16(dest + i * 2, _vm->_parse->_inter_resVal); break; case TYPE_VAR_INT32: case TYPE_ARRAY_INT32: - WRITE_VAR_OFFSET(dest + i * 4, _vm->_global->_inter_resVal); + WRITE_VAR_OFFSET(dest + i * 4, _vm->_parse->_inter_resVal); break; case TYPE_VAR_INT32_AS_INT16: - WRITE_VARO_UINT16(dest + i * 4, _vm->_global->_inter_resVal); + WRITE_VARO_UINT16(dest + i * 4, _vm->_parse->_inter_resVal); break; case TYPE_VAR_STR: @@ -912,7 +912,7 @@ bool Inter_v6::o6_assign(OpFuncParams ¶ms) { if (srcType == TYPE_IMM_INT16) WRITE_VARO_UINT8(dest, result); else - WRITE_VARO_STR(dest, _vm->_global->_inter_resStr); + WRITE_VARO_STR(dest, _vm->_parse->_inter_resStr); break; } } @@ -979,8 +979,8 @@ bool Inter_v6::o6_fillRect(OpFuncParams ¶ms) { evalExpr(0); - _vm->_draw->_backColor = _vm->_global->_inter_resVal & 0xFFFF; - uint16 extraVar = _vm->_global->_inter_resVal >> 16; + _vm->_draw->_backColor = _vm->_parse->_inter_resVal & 0xFFFF; + uint16 extraVar = _vm->_parse->_inter_resVal >> 16; if (extraVar != 0) warning("Urban Stub: o6_fillRect(), extraVar = %d", extraVar); diff --git a/engines/gob/parse.cpp b/engines/gob/parse.cpp index 31c05bc39a..22e97c86b3 100644 --- a/engines/gob/parse.cpp +++ b/engines/gob/parse.cpp @@ -34,6 +34,8 @@ namespace Gob { Parse::Parse(GobEngine *vm) : _vm(vm) { + _inter_resStr[0] = 0; + _inter_resVal = 0; } int32 Parse::encodePtr(byte *ptr, int type) { @@ -47,7 +49,7 @@ int32 Parse::encodePtr(byte *ptr, int type) { offset = ptr - ((byte *) _vm->_inter->_variables->getAddressOff8(0)); break; case kResStr: - offset = ptr - ((byte *) _vm->_global->_inter_resStr); + offset = ptr - ((byte *) _vm->_parse->_inter_resStr); break; default: error("Parse::encodePtr(): Unknown pointer type"); @@ -67,7 +69,7 @@ byte *Parse::decodePtr(int32 n) { ptr = (byte *) _vm->_inter->_variables->getAddressOff8(0); break; case kResStr: - ptr = (byte *) _vm->_global->_inter_resStr; + ptr = (byte *) _vm->_parse->_inter_resStr; break; default: error("Parse::decodePtr(): Unknown pointer type"); @@ -463,11 +465,11 @@ int Parse::cmpHelper(byte *operPtr, int32 *valPtr) { if (type == OP_LOAD_IMM_INT16) { cmpTemp = (int)valPtr[-3] - (int)valPtr[-1]; } else if (type == OP_LOAD_IMM_STR) { - if ((char *)decodePtr(valPtr[-3]) != _vm->_global->_inter_resStr) { - strcpy(_vm->_global->_inter_resStr, (char *)decodePtr(valPtr[-3])); - valPtr[-3] = encodePtr((byte *) _vm->_global->_inter_resStr, kResStr); + if ((char *)decodePtr(valPtr[-3]) != _vm->_parse->_inter_resStr) { + strcpy(_vm->_parse->_inter_resStr, (char *)decodePtr(valPtr[-3])); + valPtr[-3] = encodePtr((byte *) _vm->_parse->_inter_resStr, kResStr); } - cmpTemp = strcmp(_vm->_global->_inter_resStr, (char *)decodePtr(valPtr[-1])); + cmpTemp = strcmp(_vm->_parse->_inter_resStr, (char *)decodePtr(valPtr[-1])); } return cmpTemp; @@ -621,7 +623,7 @@ int16 Parse::parseVarIndex(uint16 *size, uint16 *type) { int16 Parse::parseValExpr(byte stopToken) { parseExpr(stopToken, 0); - return _vm->_global->_inter_resVal; + return _vm->_parse->_inter_resVal; } // Load a value according to the operation @@ -740,29 +742,29 @@ void Parse::loadValue(byte operation, uint32 varBase, byte *operPtr, int32 *valP do { prevPrevVal = prevVal; prevVal = curVal; - curVal = (curVal + _vm->_global->_inter_resVal / curVal) / 2; + curVal = (curVal + _vm->_parse->_inter_resVal / curVal) / 2; } while ((curVal != prevVal) && (curVal != prevPrevVal)); - _vm->_global->_inter_resVal = curVal; + _vm->_parse->_inter_resVal = curVal; break; case FUNC_SQR: - _vm->_global->_inter_resVal = - _vm->_global->_inter_resVal * _vm->_global->_inter_resVal; + _vm->_parse->_inter_resVal = + _vm->_parse->_inter_resVal * _vm->_parse->_inter_resVal; break; case FUNC_ABS: - if (_vm->_global->_inter_resVal < 0) - _vm->_global->_inter_resVal = -_vm->_global->_inter_resVal; + if (_vm->_parse->_inter_resVal < 0) + _vm->_parse->_inter_resVal = -_vm->_parse->_inter_resVal; break; case FUNC_RAND: - _vm->_global->_inter_resVal = - _vm->_util->getRandom(_vm->_global->_inter_resVal); + _vm->_parse->_inter_resVal = + _vm->_util->getRandom(_vm->_parse->_inter_resVal); break; } *operPtr = OP_LOAD_IMM_INT16; - *valPtr = _vm->_global->_inter_resVal; + *valPtr = _vm->_parse->_inter_resVal; break; } } @@ -771,11 +773,11 @@ void Parse::simpleArithmetic1(byte *&operPtr, int32 *&valPtr, int16 &stkPos) { switch (operPtr[-1]) { case OP_ADD: if (operPtr[-2] == OP_LOAD_IMM_STR) { - if ((char *) decodePtr(valPtr[-2]) != _vm->_global->_inter_resStr) { - strcpy(_vm->_global->_inter_resStr, (char *) decodePtr(valPtr[-2])); - valPtr[-2] = encodePtr((byte *) _vm->_global->_inter_resStr, kResStr); + if ((char *) decodePtr(valPtr[-2]) != _vm->_parse->_inter_resStr) { + strcpy(_vm->_parse->_inter_resStr, (char *) decodePtr(valPtr[-2])); + valPtr[-2] = encodePtr((byte *) _vm->_parse->_inter_resStr, kResStr); } - strcat(_vm->_global->_inter_resStr, (char *) decodePtr(valPtr[0])); + strcat(_vm->_parse->_inter_resStr, (char *) decodePtr(valPtr[0])); stkPos -= 2; operPtr -= 2; valPtr -= 2; @@ -871,12 +873,12 @@ bool Parse::complexArithmetic(byte *&operPtr, int32 *&valPtr, int16 &stkPos, if (operStack[brackStart] == OP_LOAD_IMM_INT16) { values[brackStart] += valPtr[-1]; } else if (operStack[brackStart] == OP_LOAD_IMM_STR) { - if ((char *) decodePtr(values[brackStart]) != _vm->_global->_inter_resStr) { - strcpy(_vm->_global->_inter_resStr, (char *) decodePtr(values[brackStart])); + if ((char *) decodePtr(values[brackStart]) != _vm->_parse->_inter_resStr) { + strcpy(_vm->_parse->_inter_resStr, (char *) decodePtr(values[brackStart])); values[brackStart] = - encodePtr((byte *) _vm->_global->_inter_resStr, kResStr); + encodePtr((byte *) _vm->_parse->_inter_resStr, kResStr); } - strcat(_vm->_global->_inter_resStr, (char *) decodePtr(valPtr[-1])); + strcat(_vm->_parse->_inter_resStr, (char *) decodePtr(valPtr[-1])); } stkPos -= 2; operPtr -= 2; @@ -1006,12 +1008,12 @@ void Parse::getResult(byte operation, int32 value, byte *type) { break; case OP_LOAD_IMM_INT16: - _vm->_global->_inter_resVal = value; + _vm->_parse->_inter_resVal = value; break; case OP_LOAD_IMM_STR: - if ((char *) decodePtr(value) != _vm->_global->_inter_resStr) - strcpy(_vm->_global->_inter_resStr, (char *) decodePtr(value)); + if ((char *) decodePtr(value) != _vm->_parse->_inter_resStr) + strcpy(_vm->_parse->_inter_resStr, (char *) decodePtr(value)); break; case OP_LOAD_VAR_INT32: @@ -1019,7 +1021,7 @@ void Parse::getResult(byte operation, int32 value, byte *type) { break; default: - _vm->_global->_inter_resVal = 0; + _vm->_parse->_inter_resVal = 0; if (type != 0) *type = OP_LOAD_IMM_INT16; break; @@ -1163,11 +1165,11 @@ int16 Parse::parseExpr(byte stopToken, byte *type) { if (operPtr[-3] == OP_LOAD_IMM_INT16) { valPtr[-3] += valPtr[-1]; } else if (operPtr[-3] == OP_LOAD_IMM_STR) { - if ((char *) decodePtr(valPtr[-3]) != _vm->_global->_inter_resStr) { - strcpy(_vm->_global->_inter_resStr, (char *) decodePtr(valPtr[-3])); - valPtr[-3] = encodePtr((byte *) _vm->_global->_inter_resStr, kResStr); + if ((char *) decodePtr(valPtr[-3]) != _vm->_parse->_inter_resStr) { + strcpy(_vm->_parse->_inter_resStr, (char *) decodePtr(valPtr[-3])); + valPtr[-3] = encodePtr((byte *) _vm->_parse->_inter_resStr, kResStr); } - strcat(_vm->_global->_inter_resStr, (char *) decodePtr(valPtr[-1])); + strcat(_vm->_parse->_inter_resStr, (char *) decodePtr(valPtr[-1])); } stkPos -= 2; operPtr -= 2; diff --git a/engines/gob/parse.h b/engines/gob/parse.h index 40f87b333a..4c200236f6 100644 --- a/engines/gob/parse.h +++ b/engines/gob/parse.h @@ -118,6 +118,9 @@ public: Parse(GobEngine *vm); virtual ~Parse() {} + char _inter_resStr[200]; + int32 _inter_resVal; + private: enum PointerType { kExecPtr = 0, |