[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.64,2.65 script.cpp,1.64,1.65 script_v2.cpp,2.24,2.25 scumm.h,1.167,1.168

Pawel Kolodziejski aquadran at users.sourceforge.net
Sun Apr 27 00:53:03 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv16247

Modified Files:
	intern.h script.cpp script_v2.cpp scumm.h 
Log Message:
put some v2 code into share code

Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.64
retrieving revision 2.65
diff -u -d -r2.64 -r2.65
--- intern.h	27 Apr 2003 07:13:02 -0000	2.64
+++ intern.h	27 Apr 2003 07:52:25 -0000	2.65
@@ -194,11 +194,6 @@
 	virtual void setupOpcodes();
 	virtual void executeOpcode(int i);
 	virtual const char *getOpcodeDesc(int i);
-	virtual void getResultPos();
-	virtual void getResultPosDirect();
-	virtual int getVar();
-	virtual int getVarOrDirectByte(byte mask);
-	virtual int getVarOrDirectWord(byte mask);
 	virtual void ifStateCommon(byte type);
 	virtual void ifNotStateCommon(byte type);
 	virtual void setStateCommon(byte type);
@@ -283,15 +278,12 @@
 	void o2_roomOps();
 	void o2_getDist();
 	void o2_findObject();
-	void o2_subtract();
 	void o2_cutscene();
-	void o2_increment();
 	void o2_chainScript();
 	void o2_pickupObject();
 	void o2_actorFollowCamera();
 	void o2_setObjectName();
 	void o2_getActorMoving();
-	void o2_add();
 	void o2_cursorCommand();
 	void o2_stopScript();
 	void o2_getActorFacing();
@@ -304,7 +296,6 @@
 	void o2_delay();
 	void o2_stopSound();
 	void o2_endCutscene();
-	void o2_decrement();
 	void o2_drawSentence();
 };
 

Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script.cpp,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- script.cpp	26 Apr 2003 16:37:34 -0000	1.64
+++ script.cpp	27 Apr 2003 07:52:25 -0000	1.65
@@ -330,6 +330,25 @@
 	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 fetchScriptWord();
+}
+
 #ifndef BYPASS_COPY_PROT
 #define BYPASS_COPY_PROT
 #endif
@@ -352,7 +371,12 @@
 #endif
 
 		checkRange(_numVariables - 1, 0, var, "Variable %d out of range(r)");
-		return _vars[var];
+
+		if ((_features & GF_AFTER_V2) && (var >= 14) && (var <= 16)) {
+			return _vars[_vars[var]];
+		} else {
+			return _vars[var];
+		}
 	}
 
 	if (var & 0x2000 && !(_features & GF_NEW_OPCODES)) {
@@ -470,8 +494,17 @@
 	error("Illegal varbits (w)");
 }
 
