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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sat May 23 21:59:42 CEST 2009


Revision: 40818
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40818&view=rev
Author:   thebluegr
Date:     2009-05-23 19:59:42 +0000 (Sat, 23 May 2009)

Log Message:
-----------
Moved the "dump" and "dissectscript" commands to console.cpp and renamed them to "hexdump" and "dissect_script" respectively

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

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-05-23 19:48:41 UTC (rev 40817)
+++ scummvm/trunk/engines/sci/console.cpp	2009-05-23 19:59:42 UTC (rev 40818)
@@ -84,11 +84,24 @@
 	DCmd_Register("suffixes",			WRAP_METHOD(Console, cmdSuffixes));
 	DCmd_Register("kernelwords",		WRAP_METHOD(Console, cmdKernelWords));
 	DCmd_Register("man",				WRAP_METHOD(Console, cmdMan));
+	DCmd_Register("hexdump",			WRAP_METHOD(Console, cmdHexDump));
+	DCmd_Register("dissect_script",		WRAP_METHOD(Console, cmdDissectScript));
 }
 
 Console::~Console() {
 }
 
+static ResourceType parseResourceType(const char *resid) {
+	// Gets the resource number of a resource string, or returns -1
+	ResourceType res = kResourceTypeInvalid;
+
+	for (int i = 0; i < kResourceTypeInvalid; i++)
+		if (strcmp(getResourceTypeName((ResourceType)i), resid) == 0)
+			res = (ResourceType)i;
+
+	return res;
+}
+
 void Console::con_hook_command(ConCommand command, const char *name, const char *param, const char *description) {
 	DCmd_Register(name, new ConsoleFunc(command, param));
 }
@@ -98,7 +111,6 @@
 	int ver = _vm->getVersion();
 
 	DebugPrintf("Resource file version:        %s\n", sci_version_types[_vm->getResMgr()->_sciVersion]);
-
 	DebugPrintf("Emulated interpreter version: %s\n", versionNames[ver]);
 
 	return true;
@@ -233,4 +245,59 @@
 	return true;
 }
 
+bool Console::cmdHexDump(int argc, const char **argv) {
+	if (argc != 3) {
+		DebugPrintf("Usage: %s <resource type> <resource number>\n", argv[0]);
+		DebugPrintf("The 20 valid resource types are:\n");
+		// There are 20 resource types supported by SCI1.1
+		for (int i = 0; i < 20; i++) {
+			DebugPrintf("%s", getResourceTypeName((ResourceType) i));
+			DebugPrintf((i < 19) ? ", " : "\n");
+		}
+
+		return true;
+	}
+
+	int resNum = atoi(argv[2]);
+	if (resNum == 0) {
+		DebugPrintf("The resource number specified is not a number");
+		return true;
+	}
+
+	ResourceType res = parseResourceType(argv[1]);
+
+	if (res == kResourceTypeInvalid)
+		DebugPrintf("Resource type '%s' is not valid\n", argv[1]);
+	else {
+		Resource *resource = _vm->getResMgr()->findResource(res, resNum, 0);
+		if (resource) {
+			Common::hexdump(resource->data, resource->size, 16, 0);
+			DebugPrintf("Resource %s.%03d not has been dumped to standard output\n", argv[1], resNum);
+		} else {
+			DebugPrintf("Resource %s.%03d not found\n", argv[1], resNum);
+		}
+	}
+
+	return true;
+}
+
+bool Console::cmdDissectScript(int argc, const char **argv) {
+	Common::StringList selectorNames;
+
+	if (argc != 2) {
+		DebugPrintf("Examines a script\n");
+		DebugPrintf("Usage: %s <script number>\n", argv[0]);
+		return true;
+	}
+
+	if (!vocabulary_get_snames(_vm->getResMgr(), (_vm->getFlags() & GF_SCI0_OLD), selectorNames)) {
+		DebugPrintf("No selector name table found!\n");
+		return true;
+	}
+
+	script_dissect(_vm->getResMgr(), atoi(argv[1]), selectorNames);
+
+	return true;
+}
+
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/console.h
===================================================================
--- scummvm/trunk/engines/sci/console.h	2009-05-23 19:48:41 UTC (rev 40817)
+++ scummvm/trunk/engines/sci/console.h	2009-05-23 19:59:42 UTC (rev 40818)
@@ -49,6 +49,8 @@
 	bool cmdSuffixes(int argc, const char **argv);
 	bool cmdKernelWords(int argc, const char **argv);
 	bool cmdMan(int argc, const char **argv);
