[Scummvm-cvs-logs] SF.net SVN: scummvm:[43129] scummvm/branches/gsoc2009-draci/engines/draci

dkasak13 at users.sourceforge.net dkasak13 at users.sourceforge.net
Sat Aug 8 17:55:19 CEST 2009


Revision: 43129
          http://scummvm.svn.sourceforge.net/scummvm/?rev=43129&view=rev
Author:   dkasak13
Date:     2009-08-08 15:55:19 +0000 (Sat, 08 Aug 2009)

Log Message:
-----------
Implemented Script::testExpression().

Modified Paths:
--------------
    scummvm/branches/gsoc2009-draci/engines/draci/script.cpp
    scummvm/branches/gsoc2009-draci/engines/draci/script.h

Modified: scummvm/branches/gsoc2009-draci/engines/draci/script.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/script.cpp	2009-08-08 15:53:47 UTC (rev 43128)
+++ scummvm/branches/gsoc2009-draci/engines/draci/script.cpp	2009-08-08 15:55:19 UTC (rev 43129)
@@ -598,6 +598,8 @@
 	GPL2Operator oper;
 	GPL2Function func;
 
+	debugC(3, kDraciBytecodeDebugLevel, "\t<MATHEXPR>");
+
 	// Read in initial math object
 	obj = (mathExpressionObject)reader.readSint16LE();
 
@@ -688,6 +690,36 @@
 }
 
 /**
+ * @brief Evaluates a GPL mathematical expression on a given offset and returns 
+ * the result (which is normally a boolean-like value)
+ * 
+ * @param program	A GPL2Program instance of the program containing the expression
+ * @param offset	Offset of the expression inside the program (in multiples of 2 bytes)
+ * 
+ * @return The result of the expression converted to a bool.
+ *
+ * Reference: the function equivalent to this one is called "Can()" in the original engine.
+ */
+bool Script::testExpression(GPL2Program program, uint16 offset) {
+	
+	// Initialize program reader
+	Common::MemoryReadStream reader(program._bytecode, program._length);
+
+	// Offset is given as number of 16-bit integers so we need to convert
+	// it to a number of bytes  
+	offset -= 1;
+	offset *= 2;
+
+	// Seek to the expression
+	reader.seek(offset);
+
+	debugC(2, kDraciBytecodeDebugLevel, 
+		"Evaluating (standalone) GPL expression at offset %d:", offset);
+
+	return (bool)handleMathExpression(reader);
+}
+
+/**
  * @brief Find the current command in the internal table
  *
  * @param num 		Command number
@@ -812,7 +844,8 @@
 
 			for (int i = 0; i < cmd->_numParams; ++i) {
 				if (cmd->_paramTypes[i] == 4) {
-					debugC(2, kDraciBytecodeDebugLevel, "\t<MATHEXPR>");
+					debugC(2, kDraciBytecodeDebugLevel, 
+						"Evaluating (in-script) GPL expression at offset %d: ", offset);
 					params.push(handleMathExpression(reader));
 				}
 				else {

Modified: scummvm/branches/gsoc2009-draci/engines/draci/script.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/script.h	2009-08-08 15:53:47 UTC (rev 43128)
+++ scummvm/branches/gsoc2009-draci/engines/draci/script.h	2009-08-08 15:55:19 UTC (rev 43129)
@@ -89,6 +89,7 @@
 	Script(DraciEngine *vm) : _vm(vm), _jump(0) { setupCommandList(); };	
 
 	int run(GPL2Program program, uint16 offset);
+	bool testExpression(GPL2Program, uint16 offset);
 	void endCurrentProgram();
 
 private:


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list