diff options
author | Travis Howell | 2006-10-20 02:10:51 +0000 |
---|---|---|
committer | Travis Howell | 2006-10-20 02:10:51 +0000 |
commit | ff574a63ee368cdb4889dd0e17966b4a1ae1f117 (patch) | |
tree | 40f477be1667843709f794e9628870ac3e3258cc /engines/agos/script.cpp | |
parent | e26954bcdb0a0277b5c6df4e785d1909d9865c7f (diff) | |
download | scummvm-rg350-ff574a63ee368cdb4889dd0e17966b4a1ae1f117.tar.gz scummvm-rg350-ff574a63ee368cdb4889dd0e17966b4a1ae1f117.tar.bz2 scummvm-rg350-ff574a63ee368cdb4889dd0e17966b4a1ae1f117.zip |
Split code into more specific files and cleanup
svn-id: r24394
Diffstat (limited to 'engines/agos/script.cpp')
-rw-r--r-- | engines/agos/script.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/engines/agos/script.cpp b/engines/agos/script.cpp index 3a03444a74..5ebdadfdbe 100644 --- a/engines/agos/script.cpp +++ b/engines/agos/script.cpp @@ -1333,6 +1333,87 @@ void AGOSEngine::o_unfreezeZones() { // ----------------------------------------------------------------------- +byte AGOSEngine::getByte() { + return *_codePtr++; +} + +int AGOSEngine::getNextWord() { + int16 a = (int16)READ_BE_UINT16(_codePtr); + _codePtr += 2; + return a; +} + +uint AGOSEngine::getNextStringID() { + return (uint16)getNextWord(); +} + +uint AGOSEngine::getVarOrByte() { + if (getGameType() == GType_ELVIRA1) { + return getVarOrWord(); + } else { + uint a = *_codePtr++; + if (a != 255) + return a; + return readVariable(*_codePtr++); + } +} + +uint AGOSEngine::getVarOrWord() { + uint a = READ_BE_UINT16(_codePtr); + _codePtr += 2; + if (getGameType() == GType_PP) { + if (a >= 60000 && a < 62048) { + return readVariable(a - 60000); + } + } else { + if (a >= 30000 && a < 30512) { + return readVariable(a - 30000); + } + } + return a; +} + +uint AGOSEngine::getVarWrapper() { + if (getGameType() == GType_ELVIRA1 || getGameType() == GType_PP) + return getVarOrWord(); + else + return getVarOrByte(); +} + +uint AGOSEngine::getNextVarContents() { + return (uint16)readVariable(getVarWrapper()); +} + +uint AGOSEngine::readVariable(uint variable) { + if (variable >= _numVars) + error("readVariable: Variable %d out of range", variable); + + if (getGameType() == GType_PP) { + return (uint16)_variableArray[variable]; + } else if (getGameType() == GType_FF) { + if (getBitFlag(83)) + return (uint16)_variableArray2[variable]; + else + return (uint16)_variableArray[variable]; + } else { + return _variableArray[variable]; + } +} + +void AGOSEngine::writeNextVarContents(uint16 contents) { + writeVariable(getVarWrapper(), contents); +} + +void AGOSEngine::writeVariable(uint variable, uint16 contents) { + if (variable >= _numVars) + error("writeVariable: Variable %d out of range", variable); + + if (getGameType() == GType_FF && getBitFlag(83)) + _variableArray2[variable] = contents; + else + _variableArray[variable] = contents; +} + int AGOSEngine::runScript() { int opcode; bool flag; |