aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/gob/draw_v1.cpp1
-rw-r--r--engines/gob/draw_v2.cpp1
-rw-r--r--engines/gob/game.cpp28
-rw-r--r--engines/gob/game.h5
-rw-r--r--engines/gob/game_v1.cpp8
-rw-r--r--engines/gob/game_v2.cpp13
-rw-r--r--engines/gob/global.cpp2
-rw-r--r--engines/gob/global.h64
-rw-r--r--engines/gob/gob.h49
-rw-r--r--engines/gob/goblin.cpp1
-rw-r--r--engines/gob/goblin_v2.cpp1
-rw-r--r--engines/gob/goblin_v4.cpp1
-rw-r--r--engines/gob/init.cpp12
-rw-r--r--engines/gob/inter.cpp20
-rw-r--r--engines/gob/inter.h10
-rw-r--r--engines/gob/inter_v1.cpp26
-rw-r--r--engines/gob/inter_v2.cpp33
-rw-r--r--engines/gob/inter_v4.cpp19
-rw-r--r--engines/gob/map_v2.cpp13
-rw-r--r--engines/gob/map_v4.cpp13
-rw-r--r--engines/gob/module.mk1
-rw-r--r--engines/gob/mult.cpp1
-rw-r--r--engines/gob/parse.cpp4
-rw-r--r--engines/gob/parse_v1.cpp6
-rw-r--r--engines/gob/parse_v2.cpp6
-rw-r--r--engines/gob/saveload.cpp112
-rw-r--r--engines/gob/saveload.h11
-rw-r--r--engines/gob/saveload_v2.cpp18
-rw-r--r--engines/gob/saveload_v3.cpp33
-rw-r--r--engines/gob/saveload_v4.cpp33
-rw-r--r--engines/gob/sound/sound.cpp3
-rw-r--r--engines/gob/variables.cpp309
-rw-r--r--engines/gob/variables.h147
-rw-r--r--engines/gob/videoplayer.cpp12
34 files changed, 756 insertions, 260 deletions
diff --git a/engines/gob/draw_v1.cpp b/engines/gob/draw_v1.cpp
index 9a78769d41..b5bc56b6f5 100644
--- a/engines/gob/draw_v1.cpp
+++ b/engines/gob/draw_v1.cpp
@@ -32,6 +32,7 @@
#include "gob/util.h"
#include "gob/game.h"
#include "gob/scenery.h"
+#include "gob/inter.h"
#include "gob/sound/sound.h"
namespace Gob {
diff --git a/engines/gob/draw_v2.cpp b/engines/gob/draw_v2.cpp
index 8c12079b83..378ff0dcdf 100644
--- a/engines/gob/draw_v2.cpp
+++ b/engines/gob/draw_v2.cpp
@@ -32,6 +32,7 @@
#include "gob/util.h"
#include "gob/game.h"
#include "gob/scenery.h"
+#include "gob/inter.h"
#include "gob/video.h"
namespace Gob {
diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp
index 9bdcae567d..73fa820fa0 100644
--- a/engines/gob/game.cpp
+++ b/engines/gob/game.cpp
@@ -350,7 +350,7 @@ int16 Game::checkKeys(int16 *pMouseX, int16 *pMouseY,
_vm->_util->processInput(true);
- if (_vm->_mult->_multData && _vm->_global->_inter_variables &&
+ if (_vm->_mult->_multData && _vm->_inter->_variables &&
(VAR(58) != 0)) {
if (_vm->_mult->_multData->frameStart != (int) VAR(58) - 1)
_vm->_mult->_multData->frameStart++;
@@ -480,8 +480,7 @@ void Game::totSub(int8 flags, const char *newTotFile) {
_extTableArray[_backupedCount] = _extTable;
_extHandleArray[_backupedCount] = _extHandle;
_imFileDataArray[_backupedCount] = _imFileData;
- _variablesArray[_backupedCount] = _vm->_global->_inter_variables;
- _variablesSizesArray[_backupedCount] = _vm->_global->_inter_variablesSizes;
+ _variablesArray[_backupedCount] = _vm->_inter->_variables;
strcpy(_curTotFileArray[_backupedCount], _curTotFile);
curBackupPos = _curBackupPos;
@@ -491,10 +490,8 @@ void Game::totSub(int8 flags, const char *newTotFile) {
_totTextData = 0;
_totFileData = 0;
_totResourceTable = 0;
- if (flags & 1) {
- _vm->_global->_inter_variables = 0;
- _vm->_global->_inter_variablesSizes = 0;
- }
+ if (flags & 1)
+ _vm->_inter->_variables = 0;
strncpy0(_curTotFile, newTotFile, 9);
strcat(_curTotFile, ".TOT");
@@ -514,9 +511,8 @@ void Game::totSub(int8 flags, const char *newTotFile) {
popCollisions();
- if ((flags & 1) && _vm->_global->_inter_variables) {
- delete[] _vm->_global->_inter_variables;
- delete[] _vm->_global->_inter_variablesSizes;
+ if ((flags & 1) && _vm->_inter->_variables) {
+ _vm->_inter->delocateVars();
}
_backupedCount--;
@@ -530,8 +526,7 @@ void Game::totSub(int8 flags, const char *newTotFile) {
_extTable = _extTableArray[_backupedCount];
_extHandle = _extHandleArray[_backupedCount];
_imFileData = _imFileDataArray[_backupedCount];
- _vm->_global->_inter_variables = _variablesArray[_backupedCount];
- _vm->_global->_inter_variablesSizes = _variablesSizesArray[_backupedCount];
+ _vm->_inter->_variables = _variablesArray[_backupedCount];
strcpy(_curTotFile, _curTotFileArray[_backupedCount]);
strcpy(_curExtFile, _curTotFile);
_curExtFile[strlen(_curExtFile) - 4] = '\0';
@@ -563,8 +558,7 @@ void Game::switchTotSub(int16 index, int16 skipPlay) {
_extTableArray[_backupedCount] = _extTable;
_extHandleArray[_backupedCount] = _extHandle;
_imFileDataArray[_backupedCount] = _imFileData;
- _variablesArray[_backupedCount] = _vm->_global->_inter_variables;
- _variablesSizesArray[_backupedCount] = _vm->_global->_inter_variablesSizes;
+ _variablesArray[_backupedCount] = _vm->_inter->_variables;
strcpy(_curTotFileArray[_backupedCount], _curTotFile);
_backupedCount++;
}
@@ -580,8 +574,7 @@ void Game::switchTotSub(int16 index, int16 skipPlay) {
_imFileData = _imFileDataArray[_curBackupPos];
_extTable = _extTableArray[_curBackupPos];
_extHandle = _extHandleArray[_curBackupPos];
- _vm->_global->_inter_variables = _variablesArray[_curBackupPos];
- _vm->_global->_inter_variablesSizes = _variablesSizesArray[_curBackupPos];
+ _vm->_inter->_variables = _variablesArray[_curBackupPos];
strcpy(_curTotFile, _curTotFileArray[_curBackupPos]);
strcpy(_curExtFile, _curTotFile);
_curExtFile[strlen(_curExtFile) - 4] = '\0';
@@ -608,8 +601,7 @@ void Game::switchTotSub(int16 index, int16 skipPlay) {
_extTable = _extTableArray[_curBackupPos];
_extHandle = _extHandleArray[_curBackupPos];
_imFileData = _imFileDataArray[_curBackupPos];
- _vm->_global->_inter_variables = _variablesArray[_curBackupPos];
- _vm->_global->_inter_variablesSizes = _variablesSizesArray[_curBackupPos];
+ _vm->_inter->_variables = _variablesArray[_curBackupPos];
strcpy(_curTotFile, _curTotFileArray[_curBackupPos]);
strcpy(_curExtFile, _curTotFile);
_curExtFile[strlen(_curExtFile) - 4] = '\0';
diff --git a/engines/gob/game.h b/engines/gob/game.h
index bca55cd4dc..15f6ab963a 100644
--- a/engines/gob/game.h
+++ b/engines/gob/game.h
@@ -26,6 +26,8 @@
#ifndef GOB_GAME_H
#define GOB_GAME_H
+#include "gob/variables.h"
+
namespace Gob {
class Game {
@@ -200,9 +202,8 @@ protected:
ExtTable *_extTableArray[5];
int16 _extHandleArray[5];
byte *_imFileDataArray[5];
- byte *_variablesArray[5];
+ Variables *_variablesArray[5];
char _curTotFileArray[5][14];
- byte *_variablesSizesArray[5];
GobEngine *_vm;
diff --git a/engines/gob/game_v1.cpp b/engines/gob/game_v1.cpp
index 435decd9f2..66deea8ec4 100644
--- a/engines/gob/game_v1.cpp
+++ b/engines/gob/game_v1.cpp
@@ -166,12 +166,8 @@ void Game_v1::playTot(int16 skipPlay) {
_vm->_global->_inter_animDataSize =
READ_LE_UINT16(_totFileData + 0x38);
- if (!_vm->_global->_inter_variables) {
- variablesCount = READ_LE_UINT16(_totFileData + 0x2C);
- _vm->_global->_inter_variables = new byte[variablesCount * 4];
- _vm->_global->_inter_variablesSizes = new byte[variablesCount * 4];
- _vm->_global->clearVars(variablesCount);
- }
+ if (!_vm->_inter->_variables)
+ _vm->_inter->allocateVars(READ_LE_UINT16(_totFileData + 0x2C));
_vm->_global->_inter_execPtr = _totFileData;
_vm->_global->_inter_execPtr += READ_LE_UINT32(_totFileData + 0x64);
diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp
index e783f5bfb5..adf75176ab 100644
--- a/engines/gob/game_v2.cpp
+++ b/engines/gob/game_v2.cpp
@@ -54,7 +54,6 @@ void Game_v2::playTot(int16 skipPlay) {
int16 _captureCounter;
int16 breakFrom;
int16 nestLevel;
- int32 variablesCount;
int32 totSize;
byte *filePtr;
byte *savedIP;
@@ -72,7 +71,7 @@ void Game_v2::playTot(int16 skipPlay) {
if (skipPlay <= 0) {
while (!_vm->_quitRequested) {
- if (_vm->_global->_inter_variables)
+ if (_vm->_inter->_variables)
_vm->_draw->animateCursor(4);
if (skipPlay != -1) {
@@ -204,12 +203,8 @@ void Game_v2::playTot(int16 skipPlay) {
_vm->_global->_inter_animDataSize =
READ_LE_UINT16(_totFileData + 0x38);
- if (!_vm->_global->_inter_variables) {
- variablesCount = READ_LE_UINT16(_totFileData + 0x2C);
- _vm->_global->_inter_variables = new byte[variablesCount * 4];
- _vm->_global->_inter_variablesSizes = new byte[variablesCount * 4];
- _vm->_global->clearVars(variablesCount);
- }
+ if (!_vm->_inter->_variables)
+ _vm->_inter->allocateVars(READ_LE_UINT16(_totFileData + 0x2C));
_vm->_global->_inter_execPtr = _totFileData;
_vm->_global->_inter_execPtr +=
@@ -1408,7 +1403,7 @@ int16 Game_v2::inputArea(int16 xPos, int16 yPos, int16 width, int16 height,
flag = 1;
- if (_vm->_global->_inter_variables)
+ if (_vm->_inter->_variables)
WRITE_VAR(56, pos);
while (1) {
diff --git a/engines/gob/global.cpp b/engines/gob/global.cpp
index 1445601017..acca5564dd 100644
--- a/engines/gob/global.cpp
+++ b/engines/gob/global.cpp
@@ -123,8 +123,6 @@ Global::Global(GobEngine *vm) : _vm(vm) {
_inter_resStr[0] = 0;
_inter_resVal = 0;
- _inter_variablesSizes = 0;
- _inter_variables = 0;
_inter_execPtr = 0;
_inter_animDataSize = 10;
diff --git a/engines/gob/global.h b/engines/gob/global.h
index 45c179d277..32651cf15d 100644
--- a/engines/gob/global.h
+++ b/engines/gob/global.h
@@ -123,8 +123,6 @@ public:
char _inter_resStr[200];
int32 _inter_resVal;
- byte *_inter_variablesSizes; // 0: single byte, 1: two bytes, 3: four bytes
- byte *_inter_variables;
byte *_inter_execPtr;
int16 _inter_animDataSize;
@@ -134,73 +132,11 @@ public:
// Can be 1, 2 or 3 for normal, double and triple speed, respectively
uint8 _speedFactor;
- void clearVars(uint32 count) {
- uint32 size = count * 4;
-
- memset(_inter_variables, 0, size);
- memset(_inter_variablesSizes, 0, size);
- for (uint32 i = 0; i < size; i += 4)
- _inter_variablesSizes[i] = 3;
- }
-
- void writeVarSizeStr(uint32 offset, uint32 len) {
- uint32 i;
- uint32 inVar;
- uint32 varOff;
-
- inVar = offset % 4;
- varOff = (offset >> 2) << 2;
- for (i = 0; i < 4; i++) {
- if (_inter_variablesSizes[varOff + i] == 3)
- _inter_variablesSizes[varOff + i] = 0;
- else if ((inVar == (i+1)) && (_inter_variablesSizes[varOff + i] == 1))
- _inter_variablesSizes[varOff + i] = 0;
- }
- memset(_inter_variablesSizes + offset, 0, len);
- }
-
- void writeVar(uint32 offset, uint32 val) {
- WRITE_UINT32(_inter_variables + offset, val);
- writeVarSize(offset, 3);
- }
- void writeVar(uint32 offset, uint16 val) {
- WRITE_UINT16(_inter_variables + offset, val);
- writeVarSize(offset, 1);
- }
- void writeVar(uint32 offset, uint8 val) {
- (*(uint8 *)(_inter_variables + offset)) = val;
- writeVarSize(offset, 0);
- }
- void writeVar(uint32 offset, const char *str) {
- writeVarSizeStr(offset, strlen(str));
- strcpy((char *) (_inter_variables + offset), str);
- }
-
Global(GobEngine *vm);
~Global();
protected:
GobEngine *_vm;
-
- void writeVarSize(uint32 offset, byte n) {
- uint32 i;
- uint32 inVar;
- uint32 varOff;
-
- inVar = offset % 4;
- varOff = (offset >> 2) << 2;
- for (i = 0; i < 4; i++) {
- if (_inter_variablesSizes[varOff + i] == 3)
- _inter_variablesSizes[varOff + i] = 0;
- else if ((inVar == (i+1)) && (_inter_variablesSizes[varOff + i] == 1))
- _inter_variablesSizes[varOff + i] = 0;
- }
-
- _inter_variablesSizes[offset] = n;
- for (; n > 0; n--)
- _inter_variablesSizes[offset + n] = 0;
- }
-
};
} // End of namespace Gob
diff --git a/engines/gob/gob.h b/engines/gob/gob.h
index efc9718098..ae2b53bc31 100644
--- a/engines/gob/gob.h
+++ b/engines/gob/gob.h
@@ -52,29 +52,32 @@ class Scenery;
class Util;
class SaveLoad;
-#define VARP(offs) (_vm->_global->_inter_variables + (offs))
-#define WRITE_VARO_UINT32(offs, val) _vm->_global->writeVar(offs, (uint32) (val))
-#define WRITE_VARO_UINT16(offs, val) _vm->_global->writeVar(offs, (uint16) (val))
-#define WRITE_VARO_UINT8(offs, val) _vm->_global->writeVar(offs, (uint8) (val))
-#define WRITE_VARO_STR(offs, str) _vm->_global->writeVar(offs, (const char *) (str))
-#define WRITE_VAR_UINT32(var, val) WRITE_VARO_UINT32((var) << 2, (val))
-#define WRITE_VAR_UINT16(var, val) WRITE_VARO_UINT16((var) << 2, (val))
-#define WRITE_VAR_UINT8(var, val) WRITE_VARO_UINT8((var) << 2, (val))
-#define WRITE_VAR_STR(var, str) WRITE_VARO_STR((var) << 2, (str))
-#define READ_VARO_UINT32(offs) READ_UINT32(VARP(offs))
-#define READ_VARO_UINT16(offs) READ_UINT16(VARP(offs))
-#define READ_VARO_UINT8(offs) (*((uint8 *) VARP(offs)))
-#define READ_VAR_UINT32(var) READ_VARO_UINT32((var) << 2)
-#define READ_VAR_UINT16(var) READ_VARO_UINT16((var) << 2)
-#define READ_VAR_UINT8(var) READ_VARO_UINT8((var) << 2)
-#define GET_VARO_STR(offs) ((char *) VARP(offs))
-#define GET_VAR_STR(var) GET_VARO_STR((var) << 2)
-
-#define WRITE_VAR_OFFSET(offs, val) WRITE_VARO_UINT32((offs), (val))
-#define WRITE_VAR(var, val) WRITE_VAR_UINT32((var), (val))
-#define VAR_OFFSET(offs) READ_VARO_UINT32(offs)
-#define VAR(var) READ_VAR_UINT32(var)
-#define VAR_ADDRESS(var) ((uint32 *) VARP((var) << 2))
+#define WRITE_VAR_UINT32(var, val) _vm->_inter->_variables->writeVar32(var, val)
+#define WRITE_VAR_UINT16(var, val) _vm->_inter->_variables->writeVar16(var, val)
+#define WRITE_VAR_UINT8(var, val) _vm->_inter->_variables->writeVar8(var, val)
+#define WRITE_VAR_STR(var, str) _vm->_inter->_variables->writeVarString(var, str)
+#define WRITE_VARO_UINT32(off, val) _vm->_inter->_variables->writeOff32(off, val)
+#define WRITE_VARO_UINT16(off, val) _vm->_inter->_variables->writeOff16(off, val)
+#define WRITE_VARO_UINT8(off, val) _vm->_inter->_variables->writeOff8(off, val)
+#define WRITE_VARO_STR(off, str) _vm->_inter->_variables->writeOffString(off, str)
+#define READ_VAR_UINT32(var) _vm->_inter->_variables->readVar32(var)
+#define READ_VAR_UINT16(var) _vm->_inter->_variables->readVar16(var)
+#define READ_VAR_UINT8(var) _vm->_inter->_variables->readVar8(var)
+#define READ_VARO_UINT32(off) _vm->_inter->_variables->readOff32(off)
+#define READ_VARO_UINT16(off) _vm->_inter->_variables->readOff16(off)
+#define READ_VARO_UINT8(off) _vm->_inter->_variables->readOff8(off)
+#define GET_VAR_STR(var) _vm->_inter->_variables->getAddressVarString(var, 0)
+#define GET_VARO_STR(off) _vm->_inter->_variables->getAddressOffString(off, 0)
+#define GET_VAR_FSTR(var) _vm->_inter->_variables->getAddressVarString(var)
+#define GET_VARO_FSTR(off) _vm->_inter->_variables->getAddressOffString(off)
+
+#define VAR_ADDRESS(var) _vm->_inter->_variables->getAddressVar32(var)
+
+#define WRITE_VAR_OFFSET(off, val) WRITE_VARO_UINT32((off), (val))
+#define WRITE_VAR(var, val) WRITE_VAR_UINT32((var), (val))
+#define VAR_OFFSET(off) READ_VARO_UINT32(off)
+#define VAR(var) READ_VAR_UINT32(var)
+
enum GameType {
kGameTypeNone = 0,
diff --git a/engines/gob/goblin.cpp b/engines/gob/goblin.cpp
index d3857e2066..e7aed0790e 100644
--- a/engines/gob/goblin.cpp
+++ b/engines/gob/goblin.cpp
@@ -32,6 +32,7 @@
#include "gob/map.h"
#include "gob/mult.h"
#include "gob/scenery.h"
+#include "gob/inter.h"
#include "gob/sound/sound.h"
namespace Gob {
diff --git a/engines/gob/goblin_v2.cpp b/engines/gob/goblin_v2.cpp
index 93c4c74ecc..9144e35070 100644
--- a/engines/gob/goblin_v2.cpp
+++ b/engines/gob/goblin_v2.cpp
@@ -33,6 +33,7 @@
#include "gob/map.h"
#include "gob/mult.h"
#include "gob/scenery.h"
+#include "gob/inter.h"
namespace Gob {
diff --git a/engines/gob/goblin_v4.cpp b/engines/gob/goblin_v4.cpp
index 167946e30d..1df5aab606 100644
--- a/engines/gob/goblin_v4.cpp
+++ b/engines/gob/goblin_v4.cpp
@@ -29,6 +29,7 @@
#include "gob/mult.h"
#include "gob/map.h"
#include "gob/scenery.h"
+#include "gob/inter.h"
namespace Gob {
diff --git a/engines/gob/init.cpp b/engines/gob/init.cpp
index b1e31b34c2..c2f8b48626 100644
--- a/engines/gob/init.cpp
+++ b/engines/gob/init.cpp
@@ -33,6 +33,7 @@
#include "gob/draw.h"
#include "gob/game.h"
#include "gob/palanim.h"
+#include "gob/inter.h"
#include "gob/video.h"
#include "gob/videoplayer.h"
#include "gob/sound/sound.h"
@@ -62,7 +63,6 @@ void Init::initGame(const char *totName) {
char *infPtr;
char *infEnd;
char buffer[128];
- int32 varsCount;
initVideo();
@@ -90,8 +90,6 @@ void Init::initGame(const char *totName) {
_vm->_game->_totTextData = 0;
_vm->_game->_totFileData = 0;
_vm->_game->_totResourceTable = 0;
- _vm->_global->_inter_variables = 0;
- _vm->_global->_inter_variablesSizes = 0;
_palDesc = new Video::PalDesc;
_vm->validateVideoMode(_vm->_global->_videoMode);
@@ -157,14 +155,10 @@ void Init::initGame(const char *totName) {
DataStream *stream = _vm->_dataIO->openAsStream(handle, true);
stream->seek(0x2C);
- varsCount = stream->readUint16LE();
+ _vm->_inter->allocateVars(stream->readUint16LE());
delete stream;
- _vm->_global->_inter_variables = new byte[varsCount * 4];
- _vm->_global->_inter_variablesSizes = new byte[varsCount * 4];
- _vm->_global->clearVars(varsCount);
-
strcpy(_vm->_game->_curTotFile, buffer);
_vm->_sound->cdTest(1, "GOB");
@@ -214,8 +208,6 @@ void Init::initGame(const char *totName) {
_vm->_sound->cdStop();
_vm->_sound->cdUnloadLIC();
- delete[] _vm->_global->_inter_variables;
- delete[] _vm->_global->_inter_variablesSizes;
delete[] _vm->_game->_totFileData;
if (_vm->_game->_totTextData) {
if (_vm->_game->_totTextData->items)
diff --git a/engines/gob/inter.cpp b/engines/gob/inter.cpp
index 9e5005f443..9c39653a1d 100644
--- a/engines/gob/inter.cpp
+++ b/engines/gob/inter.cpp
@@ -60,6 +60,12 @@ Inter::Inter(GobEngine *vm) : _vm(vm) {
_pastePos = 0;
_noBusyWait = false;
+
+ _variables = 0;
+}
+
+Inter::~Inter() {
+ delocateVars();
}
void Inter::initControlVars(char full) {
@@ -279,4 +285,18 @@ void Inter::callSub(int16 retFlag) {
_terminate = 1;
}
+void Inter::allocateVars(uint32 count) {
+ if ((_vm->getPlatform() == Common::kPlatformAmiga) ||
+ (_vm->getPlatform() == Common::kPlatformMacintosh) ||
+ (_vm->getPlatform() == Common::kPlatformAtariST))
+ _variables = new VariablesBE(count * 4);
+ else
+ _variables = new VariablesLE(count * 4);
+}
+
+void Inter::delocateVars() {
+ delete _variables;
+ _variables = 0;
+}
+
} // End of namespace Gob
diff --git a/engines/gob/inter.h b/engines/gob/inter.h
index e43cb4e891..60b3974d6d 100644
--- a/engines/gob/inter.h
+++ b/engines/gob/inter.h
@@ -27,6 +27,7 @@
#define GOB_INTER_H
#include "gob/goblin.h"
+#include "gob/variables.h"
namespace Gob {
@@ -48,6 +49,8 @@ public:
uint32 _soundEndTimeKey;
int16 _soundStopVal;
+ Variables *_variables;
+
void initControlVars(char full);
int16 load16();
char evalExpr(int16 *pRes);
@@ -59,11 +62,14 @@ public:
void funcBlock(int16 retFlag);
void callSub(int16 retFlag);
+ void allocateVars(uint32 count);
+ void delocateVars();
+
virtual int16 loadSound(int16 slot) = 0;
virtual void animPalette() = 0;
Inter(GobEngine *vm);
- virtual ~Inter() {}
+ virtual ~Inter();
protected:
struct OpFuncParams {
@@ -83,7 +89,7 @@ protected:
int16 _animPalHighIndex[8];
int16 _animPalDir[8];
- char _pasteBuf[300];
+ byte _pasteBuf[300];
byte _pasteSizeBuf[300];
int16 _pastePos;
diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp
index a809a44b40..e2b8d65112 100644
--- a/engines/gob/inter_v1.cpp
+++ b/engines/gob/inter_v1.cpp
@@ -929,16 +929,16 @@ void Inter_v1::o1_initMult() {
_vm->_mult->_objCount * sizeof(Mult::Mult_Object));
for (int i = 0; i < _vm->_mult->_objCount; i++) {
- _vm->_mult->_objects[i].pPosX =
- (int32 *)(_vm->_global->_inter_variables +
- i * 4 + (posXVar / 4) * 4);
- _vm->_mult->_objects[i].pPosY =
- (int32 *)(_vm->_global->_inter_variables +
- i * 4 + (posYVar / 4) * 4);
+ uint32 offPosX = i * 4 + (posXVar / 4) * 4;
+ uint32 offPosY = i * 4 + (posYVar / 4) * 4;
+ uint32 offAnim = animDataVar + i * 4 * _vm->_global->_inter_animDataSize;
+
+ _vm->_mult->_objects[i].pPosX = (int32 *) _variables->getAddressOff32(offPosX);
+ _vm->_mult->_objects[i].pPosY = (int32 *) _variables->getAddressOff32(offPosY);
_vm->_mult->_objects[i].pAnimData =
- (Mult::Mult_AnimData *) (_vm->_global->_inter_variables +
- animDataVar + i * 4 * _vm->_global->_inter_animDataSize);
+ (Mult::Mult_AnimData *) _variables->getAddressOff8(offAnim,
+ _vm->_global->_inter_animDataSize);
_vm->_mult->_objects[i].pAnimData->isStatic = 1;
_vm->_mult->_objects[i].tick = 0;
@@ -2069,8 +2069,7 @@ bool Inter_v1::o1_prepareStr(OpFuncParams &params) {
int16 strVar;
strVar = _vm->_parse->parseVarIndex();
- _vm->_util->prepareStr(GET_VARO_STR(strVar));
- _vm->_global->writeVarSizeStr(strVar, strlen(GET_VARO_STR(strVar)));
+ _vm->_util->prepareStr(GET_VARO_FSTR(strVar));
return false;
}
@@ -2081,8 +2080,9 @@ bool Inter_v1::o1_insertStr(OpFuncParams &params) {
strVar = _vm->_parse->parseVarIndex();
evalExpr(0);
pos = _vm->_parse->parseValExpr();
- _vm->_util->insertStr(_vm->_global->_inter_resStr, GET_VARO_STR(strVar), pos);
- _vm->_global->writeVarSizeStr(strVar, strlen(GET_VARO_STR(strVar)));
+
+ char *str = GET_VARO_FSTR(strVar);
+ _vm->_util->insertStr(_vm->_global->_inter_resStr, str, pos);
return false;
}
@@ -2222,7 +2222,7 @@ bool Inter_v1::o1_readData(OpFuncParams &params) {
if (((dataVar >> 2) == 59) && (size == 4))
WRITE_VAR(59, stream->readUint32LE());
else
- retSize = stream->read(_vm->_global->_inter_variables + dataVar, size);
+ retSize = stream->read((byte *) _variables->getAddressOff8(dataVar, size), size);
if (retSize == size)
WRITE_VAR(1, 0);
diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp
index e442ec4eca..d8c33fcce6 100644
--- a/engines/gob/inter_v2.cpp
+++ b/engines/gob/inter_v2.cpp
@@ -903,19 +903,16 @@ void Inter_v2::o2_initMult() {
_vm->_mult->_objCount * sizeof(Mult::Mult_Object));
for (int i = 0; i < _vm->_mult->_objCount; i++) {
- _vm->_mult->_objects[i].pPosX =
- (int32 *)(_vm->_global->_inter_variables +
- i * 4 + (posXVar / 4) * 4);
- _vm->_mult->_objects[i].pPosY =
- (int32 *)(_vm->_global->_inter_variables +
- i * 4 + (posYVar / 4) * 4);
+ uint32 offPosX = i * 4 + (posXVar / 4) * 4;
+ uint32 offPosY = i * 4 + (posYVar / 4) * 4;
+ uint32 offAnim = animDataVar + i * 4 * _vm->_global->_inter_animDataSize;
+
+ _vm->_mult->_objects[i].pPosX = (int32 *) _variables->getAddressOff32(offPosX);
+ _vm->_mult->_objects[i].pPosY = (int32 *) _variables->getAddressOff32(offPosY);
_vm->_mult->_objects[i].pAnimData =
- (Mult::Mult_AnimData *) (_vm->_global->_inter_variables +
- animDataVar + i * 4 * _vm->_global->_inter_animDataSize);
- memset(_vm->_global->_inter_variablesSizes +
- i * 4 * _vm->_global->_inter_animDataSize, 0,
- _vm->_global->_inter_animDataSize);
+ (Mult::Mult_AnimData *) _variables->getAddressOff8(offAnim,
+ _vm->_global->_inter_animDataSize);
_vm->_mult->_objects[i].pAnimData->isStatic = 1;
_vm->_mult->_objects[i].tick = 0;
@@ -1186,10 +1183,7 @@ void Inter_v2::o2_copyVars() {
varOff = _vm->_parse->parseVarIndex();
_vm->_global->_inter_execPtr++;
- memcpy(_pasteBuf + _pastePos, _vm->_global->_inter_variables + varOff,
- _vm->_global->_inter_animDataSize * 4);
- memcpy(_pasteSizeBuf + _pastePos,
- _vm->_global->_inter_variablesSizes + varOff,
+ _variables->copyTo(varOff, _pasteBuf + _pastePos, _pasteSizeBuf + _pastePos,
_vm->_global->_inter_animDataSize * 4);
_pastePos += _vm->_global->_inter_animDataSize * 4;
@@ -1199,6 +1193,7 @@ void Inter_v2::o2_copyVars() {
} else {
if (evalExpr(&varOff) == 20)
_vm->_global->_inter_resVal = 0;
+
memcpy(_pasteBuf + _pastePos, &_vm->_global->_inter_resVal, 4);
memcpy(_pasteSizeBuf + _pastePos, &_vm->_global->_inter_resVal, 4);
_pastePos += 4;
@@ -1222,8 +1217,7 @@ void Inter_v2::o2_pasteVars() {
assert(sizeV == sizeS);
_pastePos -= sizeV;
- memcpy(_vm->_global->_inter_variables + varOff, _pasteBuf + _pastePos, sizeV);
- memcpy(_vm->_global->_inter_variablesSizes + varOff, _pasteSizeBuf + _pastePos, sizeS);
+ _variables->copyFrom(varOff, _pasteBuf + _pastePos, _pasteSizeBuf + _pastePos, sizeV);
}
}
@@ -1558,7 +1552,7 @@ void Inter_v2::o2_playImd() {
startFrame, lastFrame, palCmd, palStart, palEnd, flags);
if ((imd[0] != 0) && !_vm->_vidPlayer->primaryOpen(imd, x, y, flags)) {
- WRITE_VAR(11, -1);
+ WRITE_VAR(11, (uint32) -1);
return;
}
@@ -1972,8 +1966,7 @@ bool Inter_v2::o2_readData(OpFuncParams &params) {
size = READ_LE_UINT32(_vm->_game->_totFileData + 0x2C) * 4;
}
- buf = _vm->_global->_inter_variables + dataVar;
- memset(_vm->_global->_inter_variablesSizes + dataVar, 0, size);
+ buf = _variables->getAddressOff8(dataVar, size);
if (_vm->_global->_inter_resStr[0] == 0) {
WRITE_VAR(1, size);
diff --git a/engines/gob/inter_v4.cpp b/engines/gob/inter_v4.cpp
index fd90b731a2..fb895dd5b2 100644
--- a/engines/gob/inter_v4.cpp
+++ b/engines/gob/inter_v4.cpp
@@ -642,9 +642,8 @@ void Inter_v4::setupOpcodes() {
}
void Inter_v4::executeDrawOpcode(byte i) {
- debugC(1, kDebugDrawOp, "opcodeDraw %d [0x%X] (%s) - %s, %d",
- i, i, getOpcodeDrawDesc(i),
- _vm->_game->_curTotFile, uint(_vm->_global->_inter_execPtr - _vm->_game->_totFileData));
+ debugC(1, kDebugDrawOp, "opcodeDraw %d [0x%X] (%s)",
+ i, i, getOpcodeDrawDesc(i));
OpcodeDrawProcV4 op = _opcodesDrawV4[i].proc;
@@ -655,9 +654,10 @@ void Inter_v4::executeDrawOpcode(byte i) {
}
bool Inter_v4::executeFuncOpcode(byte i, byte j, OpFuncParams &params) {
- debugC(1, kDebugFuncOp, "opcodeFunc %d.%d [0x%X.0x%X] (%s) - %s, %d",
- i, j, i, j, getOpcodeFuncDesc(i, j),
- _vm->_game->_curTotFile, uint(_vm->_global->_inter_execPtr - _vm->_game->_totFileData));
+ debugC(1, kDebugFuncOp, "opcodeFunc %d.%d [0x%X.0x%X] (%s) - %s, %d, %d",
+ i, j, i, j, getOpcodeFuncDesc(i, j), _vm->_game->_curTotFile,
+ (uint) (_vm->_global->_inter_execPtr - _vm->_game->_totFileData),
+ (uint) (_vm->_global->_inter_execPtr - _vm->_game->_totFileData - params.counter - 4));
if ((i > 4) || (j > 15)) {
warning("unimplemented opcodeFunc: %d.%d", i, j);
@@ -675,9 +675,8 @@ bool Inter_v4::executeFuncOpcode(byte i, byte j, OpFuncParams &params) {
}
void Inter_v4::executeGoblinOpcode(int i, OpGobParams &params) {
- debugC(1, kDebugGobOp, "opcodeGoblin %d [0x%X] (%s) - %s, %d",
- i, i, getOpcodeGoblinDesc(i),
- _vm->_game->_curTotFile, uint(_vm->_global->_inter_execPtr - _vm->_game->_totFileData));
+ debugC(1, kDebugGobOp, "opcodeGoblin %d [0x%X] (%s)",
+ i, i, getOpcodeGoblinDesc(i));
OpcodeGoblinProcV4 op = NULL;
@@ -884,7 +883,7 @@ void Inter_v4::o4_playVmdOrMusic() {
}
if ((fileName[0] != 0) && !_vm->_vidPlayer->primaryOpen(fileName, x, y, flags)) {
- WRITE_VAR(11, -1);
+ WRITE_VAR(11, (uint32) -1);
return;
}
diff --git a/engines/gob/map_v2.cpp b/engines/gob/map_v2.cpp
index 668b4d2e97..bd9f5b3efc 100644
--- a/engines/gob/map_v2.cpp
+++ b/engines/gob/map_v2.cpp
@@ -56,12 +56,12 @@ void Map_v2::loadMapObjects(const char *avjFile) {
uint32 passPos;
var = _vm->_parse->parseVarIndex();
- variables = _vm->_global->_inter_variables + var;
+ variables = _vm->_inter->_variables->getAddressOff8(var, 0);
id = _vm->_inter->load16();
if (id == -1) {
- _passMap = (int8 *)(_vm->_global->_inter_variables + var);
+ _passMap = (int8 *) _vm->_inter->_variables->getAddressOff8(var, 0);
return;
}
@@ -104,18 +104,17 @@ void Map_v2::loadMapObjects(const char *avjFile) {
// In the original asm, this writes byte-wise into the variables-array
tmpPos = mapData.pos();
mapData.seek(passPos);
- if (variables != _vm->_global->_inter_variables) {
- byte *sizes;
+ if ((variables != 0) &&
+ (variables != _vm->_inter->_variables->getAddressOff8(0, 0))) {
_passMap = (int8 *) variables;
mapHeight = _screenHeight / _tilesHeight;
mapWidth = _screenWidth / _tilesWidth;
- sizes = _vm->_global->_inter_variablesSizes +
- (((byte *) _passMap) - _vm->_global->_inter_variables);
+
for (int i = 0; i < mapHeight; i++) {
for (int j = 0; j < mapWidth; j++)
setPass(j, i, mapData.readSByte());
- memset(sizes + i * _passWidth, 0, mapWidth);
+ _vm->_inter->_variables->getAddressOff8(var + i * _passWidth, mapWidth);
}
}
mapData.seek(tmpPos);
diff --git a/engines/gob/map_v4.cpp b/engines/gob/map_v4.cpp
index a3c3222213..3a74c4b6aa 100644
--- a/engines/gob/map_v4.cpp
+++ b/engines/gob/map_v4.cpp
@@ -54,7 +54,7 @@ void Map_v4::loadMapObjects(const char *avjFile) {
uint32 passPos;
var = _vm->_parse->parseVarIndex();
- variables = _vm->_global->_inter_variables + var;
+ variables = _vm->_inter->_variables->getAddressOff8(var, 0);
id = _vm->_inter->load16();
@@ -62,7 +62,7 @@ void Map_v4::loadMapObjects(const char *avjFile) {
warning("Woodruff Stub: loadMapObjects ID >= 65520");
return;
} else if (id == -1) {
- _passMap = (int8 *)(_vm->_global->_inter_variables + var);
+ _passMap = (int8 *) _vm->_inter->_variables->getAddressOff8(var, 0);
return;
}
@@ -120,18 +120,17 @@ void Map_v4::loadMapObjects(const char *avjFile) {
// In the original asm, this writes byte-wise into the variables-array
tmpPos = mapData.pos();
mapData.seek(passPos);
- if (variables != _vm->_global->_inter_variables) {
- byte *sizes;
+ if ((variables != 0) &&
+ (variables != _vm->_inter->_variables->getAddressOff8(0, 0))) {
_passMap = (int8 *) variables;
mapHeight = _screenHeight / _tilesHeight;
mapWidth = _screenWidth / _tilesWidth;
- sizes = _vm->_global->_inter_variablesSizes +
- (((byte *) _passMap) - _vm->_global->_inter_variables);
+
for (int i = 0; i < mapHeight; i++) {
for (int j = 0; j < mapWidth; j++)
setPass(j, i, mapData.readSByte());
- memset(sizes + i * _passWidth, 0, mapWidth);
+ _vm->_inter->_variables->getAddressOff8(var + i * _passWidth, mapWidth);
}
}
mapData.seek(tmpPos);
diff --git a/engines/gob/module.mk b/engines/gob/module.mk
index c95391cedc..45048a0899 100644
--- a/engines/gob/module.mk
+++ b/engines/gob/module.mk
@@ -49,6 +49,7 @@ MODULE_OBJS := \
scenery_v1.o \
scenery_v2.o \
util.o \
+ variables.o \
video.o \
video_v1.o \
video_v2.o \
diff --git a/engines/gob/mult.cpp b/engines/gob/mult.cpp
index bc9fe4dc11..3d6a7942f9 100644
--- a/engines/gob/mult.cpp
+++ b/engines/gob/mult.cpp
@@ -35,6 +35,7 @@
#include "gob/scenery.h"
#include "gob/video.h"
#include "gob/videoplayer.h"
+#include "gob/inter.h"
#include "gob/sound/sound.h"
namespace Gob {
diff --git a/engines/gob/parse.cpp b/engines/gob/parse.cpp
index 5d7cef0341..ad1f53bb6f 100644
--- a/engines/gob/parse.cpp
+++ b/engines/gob/parse.cpp
@@ -44,7 +44,7 @@ int32 Parse::encodePtr(byte *ptr, int type) {
offset = ptr - _vm->_game->_totFileData;
break;
case kInterVar:
- offset = ptr - _vm->_global->_inter_variables;
+ offset = ptr - ((byte *) _vm->_inter->_variables->getAddressOff8(0, 0));
break;
case kResStr:
offset = ptr - ((byte *) _vm->_global->_inter_resStr);
@@ -64,7 +64,7 @@ byte *Parse::decodePtr(int32 n) {
ptr = _vm->_game->_totFileData;
break;
case kInterVar:
- ptr = _vm->_global->_inter_variables;
+ ptr = (byte *) _vm->_inter->_variables->getAddressOff8(0, 0);
break;
case kResStr:
ptr = (byte *) _vm->_global->_inter_resStr;
diff --git a/engines/gob/parse_v1.cpp b/engines/gob/parse_v1.cpp
index f18f63de4f..3c5f90c068 100644
--- a/engines/gob/parse_v1.cpp
+++ b/engines/gob/parse_v1.cpp
@@ -375,7 +375,7 @@ int16 Parse_v1::parseExpr(byte stopToken, byte *arg_2) {
case 25:
*operPtr = 22;
temp = _vm->_inter->load16() * 4;
- *valPtr = encodePtr(_vm->_global->_inter_variables + temp,
+ *valPtr = encodePtr(_vm->_inter->_variables->getAddressOff8(temp, 0),
kInterVar);
if (*_vm->_global->_inter_execPtr == 13) {
_vm->_global->_inter_execPtr++;
@@ -403,8 +403,8 @@ int16 Parse_v1::parseExpr(byte stopToken, byte *arg_2) {
*valPtr = VAR(temp + offset);
break;
}
- *valPtr = encodePtr(_vm->_global->_inter_variables +
- temp * 4 + offset * _vm->_global->_inter_animDataSize * 4,
+ *valPtr = encodePtr(_vm->_inter->_variables->getAddressOff8(
+ temp * 4 + offset * _vm->_global->_inter_animDataSize * 4, 0),
kInterVar);
if (*_vm->_global->_inter_execPtr == 13) {
_vm->_global->_inter_execPtr++;
diff --git a/engines/gob/parse_v2.cpp b/engines/gob/parse_v2.cpp
index 463a3870ee..a2e6b8fb37 100644
--- a/engines/gob/parse_v2.cpp
+++ b/engines/gob/parse_v2.cpp
@@ -408,8 +408,8 @@ int16 Parse_v2::parseExpr(byte stopToken, byte *arg_2) {
else if (operation == 27)
*valPtr = (int16) READ_VARO_UINT16(temp * 2 + offset * 2);
else if (operation == 28) {
- *valPtr = encodePtr(_vm->_global->_inter_variables +
- temp * 4 + offset * _vm->_global->_inter_animDataSize * 4,
+ *valPtr = encodePtr(_vm->_inter->_variables->getAddressOff8(
+ temp * 4 + offset * _vm->_global->_inter_animDataSize * 4, 0),
kInterVar);
if (*_vm->_global->_inter_execPtr == 13) {
_vm->_global->_inter_execPtr++;
@@ -467,7 +467,7 @@ int16 Parse_v2::parseExpr(byte stopToken, byte *arg_2) {
case 25:
*operPtr = 22;
temp = _vm->_inter->load16() * 4;
- *valPtr = encodePtr(_vm->_global->_inter_variables + temp, kInterVar);
+ *valPtr = encodePtr(_vm->_inter->_variables->getAddressOff8(temp, 0), kInterVar);
if (*_vm->_global->_inter_execPtr == 13) {
_vm->_global->_inter_execPtr++;
temp += parseValExpr(12);
diff --git a/engines/gob/saveload.cpp b/engines/gob/saveload.cpp
index 50f41db47e..2788716858 100644
--- a/engines/gob/saveload.cpp
+++ b/engines/gob/saveload.cpp
@@ -160,6 +160,60 @@ PlainSave::~PlainSave() {
}
bool PlainSave::save(int16 dataVar, int32 size, int32 offset, const char *name,
+ const Variables *variables) {
+
+ if ((size <= 0) || (offset != 0)) {
+ warning("Invalid size (%d) or offset (%d)", size, offset);
+ return false;
+ }
+
+ byte *vars = new byte[size];
+ byte *varSizes = new byte[size];
+
+ if (!variables->copyTo(dataVar, vars, varSizes, size)) {
+ delete[] vars;
+ delete[] varSizes;
+ warning("dataVar (%d) or size (%d) out of range", dataVar, size);
+ return false;
+ }
+
+ bool result = save(0, size, offset, name, vars, varSizes);
+
+ delete[] vars;
+ delete[] varSizes;
+
+ return result;
+}
+
+bool PlainSave::load(int16 dataVar, int32 size, int32 offset, const char *name,
+ Variables *variables) {
+
+ if ((size <= 0) || (offset != 0)) {
+ warning("Invalid size (%d) or offset (%d)", size, offset);
+ return false;
+ }
+
+ byte *vars = new byte[size];
+ byte *varSizes = new byte[size];
+
+ bool result = load(0, size, offset, name, vars, varSizes);
+
+ if (result && variables) {
+ if (!variables->copyFrom(dataVar, vars, varSizes, size)) {
+ delete[] vars;
+ delete[] varSizes;
+ warning("dataVar (%d) or size (%d) out of range", dataVar, size);
+ return false;
+ }
+ }
+
+ delete[] vars;
+ delete[] varSizes;
+
+ return result;
+}
+
+bool PlainSave::save(int16 dataVar, int32 size, int32 offset, const char *name,
const byte *variables, const byte *variableSizes) const {
if ((size <= 0) || (offset != 0)) {
@@ -286,6 +340,64 @@ void StagedSave::assertMode(Mode mode, const char *name) {
}
bool StagedSave::save(int16 dataVar, int32 size, int32 offset, const char *name,
+ const Variables *variables) {
+
+ if ((dataVar < 0) || (size <= 0) || (offset < 0)) {
+ warning("Invalid dataVar (%d), size (%d) or offset (%d)", dataVar, size, offset);
+ return false;
+ }
+
+ byte *vars = 0, *varSizes = 0;
+
+ if (variables) {
+ vars = new byte[size];
+ varSizes = new byte[size];
+
+ if (!variables->copyTo(dataVar, vars, varSizes, size)) {
+ delete[] vars;
+ delete[] varSizes;
+ warning("dataVar (%d) or size (%d) out of range", dataVar, size);
+ return false;
+ }
+ }
+
+ bool result = save(0, size, offset, name, vars, varSizes);
+
+ delete[] vars;
+ delete[] varSizes;
+
+ return result;
+}
+
+bool StagedSave::load(int16 dataVar, int32 size, int32 offset, const char *name,
+ Variables *variables) {
+
+ if ((dataVar < 0) || (size <= 0) || (offset < 0)) {
+ warning("Invalid dataVar (%d), size (%d) or offset (%d)", dataVar, size, offset);
+ return false;
+ }
+
+ byte *vars = new byte[size];
+ byte *varSizes = new byte[size];
+
+ bool result = load(0, size, offset, name, vars, varSizes);
+
+ if (result && variables) {
+ if (!variables->copyFrom(dataVar, vars, varSizes, size)) {
+ delete[] vars;
+ delete[] varSizes;
+ warning("dataVar (%d) or size (%d) out of range", dataVar, size);
+ return false;
+ }
+ }
+
+ delete[] vars;
+ delete[] varSizes;
+
+ return result;
+}
+
+bool StagedSave::save(int16 dataVar, int32 size, int32 offset, const char *name,
const byte *variables, const byte *variableSizes) {
if ((dataVar < 0) || (size <= 0) || (offset < 0)) {
diff --git a/engines/gob/saveload.h b/engines/gob/saveload.h
index 6c5ffe3bbe..29f7ee2594 100644
--- a/engines/gob/saveload.h
+++ b/engines/gob/saveload.h
@@ -30,6 +30,7 @@
#include "common/stream.h"
#include "gob/video.h"
+#include "gob/variables.h"
namespace Gob {
@@ -68,6 +69,11 @@ public:
~PlainSave();
bool save(int16 dataVar, int32 size, int32 offset, const char *name,
+ const Variables *variables);
+ bool load(int16 dataVar, int32 size, int32 offset, const char *name,
+ Variables *variables);
+
+ bool save(int16 dataVar, int32 size, int32 offset, const char *name,
const byte *variables, const byte *variableSizes) const;
bool load(int16 dataVar, int32 size, int32 offset, const char *name,
byte *variables, byte *variableSizes) const;
@@ -81,6 +87,11 @@ public:
void addStage(int32 size, bool endianed = true);
bool save(int16 dataVar, int32 size, int32 offset, const char *name,
+ const Variables *variables);
+ bool load(int16 dataVar, int32 size, int32 offset, const char *name,
+ Variables *variables);
+
+ bool save(int16 dataVar, int32 size, int32 offset, const char *name,
const byte *variables, const byte *variableSizes);
bool load(int16 dataVar, int32 size, int32 offset, const char *name,
byte *variables, byte *variableSizes);
diff --git a/engines/gob/saveload_v2.cpp b/engines/gob/saveload_v2.cpp
index 153b6dc2cd..a92fe8cf01 100644
--- a/engines/gob/saveload_v2.cpp
+++ b/engines/gob/saveload_v2.cpp
@@ -31,6 +31,7 @@
#include "gob/global.h"
#include "gob/game.h"
#include "gob/draw.h"
+#include "gob/inter.h"
namespace Gob {
@@ -209,9 +210,8 @@ bool SaveLoad_v2::loadGame(SaveFile &saveFile,
return false;
}
- SaveLoad::buildIndex(_vm->_global->_inter_variables + dataVar,
+ SaveLoad::buildIndex(_vm->_inter->_variables->getAddressOff8(dataVar, 600),
saveFile.destName, 15, 40);
- memset(_vm->_global->_inter_variablesSizes + dataVar, 0, 600);
} else {
int slot = getSlot(offset);
@@ -227,8 +227,7 @@ bool SaveLoad_v2::loadGame(SaveFile &saveFile,
return false;
}
- if (!_save.load(dataVar, size, 40, saveFile.destName,
- _vm->_global->_inter_variables, _vm->_global->_inter_variablesSizes))
+ if (!_save.load(dataVar, size, 40, saveFile.destName, _vm->_inter->_variables))
return false;
}
@@ -269,8 +268,7 @@ bool SaveLoad_v2::loadNotes(SaveFile &saveFile,
debugC(2, kDebugSaveLoad, "Loading the notes");
- return _notes.load(dataVar, size, offset, saveFile.destName,
- _vm->_global->_inter_variables, _vm->_global->_inter_variablesSizes);
+ return _notes.load(dataVar, size, offset, saveFile.destName, _vm->_inter->_variables);
}
bool SaveLoad_v2::saveGame(SaveFile &saveFile,
@@ -289,7 +287,7 @@ bool SaveLoad_v2::saveGame(SaveFile &saveFile,
return false;
}
- memcpy(_indexBuffer, _vm->_global->_inter_variables + dataVar, 600);
+ _vm->_inter->_variables->copyTo(dataVar, _indexBuffer, 0, 600);
_hasIndex = true;
} else {
@@ -318,8 +316,7 @@ bool SaveLoad_v2::saveGame(SaveFile &saveFile,
if(!_save.save(0, 40, 0, saveFile.destName, _indexBuffer + (slot * 40), sizes))
return false;
- if (!_save.save(dataVar, size, 40, saveFile.destName,
- _vm->_global->_inter_variables, _vm->_global->_inter_variablesSizes))
+ if (!_save.save(dataVar, size, 40, saveFile.destName, _vm->_inter->_variables))
return false;
}
@@ -353,8 +350,7 @@ bool SaveLoad_v2::saveNotes(SaveFile &saveFile,
debugC(2, kDebugSaveLoad, "Saving the notes");
- return _notes.save(dataVar, size, offset, saveFile.destName,
- _vm->_global->_inter_variables, _vm->_global->_inter_variablesSizes);
+ return _notes.save(dataVar, size, offset, saveFile.destName, _vm->_inter->_variables);
return false;
}
diff --git a/engines/gob/saveload_v3.cpp b/engines/gob/saveload_v3.cpp
index d8eadd5677..67879db3d1 100644
--- a/engines/gob/saveload_v3.cpp
+++ b/engines/gob/saveload_v3.cpp
@@ -31,6 +31,7 @@
#include "gob/global.h"
#include "gob/game.h"
#include "gob/draw.h"
+#include "gob/inter.h"
namespace Gob {
@@ -279,10 +280,8 @@ bool SaveLoad_v3::loadGame(SaveFile &saveFile,
return false;
}
- memcpy(_vm->_global->_inter_variables + dataVar,
- _propBuffer + offset, size);
- memcpy(_vm->_global->_inter_variablesSizes + dataVar,
- _propBuffer + offset + 500, size);
+ _vm->_inter->_variables->copyFrom(dataVar,
+ _propBuffer + offset, _propBuffer + offset + 500, size);
} else if (offset == 500) {
debugC(3, kDebugSaveLoad, "Loading save index");
@@ -294,9 +293,8 @@ bool SaveLoad_v3::loadGame(SaveFile &saveFile,
int slot = saveFile.slot;
- SaveLoad::buildIndex(_vm->_global->_inter_variables + dataVar,
+ SaveLoad::buildIndex(_vm->_inter->_variables->getAddressOff8(dataVar, 1200),
saveFile.destName, 30, 40, 1000);
- memset(_vm->_global->_inter_variablesSizes + dataVar, 0, 1200);
setCurrentSlot(saveFile.destName, slot);
@@ -314,8 +312,7 @@ bool SaveLoad_v3::loadGame(SaveFile &saveFile,
return false;
}
- if (!_save.load(dataVar, size, 540, saveFile.destName,
- _vm->_global->_inter_variables, _vm->_global->_inter_variablesSizes))
+ if (!_save.load(dataVar, size, 540, saveFile.destName, _vm->_inter->_variables))
return false;
}
@@ -356,8 +353,7 @@ bool SaveLoad_v3::loadNotes(SaveFile &saveFile,
debugC(2, kDebugSaveLoad, "Loading the notes");
- return _notes.load(dataVar, size, offset, saveFile.destName,
- _vm->_global->_inter_variables, _vm->_global->_inter_variablesSizes);
+ return _notes.load(dataVar, size, offset, saveFile.destName, _vm->_inter->_variables);
}
bool SaveLoad_v3::loadScreenshot(SaveFile &saveFile,
@@ -383,8 +379,7 @@ bool SaveLoad_v3::loadScreenshot(SaveFile &saveFile,
buildScreenshotIndex(buffer, saveFile.destName, 30);
setCurrentSlot(saveFile.destName, slot);
- memcpy(_vm->_global->_inter_variables + dataVar, buffer, 40);
- memset(_vm->_global->_inter_variablesSizes + dataVar, 0, 40);
+ memcpy(_vm->_inter->_variables->getAddressOff8(dataVar, 40), buffer, 40);
} else {
saveFile.slot = (offset - _screenshotOffset) / _screenshotSize;
@@ -453,10 +448,8 @@ bool SaveLoad_v3::saveGame(SaveFile &saveFile,
return false;
}
- memcpy(_propBuffer + offset,
- _vm->_global->_inter_variables + dataVar, size);
- memcpy(_propBuffer + offset + 500,
- _vm->_global->_inter_variablesSizes + dataVar, size);
+ _vm->_inter->_variables->copyTo(dataVar,
+ _propBuffer + offset, _propBuffer + offset + 500, size);
} else if (offset == 500) {
debugC(3, kDebugSaveLoad, "Saving save index");
@@ -466,7 +459,7 @@ bool SaveLoad_v3::saveGame(SaveFile &saveFile,
return false;
}
- memcpy(_indexBuffer, _vm->_global->_inter_variables + dataVar, size);
+ _vm->_inter->_variables->copyTo(dataVar, _indexBuffer, 0, size);
_hasIndex = true;
} else {
@@ -496,8 +489,7 @@ bool SaveLoad_v3::saveGame(SaveFile &saveFile,
if(!_save.save(0, 40, 500, saveFile.destName, _indexBuffer + (saveFile.slot * 40), 0))
return false;
- if (!_save.save(dataVar, size, 540, saveFile.destName,
- _vm->_global->_inter_variables, _vm->_global->_inter_variablesSizes))
+ if (!_save.save(dataVar, size, 540, saveFile.destName, _vm->_inter->_variables))
return false;
}
@@ -531,8 +523,7 @@ bool SaveLoad_v3::saveNotes(SaveFile &saveFile,
debugC(2, kDebugSaveLoad, "Saving the notes");
- return _notes.save(dataVar, size - 160, offset, saveFile.destName,
- _vm->_global->_inter_variables, _vm->_global->_inter_variablesSizes);
+ return _notes.save(dataVar, size - 160, offset, saveFile.destName, _vm->_inter->_variables);
return false;
}
diff --git a/engines/gob/saveload_v4.cpp b/engines/gob/saveload_v4.cpp
index 9b46bb26ac..a6548dd82d 100644
--- a/engines/gob/saveload_v4.cpp
+++ b/engines/gob/saveload_v4.cpp
@@ -27,8 +27,8 @@
#include "gob/gob.h"
#include "gob/saveload.h"
-#include "gob/global.h"
#include "gob/game.h"
+#include "gob/inter.h"
namespace Gob {
@@ -247,8 +247,8 @@ bool SaveLoad_v4::loadScreenProps(SaveFile &saveFile,
debugC(3, kDebugSaveLoad, "Loading screen properties (%d, %d, %d)",
dataVar, size, offset);
- memcpy(_vm->_global->_inter_variables + dataVar, _screenProps + offset, size);
- memcpy(_vm->_global->_inter_variablesSizes + dataVar, _screenProps + 256000 + offset, size);
+ _vm->_inter->_variables->copyFrom(dataVar,
+ _screenProps + offset, _screenProps + 256000 + offset, size);
return true;
}
@@ -269,10 +269,8 @@ bool SaveLoad_v4::loadGame(SaveFile &saveFile,
return false;
}
- memcpy(_vm->_global->_inter_variables + dataVar,
- _propBuffer + offset, size);
- memcpy(_vm->_global->_inter_variablesSizes + dataVar,
- _propBuffer + offset + 500, size);
+ _vm->_inter->_variables->copyFrom(dataVar,
+ _propBuffer + offset, _propBuffer + offset + 500, size);
} else if (offset == 500) {
debugC(3, kDebugSaveLoad, "Loading save index");
@@ -282,9 +280,8 @@ bool SaveLoad_v4::loadGame(SaveFile &saveFile,
return false;
}
- SaveLoad::buildIndex(_vm->_global->_inter_variables + dataVar,
+ SaveLoad::buildIndex(_vm->_inter->_variables->getAddressOff8(dataVar, 1200),
saveFile.destName, 30, 40, 1000);
- memset(_vm->_global->_inter_variablesSizes + dataVar, 0, 1200);
} else {
int slot = getSlot(offset);
@@ -300,8 +297,7 @@ bool SaveLoad_v4::loadGame(SaveFile &saveFile,
return false;
}
- if (!_save.load(dataVar, size, 540, saveFile.destName,
- _vm->_global->_inter_variables, _vm->_global->_inter_variablesSizes))
+ if (!_save.load(dataVar, size, 540, saveFile.destName, _vm->_inter->_variables))
return false;
}
@@ -340,8 +336,8 @@ bool SaveLoad_v4::saveScreenProps(SaveFile &saveFile,
debugC(3, kDebugSaveLoad, "Saving screen properties (%d, %d, %d)",
dataVar, size, offset);
- memcpy(_screenProps + offset, _vm->_global->_inter_variables + dataVar, size);
- memcpy(_screenProps + 256000 + offset, _vm->_global->_inter_variablesSizes + dataVar, size);
+ _vm->_inter->_variables->copyTo(dataVar,
+ _screenProps + offset, _screenProps + 256000 + offset, size);
return true;
}
@@ -362,10 +358,8 @@ bool SaveLoad_v4::saveGame(SaveFile &saveFile,
return false;
}
- memcpy(_propBuffer + offset,
- _vm->_global->_inter_variables + dataVar, size);
- memcpy(_propBuffer + offset + 500,
- _vm->_global->_inter_variablesSizes + dataVar, size);
+ _vm->_inter->_variables->copyTo(dataVar,
+ _propBuffer + offset, _propBuffer + offset + 500, size);
} else if (offset == 500) {
debugC(3, kDebugSaveLoad, "Saving save index");
@@ -375,7 +369,7 @@ bool SaveLoad_v4::saveGame(SaveFile &saveFile,
return false;
}
- memcpy(_indexBuffer, _vm->_global->_inter_variables + dataVar, size);
+ _vm->_inter->_variables->copyTo(dataVar, _indexBuffer, 0, size);
_hasIndex = true;
} else {
@@ -405,8 +399,7 @@ bool SaveLoad_v4::saveGame(SaveFile &saveFile,
if(!_save.save(0, 40, 500, saveFile.destName, _indexBuffer + (slot * 40), 0))
return false;
- if (!_save.save(dataVar, size, 540, saveFile.destName,
- _vm->_global->_inter_variables, _vm->_global->_inter_variablesSizes))
+ if (!_save.save(dataVar, size, 540, saveFile.destName, _vm->_inter->_variables))
return false;
}
diff --git a/engines/gob/sound/sound.cpp b/engines/gob/sound/sound.cpp
index a90afe0e27..2d2bf8e043 100644
--- a/engines/gob/sound/sound.cpp
+++ b/engines/gob/sound/sound.cpp
@@ -29,6 +29,7 @@
#include "gob/util.h"
#include "gob/dataio.h"
#include "gob/game.h"
+#include "gob/inter.h"
namespace Gob {
@@ -370,7 +371,7 @@ void Sound::blasterWaitEndPlay(bool interruptible, bool stopComp) {
while (_blaster->isPlaying() && !_vm->_quitRequested) {
if (interruptible && (_vm->_util->checkKey() == 0x11B)) {
- WRITE_VAR(57, -1);
+ WRITE_VAR(57, (uint32) -1);
return;
}
_vm->_util->longDelay(200);
diff --git a/engines/gob/variables.cpp b/engines/gob/variables.cpp
new file mode 100644
index 0000000000..af93252fb0
--- /dev/null
+++ b/engines/gob/variables.cpp
@@ -0,0 +1,309 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/endian.h"
+
+#include "gob/gob.h"
+#include "gob/variables.h"
+
+namespace Gob {
+
+Variables::Variables(uint32 size) {
+ _size = size;
+
+ _vars = new byte[_size];
+ _sizes = new byte[_size];
+}
+
+Variables::~Variables() {
+ delete[] _vars;
+ delete[] _sizes;
+}
+
+void Variables::clear() {
+ memset(_vars, 0, _size);
+
+ // All variables are 32 bit wide per default
+ memset(_sizes, 0, _size);
+ for (uint32 i = 0; i < _size; i += 4)
+ _sizes[i] = kSize32;
+}
+
+void Variables::clearSize(uint32 offset) {
+ uint32 inVar = offset % 4;
+ uint32 varOff = (offset >> 2) << 2;
+
+ // Clearing out the old size
+ for (uint32 i = 0; i < 4; i++) {
+ if (_sizes[varOff + i] == kSize32)
+ _sizes[varOff + i] = kSize8;
+ else if ((inVar == (i + 1)) && (_sizes[varOff + i] == kSize16))
+ _sizes[varOff + i] = kSize8;
+ }
+}
+
+void Variables::writeSize(uint32 offset, byte n) {
+ clearSize(offset);
+
+ _sizes[offset] = n;
+ // Setting following bytes of size to 8 bit, for easy clearing out afterwards
+ for (; n > 0; n--)
+ _sizes[offset + n] = kSize8;
+}
+
+void Variables::writeSizeString(uint32 offset, uint32 length) {
+ clearSize(offset);
+
+ memset(_sizes + offset, kSize8, length);
+}
+
+void Variables::writeVar8(uint32 var, uint8 value) {
+ writeOff8(var * 4, value);
+}
+
+void Variables::writeVar16(uint32 var, uint16 value) {
+ writeOff16(var * 4, value);
+}
+
+void Variables::writeVar32(uint32 var, uint32 value) {
+ writeOff32(var * 4, value);
+}
+
+void Variables::writeVarString(uint32 var, const char *value) {
+ writeOffString(var * 4, value);
+}
+
+void Variables::writeOff8(uint32 offset, uint8 value) {
+ write8(_vars + offset, value);
+ writeSize(offset, kSize8);
+}
+
+void Variables::writeOff16(uint32 offset, uint16 value) {
+ write16(_vars + offset, value);
+ writeSize(offset, kSize16);
+}
+
+void Variables::writeOff32(uint32 offset, uint32 value) {
+ write32(_vars + offset, value);
+ writeSize(offset, kSize32);
+}
+
+void Variables::writeOffString(uint32 offset, const char *value) {
+ strcpy((char *) (_vars + offset), value);
+ writeSizeString(offset, strlen(value));
+}
+
+uint8 Variables::readVar8(uint32 var) const {
+ return readOff8(var * 4);
+}
+
+uint16 Variables::readVar16(uint32 var) const {
+ return readOff16(var * 4);
+}
+
+uint32 Variables::readVar32(uint32 var) const {
+ return readOff32(var * 4);
+}
+
+void Variables::readVarString(uint32 var, char *value, uint32 length) {
+ readOffString(var * 4, value, length);
+}
+
+uint8 Variables::readOff8(uint32 offset) const {
+ return read8(_vars + offset);
+}
+
+uint16 Variables::readOff16(uint32 offset) const {
+ return read16(_vars + offset);
+}
+
+uint32 Variables::readOff32(uint32 offset) const {
+ return read32(_vars + offset);
+}
+
+void Variables::readOffString(uint32 offset, char *value, uint32 length) {
+ strncpy0(value, (const char *) (_vars + offset), length - 1);
+}
+
+const uint8 *Variables::getAddressVar8(uint32 var) const {
+ return getAddressOff8(var * 4);
+}
+
+uint8 *Variables::getAddressVar8(uint32 var, uint32 n) {
+ return getAddressOff8(var * 4, n);
+}
+
+const uint16 *Variables::getAddressVar16(uint32 var) const {
+ return getAddressOff16(var * 4);
+}
+
+uint16 *Variables::getAddressVar16(uint32 var, uint32 n) {
+ return getAddressOff16(var * 4, n);
+}
+
+const uint32 *Variables::getAddressVar32(uint32 var) const {
+ return getAddressOff32(var * 4);
+}
+
+uint32 *Variables::getAddressVar32(uint32 var, uint32 n) {
+ return getAddressOff32(var * 4, n);
+}
+
+const char *Variables::getAddressVarString(uint32 var) const {
+ return getAddressOffString(var * 4);
+}
+
+char *Variables::getAddressVarString(uint32 var, uint32 n) {
+ return getAddressOffString(var * 4, n);
+}
+
+const uint8 *Variables::getAddressOff8(uint32 offset) const {
+ return ((const uint8 *) (_vars + offset));
+}
+
+uint8 *Variables::getAddressOff8(uint32 offset, uint32 n) {
+ for (uint32 i = 0; i < n; i++)
+ writeSize(offset + i, kSize8);
+
+ return ((uint8 *) (_vars + offset));
+}
+
+const uint16 *Variables::getAddressOff16(uint32 offset) const {
+ return ((const uint16 *) (_vars + offset));
+}
+
+uint16 *Variables::getAddressOff16(uint32 offset, uint32 n) {
+ for (uint32 i = 0; i < n; i++)
+ writeSize(offset + i * 2, kSize16);
+
+ return ((uint16 *) (_vars + offset));
+}
+
+const uint32 *Variables::getAddressOff32(uint32 offset) const {
+ return ((const uint32 *) (_vars + offset));
+}
+
+uint32 *Variables::getAddressOff32(uint32 offset, uint32 n) {
+ for (uint32 i = 0; i < n; i++)
+ writeSize(offset + i * 4, kSize32);
+
+ return ((uint32 *) (_vars + offset));
+}
+
+const char *Variables::getAddressOffString(uint32 offset) const {
+ return ((const char *) (_vars + offset));
+}
+
+char *Variables::getAddressOffString(uint32 offset, uint32 n) {
+ writeSizeString(offset, (n == 0xFFFFFFFF) ? strlen((char *) (_vars + offset)) : n);
+
+ return ((char *) (_vars + offset));
+}
+
+bool Variables::copyTo(uint32 offset, byte *variables, byte *sizes, uint32 n) const {
+ if ((offset + n) > _size)
+ return false;
+
+ if (variables)
+ memcpy(variables, _vars + offset, n);
+ if (sizes)
+ memcpy(sizes, _sizes + offset, n);
+
+ return true;
+}
+
+bool Variables::copyFrom(uint32 offset, const byte *variables, const byte *sizes, uint32 n) {
+ if (((offset + n) > _size) || !variables || !sizes)
+ return false;
+
+ memcpy(_vars + offset, variables, n);
+ memcpy(_sizes + offset, sizes, n);
+
+ return true;
+}
+
+
+VariablesLE::VariablesLE(uint32 size) : Variables(size) {
+}
+
+VariablesLE::~VariablesLE() {
+}
+
+void VariablesLE::write8(byte *buf, uint8 data) const {
+ *buf = (byte) data;
+}
+
+void VariablesLE::write16(byte *buf, uint16 data) const {
+ WRITE_LE_UINT16(buf, data);
+}
+
+void VariablesLE::write32(byte *buf, uint32 data) const {
+ WRITE_LE_UINT32(buf, data);
+}
+
+uint8 VariablesLE::read8(const byte *buf) const {
+ return (uint8) *buf;
+}
+
+uint16 VariablesLE::read16(const byte *buf) const {
+ return READ_LE_UINT16(buf);
+}
+
+uint32 VariablesLE::read32(const byte *buf) const {
+ return READ_LE_UINT32(buf);
+}
+
+
+VariablesBE::VariablesBE(uint32 size) : Variables(size) {
+}
+
+VariablesBE::~VariablesBE() {
+}
+
+void VariablesBE::write8(byte *buf, uint8 data) const {
+ *buf = (byte) data;
+}
+
+void VariablesBE::write16(byte *buf, uint16 data) const {
+ WRITE_BE_UINT16(buf, data);
+}
+
+void VariablesBE::write32(byte *buf, uint32 data) const {
+ WRITE_BE_UINT32(buf, data);
+}
+
+uint8 VariablesBE::read8(const byte *buf) const {
+ return (uint8) *buf;
+}
+
+uint16 VariablesBE::read16(const byte *buf) const {
+ return READ_BE_UINT16(buf);
+}
+
+uint32 VariablesBE::read32(const byte *buf) const {
+ return READ_BE_UINT32(buf);
+}
+
+} // End of namespace Gob
diff --git a/engines/gob/variables.h b/engines/gob/variables.h
new file mode 100644
index 0000000000..5989ed38ee
--- /dev/null
+++ b/engines/gob/variables.h
@@ -0,0 +1,147 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef GOB_VARIABLES_H
+#define GOB_VARIABLES_H
+
+namespace Gob {
+
+class Variables {
+public:
+ Variables(uint32 size);
+ virtual ~Variables();
+
+ void writeVar8(uint32 var, uint8 value);
+ void writeVar16(uint32 var, uint16 value);
+ void writeVar32(uint32 var, uint32 value);
+
+ void writeVarString(uint32 var, const char *value);
+
+ void writeOff8(uint32 offset, uint8 value);
+ void writeOff16(uint32 offset, uint16 value);
+ void writeOff32(uint32 offset, uint32 value);
+
+ void writeOffString(uint32 offset, const char *value);
+
+ uint8 readVar8(uint32 var) const;
+ uint16 readVar16(uint32 var) const;
+ uint32 readVar32(uint32 var) const;
+
+ void readVarString(uint32 var, char *value, uint32 length);
+
+ uint8 readOff8(uint32 offset) const;
+ uint16 readOff16(uint32 offset) const;
+ uint32 readOff32(uint32 offset) const;
+
+ void readOffString(uint32 offset, char *value, uint32 length);
+
+
+ const uint8 *getAddressVar8(uint32 var) const;
+ uint8 *getAddressVar8(uint32 var, uint32 n = 1);
+
+ const uint16 *getAddressVar16(uint32 var) const;
+ uint16 *getAddressVar16(uint32 var, uint32 n = 1);
+
+ const uint32 *getAddressVar32(uint32 var) const;
+ uint32 *getAddressVar32(uint32 var, uint32 n = 1);
+
+ const char *getAddressVarString(uint32 var) const;
+ char *getAddressVarString(uint32 var, uint32 n = 0xFFFFFFFF);
+
+ const uint8 *getAddressOff8(uint32 offset) const;
+ uint8 *getAddressOff8(uint32 offset, uint32 n = 1);
+
+ const uint16 *getAddressOff16(uint32 offset) const;
+ uint16 *getAddressOff16(uint32 offset, uint32 n = 1);
+
+ const uint32 *getAddressOff32(uint32 offset) const;
+ uint32 *getAddressOff32(uint32 offset, uint32 n = 1);
+
+ const char *getAddressOffString(uint32 offset) const;
+ char *getAddressOffString(uint32 offset, uint32 n = 0xFFFFFFFF);
+
+
+ bool copyTo(uint32 offset, byte *variables, byte *sizes, uint32 n) const;
+ bool copyFrom(uint32 offset, const byte *variables, const byte *sizes, uint32 n);
+
+protected:
+ virtual void write8(byte *buf, uint8 data) const = 0;
+ virtual void write16(byte *buf, uint16 data) const = 0;
+ virtual void write32(byte *buf, uint32 data) const = 0;
+
+ virtual uint8 read8(const byte *buf) const = 0;
+ virtual uint16 read16(const byte *buf) const = 0;
+ virtual uint32 read32(const byte *buf) const = 0;
+
+private:
+ // Basically the number of additional bytes occupied
+ static const byte kSize8 = 0;
+ static const byte kSize16 = 1;
+ static const byte kSize32 = 3;
+
+ uint32 _size;
+
+ byte *_vars;
+ byte *_sizes;
+
+ void clear();
+ void clearSize(uint32 offset);
+ void writeSize(uint32 offset, byte n);
+ void writeSizeString(uint32 offset, uint32 length);
+};
+
+class VariablesLE : public Variables {
+public:
+ VariablesLE(uint32 size);
+ ~VariablesLE();
+
+protected:
+ void write8(byte *buf, uint8 data) const;
+ void write16(byte *buf, uint16 data) const;
+ void write32(byte *buf, uint32 data) const;
+
+ uint8 read8(const byte *buf) const;
+ uint16 read16(const byte *buf) const;
+ uint32 read32(const byte *buf) const;
+};
+
+class VariablesBE : public Variables {
+public:
+ VariablesBE(uint32 size);
+ ~VariablesBE();
+
+protected:
+ void write8(byte *buf, uint8 data) const;
+ void write16(byte *buf, uint16 data) const;
+ void write32(byte *buf, uint32 data) const;
+
+ uint8 read8(const byte *buf) const;
+ uint16 read16(const byte *buf) const;
+ uint32 read32(const byte *buf) const;
+};
+
+} // End of namespace Gob
+
+#endif // GOB_VARIABLES_H
diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp
index 4a337d48b4..909d39a63b 100644
--- a/engines/gob/videoplayer.cpp
+++ b/engines/gob/videoplayer.cpp
@@ -614,15 +614,15 @@ void VideoPlayer::writeVideoInfo(const char *videoFile, int16 varX, int16 varY,
WRITE_VAR_OFFSET(varY, y);
WRITE_VAR_OFFSET(varFrames, _primaryVideo->getVideo()->getFramesCount());
WRITE_VAR_OFFSET(varWidth, width);
- WRITE_VARO_UINT16(varHeight & 0xFFFFFFFC, height);
+ WRITE_VAR_OFFSET(varHeight, height);
primaryClose();
} else {
- WRITE_VAR_OFFSET(varX, -1);
- WRITE_VAR_OFFSET(varY, -1);
- WRITE_VAR_OFFSET(varFrames, -1);
- WRITE_VAR_OFFSET(varWidth, -1);
- WRITE_VAR_OFFSET(varHeight, -1);
+ WRITE_VAR_OFFSET(varX, (uint32) -1);
+ WRITE_VAR_OFFSET(varY, (uint32) -1);
+ WRITE_VAR_OFFSET(varFrames, (uint32) -1);
+ WRITE_VAR_OFFSET(varWidth, (uint32) -1);
+ WRITE_VAR_OFFSET(varHeight, (uint32) -1);
}
}