aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2009-04-20 12:35:17 +0000
committerMax Horn2009-04-20 12:35:17 +0000
commit6a7bb77305dc280e6af2afb4beb5cc06ca6350b8 (patch)
tree57399b6035ea9b2467a36d6b5f3eb18a5359610b
parent4cf0f0a9a50f6a87a9a769c51f7a7958c13844a7 (diff)
downloadscummvm-rg350-6a7bb77305dc280e6af2afb4beb5cc06ca6350b8.tar.gz
scummvm-rg350-6a7bb77305dc280e6af2afb4beb5cc06ca6350b8.tar.bz2
scummvm-rg350-6a7bb77305dc280e6af2afb4beb5cc06ca6350b8.zip
SCUMM: Introduced new method ScummEngine_v5::jumpRelative; unified some v0 and v2 opcodes
svn-id: r40025
-rw-r--r--engines/scumm/script_v0.cpp173
-rw-r--r--engines/scumm/script_v2.cpp72
-rw-r--r--engines/scumm/script_v4.cpp10
-rw-r--r--engines/scumm/script_v5.cpp89
-rw-r--r--engines/scumm/scumm_v0.h18
-rw-r--r--engines/scumm/scumm_v2.h9
-rw-r--r--engines/scumm/scumm_v5.h8
7 files changed, 95 insertions, 284 deletions
diff --git a/engines/scumm/script_v0.cpp b/engines/scumm/script_v0.cpp
index 23f1ef7de2..1b8368d636 100644
--- a/engines/scumm/script_v0.cpp
+++ b/engines/scumm/script_v0.cpp
@@ -41,12 +41,12 @@ void ScummEngine_v0::setupOpcodes() {
OPCODE(0x02, o5_startMusic);
OPCODE(0x03, o_doSentence);
/* 04 */
- OPCODE(0x04, o_isGreaterEqual);
+ OPCODE(0x04, o2_isGreaterEqual);
OPCODE(0x05, o_stopCurrentScript);
OPCODE(0x06, o5_getDist);
OPCODE(0x07, o5_getActorRoom);
/* 08 */
- OPCODE(0x08, o_isNotEqual);
+ OPCODE(0x08, o5_isNotEqual);
OPCODE(0x09, o_stopCurrentScript);
OPCODE(0x0a, o_stopCurrentScript);
OPCODE(0x0b, o_setActorBitVar);
@@ -64,9 +64,9 @@ void ScummEngine_v0::setupOpcodes() {
OPCODE(0x14, o_print_c64);
OPCODE(0x15, o5_walkActorToActor);
OPCODE(0x16, o5_getRandomNr);
- OPCODE(0x17, o_clearState08);
+ OPCODE(0x17, o2_clearState08);
/* 18 */
- OPCODE(0x18, o_jumpRelative);
+ OPCODE(0x18, o5_jumpRelative);
OPCODE(0x19, o_stopCurrentScript);
OPCODE(0x1a, o5_move);
OPCODE(0x1b, o_getActorBitVar);
@@ -86,7 +86,7 @@ void ScummEngine_v0::setupOpcodes() {
OPCODE(0x26, o_getClosestObjActor);
OPCODE(0x27, o2_getActorY);
/* 28 */
- OPCODE(0x28, o_equalZero);
+ OPCODE(0x28, o5_equalZero);
OPCODE(0x29, o_setOwnerOf);
OPCODE(0x2a, o2_delay);
OPCODE(0x2b, o_setActorBitVar);
@@ -106,7 +106,7 @@ void ScummEngine_v0::setupOpcodes() {
OPCODE(0x36, o2_walkActorToObject);
OPCODE(0x37, o2_clearState04);
/* 38 */
- OPCODE(0x38, o_isLessEqual);
+ OPCODE(0x38, o2_isLessEqual);
OPCODE(0x39, o_stopCurrentScript);
OPCODE(0x3a, o2_subtract);
OPCODE(0x3b, o_stopCurrentScript);
@@ -121,12 +121,12 @@ void ScummEngine_v0::setupOpcodes() {
OPCODE(0x42, o2_startScript);
OPCODE(0x43, o_doSentence);
/* 44 */
- OPCODE(0x44, o_isLess);
+ OPCODE(0x44, o2_isLess);
OPCODE(0x45, o_stopCurrentScript);
OPCODE(0x46, o5_increment);
OPCODE(0x47, o2_getActorX);
/* 48 */
- OPCODE(0x48, o_isEqual);
+ OPCODE(0x48, o5_isEqual);
OPCODE(0x49, o_stopCurrentScript);
OPCODE(0x4a, o_loadRoom);
OPCODE(0x4b, o_setActorBitVar);
@@ -144,7 +144,7 @@ void ScummEngine_v0::setupOpcodes() {
OPCODE(0x54, o_setObjectName);
OPCODE(0x55, o5_walkActorToActor);
OPCODE(0x56, o_getActorMoving);
- OPCODE(0x57, o_clearState08);
+ OPCODE(0x57, o2_clearState08);
/* 58 */
OPCODE(0x58, o_beginOverride);
OPCODE(0x59, o_stopCurrentScript);
@@ -186,7 +186,7 @@ void ScummEngine_v0::setupOpcodes() {
OPCODE(0x76, o2_walkActorToObject);
OPCODE(0x77, o2_clearState04);
/* 78 */
- OPCODE(0x78, o_isGreater);
+ OPCODE(0x78, o2_isGreater);
OPCODE(0x79, o_stopCurrentScript);
OPCODE(0x7a, o_stopCurrentScript);
OPCODE(0x7b, o_stopCurrentScript);
@@ -201,12 +201,12 @@ void ScummEngine_v0::setupOpcodes() {
OPCODE(0x82, o_stopCurrentScript);
OPCODE(0x83, o_doSentence);
/* 84 */
- OPCODE(0x84, o_isGreaterEqual);
+ OPCODE(0x84, o2_isGreaterEqual);
OPCODE(0x85, o_stopCurrentScript);
OPCODE(0x86, o_nop);
OPCODE(0x87, o5_getActorRoom);
/* 88 */
- OPCODE(0x88, o_isNotEqual);
+ OPCODE(0x88, o5_isNotEqual);
OPCODE(0x89, o_stopCurrentScript);
OPCODE(0x8a, o_stopCurrentScript);
OPCODE(0x8b, o_setActorBitVar);
@@ -224,7 +224,7 @@ void ScummEngine_v0::setupOpcodes() {
OPCODE(0x94, o5_print);
OPCODE(0x95, o2_actorFromPos);
OPCODE(0x96, o_stopCurrentScript);
- OPCODE(0x97, o_setState08);
+ OPCODE(0x97, o2_setState08);
/* 98 */
OPCODE(0x98, o2_restart);
OPCODE(0x99, o_stopCurrentScript);
@@ -246,7 +246,7 @@ void ScummEngine_v0::setupOpcodes() {
OPCODE(0xa6, o_stopCurrentScript);
OPCODE(0xa7, o2_getActorY);
/* A8 */
- OPCODE(0xa8, o_notEqualZero);
+ OPCODE(0xa8, o5_notEqualZero);
OPCODE(0xa9, o_setOwnerOf);
OPCODE(0xaa, o_stopCurrentScript);
OPCODE(0xab, o_setActorBitVar);
@@ -266,7 +266,7 @@ void ScummEngine_v0::setupOpcodes() {
OPCODE(0xb6, o2_walkActorToObject);
OPCODE(0xb7, o2_setState04);
/* B8 */
- OPCODE(0xb8, o_isLessEqual);
+ OPCODE(0xb8, o2_isLessEqual);
OPCODE(0xb9, o_stopCurrentScript);
OPCODE(0xba, o2_subtract);
OPCODE(0xbb, o_stopCurrentScript);
@@ -281,12 +281,12 @@ void ScummEngine_v0::setupOpcodes() {
OPCODE(0xc2, o2_startScript);
OPCODE(0xc3, o_doSentence);
/* C4 */
- OPCODE(0xc4, o_isLess);
+ OPCODE(0xc4, o2_isLess);
OPCODE(0xc5, o_stopCurrentScript);
OPCODE(0xc6, o5_decrement);
OPCODE(0xc7, o2_getActorX);
/* C8 */
- OPCODE(0xc8, o_isEqual);
+ OPCODE(0xc8, o5_isEqual);
OPCODE(0xc9, o_stopCurrentScript);
OPCODE(0xca, o_loadRoom);
OPCODE(0xcb, o_setActorBitVar);
@@ -304,7 +304,7 @@ void ScummEngine_v0::setupOpcodes() {
OPCODE(0xd4, o_setObjectName);
OPCODE(0xd5, o2_actorFromPos);
OPCODE(0xd6, o_getActorMoving);
- OPCODE(0xd7, o_setState08);
+ OPCODE(0xd7, o2_setState08);
/* D8 */
OPCODE(0xd8, o_stopCurrentScript);
OPCODE(0xd9, o_stopCurrentScript);
@@ -346,7 +346,7 @@ void ScummEngine_v0::setupOpcodes() {
OPCODE(0xf6, o2_walkActorToObject);
OPCODE(0xf7, o2_setState04);
/* F8 */
- OPCODE(0xf8, o_isGreater);
+ OPCODE(0xf8, o2_isGreater);
OPCODE(0xf9, o_stopCurrentScript);
OPCODE(0xfa, o_stopCurrentScript);
OPCODE(0xfb, o_stopCurrentScript);
@@ -367,8 +367,8 @@ uint ScummEngine_v0::fetchScriptWord() {
return fetchScriptByte();
}
-int ScummEngine_v0::getObjectFlag() {
- if (_opcode & 0x40)
+int ScummEngine_v0::getActiveObject() {
+ if (_opcode & PARAM_2)
return _activeObject;
return fetchScriptByte();
@@ -410,34 +410,6 @@ void ScummEngine_v0::decodeParseString() {
actorTalk(buffer);
}
-void ScummEngine_v0::setStateCommon(byte type) {
- int obj = getObjectFlag();
- putState(obj, getState(obj) | type);
-}
-
-void ScummEngine_v0::clearStateCommon(byte type) {
- int obj = getObjectFlag();
- putState(obj, getState(obj) & ~type);
-}
-
-void ScummEngine_v0::ifStateCommon(byte type) {
- int obj = getObjectFlag();
-
- if ((getState(obj) & type) != 0)
- ScummEngine::fetchScriptWord();
- else
- o_jumpRelative();
-}
-
-void ScummEngine_v0::ifNotStateCommon(byte type) {
- int obj = getObjectFlag();
-
- if ((getState(obj) & type) == 0)
- ScummEngine::fetchScriptWord();
- else
- o_jumpRelative();
-}
-
void ScummEngine_v0::drawSentence() {
Common::Rect sentenceline;
const byte *temp;
@@ -541,20 +513,6 @@ void ScummEngine_v0::drawSentence() {
drawString(2, (byte*)string);
}
-void ScummEngine_v0::o_setState08() {
- int obj = getObjectFlag();
- putState(obj, getState(obj) | kObjectState_08);
- markObjectRectAsDirty(obj);
- clearDrawObjectQueue();
-}
-
-void ScummEngine_v0::o_clearState08() {
- int obj = getObjectFlag();
- putState(obj, getState(obj) & ~kObjectState_08);
- markObjectRectAsDirty(obj);
- clearDrawObjectQueue();
-}
-
void ScummEngine_v0::o_stopCurrentScript() {
int script;
@@ -850,10 +808,7 @@ void ScummEngine_v0::o_unknown2() {
void ScummEngine_v0::o_ifActiveObject() {
byte obj = fetchScriptByte();
- if (obj == _activeInventory)
- ScummEngine::fetchScriptWord();
- else
- o_jumpRelative();
+ jumpRelative(obj == _activeInventory);
}
void ScummEngine_v0::o_getClosestObjActor() {
@@ -870,7 +825,7 @@ void ScummEngine_v0::o_getClosestObjActor() {
getResultPos();
act = getVarOrDirectByte(PARAM_1);
- obj = (_opcode & 0x40) ? 25 : 7;
+ obj = (_opcode & PARAM_2) ? 25 : 7;
do {
dist = getObjActToObjActDist(act, obj);
@@ -933,88 +888,6 @@ void ScummEngine_v0::o_beginOverride() {
VAR(VAR_OVERRIDE) = 0;
}
-void ScummEngine_v0::o_isEqual() {
- int16 a, b;
- int var;
-
- var = fetchScriptByte();
- a = readVar(var);
- b = getVarOrDirectByte(PARAM_1);
-
- if (b == a)
- ScummEngine::fetchScriptWord();
- else
- o_jumpRelative();
-
-}
-
-void ScummEngine_v0::o_isGreater() {
- int16 a = getVar();
- int16 b = getVarOrDirectByte(PARAM_1);
- if (b > a)
- ScummEngine::fetchScriptWord();
- else
- o_jumpRelative();
-}
-
-void ScummEngine_v0::o_isGreaterEqual() {
- int16 a = getVar();
- int16 b = getVarOrDirectByte(PARAM_1);
- if (b >= a)
- ScummEngine::fetchScriptWord();
- else
- o_jumpRelative();
-}
-
-void ScummEngine_v0::o_isLess() {
- int16 a = getVar();
- int16 b = getVarOrDirectByte(PARAM_1);
- if (b < a)
- ScummEngine::fetchScriptWord();
- else
- o_jumpRelative();
-}
-
-void ScummEngine_v0::o_isLessEqual() {
- int16 a = getVar();
- int16 b = getVarOrDirectByte(PARAM_1);
-
- if (b <= a)
- ScummEngine::fetchScriptWord();
- else
- o_jumpRelative();
-}
-
-void ScummEngine_v0::o_isNotEqual() {
- int16 a = getVar();
- int16 b = getVarOrDirectByte(PARAM_1);
- if (b != a)
- ScummEngine::fetchScriptWord();
- else
- o_jumpRelative();
-}
-
-void ScummEngine_v0::o_notEqualZero() {
- int a = getVar();
- if (a != 0)
- ScummEngine::fetchScriptWord();
- else
- o_jumpRelative();
-}
-
-void ScummEngine_v0::o_equalZero() {
- int a = getVar();
- if (a == 0)
- ScummEngine::fetchScriptWord();
- else
- o_jumpRelative();
-}
-
-void ScummEngine_v0::o_jumpRelative() {
- int16 offset = (int16)ScummEngine::fetchScriptWord();
- _scriptPointer += offset;
-}
-
void ScummEngine_v0::o_setOwnerOf() {
int obj, owner;
diff --git a/engines/scumm/script_v2.cpp b/engines/scumm/script_v2.cpp
index 941c3246b1..b2793fbb5f 100644
--- a/engines/scumm/script_v2.cpp
+++ b/engines/scumm/script_v2.cpp
@@ -23,7 +23,6 @@
*
*/
-
#include "scumm/actor.h"
#include "scumm/charset.h"
#include "scumm/object.h"
@@ -444,25 +443,41 @@ void ScummEngine_v2::getResultPos() {
_resultVarNumber = fetchScriptByte();
}
+int ScummEngine_v2::getActiveObject() {
+ return getVarOrDirectWord(PARAM_1);
+}
+
void ScummEngine_v2::setStateCommon(byte type) {
- int obj = getVarOrDirectWord(PARAM_1);
+ int obj = getActiveObject();
putState(obj, getState(obj) | type);
}
void ScummEngine_v2::clearStateCommon(byte type) {
- int obj = getVarOrDirectWord(PARAM_1);
+ int obj = getActiveObject();
putState(obj, getState(obj) & ~type);
}
+void ScummEngine_v2::ifStateCommon(byte type) {
+ int obj = getActiveObject();
+
+ jumpRelative((getState(obj) & type) != 0);
+}
+
+void ScummEngine_v2::ifNotStateCommon(byte type) {
+ int obj = getActiveObject();
+
+ jumpRelative((getState(obj) & type) == 0);
+}
+
void ScummEngine_v2::o2_setState08() {
- int obj = getVarOrDirectWord(PARAM_1);
+ int obj = getActiveObject();
putState(obj, getState(obj) | kObjectState_08);
markObjectRectAsDirty(obj);
clearDrawObjectQueue();
}
void ScummEngine_v2::o2_clearState08() {
- int obj = getVarOrDirectWord(PARAM_1);
+ int obj = getActiveObject();
putState(obj, getState(obj) & ~kObjectState_08);
markObjectRectAsDirty(obj);
clearDrawObjectQueue();
@@ -556,24 +571,6 @@ void ScummEngine_v2::o2_getBitVar() {
setResult((_scummVars[bit_var] & (1 << bit_offset)) ? 1 : 0);
}
-void ScummEngine_v2::ifStateCommon(byte type) {
- int obj = getVarOrDirectWord(PARAM_1);
-
- if ((getState(obj) & type) != 0)
- ignoreScriptWord();
- else
- o5_jumpRelative();
-}
-
-void ScummEngine_v2::ifNotStateCommon(byte type) {
- int obj = getVarOrDirectWord(PARAM_1);
-
- if ((getState(obj) & type) == 0)
- ignoreScriptWord();
- else
- o5_jumpRelative();
-}
-
void ScummEngine_v2::o2_ifState08() {
ifStateCommon(kObjectState_08);
}
@@ -1087,6 +1084,8 @@ void ScummEngine_v2::o2_drawSentence() {
void ScummEngine_v2::o2_ifClassOfIs() {
int obj = getVarOrDirectWord(PARAM_1);
int clsop = getVarOrDirectByte(PARAM_2);
+
+
byte *obcd = getOBCDFromObject(obj);
if (obcd == 0) {
@@ -1095,11 +1094,7 @@ void ScummEngine_v2::o2_ifClassOfIs() {
}
byte cls = *(obcd + 6);
- if ((cls & clsop) != clsop) {
- o5_jumpRelative();
- return;
- }
- ignoreScriptWord();
+ jumpRelative((cls & clsop) == clsop);
}
void ScummEngine_v2::o2_walkActorTo() {
@@ -1127,7 +1122,6 @@ void ScummEngine_v2::o2_putActor() {
Actor *a;
a = derefActor(act, "o2_putActor");
-
x = getVarOrDirectByte(PARAM_2);
y = getVarOrDirectByte(PARAM_3);
@@ -1283,38 +1277,26 @@ void ScummEngine_v2::o2_getActorY() {
void ScummEngine_v2::o2_isGreater() {
uint16 a = getVar();
uint16 b = getVarOrDirectWord(PARAM_1);
- if (b > a)
- ignoreScriptWord();
- else
- o5_jumpRelative();
+ jumpRelative(b > a);
}
void ScummEngine_v2::o2_isGreaterEqual() {
uint16 a = getVar();
uint16 b = getVarOrDirectWord(PARAM_1);
- if (b >= a)
- ignoreScriptWord();
- else
- o5_jumpRelative();
+ jumpRelative(b >= a);
}
void ScummEngine_v2::o2_isLess() {
uint16 a = getVar();
uint16 b = getVarOrDirectWord(PARAM_1);
- if (b < a)
- ignoreScriptWord();
- else
- o5_jumpRelative();
+ jumpRelative(b < a);
}
void ScummEngine_v2::o2_isLessEqual() {
uint16 a = getVar();
uint16 b = getVarOrDirectWord(PARAM_1);
- if (b <= a)
- ignoreScriptWord();
- else
- o5_jumpRelative();
+ jumpRelative(b <= a);
}
void ScummEngine_v2::o2_lights() {
diff --git a/engines/scumm/script_v4.cpp b/engines/scumm/script_v4.cpp
index b8964c4194..a8702a5d79 100644
--- a/engines/scumm/script_v4.cpp
+++ b/engines/scumm/script_v4.cpp
@@ -66,20 +66,14 @@ void ScummEngine_v4::o4_ifState() {
int a = getVarOrDirectWord(PARAM_1);
int b = getVarOrDirectByte(PARAM_2);
- if (getState(a) != b)
- o5_jumpRelative();
- else
- ignoreScriptWord();
+ jumpRelative(getState(a) == b);
}
void ScummEngine_v4::o4_ifNotState() {
int a = getVarOrDirectWord(PARAM_1);
int b = getVarOrDirectByte(PARAM_2);
- if (getState(a) == b)
- o5_jumpRelative();
- else
- ignoreScriptWord();
+ jumpRelative(getState(a) != b);
}
void ScummEngine_v4::o4_pickupObject() {
diff --git a/engines/scumm/script_v5.cpp b/engines/scumm/script_v5.cpp
index 84c299183c..191826f492 100644
--- a/engines/scumm/script_v5.cpp
+++ b/engines/scumm/script_v5.cpp
@@ -110,7 +110,7 @@ void ScummEngine_v5::setupOpcodes() {
OPCODE(0x36, o5_walkActorToObject);
OPCODE(0x37, o5_startObject);
/* 38 */
- OPCODE(0x38, o5_lessOrEqual);
+ OPCODE(0x38, o5_isLessEqual);
OPCODE(0x39, o5_doSentence);
OPCODE(0x3a, o5_subtract);
OPCODE(0x3b, o5_getActorScale);
@@ -270,7 +270,7 @@ void ScummEngine_v5::setupOpcodes() {
OPCODE(0xb6, o5_walkActorToObject);
OPCODE(0xb7, o5_startObject);
/* B8 */
- OPCODE(0xb8, o5_lessOrEqual);
+ OPCODE(0xb8, o5_isLessEqual);
OPCODE(0xb9, o5_doSentence);
OPCODE(0xba, o5_subtract);
OPCODE(0xbb, o5_getActorScale);
@@ -374,7 +374,17 @@ int ScummEngine_v5::getVarOrDirectByte(byte mask) {
int ScummEngine_v5::getVarOrDirectWord(byte mask) {
if (_opcode & mask)
return getVar();
- return (int16)fetchScriptWord();
+ return fetchScriptWordSigned();
+}
+
+void ScummEngine_v5::jumpRelative(bool cond) {
+ // We explicitly call ScummEngine::fetchScriptWordSigned()
+ // to make this method work also in v0, which overloads
+ // fetchScriptWord to only read bytes (which is the right thing
+ // to do for most opcodes, but not for jump offsets).
+ int16 offset = ScummEngine::fetchScriptWordSigned();
+ if (!cond)
+ _scriptPointer += offset;
}
void ScummEngine_v5::o5_actorFollowCamera() {
@@ -1121,21 +1131,18 @@ void ScummEngine_v5::o5_getVerbEntrypoint() {
}
void ScummEngine_v5::o5_ifClassOfIs() {
- int act, cls, b = 0;
+ int obj, cls, b = 0;
bool cond = true;
- act = getVarOrDirectWord(PARAM_1);
+ obj = getVarOrDirectWord(PARAM_1);
while ((_opcode = fetchScriptByte()) != 0xFF) {
cls = getVarOrDirectWord(PARAM_1);
- b = getClass(act, cls);
+ b = getClass(obj, cls);
if (((cls & 0x80) && !b) || (!(cls & 0x80) && b))
cond = false;
}
- if (cond)
- ignoreScriptWord();
- else
- o5_jumpRelative();
+ jumpRelative(cond);
}
void ScummEngine_v5::o5_increment() {
@@ -1148,10 +1155,7 @@ void ScummEngine_v5::o5_isActorInBox() {
int box = getVarOrDirectByte(PARAM_2);
Actor *a = derefActor(act, "o5_isActorInBox");
- if (!checkXYInBoxBounds(box, a->getRealPos().x, a->getRealPos().y))
- o5_jumpRelative();
- else
- ignoreScriptWord();
+ jumpRelative(checkXYInBoxBounds(box, a->getRealPos().x, a->getRealPos().y));
}
void ScummEngine_v5::o5_isEqual() {
@@ -1178,41 +1182,28 @@ void ScummEngine_v5::o5_isEqual() {
if (_game.id == GID_MANIAC && _game.version == 2 && (_game.features & GF_DEMO) && isScriptRunning(173) && b == 180)
b = 100;
- if (b == a)
- ignoreScriptWord();
- else
- o5_jumpRelative();
-
+ jumpRelative(b == a);
}
void ScummEngine_v5::o5_isGreater() {
int16 a = getVar();
int16 b = getVarOrDirectWord(PARAM_1);
- if (b > a)
- ignoreScriptWord();
- else
- o5_jumpRelative();
+ jumpRelative(b > a);
}
void ScummEngine_v5::o5_isGreaterEqual() {
int16 a = getVar();
int16 b = getVarOrDirectWord(PARAM_1);
- if (b >= a)
- ignoreScriptWord();
- else
- o5_jumpRelative();
+ jumpRelative(b >= a);
}
void ScummEngine_v5::o5_isLess() {
int16 a = getVar();
int16 b = getVarOrDirectWord(PARAM_1);
- if (b < a)
- ignoreScriptWord();
- else
- o5_jumpRelative();
+ jumpRelative(b < a);
}
-void ScummEngine_v5::o5_lessOrEqual() {
+void ScummEngine_v5::o5_isLessEqual() {
int16 a = getVar();
int16 b = getVarOrDirectWord(PARAM_1);
@@ -1224,47 +1215,27 @@ void ScummEngine_v5::o5_lessOrEqual() {
return;
}
- if (b <= a)
- ignoreScriptWord();
- else
- o5_jumpRelative();
+ jumpRelative(b <= a);
}
void ScummEngine_v5::o5_isNotEqual() {
int16 a = getVar();
int16 b = getVarOrDirectWord(PARAM_1);
- if (b != a)
- ignoreScriptWord();
- else
- o5_jumpRelative();
+ jumpRelative(b != a);
}
void ScummEngine_v5::o5_notEqualZero() {
int a = getVar();
- if (a != 0)
- ignoreScriptWord();
- else
- o5_jumpRelative();
+ jumpRelative(a != 0);
}
void ScummEngine_v5::o5_equalZero() {
int a = getVar();
- if (a == 0)
- ignoreScriptWord();
- else
- o5_jumpRelative();
+ jumpRelative(a == 0);
}
void ScummEngine_v5::o5_jumpRelative() {
- // Note that calling fetchScriptWord() will also modify _scriptPointer,
- // so *don't* do this: _scriptPointer += (int16)fetchScriptWord();
- //
- // I'm not enough of a language lawyer to say for certain that this is
- // undefined, but I do know that GCC 4.0 doesn't think it means what
- // we want it to mean.
-
- int16 offset = (int16)fetchScriptWord();
- _scriptPointer += offset;
+ jumpRelative(false);
}
void ScummEngine_v5::o5_lights() {
@@ -1311,8 +1282,8 @@ void ScummEngine_v5::o5_loadRoomWithEgo() {
oldDir = a->getFacing();
_egoPositioned = false;
- x = (int16)fetchScriptWord();
- y = (int16)fetchScriptWord();
+ x = fetchScriptWordSigned();
+ y = fetchScriptWordSigned();
VAR(VAR_WALKTO_OBJ) = obj;
startScene(a->_room, a, obj);
diff --git a/engines/scumm/scumm_v0.h b/engines/scumm/scumm_v0.h
index 13e99b8591..ccca5df0d3 100644
--- a/engines/scumm/scumm_v0.h
+++ b/engines/scumm/scumm_v0.h
@@ -66,18 +66,11 @@ protected:
virtual int getVarOrDirectWord(byte mask);
virtual uint fetchScriptWord();
- virtual void ifStateCommon(byte type);
- virtual void ifNotStateCommon(byte type);
- virtual void setStateCommon(byte type);
- virtual void clearStateCommon(byte type);
+ virtual int getActiveObject();
virtual void resetSentence();
- int getObjectFlag();
-
/* Version C64 script opcodes */
- void o_setState08();
- void o_clearState08();
void o_stopCurrentScript();
void o_loadSound();
void o_getActorMoving();
@@ -114,15 +107,6 @@ protected:
void o_cutscene();
void o_endCutscene();
void o_beginOverride();
- void o_isEqual();
- void o_isGreater();
- void o_isGreaterEqual();
- void o_isLess();
- void o_isLessEqual();
- void o_isNotEqual();
- void o_notEqualZero();
- void o_equalZero();
- void o_jumpRelative();
void o_setOwnerOf();
};
diff --git a/engines/scumm/scumm_v2.h b/engines/scumm/scumm_v2.h
index e40d6dc40f..338b5f6167 100644
--- a/engines/scumm/scumm_v2.h
+++ b/engines/scumm/scumm_v2.h
@@ -84,10 +84,11 @@ protected:
virtual int readVar(uint var);
virtual void writeVar(uint var, int value);
- virtual void ifStateCommon(byte type);
- virtual void ifNotStateCommon(byte type);
- virtual void setStateCommon(byte type);
- virtual void clearStateCommon(byte type);
+ virtual int getActiveObject();
+ void ifStateCommon(byte type);
+ void ifNotStateCommon(byte type);
+ void setStateCommon(byte type);
+ void clearStateCommon(byte type);
virtual void resetSentence();
void setUserState(byte state);
diff --git a/engines/scumm/scumm_v5.h b/engines/scumm/scumm_v5.h
index a8e2417017..2580384fd8 100644
--- a/engines/scumm/scumm_v5.h
+++ b/engines/scumm/scumm_v5.h
@@ -85,6 +85,12 @@ protected:
void drawFlashlight();
+ /**
+ * Fetch the next script word, then if cond is *false*, perform a relative jump.
+ * So this corresponds to a "jne" jump instruction.
+ */
+ void jumpRelative(bool cond);
+
/* Version 5 script opcodes */
void o5_actorFollowCamera();
void o5_actorFromPos();
@@ -138,11 +144,11 @@ protected:
void o5_isGreater();
void o5_isGreaterEqual();
void o5_isLess();
+ void o5_isLessEqual();
void o5_isNotEqual();
void o5_isScriptRunning();
void o5_isSoundRunning();
void o5_jumpRelative();
- void o5_lessOrEqual();
void o5_lights();
void o5_loadRoom();
void o5_loadRoomWithEgo();