aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorSven Hesse2009-06-23 01:20:05 +0000
committerSven Hesse2009-06-23 01:20:05 +0000
commitec5b2d6c9ac7ef9370392f3a0c3e25b136dcb72b (patch)
treee6ab25e769e88275f8752466ca932c7b10d0135a /engines
parent4fa11436a0f97be92bcb0a8bfcfc6fd55840013c (diff)
downloadscummvm-rg350-ec5b2d6c9ac7ef9370392f3a0c3e25b136dcb72b.tar.gz
scummvm-rg350-ec5b2d6c9ac7ef9370392f3a0c3e25b136dcb72b.tar.bz2
scummvm-rg350-ec5b2d6c9ac7ef9370392f3a0c3e25b136dcb72b.zip
Added a method to query the number of variables needed by a Script
svn-id: r41791
Diffstat (limited to 'engines')
-rw-r--r--engines/gob/game_v1.cpp4
-rw-r--r--engines/gob/game_v2.cpp2
-rw-r--r--engines/gob/init.cpp10
-rw-r--r--engines/gob/inter_v2.cpp4
-rw-r--r--engines/gob/script.cpp19
-rw-r--r--engines/gob/script.h4
6 files changed, 30 insertions, 13 deletions
diff --git a/engines/gob/game_v1.cpp b/engines/gob/game_v1.cpp
index f038c7edc3..725ee6d8ff 100644
--- a/engines/gob/game_v1.cpp
+++ b/engines/gob/game_v1.cpp
@@ -49,7 +49,6 @@ void Game_v1::playTot(int16 skipPlay) {
int16 _captureCounter;
int16 breakFrom;
int16 nestLevel;
- int32 variablesCount;
int16 *oldNestLevel = _vm->_inter->_nestLevel;
int16 *oldBreakFrom = _vm->_inter->_breakFromLevel;
@@ -169,7 +168,7 @@ void Game_v1::playTot(int16 skipPlay) {
_vm->_global->_inter_animDataSize =
READ_LE_UINT16(_script->getData() + 0x38);
if (!_vm->_inter->_variables)
- _vm->_inter->allocateVars(READ_LE_UINT16(_script->getData() + 0x2C));
+ _vm->_inter->allocateVars(_script->getVariablesCount() & 0xFFFF);
_script->seek(READ_LE_UINT32(_script->getData() + 0x64));
@@ -186,7 +185,6 @@ void Game_v1::playTot(int16 skipPlay) {
if (_totToLoad[0] != 0)
_vm->_inter->_terminate = 0;
- variablesCount = READ_LE_UINT32(_script->getData() + 0x2C);
_vm->_draw->blitInvalidated();
_script->unload();
diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp
index ace842f18e..c1205f3bcd 100644
--- a/engines/gob/game_v2.cpp
+++ b/engines/gob/game_v2.cpp
@@ -205,7 +205,7 @@ void Game_v2::playTot(int16 skipPlay) {
_vm->_global->_inter_animDataSize =
READ_LE_UINT16(_script->getData() + 0x38);
if (!_vm->_inter->_variables)
- _vm->_inter->allocateVars(READ_LE_UINT16(_script->getData() + 0x2C));
+ _vm->_inter->allocateVars(_script->getVariablesCount() & 0xFFFF);
_script->seek(READ_LE_UINT16(_script->getData() + 0x64));
diff --git a/engines/gob/init.cpp b/engines/gob/init.cpp
index 4ac3ef5fc5..8c47fb76f9 100644
--- a/engines/gob/init.cpp
+++ b/engines/gob/init.cpp
@@ -32,6 +32,7 @@
#include "gob/dataio.h"
#include "gob/draw.h"
#include "gob/game.h"
+#include "gob/script.h"
#include "gob/palanim.h"
#include "gob/inter.h"
#include "gob/video.h"
@@ -152,12 +153,7 @@ void Init::initGame() {
}
if (_vm->_dataIO->existData(_vm->_startTot.c_str())) {
- DataStream *stream = _vm->_dataIO->getDataStream(_vm->_startTot.c_str());
-
- stream->seek(0x2C);
- _vm->_inter->allocateVars(stream->readUint16LE());
-
- delete stream;
+ _vm->_inter->allocateVars(Script::getVariablesCount(_vm->_startTot.c_str(), _vm));
strcpy(_vm->_game->_curTotFile, _vm->_startTot.c_str());
@@ -181,7 +177,7 @@ void Init::initGame() {
_vm->_draw->initScreen();
_vm->_util->clearPalette();
- stream = _vm->_dataIO->getDataStream("coktel.clt");
+ DataStream *stream = _vm->_dataIO->getDataStream("coktel.clt");
stream->read((byte *) _vm->_draw->_vgaPalette, 768);
delete stream;
diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp
index c4395bb329..43423928b1 100644
--- a/engines/gob/inter_v2.cpp
+++ b/engines/gob/inter_v2.cpp
@@ -1295,7 +1295,7 @@ bool Inter_v2::o2_getFreeMem(OpFuncParams &params) {
// HACK
WRITE_VAR_OFFSET(freeVar, 1000000);
WRITE_VAR_OFFSET(maxFreeVar, 1000000);
- WRITE_VAR(16, READ_LE_UINT32(_vm->_game->_script->getData() + 0x2C) * 4);
+ WRITE_VAR(16, _vm->_game->_script->getVariablesCount() * 4);
return false;
}
@@ -1370,7 +1370,7 @@ bool Inter_v2::o2_readData(OpFuncParams &params) {
return false ;
} else if (size == 0) {
dataVar = 0;
- size = READ_LE_UINT32(_vm->_game->_script->getData() + 0x2C) * 4;
+ size = _vm->_game->_script->getVariablesCount() * 4;
}
buf = _variables->getAddressOff8(dataVar);
diff --git a/engines/gob/script.cpp b/engines/gob/script.cpp
index c0c4a09943..935bf80cd2 100644
--- a/engines/gob/script.cpp
+++ b/engines/gob/script.cpp
@@ -411,6 +411,8 @@ bool Script::getTOTProperties() {
_versionMajor = _totData[39] - '0';
_versionMinor = _totData[41] - '0';
+ _variablesCount = READ_LE_UINT32(_totData + 44);
+
_imFileNumber = _totData[59];
_exFileNumber = _totData[60];
_communHandling = _totData[61];
@@ -499,6 +501,10 @@ uint8 Script::getVersionMinor() const {
return _versionMinor;
}
+uint32 Script::getVariablesCount() const {
+ return _variablesCount;
+}
+
uint8 Script::getImFileNumber() const {
return _imFileNumber;
}
@@ -511,4 +517,17 @@ uint8 Script::getCommunHandling() const {
return _communHandling;
}
+uint32 Script::getVariablesCount(const char *fileName, GobEngine *vm) {
+ if (!vm->_dataIO->existData(fileName))
+ return 0;
+
+ DataStream *stream = vm->_dataIO->getDataStream(fileName);
+
+ stream->seek(0x2C);
+ uint32 variablesCount = stream->readUint32LE();
+ delete stream;
+
+ return variablesCount;
+}
+
} // End of namespace Gob
diff --git a/engines/gob/script.h b/engines/gob/script.h
index c5ed6c3e25..e038507c52 100644
--- a/engines/gob/script.h
+++ b/engines/gob/script.h
@@ -119,10 +119,13 @@ public:
// Fixed properties
uint8 getVersionMajor() const;
uint8 getVersionMinor() const;
+ uint32 getVariablesCount() const;
uint8 getImFileNumber() const;
uint8 getExFileNumber() const;
uint8 getCommunHandling() const;
+ static uint32 getVariablesCount(const char *fileName, GobEngine *vm);
+
private:
struct CallEntry {
byte *totPtr;
@@ -143,6 +146,7 @@ private:
uint8 _versionMajor;
uint8 _versionMinor;
+ uint32 _variablesCount;
uint8 _imFileNumber;
uint8 _exFileNumber;
uint8 _communHandling;