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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Tue May 26 17:06:22 CEST 2009


Revision: 40919
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40919&view=rev
Author:   fingolfin
Date:     2009-05-26 15:06:21 +0000 (Tue, 26 May 2009)

Log Message:
-----------
SCI: Added 'opcodes' command to the debugger; fixed output wrapping in the selectors & kernelnames debugger commands

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

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-05-26 15:01:52 UTC (rev 40918)
+++ scummvm/trunk/engines/sci/console.cpp	2009-05-26 15:06:21 UTC (rev 40919)
@@ -79,6 +79,8 @@
 	_vm = vm;
 
 	DCmd_Register("version",			WRAP_METHOD(Console, cmdGetVersion));
+//	DCmd_Register("classes",			WRAP_METHOD(Console, cmdClasses));	// TODO
+	DCmd_Register("opcodes",			WRAP_METHOD(Console, cmdOpcodes));
 	DCmd_Register("selectors",			WRAP_METHOD(Console, cmdSelectors));
 	DCmd_Register("kernelnames",		WRAP_METHOD(Console, cmdKernelNames));
 	DCmd_Register("suffixes",			WRAP_METHOD(Console, cmdSuffixes));
@@ -116,6 +118,27 @@
 	return true;
 }
 
+bool Console::cmdOpcodes(int argc, const char **argv) {
+	Common::Array<opcode> opcodes;
+
+	if (!vocab_get_opcodes(_vm->getResMgr(), opcodes)) {
+		DebugPrintf("No opcode name table found!\n");
+		return true;
+	}
+
+	DebugPrintf("Opcode names in numeric order [index: type name]:\n");
+	for (uint seeker = 0; seeker < opcodes.size(); seeker++) {
+		opcode &op = opcodes[seeker];
+		DebugPrintf("%03x: %03x %20s | ", seeker, op.type, op.name.c_str());
+		if ((seeker % 3) == 2)
+			DebugPrintf("\n");
+	}
+
+	DebugPrintf("\n");
+
+	return true;
+}
+
 bool Console::cmdSelectors(int argc, const char **argv) {
 	Common::StringList selectorNames;
 
@@ -127,7 +150,7 @@
 	DebugPrintf("Selector names in numeric order:\n");
 	for (uint seeker = 0; seeker < selectorNames.size(); seeker++) {
 		DebugPrintf("%03x: %20s | ", seeker, selectorNames[seeker].c_str());
-		if (seeker % 3 == 0)
+		if ((seeker % 3) == 2)
 			DebugPrintf("\n");
 	}
 
@@ -149,7 +172,7 @@
 	DebugPrintf("Selector names in numeric order:\n");
 	for (uint seeker = 0; seeker < kernelNames.size(); seeker++) {
 		DebugPrintf("%03x: %20s | ", seeker, kernelNames[seeker].c_str());
-		if (seeker % 3 == 0)
+		if ((seeker % 3) == 2)
 			DebugPrintf("\n");
 	}
 

Modified: scummvm/trunk/engines/sci/console.h
===================================================================
--- scummvm/trunk/engines/sci/console.h	2009-05-26 15:01:52 UTC (rev 40918)
+++ scummvm/trunk/engines/sci/console.h	2009-05-26 15:06:21 UTC (rev 40919)
@@ -44,6 +44,8 @@
 
 private:
 	bool cmdGetVersion(int argc, const char **argv);
+//	bool cmdClasses(int argc, const char **argv);	// TODO
+	bool cmdOpcodes(int argc, const char **argv);
 	bool cmdSelectors(int argc, const char **argv);
 	bool cmdKernelNames(int argc, const char **argv);
 	bool cmdSuffixes(int argc, const char **argv);

Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-05-26 15:01:52 UTC (rev 40918)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-05-26 15:06:21 UTC (rev 40919)
@@ -1221,7 +1221,7 @@
 	reg_t retval = make_reg(pos.segment, pos.offset + 1);
 	uint16 param_value;
 	int opsize;
-	int opcode;
+	uint opcode;
 	int bytecount = 1;
 	int i = 0;
 
@@ -1298,7 +1298,7 @@
 
 	if (print_bw_tag)
 		sciprintf("[%c] ", opsize ? 'B' : 'W');
-	sciprintf("%s", s->_opcodes[opcode].name.c_str());
+	sciprintf("%s", opcode < s->_opcodes.size() ? s->_opcodes[opcode].name.c_str() : "undefined");
 
 	i = 0;
 	while (g_opcode_formats[opcode][i]) {

Modified: scummvm/trunk/engines/sci/vocabulary.cpp
===================================================================
--- scummvm/trunk/engines/sci/vocabulary.cpp	2009-05-26 15:01:52 UTC (rev 40918)
+++ scummvm/trunk/engines/sci/vocabulary.cpp	2009-05-26 15:06:21 UTC (rev 40919)
@@ -122,7 +122,7 @@
 	return true;
 }
 
-void vocab_get_opcodes(ResourceManager *resmgr, Common::Array<opcode> &o) {
+bool vocab_get_opcodes(ResourceManager *resmgr, Common::Array<opcode> &o) {
 	int count, i = 0;
 	Resource* r = resmgr->findResource(kResourceTypeVocab, VOCAB_RESOURCE_OPCODES, 0);
 
@@ -131,27 +131,23 @@
 	// if the resource couldn't be loaded, leave
 	if (r == NULL) {
 		warning("unable to load vocab.%03d", VOCAB_RESOURCE_OPCODES);
-		return;
+		return false;
 	}
 
 	count = READ_LE_UINT16(r->data);
 
-	o.resize(256);
+	o.resize(count);
 	for (i = 0; i < count; i++) {
 		int offset = READ_LE_UINT16(r->data + 2 + i * 2);
 		int len = READ_LE_UINT16(r->data + offset) - 2;
 		o[i].type = READ_LE_UINT16(r->data + offset + 2);
-		o[i].number = i;
 		o[i].name = Common::String((char *)r->data + offset + 4, len);
 #if 1 //def VOCABULARY_DEBUG
 		printf("Opcode %02X: %s, %d\n", i, o[i].name.c_str(), o[i].type);
 #endif
 	}
-	for (i = count; i < 256; i++) {
-		o[i].type = 0;
-		o[i].number = i;
-		o[i].name = "undefined";
-	}
+
+	return true;
 }
 
 bool vocab_get_words(ResourceManager *resmgr, WordMap &words) {

Modified: scummvm/trunk/engines/sci/vocabulary.h
===================================================================
--- scummvm/trunk/engines/sci/vocabulary.h	2009-05-26 15:01:52 UTC (rev 40918)
+++ scummvm/trunk/engines/sci/vocabulary.h	2009-05-26 15:06:21 UTC (rev 40919)
@@ -48,7 +48,6 @@
 
 struct opcode {
 	int type;
-	int number;
 	Common::String name;
 };
 
@@ -186,14 +185,15 @@
 
 /**
  * Fills the given StringList with selector names.
- * Returns true upon success, false oterwise.
+ * Returns true upon success, false otherwise.
  */
 bool vocab_get_snames(ResourceManager *resmgr, bool isOldSci0, Common::StringList &selectorNames);
 
 /**
  * Obtain the list of opcodes.
+ * Returns true upon success, false otherwise.
  */
-void vocab_get_opcodes(ResourceManager *resmgr, Common::Array<opcode> &opcodes);
+bool vocab_get_opcodes(ResourceManager *resmgr, Common::Array<opcode> &opcodes);
 
 /**
  * Fills a StringList with kernel function names.


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