diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/gob/draw.cpp | 5 | ||||
-rw-r--r-- | engines/gob/game_v1.cpp | 2 | ||||
-rw-r--r-- | engines/gob/game_v2.cpp | 4 | ||||
-rw-r--r-- | engines/gob/script.cpp | 16 | ||||
-rw-r--r-- | engines/gob/script.h | 11 |
5 files changed, 20 insertions, 18 deletions
diff --git a/engines/gob/draw.cpp b/engines/gob/draw.cpp index 66f046339f..f0a84bbdcc 100644 --- a/engines/gob/draw.cpp +++ b/engines/gob/draw.cpp @@ -390,8 +390,9 @@ void Draw::printTextCentered(int16 id, int16 left, int16 top, int16 right, adjustCoords(1, &left, &top); adjustCoords(1, &right, &bottom); - if (_vm->_game->_script->getCenterOffset() != 0) { - _vm->_game->_script->call(_vm->_game->_script->getCenterOffset()); + uint16 centerOffset = _vm->_game->_script->getFunctionOffset(Script::kFunctionCenter); + if (centerOffset != 0) { + _vm->_game->_script->call(centerOffset); WRITE_VAR(17, (uint32) id); WRITE_VAR(18, (uint32) left); diff --git a/engines/gob/game_v1.cpp b/engines/gob/game_v1.cpp index 92679cb568..31847075bc 100644 --- a/engines/gob/game_v1.cpp +++ b/engines/gob/game_v1.cpp @@ -164,7 +164,7 @@ void Game_v1::playTot(int16 skipPlay) { if (!_vm->_inter->_variables) _vm->_inter->allocateVars(_script->getVariablesCount() & 0xFFFF); - _script->seek(_script->getStartOffset()); + _script->seek(_script->getFunctionOffset(Script::kFunctionStart)); _vm->_inter->renewTimeInVars(); diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp index e4b4b73661..54a70949bf 100644 --- a/engines/gob/game_v2.cpp +++ b/engines/gob/game_v2.cpp @@ -199,7 +199,7 @@ void Game_v2::playTot(int16 skipPlay) { if (!_vm->_inter->_variables) _vm->_inter->allocateVars(_script->getVariablesCount() & 0xFFFF); - _script->seek(_script->getStartOffset()); + _script->seek(_script->getFunctionOffset(Script::kFunctionStart)); _vm->_inter->renewTimeInVars(); @@ -269,7 +269,7 @@ void Game_v2::playTot(int16 skipPlay) { } else { _vm->_inter->initControlVars(0); _vm->_scenery->_pCaptureCounter = oldCaptureCounter; - _script->seek(READ_LE_UINT16(_script->getData() + (skipPlay << 1) + 0x66)); + _script->seek(_script->getFunctionOffset(skipPlay + 1)); _menuLevel++; _vm->_inter->callSub(2); diff --git a/engines/gob/script.cpp b/engines/gob/script.cpp index 4bed65704e..72085ed756 100644 --- a/engines/gob/script.cpp +++ b/engines/gob/script.cpp @@ -422,10 +422,6 @@ bool Script::getTOTProperties() { _exFileNumber = _totData[60]; _communHandling = _totData[61]; - _startOffset = READ_LE_UINT32(_totData + 100); - - _centerOffset = READ_LE_UINT16(_totData + 126); - return true; } @@ -538,12 +534,14 @@ uint8 Script::getCommunHandling() const { return _communHandling; } -uint32 Script::getStartOffset() const { - return _startOffset; -} +uint16 Script::getFunctionOffset(uint8 function) const { + if (!_totData) + return 0; + + // Offsets 100-128, 2 bytes per function + assert(function <= 13); -uint32 Script::getCenterOffset() const { - return _centerOffset; + return READ_LE_UINT16(_totData + 100 + function * 2); } uint32 Script::getVariablesCount(const char *fileName, GobEngine *vm) { diff --git a/engines/gob/script.h b/engines/gob/script.h index a1200a7ce4..f2f0571a3a 100644 --- a/engines/gob/script.h +++ b/engines/gob/script.h @@ -36,6 +36,11 @@ class Expression; class Script { public: + enum Function { + kFunctionStart = 0, + kFunctionCenter = 13 + }; + Script(GobEngine *vm); ~Script(); @@ -126,8 +131,8 @@ public: uint8 getImFileNumber () const; uint8 getExFileNumber () const; uint8 getCommunHandling () const; - uint32 getStartOffset () const; - uint32 getCenterOffset () const; + + uint16 getFunctionOffset (uint8 function) const; static uint32 getVariablesCount(const char *fileName, GobEngine *vm); @@ -158,8 +163,6 @@ private: uint8 _imFileNumber; uint8 _exFileNumber; uint8 _communHandling; - uint32 _startOffset; - uint16 _centerOffset; Common::Stack<CallEntry> _callStack; |