[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.3,2.4 script.cpp,1.17,1.18 script_v6.cpp,1.11,1.12 script_v8.cpp,2.3,2.4 scumm.h,1.90,1.91

Max Horn fingolfin at users.sourceforge.net
Sun Dec 22 16:24:02 CET 2002


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

Modified Files:
	intern.h script.cpp script_v6.cpp script_v8.cpp scumm.h 
Log Message:
word size for V8 games is 4 bytes, as opposed to 2 bytes in V6/V7 games. Hence we adjust fetchScriptWord - this way we can reuse all sorts of code (and no, this is not really a hack - word size by tradition is something which varies depending on the architecture, so it is even consistent)

Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.3
retrieving revision 2.4
diff -u -d -r2.3 -r2.4
--- intern.h	22 Dec 2002 23:51:04 -0000	2.3
+++ intern.h	23 Dec 2002 00:23:36 -0000	2.4
@@ -396,6 +396,9 @@
 	virtual void executeOpcode(int i);
 	virtual const char *getOpcodeDesc(int i);
 
+	virtual uint fetchScriptWord();
+	virtual int fetchScriptWordSigned();
+
 	/* Version 8 script opcodes */
 	void o8_unknown();
 	void o8_invalid();

Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- script.cpp	22 Dec 2002 19:14:52 -0000	1.17
+++ script.cpp	23 Dec 2002 00:23:36 -0000	1.18
@@ -297,7 +297,7 @@
 	return *_scriptPointer++;
 }
 
-int Scumm::fetchScriptWord()
+uint Scumm::fetchScriptWord()
 {
 	int a;
 	if (*_lastCodePtr + sizeof(MemBlkHeader) != _scriptOrgPointer) {
@@ -310,6 +310,11 @@
 	return a;
 }
 
+int Scumm::fetchScriptWordSigned()
+{
+	return (int16)fetchScriptWord();
+}
+
 #ifndef BYPASS_COPY_PROT
 #define BYPASS_COPY_PROT
 #endif
@@ -1010,7 +1015,11 @@
 
 	writeVar(array, id);
 
-	size = (type == 5) ? 16 : 8;
+	if (_features & GF_AFTER_V8) {
+		size = 32;	// FIXME - this is just a guess
+	} else {
+		size = (type == 5) ? 16 : 8;
+	}
 	size *= dim2 + 1;
 	size *= dim1 + 1;
 	size >>= 3;

Index: script_v6.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- script_v6.cpp	22 Dec 2002 23:26:10 -0000	1.11
+++ script_v6.cpp	23 Dec 2002 00:23:36 -0000	1.12
@@ -422,6 +422,9 @@
 
 	if (ah->type == 4) {
 		return ah->data[base];
+	} else if (_features & GF_AFTER_V8) {
+		// FIXME - this is just a guess, might be wrong
+		return (int32)READ_LE_UINT32(ah->data + base * 4);
 	} else {
 		return (int16)READ_LE_UINT16(ah->data + base * 2);
 	}
@@ -438,6 +441,9 @@
 
 	if (ah->type == 4) {
 		ah->data[base] = value;
+	} else if (_features & GF_AFTER_V8) {
+		// FIXME - this is just a guess, might be wrong
+		((uint32 *)ah->data)[base] = TO_LE_32(value);
 	} else {
 		((uint16 *)ah->data)[base] = TO_LE_16(value);
 	}
@@ -470,7 +476,7 @@
 
 void Scumm_v6::o6_pushWord()
 {
-	push((int16)fetchScriptWord());
+	push(fetchScriptWordSigned());
 }
 
 void Scumm_v6::o6_pushByteVar()
@@ -722,7 +728,7 @@
 
 void Scumm_v6::o6_jump()
 {
-	_scriptPointer += (int16)fetchScriptWord();
+	_scriptPointer += fetchScriptWordSigned();
 }
 
 void Scumm_v6::o6_startScriptEx()
@@ -2047,7 +2053,7 @@
 {
 	switch (fetchScriptByte()) {
 	case 168:{
-			int offs = (int16)fetchScriptWord();
+			int offs = fetchScriptWordSigned();
 			if (derefActorSafe(pop(), "o6_wait")->moving) {
 				_scriptPointer += offs;
 				o6_breakHere();
@@ -2092,7 +2098,7 @@
 	case 226:{										/* wait until actor drawn */
 			int actnum = pop();
 			Actor *a = derefActorSafe(actnum, "o6_wait:226");
-			int offs = (int16)fetchScriptWord();
+			int offs = fetchScriptWordSigned();
 			if (a && a->isInCurrentRoom() && a->needRedraw) {
 				_scriptPointer += offs;
 				o6_breakHere();
@@ -2102,7 +2108,7 @@
 	case 232:{										/* wait until actor stops turning */
 			int actnum = pop();
 			Actor *a = derefActorSafe(actnum, "o6_wait:232");
-			int offs = (int16)fetchScriptWord();
+			int offs = fetchScriptWordSigned();
 			if (a && a->isInCurrentRoom() && a->moving & MF_TURN) {
 				_scriptPointer += offs;
 				o6_breakHere();

Index: script_v8.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v8.cpp,v
retrieving revision 2.3
retrieving revision 2.4
diff -u -d -r2.3 -r2.4
--- script_v8.cpp	22 Dec 2002 23:51:04 -0000	2.3
+++ script_v8.cpp	23 Dec 2002 00:23:36 -0000	2.4
@@ -161,8 +161,8 @@
 		OPCODE(o8_unknown),
 		OPCODE(o8_unknown),
 		/* 64 */
-		OPCODE(o6_jumpFalse),
-		OPCODE(o6_jumpTrue),
+		OPCODE(o6_jumpFalse),	// Not sure about which of these two is which (false==if or true==if ?!?)...
+		OPCODE(o6_jumpTrue),	// ... since "if" could mean 'jump "if"' or 'execute following code "if", otherwise jump'.
 		OPCODE(o6_jump),
 		OPCODE(o6_breakHere),
 		/* 68 */
@@ -369,6 +369,25 @@
 const char *Scumm_v8::getOpcodeDesc(int i)
 {
 	return _opcodesV8[i].desc;
+}
+
+// In V8, the word size is 4 byte, not 2 bytes as in V6/V7 games
+uint Scumm_v8::fetchScriptWord()
+{
+	int a;
+	if (*_lastCodePtr + sizeof(MemBlkHeader) != _scriptOrgPointer) {
+		uint32 oldoffs = _scriptPointer - _scriptOrgPointer;
+		getScriptBaseAddress();
+		_scriptPointer = _scriptOrgPointer + oldoffs;
+	}
+	a = READ_LE_UINT32(_scriptPointer);
+	_scriptPointer += 4;
+	return a;
+}
+
+int Scumm_v8::fetchScriptWordSigned()
+{
+	return (int32)fetchScriptWord();
 }
 
 void Scumm_v8::o8_unknown()

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- scumm.h	22 Dec 2002 21:58:15 -0000	1.90
+++ scumm.h	23 Dec 2002 00:23:36 -0000	1.91
@@ -476,7 +476,8 @@
 	void getScriptBaseAddress();
 	void getScriptEntryPoint();
 	byte fetchScriptByte();
-	int fetchScriptWord();
+	virtual uint fetchScriptWord();
+	virtual int fetchScriptWordSigned();
 	void ignoreScriptWord() { fetchScriptWord(); }
 	void ignoreScriptByte() { fetchScriptByte(); }
 	void getResultPos();





More information about the Scummvm-git-logs mailing list