[Scummvm-cvs-logs] SF.net SVN: scummvm:[35419] tools/trunk

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Thu Dec 18 03:49:01 CET 2008


Revision: 35419
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35419&view=rev
Author:   drmccoy
Date:     2008-12-18 02:49:01 +0000 (Thu, 18 Dec 2008)

Log Message:
-----------
Updating the gob script decompiler a bit

Modified Paths:
--------------
    tools/trunk/degob_script.cpp
    tools/trunk/degob_script.h
    tools/trunk/degob_script_bargon.cpp
    tools/trunk/degob_script_v2.cpp
    tools/trunk/degob_script_v3.cpp
    tools/trunk/degob_script_v4.cpp
    tools/trunk/degob_script_v5.cpp
    tools/trunk/degob_script_v6.cpp

Modified: tools/trunk/degob_script.cpp
===================================================================
--- tools/trunk/degob_script.cpp	2008-12-18 02:48:15 UTC (rev 35418)
+++ tools/trunk/degob_script.cpp	2008-12-18 02:49:01 UTC (rev 35419)
@@ -266,8 +266,14 @@
 	while (1) {
 		operation = readUint8();
 
-		if ((operation >= 16) && (operation <= 29)) {
+		if ((operation >= 14) && (operation <= 29)) {
 			switch (operation) {
+			case 14:
+				skip(4);
+				if (peekUint8() == 97)
+					skip(1);
+				break;
+
 			case 17:
 			case 18:
 			case 20:
@@ -296,6 +302,9 @@
 				}
 				break;
 
+			case 15:
+				skip(2);
+								
 			case 16:
 			case 26:
 			case 27:
@@ -318,7 +327,7 @@
 				skipExpr(10);
 			}
 			continue;
-		} // if ((operation >= 16) && (operation <= 29))
+		} // if ((operation >= 14) && (operation <= 29))
 
 		if (operation == 9) {
 			num++;
@@ -355,6 +364,33 @@
 	while (1) {
 		operation = readUint8();
 
+		while ((operation == 14) || (operation == 15)) {
+			if (operation == 14) {
+				expr += printStr("#%d#", readUint16() * 4);
+
+				skip(2);
+				if (peekUint8() == 97)
+					skip(1);
+			} else if (operation == 15) {
+				expr += printStr("#%d->", readUint16() * 4);
+
+				skip(2);
+				uint8 var_A = readUint8();
+
+				skip(var_A);
+
+				for (int i = 0; i < var_A; i++)
+					expr += readExpr(12) + "->";
+
+				expr += "#";
+
+				if (peekUint8() == 97)
+					skip(1);
+			}
+
+			operation = readUint8();
+		}
+
 		if ((operation >= 16) && (operation <= 29)) {
 			// operands
 
@@ -564,8 +600,8 @@
 	}
 }
 
-std::string Script::readVarIndex() {
-	std::string expr;
+std::string Script::readVarIndex(uint16 *arg_0, uint16 *arg_4) {
+	std::string expr, pref;
 	byte *arrDesc;
 	int16 dim;
 	int16 dimCount;
@@ -573,6 +609,48 @@
 	int16 temp;
 
 	operation = readUint8();
+
+	while ((operation == 14) || (operation == 15)) {
+		if (operation == 14) {
+			pref += printStr("#%d#", readUint16() * 4);
+
+			if (arg_0)
+				*arg_0 = peekUint16();
+			if (arg_4)
+				*arg_4 = 14;
+
+			skip(2);
+			if (peekUint8() != 97)
+				return expr;
+
+			skip(1);
+		} else if (operation == 15) {
+			pref += printStr("#%d->", readUint16() * 4);
+
+			if (arg_0)
+				*arg_0 = peekUint16();
+			if (arg_4)
+				*arg_4 = 14;
+
+			skip(2);
+			uint8 var_A = readUint8();
+
+			skip(var_A);
+
+			for (int i = 0; i < var_A; i++)
+				pref += readExpr(12) + "->";
+
+			pref += "#";
+
+			if (peekUint8() != 97)
+				return expr;
+
+			skip(1);
+		}
+
+		operation = readUint8();
+	}
+
 	if ((operation == 16) || (operation == 18) || (operation == 25) || (operation == 28))
 		expr = "var8_";
 	else if ((operation == 17) || (operation == 24) || (operation == 27))
@@ -580,6 +658,8 @@
 	else if ((operation == 23) || (operation == 26))
 		expr = "var32_";
 
+	expr += pref;
+
 	switch (operation) {
 	case 23:
 	case 24:
@@ -793,6 +873,7 @@
 void Script::deGob() {
 	_funcOffsets.clear();
 	_funcOffsets.push_back(_start);
+	_funcOffsets.push_back(21921);
 
 	for (std::list<uint32>::iterator it = _funcOffsets.begin(); it != _funcOffsets.end(); ++it) {
 		seek(*it);

Modified: tools/trunk/degob_script.h
===================================================================
--- tools/trunk/degob_script.h	2008-12-18 02:48:15 UTC (rev 35418)
+++ tools/trunk/degob_script.h	2008-12-18 02:49:01 UTC (rev 35419)
@@ -141,7 +141,7 @@
 
 	void skipExpr(char stopToken = 99);
 	std::string readExpr(char stopToken = 99);
-	std::string readVarIndex();
+	std::string readVarIndex(uint16 *arg_0 = 0, uint16 *arg_4 = 0);
 
 	uint16 getBlockSize() const;
 
@@ -287,8 +287,8 @@
 
 	void o2_totSub(FuncParams &params);
 	void o2_evaluateStore(FuncParams &params);
-	void o2_copyVars(FuncParams &params);
-	void o2_pasteVars(FuncParams &params);
+	void o2_pushVars(FuncParams &params);
+	void o2_popVars(FuncParams &params);
 
 	void o2_loadSound(FuncParams &params);
 
@@ -498,6 +498,7 @@
 	virtual void goblinOpcode(int i, FuncParams &params);
 
 	void o6_loadCursor(FuncParams &params);
+	void o6_evaluateStore(FuncParams &params);
 	void o6_createSprite(FuncParams &params);
 };
 

Modified: tools/trunk/degob_script_bargon.cpp
===================================================================
--- tools/trunk/degob_script_bargon.cpp	2008-12-18 02:48:15 UTC (rev 35418)
+++ tools/trunk/degob_script_bargon.cpp	2008-12-18 02:49:01 UTC (rev 35419)
@@ -194,8 +194,8 @@
 		/* 40 */
 		{OPCODEF(o2_totSub), {PARAM_NONE}},
 		{OPCODET(o2_switchTotSub), {PARAM_UINT16, PARAM_UINT16}},
-		{OPCODEF(o2_copyVars), {PARAM_NONE}},
-		{OPCODEF(o2_pasteVars), {PARAM_NONE}},
+		{OPCODEF(o2_pushVars), {PARAM_NONE}},
+		{OPCODEF(o2_popVars), {PARAM_NONE}},
 		/* 44 */
 		{TYPE_NONE, 0, 0, {PARAM_NONE}},
 		{TYPE_NONE, 0, 0, {PARAM_NONE}},

Modified: tools/trunk/degob_script_v2.cpp
===================================================================
--- tools/trunk/degob_script_v2.cpp	2008-12-18 02:48:15 UTC (rev 35418)
+++ tools/trunk/degob_script_v2.cpp	2008-12-18 02:49:01 UTC (rev 35419)
@@ -195,8 +195,8 @@
 		/* 40 */
 		{OPCODEF(o2_totSub), {PARAM_NONE}},
 		{OPCODET(o2_switchTotSub), {PARAM_UINT16, PARAM_UINT16}},
-		{OPCODEF(o2_copyVars), {PARAM_NONE}},
-		{OPCODEF(o2_pasteVars), {PARAM_NONE}},
+		{OPCODEF(o2_pushVars), {PARAM_NONE}},
+		{OPCODEF(o2_popVars), {PARAM_NONE}},
 		/* 44 */
 		{TYPE_NONE, 0, 0, {PARAM_NONE}},
 		{TYPE_NONE, 0, 0, {PARAM_NONE}},
@@ -744,31 +744,26 @@
 	}
 }
 
-void Script_v2::o2_copyVars(FuncParams &params) {
+void Script_v2::o2_pushVars(FuncParams &params) {
 	uint8 count = readUint8();
 
-	startFunc(params);
-	print("%d", count);
-
 	for (uint16 i = 0; i < count; i++) {
+		printIndent();
 		if ((peekUint8() == 25) || (peekUint8() == 28)) {
-			print(", %s", readVarIndex().c_str());
+			print("push(%s, animDataSize);\n", readVarIndex().c_str());
 			skip(1);
 		} else
-			print(", %s", readExpr().c_str());
+			print("push(%s, 4);\n", readExpr().c_str());
 	}
-
-	endFunc();
 }
 
-void Script_v2::o2_pasteVars(FuncParams &params) {
+void Script_v2::o2_popVars(FuncParams &params) {
 	uint8 count = readUint8();
 
-	startFunc(params);
-	print("%d", count);
-	for (uint16 i = 0; i < count; i++)
-		print(", %s", readVarIndex().c_str());
-	endFunc();
+	for (uint16 i = 0; i < count; i++) {
+		printIndent();
+		print("pop(%s);\n", readVarIndex().c_str());
+	}
 }
 
 void Script_v2::o2_loadSound(FuncParams &params) {

Modified: tools/trunk/degob_script_v3.cpp
===================================================================
--- tools/trunk/degob_script_v3.cpp	2008-12-18 02:48:15 UTC (rev 35418)
+++ tools/trunk/degob_script_v3.cpp	2008-12-18 02:49:01 UTC (rev 35419)
@@ -195,8 +195,8 @@
 		/* 40 */
 		{OPCODEF(o2_totSub), {PARAM_NONE}},
 		{OPCODET(o2_switchTotSub), {PARAM_UINT16, PARAM_UINT16}},
-		{OPCODEF(o2_copyVars), {PARAM_NONE}},
-		{OPCODEF(o2_pasteVars), {PARAM_NONE}},
+		{OPCODEF(o2_pushVars), {PARAM_NONE}},
+		{OPCODEF(o2_popVars), {PARAM_NONE}},
 		/* 44 */
 		{TYPE_NONE, 0, 0, {PARAM_NONE}},
 		{TYPE_NONE, 0, 0, {PARAM_NONE}},

Modified: tools/trunk/degob_script_v4.cpp
===================================================================
--- tools/trunk/degob_script_v4.cpp	2008-12-18 02:48:15 UTC (rev 35418)
+++ tools/trunk/degob_script_v4.cpp	2008-12-18 02:49:01 UTC (rev 35419)
@@ -195,8 +195,8 @@
 		/* 40 */
 		{OPCODEF(o2_totSub), {PARAM_NONE}},
 		{OPCODET(o2_switchTotSub), {PARAM_UINT16, PARAM_UINT16}},
-		{OPCODEF(o2_copyVars), {PARAM_NONE}},
-		{OPCODEF(o2_pasteVars), {PARAM_NONE}},
+		{OPCODEF(o2_pushVars), {PARAM_NONE}},
+		{OPCODEF(o2_popVars), {PARAM_NONE}},
 		/* 44 */
 		{OPCODET(o4_draw0x44), {PARAM_EXPR, PARAM_EXPR, PARAM_EXPR, PARAM_EXPR, PARAM_EXPR}},
 		{OPCODET(o4_draw0x45), {PARAM_EXPR, PARAM_EXPR}},
@@ -233,10 +233,10 @@
 		{TYPE_NONE, 0, 0, {PARAM_NONE}},
 		{TYPE_NONE, 0, 0, {PARAM_NONE}},
 		/* 60 */
-		{OPCODET(o4_draw0x60), {PARAM_EXPR, PARAM_EXPR}},
-		{OPCODET(o4_draw0x61), {PARAM_EXPR}},
 		{TYPE_NONE, 0, 0, {PARAM_NONE}},
 		{TYPE_NONE, 0, 0, {PARAM_NONE}},
+		{TYPE_NONE, 0, 0, {PARAM_NONE}},
+		{TYPE_NONE, 0, 0, {PARAM_NONE}},
 		/* 64 */
 		{TYPE_NONE, 0, 0, {PARAM_NONE}},
 		{TYPE_NONE, 0, 0, {PARAM_NONE}},

Modified: tools/trunk/degob_script_v5.cpp
===================================================================
--- tools/trunk/degob_script_v5.cpp	2008-12-18 02:48:15 UTC (rev 35418)
+++ tools/trunk/degob_script_v5.cpp	2008-12-18 02:49:01 UTC (rev 35419)
@@ -195,8 +195,8 @@
 		/* 40 */
 		{OPCODEF(o2_totSub), {PARAM_NONE}},
 		{OPCODET(o2_switchTotSub), {PARAM_UINT16, PARAM_UINT16}},
-		{OPCODEF(o2_copyVars), {PARAM_NONE}},
-		{OPCODEF(o2_pasteVars), {PARAM_NONE}},
+		{OPCODEF(o2_pushVars), {PARAM_NONE}},
+		{OPCODEF(o2_popVars), {PARAM_NONE}},
 		/* 44 */
 		{OPCODET(o4_draw0x44), {PARAM_EXPR, PARAM_EXPR, PARAM_EXPR, PARAM_EXPR, PARAM_EXPR}},
 		{OPCODET(o4_draw0x45), {PARAM_EXPR, PARAM_EXPR}},

Modified: tools/trunk/degob_script_v6.cpp
===================================================================
--- tools/trunk/degob_script_v6.cpp	2008-12-18 02:48:15 UTC (rev 35418)
+++ tools/trunk/degob_script_v6.cpp	2008-12-18 02:49:01 UTC (rev 35419)
@@ -195,8 +195,8 @@
 		/* 40 */
 		{OPCODEF(o2_totSub), {PARAM_NONE}},
 		{OPCODET(o2_switchTotSub), {PARAM_UINT16, PARAM_UINT16}},
-		{OPCODEF(o2_copyVars), {PARAM_NONE}},
-		{OPCODEF(o2_pasteVars), {PARAM_NONE}},
+		{OPCODEF(o2_pushVars), {PARAM_NONE}},
+		{OPCODEF(o2_popVars), {PARAM_NONE}},
 		/* 44 */
 		{OPCODET(o4_draw0x44), {PARAM_EXPR, PARAM_EXPR, PARAM_EXPR, PARAM_EXPR, PARAM_EXPR}},
 		{OPCODET(o4_draw0x45), {PARAM_EXPR, PARAM_EXPR}},
@@ -234,7 +234,7 @@
 		{TYPE_NONE, 0, 0, {PARAM_NONE}},
 		/* 60 */
 		{OPCODET(o4_draw0x60), {PARAM_EXPR, PARAM_EXPR}},
-		{OPCODET(o4_draw0x61), {PARAM_EXPR}},
+		{OPCODET(o5_deleteFile), {PARAM_EXPR}},
 		{TYPE_NONE, 0, 0, {PARAM_NONE}},
 		{TYPE_NONE, 0, 0, {PARAM_NONE}},
 		/* 64 */
@@ -447,7 +447,7 @@
 		{OPCODEF(o1_whileDo), {PARAM_NONE}},
 		/* 08 */
 		{OPCODEF(o1_if), {PARAM_NONE}},
-		{OPCODEF(o2_evaluateStore), {PARAM_NONE}},
+		{OPCODEF(o6_evaluateStore), {PARAM_NONE}},
 		{OPCODEF(o1_loadSpriteToPos), {PARAM_NONE}},
 		{TYPE_NONE, 0, 0, {PARAM_NONE}},
 		/* 0C */
@@ -740,3 +740,57 @@
 	}
 	endFunc();
 }
+
+void Script_v6::o6_evaluateStore(FuncParams &params) {
+	uint8 type = peekUint8();
+	uint16 var_0, var_4;
+	std::string varIndex = readVarIndex(&var_0, &var_4);
+
+	if (var_0 != 0) {
+		std::string varIndex2;
+		uint16 var_6;
+
+		uint32 savedPos = getPos();
+
+		varIndex2 = readVarIndex(&var_6, 0);
+
+		printIndent();
+		print("memcpy(%s, %s, %d);\n", varIndex, varIndex2, var_6 * 4);
+
+		seek(savedPos);
+		skipExpr(99);
+
+		return;
+	}
+
+	if (peekUint8() == 98) {
+		skip(1);
+		uint8 loopCount = readUint8();
+
+		uint32 off = 0;
+		for (uint16 i = 0; i < loopCount; i++) {
+			uint8 c = readUint8();
+			uint16 n = readUint16();
+
+			printIndent();
+			print("memset(%s + %d, %d, %d);\n", varIndex, off, c, n);
+
+			off += n;
+		}
+	} else if (peekUint8() == 99) {
+		skip(1);
+		uint8 loopCount = readUint8();
+
+		for (uint16 i = 0; i < loopCount; i++) {
+			std::string expr = readExpr();
+			printIndent();
+			print("%s[%d] = %s;\n", varIndex.c_str(), (type == 24) ? (i * 2) : i, expr.c_str());
+		}
+	} else {
+		std::string expr = readExpr();
+
+		printIndent();
+		print("%s = %s;\n", varIndex.c_str(), expr.c_str());
+	}
+}
+


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