+	bool cmdHexDump(int argc, const char **argv);
+	bool cmdDissectScript(int argc, const char **argv);
 
 private:
 	SciEngine *_vm;

Modified: scummvm/trunk/engines/sci/engine/sciconsole.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/sciconsole.cpp	2009-05-23 19:48:41 UTC (rev 40817)
+++ scummvm/trunk/engines/sci/engine/sciconsole.cpp	2009-05-23 19:59:42 UTC (rev 40818)
@@ -43,11 +43,9 @@
 static int c_set(EngineState *s, const Common::Array<cmd_param_t> &cmdParams); // sets an int variable
 static int c_print(EngineState *s, const Common::Array<cmd_param_t> &cmdParams); // prints a variable
 static int c_size(EngineState *s, const Common::Array<cmd_param_t> &cmdParams); // displays the size of a resource
-static int c_dump(EngineState *s, const Common::Array<cmd_param_t> &cmdParams); // gives a hex dump of a resource
 //static int c_objinfo(EngineState *s, const Common::Array<cmd_param_t> &cmdParams); // shows some info about one class
 //static int c_objmethods(EngineState *s, const Common::Array<cmd_param_t> &cmdParams); // Disassembles all methods of a class
 static int c_hexgrep(EngineState *s, const Common::Array<cmd_param_t> &cmdParams); // Searches a string in one resource or resource class
-static int c_dissectscript(EngineState *s, const Common::Array<cmd_param_t> &cmdParams); // Splits a script into objects and explains them
 
 struct cmd_mm_entry_t {
 	const char *name;
@@ -171,11 +169,9 @@
 		con_hook_command(&c_print, "print", "s", "Prints an int variable");
 		con_hook_command(&c_set, "set", "si", "Sets an int variable");
 		con_hook_command(&c_size, "size", "si", "Displays the size of a resource");
-		con_hook_command(&c_dump, "dump", "si", "HexDumps a resource");
 		con_hook_command(&c_hexgrep, "hexgrep", "shh*", "Searches some resources for a\n"
 		                 "  particular sequence of bytes, re-\n  presented as hexadecimal numbers.\n\n"
 		                 "EXAMPLES:\n  hexgrep script e8 03 c8 00\n  hexgrep pic.042 fe");
-		con_hook_command(&c_dissectscript, "dissectscript", "i", "Examines a script.");
 
 		con_hook_page("addresses", "Passing address parameters\n\n"
 		              "  Address parameters may be passed in one of\n"
@@ -850,22 +846,6 @@
 	return 0;
 }
 
-static int c_dump(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	ResourceType res = parseResourceType(cmdParams[0].str);
-
-	if (res == kResourceTypeInvalid)
-		sciprintf("Resource type '%s' is not valid\n", cmdParams[0].str);
-	else {
-		Resource *resource = s->resmgr->findResource(res, cmdParams[1].val, 0);
-		if (resource)
-			Common::hexdump(resource->data, resource->size, 16, 0);
-		else
-			sciprintf("Resource %s.%03d not found\n", cmdParams[0].str, cmdParams[1].val);
-	}
-
-	return 0;
-}
-
 static int c_hexgrep(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
 	int i, seeklen, resnr, resmax;
 	unsigned char *seekstr = NULL;
@@ -939,16 +919,6 @@
 	return 0;
 }
 
-static int c_dissectscript(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	if (NULL == s) {
-		sciprintf("console.c: c_dissectscript(): NULL passed for parameter s\n");
-		return -1;
-	}
-
-	script_dissect(s->resmgr, cmdParams[0].val, s->_selectorNames);
-	return 0;
-}
-
 #endif // SCI_CONSOLE
 
 } // End of namespace Sci


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