From 8dd601d35e26c7a50ee8cabf3ec69ba72e268d20 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 23 May 2009 19:59:42 +0000 Subject: Moved the "dump" and "dissectscript" commands to console.cpp and renamed them to "hexdump" and "dissect_script" respectively svn-id: r40818 --- engines/sci/console.cpp | 69 ++++++++++++++++++++++++++++++++++++++- engines/sci/console.h | 2 ++ engines/sci/engine/sciconsole.cpp | 30 ----------------- 3 files changed, 70 insertions(+), 31 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index b76a7fea4b..a441568cc2 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -84,11 +84,24 @@ Console::Console(SciEngine *vm) : GUI::Debugger() { 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 @@ bool Console::cmdGetVersion(int argc, const char **argv) { 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 @@ bool Console::cmdMan(int argc, const char **argv) { return true; } +bool Console::cmdHexDump(int argc, const char **argv) { + if (argc != 3) { + DebugPrintf("Usage: %s \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