[Scummvm-cvs-logs] CVS: scummvm/saga script.cpp,1.55,1.56 script.h,1.62,1.63 sthread.cpp,1.69,1.70

Andrew Kurushin h00ligan at users.sourceforge.net
Sat Jan 22 07:29:03 CET 2005


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19110

Modified Files:
	script.cpp script.h sthread.cpp 
Log Message:
another 19 opcodes

Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/script.cpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- script.cpp	21 Jan 2005 21:55:53 -0000	1.55
+++ script.cpp	22 Jan 2005 15:28:23 -0000	1.56
@@ -170,92 +170,6 @@
 
 	_initialized = false;
 }
-/*
-int Script::getWord(int bufNumber, int wordNumber, ScriptDataWord *data) {
-	if ((bufNumber < 0) || (bufNumber >= SCRIPT_DATABUF_NUM)) {
-		return FAILURE;
-	}
-
-	if ((wordNumber < 0) || (wordNumber >= _dataBuf[bufNumber].length)) {
-		return FAILURE;
-	}
-
-	if (data == NULL) {
-		return FAILURE;
-	}
-
-	*data = _dataBuf[bufNumber].data[wordNumber];
-
-	return SUCCESS;
-}
-
-int Script::putWord(int bufNumber, int wordNumber, ScriptDataWord data) {
-	if ((bufNumber < 0) || (bufNumber >= SCRIPT_DATABUF_NUM)) {
-		return FAILURE;
-	}
-
-	if ((wordNumber < 0) || (wordNumber >= _dataBuf[bufNumber].length)) {
-		return FAILURE;
-	}
-
-	_dataBuf[bufNumber].data[wordNumber] = data;
-
-	return SUCCESS;
-}
-
-int Script::setBit(int bufNumber, ScriptDataWord bitNumber, int bitState) {
-	int wordNumber;
-	int bitPos;
-
-	ScriptDataWord bitPattern = 0x01;
-
-	if ((bufNumber < 0) || (bufNumber >= SCRIPT_DATABUF_NUM)) {
-		return FAILURE;
-	}
-
-	if (bitNumber >= (unsigned long)_dataBuf[bufNumber].length * (sizeof(ScriptDataWord) * CHAR_BIT)) {
-		return FAILURE;
-	}
-	
-	wordNumber = bitNumber / (sizeof(ScriptDataWord) * CHAR_BIT);
-	bitPos = bitNumber % (sizeof(ScriptDataWord) * CHAR_BIT);
-
-	bitPattern <<= ((sizeof(ScriptDataWord) * CHAR_BIT) - (bitPos + 1));
-
-	if (bitState) {
-		_dataBuf[bufNumber].data[wordNumber] |= bitPattern;
-	} else {
-		_dataBuf[bufNumber].data[wordNumber] &= ~bitPattern;
-	}
-
-	return SUCCESS;
-}
-
-int Script::getBit(int bufNumber, ScriptDataWord bitNumber, int *bitState) {
-	int wordNumber;
-	int bitPos;
-
-	ScriptDataWord bitPattern = 0x01;
-
-	if ((bufNumber < 0) || (bufNumber >= SCRIPT_DATABUF_NUM)) {
-		return FAILURE;
-	}
-
-	if (bitNumber >= (unsigned long)_dataBuf[bufNumber].length * (sizeof(ScriptDataWord) * CHAR_BIT)) {
-		return FAILURE;
-	}
-
-	wordNumber = bitNumber / (sizeof(ScriptDataWord) * CHAR_BIT);
-	bitPos = bitNumber % (sizeof(ScriptDataWord) * CHAR_BIT);
-
-	bitPattern <<= ((sizeof(ScriptDataWord) * CHAR_BIT) - (bitPos + 1));
-
-
-	*bitState = (_dataBuf[bufNumber].data[wordNumber] & bitPattern) ? 1 : 0;
-
-	return SUCCESS;
-}
-*/
 
 void Script::loadModule(int scriptModuleNumber) {
 	byte *resourcePointer;

Index: script.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/script.h,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- script.h	22 Jan 2005 14:43:49 -0000	1.62
+++ script.h	22 Jan 2005 15:28:24 -0000	1.63
@@ -152,6 +152,27 @@
 	opDecV = 0x29,
 	opPostInc = 0x2A,
 	opPostDec = 0x2B,
+	opAdd = 0x2C,
+	opSub = 0x2D,
+	opMul = 0x2E,
+	opDiv = 0x2F,
+	opMod = 0x30,
+//...	
+	opEq = 0x33,
+	opNe = 0x34,
+	opGt = 0x35,
+	opLt = 0x36,
+	opGe = 0x37,
+	opLe = 0x38,
+//...	
+	opRsh = 0x3F,
+	opLsh = 0x40,
+	opAnd = 0x41,
+	opOr = 0x42,
+	opXor = 0x43,
+	opLAnd = 0x44,
+	opLOr = 0x45,
+	opLXor = 0x46,
 
 //...
 	opSpeak = 0x53,
@@ -332,12 +353,6 @@
 
 	bool isInitialized() const { return _initialized;  }
 	bool isVoiceLUTPresent() const { return _voiceLUTPresent; }
-/*	ScriptData *currentScript() { return _currentScript; }
-	int getWord(int bufNumber, int wordNumber, ScriptDataWord *data);
-	int putWord(int bufNumber, int wordNumber, ScriptDataWord data);
-	int setBit(int bufNumber, ScriptDataWord bitNumber, int bitState);
-	int getBit(int bufNumber, ScriptDataWord bitNumber, int *bitState);	*/
-//	const char * getScriptString(int index) const { return _currentScript->strings.getString(index); }
 
 	void doVerb();
 	void showVerb(int statuscolor = -1);
@@ -521,24 +536,6 @@
 	int SF_playVoice(SCRIPTFUNC_PARAMS);
 };
 
