diff options
author | Max Horn | 2003-05-04 12:02:37 +0000 |
---|---|---|
committer | Max Horn | 2003-05-04 12:02:37 +0000 |
commit | 245c55629dc9007b1c2fc4a02c029a395e807672 (patch) | |
tree | 6b39be45cf7c6f1e97d1fe95182c580f53c03969 /scumm/script.cpp | |
parent | 8f4222fd1b2299a7985b43d6001da54df267ff28 (diff) | |
download | scummvm-rg350-245c55629dc9007b1c2fc4a02c029a395e807672.tar.gz scummvm-rg350-245c55629dc9007b1c2fc4a02c029a395e807672.tar.bz2 scummvm-rg350-245c55629dc9007b1c2fc4a02c029a395e807672.zip |
cleanup
svn-id: r7313
Diffstat (limited to 'scumm/script.cpp')
-rw-r--r-- | scumm/script.cpp | 94 |
1 files changed, 44 insertions, 50 deletions
diff --git a/scumm/script.cpp b/scumm/script.cpp index 8eb7d1b99f..ac97e4343f 100644 --- a/scumm/script.cpp +++ b/scumm/script.cpp @@ -354,10 +354,21 @@ int Scumm::getVarOrDirectWord(byte mask) { int Scumm::readVar(uint var) { int a; -#ifdef BYPASS_COPY_PROT - static byte copyprotbypassed; +#if defined(BYPASS_COPY_PROT) + static byte copyprotbypassed = false; #endif + debug(9, "readvar(%d)", var); + + if (var & 0x2000 && !(_features & GF_NEW_OPCODES)) { + a = fetchScriptWord(); + if (a & 0x2000) + var += readVar(a & ~0x2000); + else + var += a & 0xFFF; + var &= ~0x2000; + } + if (!(var & 0xF000)) { #if defined(BYPASS_COPY_PROT) if (var == 490 && _gameId == GID_MONKEY2 && !copyprotbypassed) { @@ -368,47 +379,31 @@ int Scumm::readVar(uint var) { var = 266; } #endif - checkRange(_numVariables - 1, 0, var, "Variable %d out of range(r)"); - return _vars[var]; } - if (var & 0x2000 && !(_features & GF_NEW_OPCODES)) { - a = fetchScriptWord(); - if (a & 0x2000) - var += readVar(a & ~0x2000); - else - var += a & 0xFFF; - var &= ~0x2000; - } - - if (!(var & 0xF000)) - return _vars[var]; - if (var & 0x8000) { if ((_gameId == GID_ZAK256) || (_features & GF_OLD_BUNDLE)) { - // Emulate a wierd hack in Zak256 to read individual - // bits of a normal global - int b = (var & 0x000F); - var &= 0x0FFF; - var >>= 4; - checkRange(_numVariables - 1, 0, var, "Variable %d out of range(rzb)"); + int bit = var & 0xF; + var = (var >> 4) & 0xFF; + #if defined(BYPASS_COPY_PROT) // INDY3 checks this during the game... - if (var == 94 && _gameId == GID_INDY3 && b == 4) { + if (_gameId == GID_INDY3 && var == 94 && bit == 4) { return 0; - } else if (var == 214 && b == 15 && _gameId == GID_LOOM && !copyprotbypassed) { + } else if (_gameId == GID_LOOM && var == 214 && bit == 15 && !copyprotbypassed) { copyprotbypassed = true; return 0; - } else + } #endif - return (_vars[ var ] & ( 1 << b ) ) ? 1 : 0; + checkRange(_numVariables - 1, 0, var, "Variable %d out of range(rzb)"); + return (_vars[ var ] & ( 1 << bit ) ) ? 1 : 0; + } else { + var &= 0x7FFF; + checkRange(_numBitVariables - 1, 0, var, "Bit variable %d out of range(r)"); + return (_bitVars[var >> 3] & (1 << (var & 7))) ? 1 : 0; } - - var &= 0x7FFF; - checkRange(_numBitVariables - 1, 0, var, "Bit variable %d out of range(r)"); - return (_bitVars[var >> 3] & (1 << (var & 7))) ? 1 : 0; } if (var & 0x4000) { @@ -447,30 +442,29 @@ void Scumm::writeVar(uint var, int value) { if (var & 0x8000) { if ((_gameId == GID_ZAK256) || (_features & GF_OLD_BUNDLE)) { - // Emulate a wierd hack in Zak256 to read individual - // bits of a normal global - int b = (var & 0x000F); - var &= 0x7FFF; - var >>= 4; + // In the old games, the bit variables were using the same memory + // as the normal variables! + int bit = var & 0xF; + var = (var >> 4) & 0xFF; checkRange(_numVariables - 1, 0, var, "Variable %d out of range(wzb)"); if(value) - _vars[ var ] |= ( 1 << b ); + _vars[var] |= ( 1 << bit ); else - _vars[ var ] &= ~( 1 << b ); - return; + _vars[var] &= ~( 1 << bit ); + } else { + var &= 0x7FFF; + checkRange(_numBitVariables - 1, 0, var, "Bit variable %d out of range(w)"); + + // FIXME: Enable Indy4 mousefighting by default. + // is there a better place to put this? + if (_gameId == GID_INDY4 && var == 107 && vm.slot[_currentScript].number == 1) + value = 1; + + if (value) + _bitVars[var >> 3] |= (1 << (var & 7)); + else + _bitVars[var >> 3] &= ~(1 << (var & 7)); } - var &= 0x7FFF; - checkRange(_numBitVariables - 1, 0, var, "Bit variable %d out of range(w)"); - - /* FIXME: Enable Indy4 mousefighting by default. - is there a better place to put this? */ - if (_gameId == GID_INDY4 && var == 107 && vm.slot[_currentScript].number == 1) - value = 1; - - if (value) - _bitVars[var >> 3] |= (1 << (var & 7)); - else - _bitVars[var >> 3] &= ~(1 << (var & 7)); return; } |