diff options
| author | Torbjörn Andersson | 2004-03-17 09:03:15 +0000 |
|---|---|---|
| committer | Torbjörn Andersson | 2004-03-17 09:03:15 +0000 |
| commit | 4c3a68027f7f84a58664f77c847d24ab5b9757e4 (patch) | |
| tree | bf20e888b9ea1cc2045df84aad12ef1cd54ec7de /sword2/interpreter.cpp | |
| parent | 03200025dfb030d887ff9b07d180a8f9e2f225bc (diff) | |
| download | scummvm-rg350-4c3a68027f7f84a58664f77c847d24ab5b9757e4.tar.gz scummvm-rg350-4c3a68027f7f84a58664f77c847d24ab5b9757e4.tar.bz2 scummvm-rg350-4c3a68027f7f84a58664f77c847d24ab5b9757e4.zip | |
Use the same syntax for accessing script variables as BS1 does, i.e. now
it's Logic::_scriptVars[ID] instead of just ID. Apart from looking cool, it
makes it much easier to tell the difference between variables and constants
when looking at the code.
Of course, this sort of sweeping changes is jolly good for introducing
truly weird regressions, which is why I waited until after 0.6.0.
svn-id: r13331
Diffstat (limited to 'sword2/interpreter.cpp')
| -rw-r--r-- | sword2/interpreter.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/sword2/interpreter.cpp b/sword2/interpreter.cpp index 31803c065e..c84360ffdd 100644 --- a/sword2/interpreter.cpp +++ b/sword2/interpreter.cpp @@ -25,6 +25,8 @@ namespace Sword2 { +#define STACK_SIZE 10 + // The machine code table #define OPCODE(x) { &Logic::x, #x } @@ -194,9 +196,7 @@ do { \ #define pop() (assert(stackPtr < ARRAYSIZE(stack)), stack[--stackPtr]) -void Logic::setGlobalInterpreterVariables(int32 *vars) { - _globals = vars; -} +uint32 *Logic::_scriptVars = NULL; int Logic::runScript(char *scriptData, char *objectData, uint32 *offset) { // Interestingly, unlike our BASS engine the stack is a local variable. @@ -315,9 +315,9 @@ int Logic::runScript(char *scriptData, char *objectData, uint32 *offset) { // WORKAROUND: Pyramid Bug. See explanation above. - if (checkPyramidBug && _globals[913] == 1) { + if (checkPyramidBug && _scriptVars[913] == 1) { warning("Working around Titipoco script bug (the \"Pyramid Bug\")"); - _globals[913] = 0; + _scriptVars[913] = 0; } break; @@ -355,9 +355,9 @@ int Logic::runScript(char *scriptData, char *objectData, uint32 *offset) { case CP_PUSH_GLOBAL_VAR32: // Push a global variable Read16ip(parameter); - assert(_globals); - debug(5, "Push global var %d (%d)", parameter, _globals[parameter]); - push(_globals[parameter]); + assert(_scriptVars); + debug(5, "Push global var %d (%d)", parameter, _scriptVars[parameter]); + push(_scriptVars[parameter]); break; case CP_PUSH_LOCAL_ADDR: // push the address of a local variable @@ -398,7 +398,7 @@ int Logic::runScript(char *scriptData, char *objectData, uint32 *offset) { Read16ip(parameter); value = pop(); debug(5, "Pop %d into global var %d", value, parameter); - _globals[parameter] = value; + _scriptVars[parameter] = value; break; case CP_ADDNPOP_LOCAL_VAR32: Read16ip(parameter); @@ -418,15 +418,15 @@ int Logic::runScript(char *scriptData, char *objectData, uint32 *offset) { // Add and pop a global variable Read16ip(parameter); value = pop(); - _globals[parameter] += value; - debug(5, "+= %d into global var %d -> %d", value, parameter, _globals[parameter]); + _scriptVars[parameter] += value; + debug(5, "+= %d into global var %d -> %d", value, parameter, _scriptVars[parameter]); break; case CP_SUBNPOP_GLOBAL_VAR32: // Sub and pop a global variable Read16ip(parameter); value = pop(); - _globals[parameter] -= value; - debug(5, "-= %d into global var %d -> %d", value, parameter, _globals[parameter]); + _scriptVars[parameter] -= value; + debug(5, "-= %d into global var %d -> %d", value, parameter, _scriptVars[parameter]); break; // Jump opcodes |