-/*inline int getSWord(ScriptDataWord word) {
-	uint16 uInt = word;
-	int sInt;
-
-	if (uInt & 0x8000U) {
-		sInt = (int)(uInt - 0x8000U) - 0x7FFF - 1;
-	} else {
-		sInt = uInt;
-	}
-
-	return sInt;
-}
-
-inline uint getUWord(ScriptDataWord word) {
-	return (uint16) word;
-}
-*/
-
 } // End of namespace Saga
 
 #endif

Index: sthread.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sthread.cpp,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- sthread.cpp	22 Jan 2005 14:43:49 -0000	1.69
+++ sthread.cpp	22 Jan 2005 15:28:24 -0000	1.70
@@ -174,7 +174,7 @@
 	uint16 param2;
 	int16 iparam1;
 	int16 iparam2;
-	long iresult;
+//	long iresult;
 
 	byte argumentsCount;
 	uint16 functionNumber;
@@ -294,7 +294,7 @@
 			*(uint16*)addr =  thread->pop();
 			break;
 
-// CONTROL INSTRUCTIONS    
+// FUNCTION CALL INSTRUCTIONS    
 		CASEOP(opCall)
 			argumentsCount = scriptS.readByte();
 			param1 = scriptS.readByte();
@@ -467,173 +467,118 @@
 			break;
 
 // ARITHMETIC INSTRUCTIONS    
-
-			// (ADD): Addition
-		case 0x2C:
-			param2 = thread->pop();
-			param1 = thread->pop();
-			iparam2 = (long)param2;
-			iparam1 = (long)param1;
-			iresult = iparam1 + iparam2;
-			thread->push(iresult);
+		CASEOP(opAdd)
+			iparam2 = thread->pop();
+			iparam1 = thread->pop();
+			iparam1 += iparam2;
+			thread->push(iparam1);
 			break;
-			// (SUB): Subtraction
-		case 0x2D:
-			param2 = thread->pop();
-			param1 = thread->pop();
-			iparam2 = (long)param2;
-			iparam1 = (long)param1;
-			iresult = iparam1 - iparam2;
-			thread->push(iresult);
+		CASEOP(opSub)
+			iparam2 = thread->pop();
+			iparam1 = thread->pop();
+			iparam1 -= iparam2;
+			thread->push(iparam1);
 			break;
