diff options
-rw-r--r-- | scumm/intern.h | 14 | ||||
-rw-r--r-- | scumm/script.cpp | 18 | ||||
-rw-r--r-- | scumm/script_v2.cpp | 106 | ||||
-rw-r--r-- | scumm/script_v5.cpp | 32 | ||||
-rw-r--r-- | scumm/scumm.h | 2 |
5 files changed, 48 insertions, 124 deletions
diff --git a/scumm/intern.h b/scumm/intern.h index c120d1ee2b..59145b7472 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -47,6 +47,10 @@ protected: virtual void decodeParseString(); int getWordVararg(int *ptr); + virtual int getVar(); + virtual int getVarOrDirectByte(byte mask); + virtual int getVarOrDirectWord(byte mask); + /* Version 5 script opcodes */ void o5_actorFollowCamera(); void o5_actorFromPos(); @@ -196,6 +200,8 @@ protected: virtual void decodeParseString(); + virtual int getVar(); + void getResultPosIndirect(); virtual void getResultPos(); virtual int readVar(uint var); @@ -243,13 +249,6 @@ protected: void o2_walkActorTo(); void o2_putActor(); void o2_isEqual(); - void o2_isGreater(); - void o2_isGreaterEqual(); - void o2_lessOrEqual(); - void o2_isLess(); - void o2_isNotEqual(); - void o2_equalZero(); - void o2_notEqualZero(); void o2_startScript(); void o2_panCameraTo(); void o2_setActorElevation(); @@ -262,7 +261,6 @@ protected: void o2_getActorY(); void o2_loadRoomWithEgo(); void o2_setOwnerOf(); - void o2_delayVariable(); void o2_matrixOps(); void o2_setCameraAt(); void o2_roomOps(); diff --git a/scumm/script.cpp b/scumm/script.cpp index ac97e4343f..4ff48ffca8 100644 --- a/scumm/script.cpp +++ b/scumm/script.cpp @@ -330,24 +330,6 @@ int Scumm::fetchScriptWordSigned() { return (int16)fetchScriptWord(); } -int Scumm::getVarOrDirectByte(byte mask) { - if (_opcode & mask) - if (_features & GF_AFTER_V2) - return readVar(fetchScriptByte()); - else - return readVar(fetchScriptWord()); - return fetchScriptByte(); -} - -int Scumm::getVarOrDirectWord(byte mask) { - if (_opcode & mask) - if (_features & GF_AFTER_V2) - return readVar(fetchScriptByte()); - else - return readVar(fetchScriptWord()); - return (int16)fetchScriptWord(); -} - #ifndef BYPASS_COPY_PROT #define BYPASS_COPY_PROT #endif diff --git a/scumm/script_v2.cpp b/scumm/script_v2.cpp index e892daf583..ee70356a0d 100644 --- a/scumm/script_v2.cpp +++ b/scumm/script_v2.cpp @@ -38,12 +38,12 @@ void Scumm_v2::setupOpcodes() { OPCODE(o5_startMusic), OPCODE(o5_getActorRoom), /* 04 */ - OPCODE(o2_isGreaterEqual), + OPCODE(o5_isGreaterEqual), OPCODE(o2_drawObject), OPCODE(o5_getActorElevation), OPCODE(o2_setState08), /* 08 */ - OPCODE(o2_isNotEqual), + OPCODE(o5_isNotEqual), OPCODE(o5_faceActor), OPCODE(o2_assignVarWordIndirect), OPCODE(o2_setObjY), @@ -83,10 +83,10 @@ void Scumm_v2::setupOpcodes() { OPCODE(o5_setVarRange), OPCODE(o2_ifNotState04), /* 28 */ - OPCODE(o2_equalZero), + OPCODE(o5_equalZero), OPCODE(o2_setOwnerOf), OPCODE(o2_addIndirect), - OPCODE(o2_delayVariable), + OPCODE(o5_delayVariable), /* 2C */ OPCODE(o2_assignVarByte), OPCODE(o5_putActorInRoom), @@ -103,7 +103,7 @@ void Scumm_v2::setupOpcodes() { OPCODE(o2_walkActorToObject), OPCODE(o2_setState01), /* 38 */ - OPCODE(o2_lessOrEqual), + OPCODE(o5_lessOrEqual), OPCODE(o2_doSentence), OPCODE(o5_subtract), OPCODE(o2_waitForActor), @@ -118,7 +118,7 @@ void Scumm_v2::setupOpcodes() { OPCODE(o2_startScript), OPCODE(o2_getActorX), /* 44 */ - OPCODE(o2_isLess), + OPCODE(o5_isLess), OPCODE(o2_drawObject), OPCODE(o5_increment), OPCODE(o2_setState08), @@ -183,7 +183,7 @@ void Scumm_v2::setupOpcodes() { OPCODE(o2_walkActorToObject), OPCODE(o2_clearState01), /* 78 */ - OPCODE(o2_isGreater), + OPCODE(o5_isGreater), OPCODE(o2_doSentence), OPCODE(o2_verbOps), OPCODE(o2_getActorWalkBox), @@ -198,12 +198,12 @@ void Scumm_v2::setupOpcodes() { OPCODE(o5_startMusic), OPCODE(o5_getActorRoom), /* 84 */ - OPCODE(o2_isGreaterEqual), + OPCODE(o5_isGreaterEqual), OPCODE(o2_drawObject), OPCODE(o5_getActorElevation), OPCODE(o2_setState08), /* 88 */ - OPCODE(o2_isNotEqual), + OPCODE(o5_isNotEqual), OPCODE(o5_faceActor), OPCODE(o2_assignVarWordIndirect), OPCODE(o2_setObjY), @@ -243,7 +243,7 @@ void Scumm_v2::setupOpcodes() { OPCODE(o5_setVarRange), OPCODE(o2_setState04), /* A8 */ - OPCODE(o2_notEqualZero), + OPCODE(o5_notEqualZero), OPCODE(o2_setOwnerOf), OPCODE(o2_addIndirect), OPCODE(o2_dummy), @@ -263,7 +263,7 @@ void Scumm_v2::setupOpcodes() { OPCODE(o2_walkActorToObject), OPCODE(o2_setState02), /* B8 */ - OPCODE(o2_lessOrEqual), + OPCODE(o5_lessOrEqual), OPCODE(o2_doSentence), OPCODE(o5_subtract), OPCODE(o2_waitForActor), @@ -278,7 +278,7 @@ void Scumm_v2::setupOpcodes() { OPCODE(o2_startScript), OPCODE(o2_getActorX), /* C4 */ - OPCODE(o2_isLess), + OPCODE(o5_isLess), OPCODE(o2_drawObject), OPCODE(o5_decrement), OPCODE(o2_clearState08), @@ -343,7 +343,7 @@ void Scumm_v2::setupOpcodes() { OPCODE(o2_walkActorToObject), OPCODE(o2_clearState01), /* F8 */ - OPCODE(o2_isGreater), + OPCODE(o5_isGreater), OPCODE(o2_doSentence), OPCODE(o2_verbOps), OPCODE(o2_getActorWalkBox), @@ -366,6 +366,10 @@ const char *Scumm_v2::getOpcodeDesc(int i) { return _opcodesV2[i].desc; } +int Scumm_v2::getVar() { + return readVar(fetchScriptByte()); +} + void Scumm_v2::decodeParseString() { byte buffer[256]; // FIXME byte *ptr = buffer; @@ -772,7 +776,7 @@ void Scumm_v2::o2_verbOps() { } void Scumm_v2::o2_isEqual() { - int a = readVar(fetchScriptByte()); + int a = getVar(); int b = getVarOrDirectWord(0x80); if (b == a) @@ -782,74 +786,6 @@ void Scumm_v2::o2_isEqual() { } -void Scumm_v2::o2_isGreater() { - int16 a = readVar(fetchScriptByte()); - int16 b = getVarOrDirectWord(0x80); - - if (b > a) - ignoreScriptWord(); - else - o5_jumpRelative(); -} - -void Scumm_v2::o2_isGreaterEqual() { - int16 a = readVar(fetchScriptByte()); - int16 b = getVarOrDirectWord(0x80); - - if (b >= a) - ignoreScriptWord(); - else - o5_jumpRelative(); -} - -void Scumm_v2::o2_isLess() { - int16 a = readVar(fetchScriptByte()); - int16 b = getVarOrDirectWord(0x80); - - if (b < a) - ignoreScriptWord(); - else - o5_jumpRelative(); -} - -void Scumm_v2::o2_lessOrEqual() { - int16 a = readVar(fetchScriptByte()); - int16 b = getVarOrDirectWord(0x80); - - if (b <= a) - ignoreScriptWord(); - else - o5_jumpRelative(); -} - -void Scumm_v2::o2_isNotEqual() { - int16 a = readVar(fetchScriptByte()); - int16 b = getVarOrDirectWord(0x80); - - if (b != a) - ignoreScriptWord(); - else - o5_jumpRelative(); -} - -void Scumm_v2::o2_notEqualZero() { - int a = readVar(fetchScriptByte()); - - if (a != 0) - ignoreScriptWord(); - else - o5_jumpRelative(); -} - -void Scumm_v2::o2_equalZero() { - int a = readVar(fetchScriptByte()); - - if (a == 0) - ignoreScriptWord(); - else - o5_jumpRelative(); -} - void Scumm_v2::o2_doSentence() { int a; SentenceTab *st; @@ -1053,12 +989,6 @@ void Scumm_v2::o2_setOwnerOf() { runHook(0); } -void Scumm_v2::o2_delayVariable() { - vm.slot[_currentScript].delay = readVar(fetchScriptByte()); - vm.slot[_currentScript].status = 1; - o5_breakHere(); -} - void Scumm_v2::o2_delay() { int delay = fetchScriptByte(); delay |= fetchScriptByte() << 8; diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp index c388e0131a..ed69b94606 100644 --- a/scumm/script_v5.cpp +++ b/scumm/script_v5.cpp @@ -366,6 +366,22 @@ const char *Scumm_v5::getOpcodeDesc(int i) { return _opcodesV5[i].desc; } +int Scumm_v5::getVar() { + return readVar(fetchScriptWord()); +} + +int Scumm_v5::getVarOrDirectByte(byte mask) { + if (_opcode & mask) + return getVar(); + return fetchScriptByte(); +} + +int Scumm_v5::getVarOrDirectWord(byte mask) { + if (_opcode & mask) + return getVar(); + return (int16)fetchScriptWord(); +} + void Scumm_v5::o5_actorFollowCamera() { actorFollowCamera(getVarOrDirectByte(0x80)); } @@ -697,7 +713,7 @@ void Scumm_v5::o5_delay() { } void Scumm_v5::o5_delayVariable() { - vm.slot[_currentScript].delay = readVar(fetchScriptWord()); + vm.slot[_currentScript].delay = getVar(); vm.slot[_currentScript].status = 1; o5_breakHere(); } @@ -1216,7 +1232,7 @@ void Scumm_v5::o5_isEqual() { } void Scumm_v5::o5_isGreater() { - int16 a = readVar(fetchScriptWord()); + int16 a = getVar(); int16 b = getVarOrDirectWord(0x80); if (b > a) ignoreScriptWord(); @@ -1225,7 +1241,7 @@ void Scumm_v5::o5_isGreater() { } void Scumm_v5::o5_isGreaterEqual() { - int16 a = readVar(fetchScriptWord()); + int16 a = getVar(); int16 b = getVarOrDirectWord(0x80); if (b >= a) ignoreScriptWord(); @@ -1234,7 +1250,7 @@ void Scumm_v5::o5_isGreaterEqual() { } void Scumm_v5::o5_isLess() { - int16 a = readVar(fetchScriptWord()); + int16 a = getVar(); int16 b = getVarOrDirectWord(0x80); if (b < a) @@ -1244,7 +1260,7 @@ void Scumm_v5::o5_isLess() { } void Scumm_v5::o5_lessOrEqual() { - int16 a = readVar(fetchScriptWord()); + int16 a = getVar(); int16 b = getVarOrDirectWord(0x80); if (b <= a) ignoreScriptWord(); @@ -1253,7 +1269,7 @@ void Scumm_v5::o5_lessOrEqual() { } void Scumm_v5::o5_isNotEqual() { - int16 a = readVar(fetchScriptWord()); + int16 a = getVar(); int16 b = getVarOrDirectWord(0x80); if (b != a) ignoreScriptWord(); @@ -1262,7 +1278,7 @@ void Scumm_v5::o5_isNotEqual() { } void Scumm_v5::o5_notEqualZero() { - int a = readVar(fetchScriptWord()); + int a = getVar(); if (a != 0) ignoreScriptWord(); else @@ -1270,7 +1286,7 @@ void Scumm_v5::o5_notEqualZero() { } void Scumm_v5::o5_equalZero() { - int a = readVar(fetchScriptWord()); + int a = getVar(); if (a == 0) ignoreScriptWord(); else diff --git a/scumm/scumm.h b/scumm/scumm.h index 672b85c224..be6cc8b911 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -518,8 +518,6 @@ protected: void setResult(int result); void push(int a); int pop(); - int getVarOrDirectByte(byte mask); - int getVarOrDirectWord(byte mask); public: virtual int readVar(uint var); // FIXME - should be protected, used in scumm/dialogs.cpp protected: |