[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.77,2.78 script.cpp,1.74,1.75 script_v2.cpp,2.46,2.47 script_v5.cpp,1.67,1.68 scumm.h,1.178,1.179
Max Horn
fingolfin at users.sourceforge.net
Mon May 5 02:20:08 CEST 2003
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv29578
Modified Files:
intern.h script.cpp script_v2.cpp script_v5.cpp scumm.h
Log Message:
cleanup / reduced code duplication
Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.77
retrieving revision 2.78
diff -u -d -r2.77 -r2.78
--- intern.h 4 May 2003 17:39:25 -0000 2.77
+++ intern.h 5 May 2003 09:19:14 -0000 2.78
@@ -47,6 +47,10 @@
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 @@
virtual void decodeParseString();
+ virtual int getVar();
+
void getResultPosIndirect();
virtual void getResultPos();
virtual int readVar(uint var);
@@ -243,13 +249,6 @@
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 @@
void o2_getActorY();
void o2_loadRoomWithEgo();
void o2_setOwnerOf();
- void o2_delayVariable();
void o2_matrixOps();
void o2_setCameraAt();
void o2_roomOps();
Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script.cpp,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- script.cpp 4 May 2003 12:02:37 -0000 1.74
+++ script.cpp 5 May 2003 09:19:14 -0000 1.75
@@ -330,24 +330,6 @@
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
Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v2.cpp,v
retrieving revision 2.46
retrieving revision 2.47
diff -u -d -r2.46 -r2.47
--- script_v2.cpp 5 May 2003 05:20:45 -0000 2.46
+++ script_v2.cpp 5 May 2003 09:19:14 -0000 2.47
@@ -38,12 +38,12 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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_isEqual() {
- int a = readVar(fetchScriptByte());
+ int a = getVar();
int b = getVarOrDirectWord(0x80);
if (b == a)
@@ -782,74 +786,6 @@
}
-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;
@@ -1051,12 +987,6 @@
setOwnerOf(obj, owner);
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() {
Index: script_v5.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v5.cpp,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- script_v5.cpp 4 May 2003 14:06:30 -0000 1.67
+++ script_v5.cpp 5 May 2003 09:19:15 -0000 1.68
@@ -366,6 +366,22 @@
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_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_isGreater() {
- int16 a = readVar(fetchScriptWord());
+ int16 a = getVar();
int16 b = getVarOrDirectWord(0x80);
if (b > a)
ignoreScriptWord();
@@ -1225,7 +1241,7 @@
}
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_isLess() {
- int16 a = readVar(fetchScriptWord());
+ int16 a = getVar();
int16 b = getVarOrDirectWord(0x80);
if (b < a)
@@ -1244,7 +1260,7 @@
}
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_isNotEqual() {
- int16 a = readVar(fetchScriptWord());
+ int16 a = getVar();
int16 b = getVarOrDirectWord(0x80);
if (b != a)
ignoreScriptWord();
@@ -1262,7 +1278,7 @@
}
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_equalZero() {
- int a = readVar(fetchScriptWord());
+ int a = getVar();
if (a == 0)
ignoreScriptWord();
else
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.178
retrieving revision 1.179
diff -u -d -r1.178 -r1.179
--- scumm.h 4 May 2003 02:27:22 -0000 1.178
+++ scumm.h 5 May 2003 09:19:15 -0000 1.179
@@ -518,8 +518,6 @@
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:
More information about the Scummvm-git-logs
mailing list