-			// (MULT): Integer multiplication
-		case 0x2E:
-			param2 = thread->pop();
-			param1 = thread->pop();
-			iparam2 = (long)param2;
-			iparam1 = (long)param1;
-			iresult = iparam1 * iparam2;
-			thread->push(iresult);
+		CASEOP(opMul)
+			iparam2 = thread->pop();
+			iparam1 = thread->pop();
+			iparam1 *= iparam2;
+			thread->push(iparam1);
 			break;
-			// (DIV): Integer division
-		case 0x2F:
-			param2 = thread->pop();
-			param1 = thread->pop();
-			iparam2 = (long)param2;
-			iparam1 = (long)param1;
-			iresult = iparam1 / iparam2;
-			thread->push(iresult);
+		CASEOP(opDiv)
+			iparam2 = thread->pop();
+			iparam1 = thread->pop();
+			iparam1 /= iparam2;
+			thread->push(iparam1);
 			break;
-			// (MOD) Modulus
-		case 0x30:
-			param2 = thread->pop();
-			param1 = thread->pop();
-			iparam2 = (long)param2;
-			iparam1 = (long)param1;
-			iresult = iparam1 % iparam2;
-			thread->push(iresult);
+		CASEOP(opMod)
+			iparam2 = thread->pop();
+			iparam1 = thread->pop();
+			iparam1 %= iparam2;
+			thread->push(iparam1);
 			break;
-			// (EQU) Test equality
-		case 0x33:
-			param2 = thread->pop();
-			param1 = thread->pop();
-			iparam2 = (long)param2;
-			iparam1 = (long)param1;
-			data = (iparam1 == iparam2) ? 1 : 0;
-			thread->push(data);
+
+// COMPARISION INSTRUCTIONS    
+		CASEOP(opEq)
+			iparam2 = thread->pop();
+			iparam1 = thread->pop();
+			thread->push((iparam1 == iparam2) ? 1 : 0);
 			break;
-			// (NEQU) Test inequality
-		case 0x34:
-			param2 = thread->pop();
-			param1 = thread->pop();
-			iparam2 = (long)param2;
-			iparam1 = (long)param1;
-			data = (iparam1 != iparam2) ? 1 : 0;
-			thread->push(data);
+		CASEOP(opNe)
+			iparam2 = thread->pop();
+			iparam1 = thread->pop();
+			thread->push((iparam1 != iparam2) ? 1 : 0);
 			break;
-			// (GRT) Test Greater-than
-		case 0x35:
-			param2 = thread->pop();
-			param1 = thread->pop();
-			iparam2 = (long)param2;
-			iparam1 = (long)param1;
-			data = (iparam1 > iparam2) ? 1 : 0;
-			thread->push(data);
+		CASEOP(opGt)
+			iparam2 = thread->pop();
+			iparam1 = thread->pop();
+			thread->push((iparam1 > iparam2) ? 1 : 0);
 			break;
-			// (LST) Test Less-than
-		case 0x36:
-			param2 = thread->pop();
-			param1 = thread->pop();
-			iparam2 = (long)param2;
-			iparam1 = (long)param1;
-			data = (iparam1 < iparam2) ? 1 : 0;
-			thread->push(data);
+		CASEOP(opLt)
+			iparam2 = thread->pop();
+			iparam1 = thread->pop();
+			thread->push((iparam1 < iparam2) ? 1 : 0);
 			break;
-			// (GRTE) Test Greater-than or Equal to
-		case 0x37:
-			param2 = thread->pop();
-			param1 = thread->pop();
-			iparam2 = (long)param2;
-			iparam1 = (long)param1;
-			data = (iparam1 >= iparam2) ? 1 : 0;
-			thread->push(data);
+		CASEOP(opGe)
+			iparam2 = thread->pop();
+			iparam1 = thread->pop();
+			thread->push((iparam1 >= iparam2) ? 1 : 0);
 			break;
