aboutsummaryrefslogtreecommitdiff
path: root/scumm/script.cpp
diff options
context:
space:
mode:
authorMax Horn2002-12-16 12:12:31 +0000
committerMax Horn2002-12-16 12:12:31 +0000
commitc4b6fa7f70a6a8fdad10460230fb160e78ad5df2 (patch)
tree861960e88c2864341bb137b88a1dbead514e33a4 /scumm/script.cpp
parent254d8c81f9b50839247709103edc0dc85934bc42 (diff)
downloadscummvm-rg350-c4b6fa7f70a6a8fdad10460230fb160e78ad5df2.tar.gz
scummvm-rg350-c4b6fa7f70a6a8fdad10460230fb160e78ad5df2.tar.bz2
scummvm-rg350-c4b6fa7f70a6a8fdad10460230fb160e78ad5df2.zip
refactoring: use inheritance to mode the relations between the various engine versions. E.g. the V6 opcodes are now in Scumm_v6, the V5 opcodes in Scumm_v5 (from which we now derive v2-v4. which is a bit odd - maybe we should move the v5 opcodes to Scumm_v3 ?)
svn-id: r5994
Diffstat (limited to 'scumm/script.cpp')
-rw-r--r--scumm/script.cpp63
1 files changed, 40 insertions, 23 deletions
diff --git a/scumm/script.cpp b/scumm/script.cpp
index 4ef4175921..c34f9385a3 100644
--- a/scumm/script.cpp
+++ b/scumm/script.cpp
@@ -277,17 +277,37 @@ void Scumm::getScriptEntryPoint()
/* Execute a script - Read opcode, and execute it from the table */
void Scumm::executeScript()
{
-
- OpcodeProc op;
while (_currentScript != 0xFF) {
_opcode = fetchScriptByte();
_scriptPointerStart = _scriptPointer;
vm.slot[_currentScript].didexec = 1;
- debug(8, "Script %d: [%X] %s()", vm.slot[_currentScript].number, _opcode, _opcodes[_opcode].desc);
- op = getOpcode(_opcode);
- (this->*op) ();
+ debug(8, "Script %d: [%X] %s()", vm.slot[_currentScript].number, _opcode, getOpcodeDesc(_opcode));
+ executeOpcode(_opcode);
}
-CHECK_HEAP}
+ CHECK_HEAP;
+}
+
+void Scumm_v5::executeOpcode(int i)
+{
+ OpcodeProcV5 op = _opcodesV5[i].proc;
+ (this->*op) ();
+}
+
+const char *Scumm_v5::getOpcodeDesc(int i)
+{
+ return _opcodesV5[i].desc;
+}
+
+void Scumm_v6::executeOpcode(int i)
+{
+ OpcodeProcV6 op = _opcodesV6[i].proc;
+ (this->*op) ();
+}
+
+const char *Scumm_v6::getOpcodeDesc(int i)
+{
+ return _opcodesV6[i].desc;
+}
byte Scumm::fetchScriptByte()
{
@@ -468,6 +488,20 @@ void Scumm::setResult(int value)
writeVar(_resultVarNumber, value);
}
+void Scumm::push(int a)
+{
+ assert(_scummStackPos >= 0 && (unsigned int)_scummStackPos <= ARRAYSIZE(_scummStack));
+ _scummStack[_scummStackPos++] = a;
+}
+
+int Scumm::pop()
+{
+ if ((_scummStackPos < 1) || ((unsigned int)_scummStackPos > ARRAYSIZE(_scummStack))) {
+ error("No items on stack to pop() for %s (0x%X) at [%d-%d]\n", getOpcodeDesc(_opcode), _opcode, _roomResource, vm.slot[_currentScript].number);
+ }
+
+ return _scummStack[--_scummStackPos];
+}
void Scumm::drawBox(int x, int y, int x2, int y2, int color)
{
int top, bottom, count;
@@ -865,23 +899,6 @@ int Scumm::getVerbEntrypoint(int obj, int entry)
return verboffs + READ_LE_UINT16(verbptr + 1);
}
-
-void Scumm::push(int a)
-{
- assert(_scummStackPos >= 0 && (unsigned int)_scummStackPos <= ARRAYSIZE(_scummStack));
- _scummStack[_scummStackPos++] = a;
-}
-
-int Scumm::pop()
-{
- if ((_scummStackPos < 1) || ((unsigned int)_scummStackPos > ARRAYSIZE(_scummStack))) {
- error("No items on stack to pop() for %s (0x%X) at [%d-%d]\n", _opcodes[_opcode].desc, _opcode, _roomResource, vm.slot[_currentScript].number);
- }
-
- return _scummStack[--_scummStackPos];
-}
-
-
void Scumm::endCutscene()
{
ScriptSlot *ss = &vm.slot[_currentScript];