[Scummvm-cvs-logs] SF.net SVN: scummvm:[50660] scummvm/trunk/engines/sci

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Mon Jul 5 01:38:09 CEST 2010


Revision: 50660
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50660&view=rev
Author:   mthreepwood
Date:     2010-07-04 23:38:08 +0000 (Sun, 04 Jul 2010)

Log Message:
-----------
Add a hexDumpReg function to view references that are not raw and fix SCI32 strings/arrays in segmentInfo.

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/console.h

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2010-07-04 22:48:40 UTC (rev 50659)
+++ scummvm/trunk/engines/sci/console.cpp	2010-07-04 23:38:08 UTC (rev 50660)
@@ -1558,6 +1558,15 @@
 		break;
 	}
 
+#ifdef ENABLE_SCI32
+	case SEG_TYPE_STRING:
+		DebugPrintf("SCI32 strings\n");
+		break;
+	case SEG_TYPE_ARRAY:
+		DebugPrintf("SCI32 arrays\n");
+		break;
+#endif
+
 	default :
 		DebugPrintf("Invalid type %d\n", mobj->getType());
 		break;
@@ -2112,7 +2121,7 @@
 		return true;
 	}
 
-	if (reg_end.segment != reg.segment) {
+	if (reg_end.segment != reg.segment && reg_end != NULL_REG) {
 		DebugPrintf("Ending segment different from starting segment. Assuming no bound on dump.\n");
 		reg_end = NULL_REG;
 	}
@@ -2151,13 +2160,15 @@
 			switch (_engine->_gamestate->_segMan->getSegmentType(reg.segment)) {
 #ifdef ENABLE_SCI32
 				case SEG_TYPE_STRING: {
+					DebugPrintf("SCI32 string\n");
 					const SciString *str = _engine->_gamestate->_segMan->lookupString(reg);
 					Common::hexdump((const byte *) str->getRawData(), str->getSize(), 16, 0);
 					break;
 				}
 				case SEG_TYPE_ARRAY: {
+					DebugPrintf("SCI32 array:\n");
 					const SciArray<reg_t> *array = _engine->_gamestate->_segMan->lookupArray(reg);
-					Common::hexdump((const byte *) array->getRawData(), array->getSize(), 16, 0);
+					hexDumpReg(array->getRawData(), array->getSize(), 4, 0, true);
 					break;
 				}
 #endif
@@ -2179,7 +2190,10 @@
 					if (reg_end.segment != 0)
 						DebugPrintf("Block size less than or equal to %d\n", size);
 
-					Common::hexdump(block.raw, size, 16, 0);
+					if (block.isRaw)
+						Common::hexdump(block.raw, size, 16, 0);
+					else
+						hexDumpReg(block.reg, size / 2, 4, 0);
 				}
 			}
 			break;
@@ -3284,4 +3298,58 @@
 	return 0;
 }
 
+void Console::hexDumpReg(const reg_t *data, int len, int regsPerLine, int startOffset, bool isArray) {
+	// reg_t version of Common::hexdump
+	assert(1 <= regsPerLine && regsPerLine <= 8);
+	int i;
+	byte c;
+	int offset = startOffset;
+	while (len >= regsPerLine) {
+		printf("%06x: ", offset);
+		for (i = 0; i < regsPerLine; i++) {
+			printf("%04x:%04x  ", PRINT_REG(data[i]));
+		}
+		printf(" |");
+		for (i = 0; i < regsPerLine; i++) {
+			c = data[i].toUint16() >> 8;
+			if (c < 32 || c >= 127)
+				c = '.';
+			printf("%c", c);
+			c = data[i].toUint16() & 0xff;
+			if (c < 32 || c >= 127)
+				c = '.';
+			printf("%c", c);
+		}
+		printf("|\n");
+		data += regsPerLine;
+		len -= regsPerLine;
+		offset += regsPerLine * (isArray ? 1 : 2);
+	}
+
+	if (len <= 0)
+		return;
+
+	printf("%06x: ", offset);
+	for (i = 0; i < regsPerLine; i++) {
+		if (i < len)
+			printf("%04x:%04x  ", PRINT_REG(data[i]));
+		else
+			printf("           ");
+	}
+	printf(" |");
+	for (i = 0; i < len; i++) {
+		c = data[i].toUint16() >> 8;
+		if (c < 32 || c >= 127)
+			c = '.';
+		printf("%c", c);
+		c = data[i].toUint16() & 0xff;
+		if (c < 32 || c >= 127)
+			c = '.';
+		printf("%c", c);
+	}
+	for (; i < regsPerLine; i++)
+		printf("  ");
+	printf("|\n");
+}
+
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/console.h
===================================================================
--- scummvm/trunk/engines/sci/console.h	2010-07-04 22:48:40 UTC (rev 50659)
+++ scummvm/trunk/engines/sci/console.h	2010-07-04 23:38:08 UTC (rev 50660)
@@ -151,6 +151,7 @@
 	bool segmentInfo(int nr);
 	void printList(List *list);
 	int printNode(reg_t addr);
+	void hexDumpReg(const reg_t *data, int len, int regsPerLine = 4, int startOffset = 0, bool isArray = false);
 
 private:
 	SciEngine *_engine;


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