+void Scumm::getResultPosDirect() {
+	_resultVarNumber = _vars[fetchScriptByte()];
+}
+
 void Scumm::getResultPos() {
 	int a;
+
+	if (_features & GF_AFTER_V2) {
+		_resultVarNumber = fetchScriptByte();
+		return;
+	}
 
 	_resultVarNumber = fetchScriptWord();
 	if (_resultVarNumber & 0x2000) {

Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v2.cpp,v
retrieving revision 2.24
retrieving revision 2.25
diff -u -d -r2.24 -r2.25
--- script_v2.cpp	27 Apr 2003 07:13:03 -0000	2.24
+++ script_v2.cpp	27 Apr 2003 07:52:26 -0000	2.25
@@ -105,7 +105,7 @@
 		/* 38 */
 		OPCODE(o2_lessOrEqual),
 		OPCODE(o2_doSentence),
-		OPCODE(o2_subtract),
+		OPCODE(o5_subtract),
 		OPCODE(o2_waitForActor),
 		/* 3C */
 		OPCODE(o2_stopSound),
@@ -120,7 +120,7 @@
 		/* 44 */
 		OPCODE(o2_isLess),
 		OPCODE(o2_drawObject),
-		OPCODE(o2_increment),
+		OPCODE(o5_increment),
 		OPCODE(o2_setState08),
 		/* 48 */
 		OPCODE(o2_isEqual),
@@ -145,7 +145,7 @@
 		/* 58 */
 		OPCODE(beginOverride),
 		OPCODE(o2_doSentence),
-		OPCODE(o2_add),
+		OPCODE(o5_add),
 		OPCODE(o2_setBitVar),
 		/* 5C */
 		OPCODE(o5_dummy),
@@ -265,7 +265,7 @@
 		/* B8 */
 		OPCODE(o2_lessOrEqual),
 		OPCODE(o2_doSentence),
-		OPCODE(o2_subtract),
+		OPCODE(o5_subtract),
 		OPCODE(o2_waitForActor),
 		/* BC */
 		OPCODE(o2_stopSound),
@@ -280,7 +280,7 @@
 		/* C4 */
 		OPCODE(o2_isLess),
 		OPCODE(o2_drawObject),
-		OPCODE(o2_decrement),
+		OPCODE(o5_decrement),
 		OPCODE(o2_clearState08),
 		/* C8 */
 		OPCODE(o2_isEqual),
@@ -305,7 +305,7 @@
 		/* D8 */
 		OPCODE(o2_printEgo),
 		OPCODE(o2_doSentence),
-		OPCODE(o2_add),
+		OPCODE(o5_add),
 		OPCODE(o2_setBitVar),
 		/* DC */
 		OPCODE(o5_dummy),
@@ -366,25 +366,6 @@
 	return _opcodesV2[i].desc;
 }
 
-int Scumm_v2::getVar() {
-	int var_id = fetchScriptByte();
-	if ((var_id >= 14) && (var_id <= 16))
-		return _vars[_vars[var_id]];
-	return _vars[var_id];
-}
-
-int Scumm_v2::getVarOrDirectByte(byte mask) {
-	if (_opcode & mask)
-		return getVar();
-	return fetchScriptByte();
-}
-
-int Scumm_v2::getVarOrDirectWord(byte mask) {
-	if (_opcode & mask)
-		return getVar();
-	return fetchScriptWord();
-}
-
 void Scumm_v2::setStateCommon(byte type) {
 	int obj = getVarOrDirectWord(0x80);
 	putState(obj, getState(obj) | type);
@@ -433,32 +414,24 @@
 	clearStateCommon(0x01);
 }
 
-void Scumm_v2::getResultPos() {
-	_resultVarNumber = fetchScriptByte();
-}
-
-void Scumm_v2::getResultPosDirect() {
-	_resultVarNumber = _vars[fetchScriptByte()];
-}
-
-void Scumm_v2::o2_assignVarWordDirect() {
+void Scumm_v2::o2_assignVarByteDirect() {
 	getResultPosDirect();
-	_vars[_resultVarNumber] = fetchScriptWord();
+	setResult(fetchScriptByte());
 }
 
-void Scumm_v2::o2_assignVarByteDirect() {
+void Scumm_v2::o2_assignVarWordDirect() {
 	getResultPosDirect();
-	_vars[_resultVarNumber] = fetchScriptByte();
+	setResult(fetchScriptWord());
 }
 
 void Scumm_v2::o2_assignVarByte() {
 	getResultPos();
-	_vars[_resultVarNumber] = fetchScriptByte();
+	setResult(fetchScriptByte());
 }
 
 void Scumm_v2::o2_assignVarWord() {
 	getResultPos();
-	_vars[_resultVarNumber] = fetchScriptWord();
+	setResult(fetchScriptWord());
 }
 
 void Scumm_v2::o2_setObjY() {
@@ -746,7 +719,7 @@
 }
 
 void Scumm_v2::o2_isEqual() {
-	int a = getVar();
+	int a = readVar(fetchScriptByte());
 	int b = getVarOrDirectWord(0x80);
 
 	if (b == a)
@@ -757,7 +730,7 @@
 }
 
 void Scumm_v2::o2_isGreater() {
-	int16 a = getVar();
+	int16 a = readVar(fetchScriptByte());
 	int16 b = getVarOrDirectWord(0x80);
 
 	if (b > a)
@@ -767,7 +740,7 @@
 }
 
 void Scumm_v2::o2_isGreaterEqual() {
-	int16 a = getVar();
+	int16 a = readVar(fetchScriptByte());
 	int16 b = getVarOrDirectWord(0x80);
 
 	if (b >= a)
@@ -777,7 +750,7 @@
 }
 
 void Scumm_v2::o2_isLess() {
-	int16 a = getVar();
+	int16 a = readVar(fetchScriptByte());
 	int16 b = getVarOrDirectWord(0x80);
 
 	if (b < a)
@@ -787,7 +760,7 @@
 }
 
 void Scumm_v2::o2_lessOrEqual() {
-	int16 a = getVar();
+	int16 a = readVar(fetchScriptByte());
 	int16 b = getVarOrDirectWord(0x80);
 
 	if (b <= a)
@@ -797,7 +770,7 @@
 }
 
 void Scumm_v2::o2_isNotEqual() {
-	int16 a = getVar();
+	int16 a = readVar(fetchScriptByte());
 	int16 b = getVarOrDirectWord(0x80);
 
 	if (b != a)
@@ -807,7 +780,7 @@
 }
 
 void Scumm_v2::o2_notEqualZero() {
-	int a = getVar();
+	int a = readVar(fetchScriptByte());
 
 	if (a != 0)
 		ignoreScriptWord();
@@ -816,7 +789,7 @@
 }
 
 void Scumm_v2::o2_equalZero() {
-	int a = getVar();
+	int a = readVar(fetchScriptByte());
 
 	if (a == 0)
 		ignoreScriptWord();
@@ -1164,7 +1137,7 @@
 }
 
 void Scumm_v2::o2_delayVariable() {
-	vm.slot[_currentScript].delay = getVar();
+	vm.slot[_currentScript].delay = readVar(fetchScriptByte());
 	vm.slot[_currentScript].status = 1;
 	o5_breakHere();
 }
@@ -1235,13 +1208,6 @@
 	_vars[_resultVarNumber] = findObject(x, y);
 }
 
-void Scumm_v2::o2_subtract() {
-	int a;
-	getResultPos();
-	a = getVarOrDirectWord(0x80);
-	_vars[_resultVarNumber] -= a;
-}
-
 void Scumm_v2::o2_cutscene() {
 	// TODO
 }
@@ -1250,16 +1216,6 @@
 	// TODO
 }
 
-void Scumm_v2::o2_increment() {
-	getResultPos();
-	_vars[_resultVarNumber]++;
-}
-
-void Scumm_v2::o2_decrement() {
-	getResultPos();
-	_vars[_resultVarNumber]--;
-}
-
 void Scumm_v2::o2_chainScript() {
 	int data = getVarOrDirectByte(0x80);
 	int cur = _currentScript;
@@ -1346,13 +1302,6 @@
 	}
 
 	_vars[_resultVarNumber] = a->moving;
-}
-
-void Scumm_v2::o2_add() {
-	int a;
-	getResultPos();
-	a = getVarOrDirectWord(0x80);
-	_vars[_resultVarNumber] += a;
 }
 
 void Scumm_v2::o2_cursorCommand() {

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.167
retrieving revision 1.168
diff -u -d -r1.167 -r1.168
--- scumm.h	26 Apr 2003 13:28:34 -0000	1.167
+++ scumm.h	27 Apr 2003 07:52:26 -0000	1.168
@@ -512,9 +512,12 @@
 	void ignoreScriptWord() { fetchScriptWord(); }
 	void ignoreScriptByte() { fetchScriptByte(); }
 	void getResultPos();
+	void getResultPosDirect();
 	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