-			// (LSTE) Test Less-than or Equal to
-		case 0x38:
-			param2 = thread->pop();
-			param1 = thread->pop();
-			iparam2 = (long)param2;
-			iparam1 = (long)param1;
-			data = (iparam1 <= iparam2) ? 1 : 0;
-			thread->push(data);
+		CASEOP(opLe)
+			iparam2 = thread->pop();
+			iparam1 = thread->pop();
+			thread->push((iparam1 <= iparam2) ? 1 : 0);
 			break;
 
-// BITWISE INSTRUCTIONS   
-
-			// (SHR): Arithmetic binary shift right
-		case 0x3F:
-			param2 = thread->pop();
-			param1 = thread->pop();
-			iparam2 = (long)param2;
-			// Preserve most significant bit
-			data = (0x01 << ((sizeof(param1) * CHAR_BIT) - 1)) & param1;
-			for (i = 0; i < (int)iparam2; i++) {
-				param1 >>= 1;
-				param1 |= data;
-			}
-			thread->push(param1);
+// SHIFT INSTRUCTIONS    
+		CASEOP(opRsh)
+			iparam2 = thread->pop();
+			iparam1 = thread->pop();
+			iparam1 >>= iparam2;
+			thread->push(iparam1);
 			break;
-			// (SHL) Binary shift left
-		case 0x40:
-			param2 = thread->pop();
-			param1 = thread->pop();
-			param1 <<= param2;
-			thread->push(param1);
+		CASEOP(opLsh)
+			iparam2 = thread->pop();
+			iparam1 = thread->pop();
+			iparam1 <<= iparam2;
+			thread->push(iparam1);
 			break;
-			// (AND) Binary AND
-		case 0x41:
-			param2 = thread->pop();
-			param1 = thread->pop();
-			param1 &= param2;
-			thread->push(param1);
+
+// BITWISE INSTRUCTIONS   
+		CASEOP(opAnd)
+			iparam2 = thread->pop();
+			iparam1 = thread->pop();
+			iparam1 &= iparam2;
+			thread->push(iparam1);
 			break;
-			// (OR) Binary OR
-		case 0x42:
-			param2 = thread->pop();
-			param1 = thread->pop();
-			param1 |= param2;
-			thread->push(param1);
+		CASEOP(opOr)
+			iparam2 = thread->pop();
+			iparam1 = thread->pop();
+			iparam1 |= iparam2;
+			thread->push(iparam1);
 			break;
-			// (XOR) Binary XOR
-		case 0x43:
-			param2 = thread->pop();
-			param1 = thread->pop();
-			param1 ^= param2;
-			thread->push(param1);
+		CASEOP(opXor)
+			iparam2 = thread->pop();
+			iparam1 = thread->pop();
+			iparam1 ^= iparam2;
+			thread->push(iparam1);
 			break;
 
-// BOOLEAN LOGIC INSTRUCTIONS     
-
-			// (LAND): Logical AND
-		case 0x44:
-			param2 = thread->pop();
-			param1 = thread->pop();
-			data = (param1 && param2) ? 1 : 0;
-			thread->push(data);
+// LOGICAL INSTRUCTIONS     
+		CASEOP(opLAnd)
+			iparam2 = thread->pop();
+			iparam1 = thread->pop();
+			thread->push((iparam1 && iparam2) ? 1 : 0);
 			break;
-			// (LOR): Logical OR
-		case 0x45:
-			param2 = thread->pop();
-			param1 = thread->pop();
-			data = (param1 || param2) ? 1 : 0;
-			thread->push(data);
+		CASEOP(opLOr)
+			iparam2 = thread->pop();
+			iparam1 = thread->pop();
+			thread->push((iparam1 || iparam2) ? 1 : 0);
 			break;
-			// (LXOR): Logical XOR
-		case 0x46:
-			param2 = thread->pop();
-			param1 = thread->pop();
-			data = ((param1) ? !(param2) : !!(param2));
-			thread->push(data);
+		CASEOP(opLXor)
+			iparam2 = thread->pop();
+			iparam1 = thread->pop();			
+			thread->push(((iparam1 && !iparam2) || (!iparam1 && iparam2)) ? 1 : 0);
 			break;
 
 // GAME INSTRUCTIONS  





More information about the Scummvm-git-logs mailing list