diff options
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/resource.cpp | 1 | ||||
-rw-r--r-- | scumm/script.cpp | 32 | ||||
-rw-r--r-- | scumm/scumm.cpp | 1 | ||||
-rw-r--r-- | scumm/scumm.h | 1 |
4 files changed, 24 insertions, 11 deletions
diff --git a/scumm/resource.cpp b/scumm/resource.cpp index 508b9e211f..cd2eab1725 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -2429,6 +2429,7 @@ void ScummEngine::allocateArrays() { _inventory = (uint16 *)calloc(_numInventory, sizeof(uint16)); _verbs = (VerbSlot *)calloc(_numVerbs, sizeof(VerbSlot)); _objs = (ObjectData *)calloc(_numLocalObjects, sizeof(ObjectData)); + _roomVars = (int32 *)calloc(_numBitVariables, sizeof(int32)); _scummVars = (int32 *)calloc(_numVariables, sizeof(int32)); _bitVars = (byte *)calloc(_numBitVariables >> 3, 1); _images = (uint16 *)calloc(_numImages, sizeof(uint16)); diff --git a/scumm/script.cpp b/scumm/script.cpp index 8282074d88..759e248784 100644 --- a/scumm/script.cpp +++ b/scumm/script.cpp @@ -477,13 +477,6 @@ int ScummEngine::fetchScriptWordSigned() { } int ScummEngine::readVar(uint var) { - // HACK Seems to variable difference - // Correct values for now - if (_gameId == GID_PAJAMA && var == 32770) - return 5; - else if (_gameId == GID_WATER && var == 32770) - return 23 -; int a; static byte copyprotbypassed; if (!_copyProtection) @@ -523,7 +516,12 @@ int ScummEngine::readVar(uint var) { } if (var & 0x8000) { - if ((_gameId == GID_ZAK256) || (_features & GF_OLD_BUNDLE) || + if (_gameId == GID_PAJAMA) { + var &= 0xFFF; + checkRange(_numBitVariables, 0, var, "Room variable %d out of range(w)"); + return _roomVars[var]; + + } else if ((_gameId == GID_ZAK256) || (_features & GF_OLD_BUNDLE) || (_gameId == GID_LOOM && (_features & GF_FMTOWNS))) { int bit = var & 0xF; var = (var >> 4) & 0xFF; @@ -557,7 +555,10 @@ int ScummEngine::readVar(uint var) { var &= 0xFFF; } - checkRange(20, 0, var, "Local variable %d out of range(r)"); + if (_heversion >= 72) + checkRange(24, 0, var, "Local variable %d out of range(r)"); + else + checkRange(20, 0, var, "Local variable %d out of range(r)"); return vm.localvar[_currentScript][var]; } @@ -598,7 +599,12 @@ void ScummEngine::writeVar(uint var, int value) { } if (var & 0x8000) { - if ((_gameId == GID_ZAK256) || (_features & GF_OLD_BUNDLE) || + if (_gameId == GID_PAJAMA) { + var &= 0xFFF; + checkRange(_numBitVariables, 0, var, "Room variable %d out of range(w)"); + _roomVars[var] = value; + + } else if ((_gameId == GID_ZAK256) || (_features & GF_OLD_BUNDLE) || (_gameId == GID_LOOM && (_features & GF_FMTOWNS))) { // In the old games, the bit variables were using the same memory // as the normal variables! @@ -628,7 +634,11 @@ void ScummEngine::writeVar(uint var, int value) { var &= 0xFFF; } - checkRange(20, 0, var, "Local variable %d out of range(w)"); + if (_heversion >= 72) + checkRange(24, 0, var, "Local variable %d out of range(w)"); + else + checkRange(20, 0, var, "Local variable %d out of range(w)"); + vm.localvar[_currentScript][var] = value; return; } diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp index 15d80840b9..7803b53aab 100644 --- a/scumm/scumm.cpp +++ b/scumm/scumm.cpp @@ -491,6 +491,7 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS _inventory = NULL; _newNames = NULL; _scummVars = NULL; + _roomVars = NULL; _varwatch = 0; _bitVars = NULL; _numVariables = 0; diff --git a/scumm/scumm.h b/scumm/scumm.h index 5f1c0abfd6..1fa7ca9729 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -472,6 +472,7 @@ public: protected: int16 _varwatch; + int32 *_roomVars; int32 *_scummVars; byte *_bitVars; |