[Scummvm-cvs-logs] SF.net SVN: scummvm: [24025] scummvm/trunk/engines/agos

kirben at users.sourceforge.net kirben at users.sourceforge.net
Sat Sep 30 07:51:14 CEST 2006


Revision: 24025
          http://svn.sourceforge.net/scummvm/?rev=24025&view=rev
Author:   kirben
Date:     2006-09-29 22:51:06 -0700 (Fri, 29 Sep 2006)

Log Message:
-----------
Add opcode table for Elvira 2 and cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/agos/debug.cpp
    scummvm/trunk/engines/agos/intern.h
    scummvm/trunk/engines/agos/items.cpp
    scummvm/trunk/engines/agos/res.cpp

Modified: scummvm/trunk/engines/agos/debug.cpp
===================================================================
--- scummvm/trunk/engines/agos/debug.cpp	2006-09-30 02:52:35 UTC (rev 24024)
+++ scummvm/trunk/engines/agos/debug.cpp	2006-09-30 05:51:06 UTC (rev 24025)
@@ -95,24 +95,32 @@
 			}
 
 		case 'W':{
-				int n = (int16)((p[0] << 8) | p[1]);
+				int n = (int16)READ_BE_UINT16(p);
 				p += 2;
-				if (n >= 30000 && n < 30512)
-					printf("[%d] ", n - 30000);
-				else
-					printf("%d ", n);
+				if (getGameType() == GType_PP) {
+					if (n >= 60000 && n < 62048)
+						printf("[%d] ", n - 60000);
+					else
+						printf("%d ", n);
+					
+				} else {
+					if (n >= 30000 && n < 30512)
+						printf("[%d] ", n - 30000);
+					else
+						printf("%d ", n);
+				}
 				break;
 			}
 
 		case 'w':{
-				int n = (int16)((p[0] << 8) | p[1]);
+				int n = (int16)READ_BE_UINT16(p);
 				p += 2;
 				printf("%d ", n);
 				break;
 			}
 
 		case 'I':{
-				int n = (int16)((p[0] << 8) | p[1]);;
+				int n = (int16)READ_BE_UINT16(p);
 				p += 2;
 				if (n == -1)
 					printf("ITEM_M1 ");
@@ -135,7 +143,7 @@
 			break;
 
 		case 'T':{
-				uint n = ((p[0] << 8) | p[1]);
+				uint n = READ_BE_UINT16(p);
 				p += 2;
 				if (n != 0xFFFF)
 					printf("\"%s\"(%d) ", getStringPtrByID(n), n);
@@ -188,11 +196,11 @@
 	const char *str, *strn;
 
 	do {
-		if (getGameType() == GType_SIMON1 || getGameType() == GType_WW) {
+		if (getGameType() == GType_SIMON2 || getGameType() == GType_FF || getGameType() == GType_PP) {
+			opcode = *src++;
+		} else {
 			opcode = READ_BE_UINT16(src);
 			src += 2;
-		} else {
-			opcode = *src++;
 		}
 
 		if (opcode >= _numVideoOpcodes) {
@@ -338,7 +346,7 @@
 void AGOSEngine::dump_bitmap(const char *filename, const byte *offs, int w, int h, int flags, const byte *palette,
 								 byte base) {
 
-	if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2)
+	if (getGameType() != GType_FF && getGameType() != GType_PP)
 		w *= 16;
 
 	/* allocate */

Modified: scummvm/trunk/engines/agos/intern.h
===================================================================
--- scummvm/trunk/engines/agos/intern.h	2006-09-30 02:52:35 UTC (rev 24024)
+++ scummvm/trunk/engines/agos/intern.h	2006-09-30 05:51:06 UTC (rev 24025)
@@ -42,6 +42,8 @@
 
 struct SubObject : Child {
 	uint16 objectName;
+	uint16 objectSize;
+	uint16 objectWeight;
 	uint32 objectFlags;
 	int16 objectFlagValue[1];
 };

Modified: scummvm/trunk/engines/agos/items.cpp
===================================================================
--- scummvm/trunk/engines/agos/items.cpp	2006-09-30 02:52:35 UTC (rev 24024)
+++ scummvm/trunk/engines/agos/items.cpp	2006-09-30 05:51:06 UTC (rev 24025)
@@ -516,6 +516,8 @@
 
 		opcode_table[283] = &AGOSEngine::o_isBox;
 		break;
+	case GType_ELVIRA2:
+		break;
 	case GType_WW:
 		// Confirmed
 		opcode_table[70] = &AGOSEngine::o1_printLongText;

Modified: scummvm/trunk/engines/agos/res.cpp
===================================================================
--- scummvm/trunk/engines/agos/res.cpp	2006-09-30 02:52:35 UTC (rev 24024)
+++ scummvm/trunk/engines/agos/res.cpp	2006-09-30 05:51:06 UTC (rev 24025)
@@ -40,7 +40,7 @@
 namespace AGOS {
 
 // Script opcodes to load into memory
-static const char *const opcode_arg_table_elvira[300] = {
+static const char *const opcode_arg_table_elvira1[300] = {
 	"I ", "I ", "I ", "I ", "I ", "I ", "I ", "I ",	 "II ",	"II ", "II ", "II ", "F ", "F ", "FN ",	 /*  EQ",        */
 	"FN ", "FN ", "FN ", "FF ", "FF ", "FF ", "FF ", "II ", "II ", "a ", "a ", "n ", "n ", "p ",	 /*  PREP",      */
 	"N ", "I ", "I ", "I ",	 "I ",	"IN ",	"IB ", "IB ", "II ", "IB ", "N ", " ", " ", " ", "I ",	 /*  GET",       */
@@ -64,6 +64,30 @@
 	" ", "NI ","N ",
 };
 
+static const char *const opcode_arg_table_elvira2[400] = {
+	"I ", "I ", "I ", "I ", "I ", "I ", "I ", "I ", "II ", "II ", "II ", "II ", "F ", "F ", "F ",
+	"N ", "FN ", "FN ", "FN ", "FF ", "FF ", "FF ", "FF ", "II ", "II ", "a ", "a ", "n ", "n ",
+	"p ", "N ", " ", "I ", "I ", "I ", "I ", "IN ", "IB ", "I ", "B ", "II ", "IB ", "N ", " ", " ",
+	" ", "I ", "I ", " ", "I ", "I ", "I ", "I ", "I ", "II ", "I ", "I ", "II ", "II ", "IBF ",
+	"FIB ", "FF ", "N ", "NI ", "IF ", "F ", "F ", "IB ", "IB ", "FN ", "FN ", " ", "FN ", "FF ",
+	"FF ", "FN ", "FN ", "FF ", "FF ", "FN ", "FF ", "FN ", "F ", "I ", "IN ", "IN ", "IB", " ",
+	"IB ", "IB ", "IB ", "II ", "I ", "I ", "IN ", "T ", "F ", " ", "T ", "T ", "I ", "I ", " ",
+	" ", "T ", " ", " ", " ", " ", " ", "T ", " ", "N ", "INN ", "II ", "II ", "ITN ", "ITIN ",
+	"ITI ", "N ", "I3 ", "IN ", "I ", "I ", "Ivnn ", "vnn ", "Ivnn ", "NN ", "IT ", "INN ", " ",
+	"N ", "N ", "N ", " ", "T ", "v ", " ", " ", " ", " ", "FN ", "I ", "TN ", "IT ", "II ", "I ",
+	 " ", "N ", "I ", " ", "I ", "NI ", "I ", "I ", "T ", "I ", "I ", "N ", "N ", " ", "N ", "IF ",
+	"IF ", "IF ", "I ", "F ", "IF ", "IF ", "T ", "IB ", "IB ", "IB ", "I ", " ", "vnnN ", "Ivnn ",
+	"T ", "T ", "T ", "IF ", " ", " ", " ", "Ivnn ", "IF ", "INI ", "INN ", "IN ", " ", "II ",
+	"IFF ", "IIF ", "I ", "II ", "I ", "I ", "IN ", "IN ", "II ", "II ", "II ", "II ", "IIN "
+	" ", "IIN ", "IN ", "II ", "IN ", "IN ", "T ", "v", "anpan ", "vIpI ", "T ", "T ", " ", 
+	" ", "IN ", "I ", "N ", "IN ", "IN ", "N ", "INTTT ", "ITTT ", "ITTT ", "I ", "I ", "IN ", 
+	"I ", " ", "F ", "NN ", "I ", "NN ", "INN ", "INNN ", "TF ", "NN ", "N ", "NNNN ", "N ", "N ",
+	" ", "NNNNNNN ", "N ", " ", "N ", "NN ", "N ", "NNNNNIN ", "N ", "N ", "N ", "N ", "NN ", 
+	"NNNN ", "INNN ", "IN ", "IN ", "TT ", "I ", "I ", "I ", "TTT ", "IN ", "IN ", "FN ", "FN ",
+	"F ", "N ", "N ", "N ", "N ", "NI ", " ", " ", "N ", "I ", "INN ", "NN ", "N ", "N ", "Nan ",
+	"NN ", " ", " ", " ", " ", " ", " ", " ", "IF ", "N ", " ", " ", " ", "II ", " ", "NI ", "N "
+};
+
 static const char *const opcode_arg_table_waxworks[256] = {
 	" ", "I ", "I ", "I ", "I ", "I ", "I ", "II ", "II ", "II ", "II ", "B ", "B ", "BN ", "BN ",
 	"BN ", "BN ", "BB ", "BB ", "BB ", "BB ", "II ", "II ", "N ", "I ", "I ", "I ", "IN ", "IB ",
@@ -443,7 +467,7 @@
 
 void AGOSEngine::readItemChildren(Common::File *in, Item *item, uint type) {
 	if (type == 1) {
-		if (getGameType() == GType_ELVIRA) {
+		if (getGameType() == GType_ELVIRA || getGameType() == GType_ELVIRA2) {
 			SubRoom *subRoom = (SubRoom *)allocateChildBlock(item, 1, sizeof(SubRoom));
 			subRoom->roomShort = in->readUint32BE();
 			subRoom->roomLong = in->readUint32BE();
@@ -469,27 +493,38 @@
 					subRoom->roomExit[k++] = (uint16)fileReadItemID(in);
 		}
 	} else if (type == 2) {
-		uint32 fr = in->readUint32BE();
-		uint i, k, size;
-		SubObject *subObject;
+		if (getGameType() == GType_ELVIRA || getGameType() == GType_ELVIRA2) {
+			SubObject *subObject = (SubObject *)allocateChildBlock(item, 2, sizeof(SubObject));
+			in->readUint32BE();
+			in->readUint32BE();
+			in->readUint32BE();
+			subObject->objectName = in->readUint32BE();
+			subObject->objectSize = in->readUint16BE();
+			subObject->objectWeight = in->readUint16BE();
+			subObject->objectFlags = in->readUint16BE();
+		} else {
+			uint32 fr = in->readUint32BE();
+			uint i, k, size;
+			SubObject *subObject;
 
-		size = SubObject_SIZE;
-		for (i = 0; i != 16; i++)
-			if (fr & (1 << i))
-				size += sizeof(subObject->objectFlagValue[0]);
+			size = SubObject_SIZE;
+			for (i = 0; i != 16; i++)
+				if (fr & (1 << i))
+					size += sizeof(subObject->objectFlagValue[0]);
 
-		subObject = (SubObject *)allocateChildBlock(item, 2, size);
-		subObject->objectFlags = fr;
+			subObject = (SubObject *)allocateChildBlock(item, 2, size);
+			subObject->objectFlags = fr;
 
-		k = 0;
-		if (fr & 1) {
-			subObject->objectFlagValue[k++] = (uint16)in->readUint32BE();
+			k = 0;
+			if (fr & 1) {
+				subObject->objectFlagValue[k++] = (uint16)in->readUint32BE();
+			}
+			for (i = 1; i != 16; i++)
+				if (fr & (1 << i))
+					subObject->objectFlagValue[k++] = in->readUint16BE();
+
+			subObject->objectName = (uint16)in->readUint32BE();
 		}
-		for (i = 1; i != 16; i++)
-			if (fr & (1 << i))
-				subObject->objectFlagValue[k++] = in->readUint16BE();
-
-		subObject->objectName = (uint16)in->readUint32BE();
 	} else if (type == 4) {
 		SubGenExit *genExit = (SubGenExit *)allocateChildBlock(item, 4, sizeof(SubGenExit));
 		genExit->dest[0] = (uint16)fileReadItemID(in);
@@ -516,7 +551,7 @@
 		setUserFlag(item, 1, in->readUint16BE());
 		setUserFlag(item, 2, in->readUint16BE());
 		setUserFlag(item, 3, in->readUint16BE());
-		if (getGameType() == GType_ELVIRA) {
+		if (getGameType() == GType_ELVIRA || getGameType() == GType_ELVIRA2) {
 			setUserFlag(item, 4, in->readUint16BE());
 			setUserFlag(item, 5, in->readUint16BE());
 			setUserFlag(item, 6, in->readUint16BE());
@@ -563,8 +598,10 @@
 		table = opcode_arg_table_simon1dos;
 	else if (getGameType() == GType_WW)
 		table = opcode_arg_table_waxworks;
+	else if (getGameType() == GType_ELVIRA2)
+		table = opcode_arg_table_elvira2;
 	else
-		table = opcode_arg_table_elvira;
+		table = opcode_arg_table_elvira1;
 
 	i = 0;
 	if (getGameType() == GType_ELVIRA || getGameType() == GType_ELVIRA2) {
@@ -594,15 +631,13 @@
 		case 'v':
 		case '3':
 			val = in->readUint16BE();
-			*ptr++ = val >> 8;
-			*ptr++ = val & 255;
+			WRITE_BE_UINT16(ptr, val); ptr += 2;
 			break;
 
 		case 'B':
 			if (getGameType() == GType_ELVIRA || getGameType() == GType_ELVIRA2) {
 				val = in->readUint16BE();
-				*ptr++ = val >> 8;
-				*ptr++ = val & 255;
+				WRITE_BE_UINT16(ptr, val); ptr += 2;
 			} else {
 				*ptr++ = in->readByte();
 				if (ptr[-1] == 0xFF) {
@@ -632,8 +667,7 @@
 			default:
 				val = fileReadItemID(in);;
 			}
-			*ptr++ = val >> 8;
-			*ptr++ = val & 255;
+			WRITE_BE_UINT16(ptr, val); ptr += 2;
 			break;
 
 		case 'T':
@@ -649,11 +683,10 @@
 				val = (uint16)in->readUint32BE();
 				break;
 			}
-			*ptr++ = val >> 8;
-			*ptr++ = val & 255;
+			WRITE_BE_UINT16(ptr, val); ptr += 2;
 			break;
 		default:
-			error("readSingleOpcode: Bad cmd table entry %c", l);
+			error("readSingleOpcode: Bad cmd table entry %d", l);
 		}
 	}
 }


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