aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/console.cpp69
-rw-r--r--engines/sci/console.h2
-rw-r--r--engines/sci/engine/sciconsole.cpp30
3 files changed, 70 insertions, 31 deletions
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 <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
diff --git a/engines/sci/console.h b/engines/sci/console.h
index 5307fa14cc..fe88388de9 100644
--- a/engines/sci/console.h
+++ b/engines/sci/console.h
@@ -49,6 +49,8 @@ private:
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;
diff --git a/engines/sci/engine/sciconsole.cpp b/engines/sci/engine/sciconsole.cpp
index 7f90eed87c..38027ce184 100644
--- a/engines/sci/engine/sciconsole.cpp
+++ b/engines/sci/engine/sciconsole.cpp
@@ -43,11 +43,9 @@ static int c_man(EngineState *s, const Common::Array<cmd_param_t> &cmdParams); /
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 @@ void con_init() {
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 @@ static int c_size(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
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 @@ static int c_hexgrep(EngineState *s, const Common::Array<cmd_param_t> &cmdParams
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