aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2010-11-17 00:05:09 +0000
committerFilippos Karapetis2010-11-17 00:05:09 +0000
commitc2d9c1b06b455a5f41feb460ff0875962b6d6357 (patch)
tree43d57ba52d54bc391f0c3b139bd6cb8af51dc9ae /engines
parentf81b42dcafba4ddbffd12cc8b66f9b47c42f2314 (diff)
downloadscummvm-rg350-c2d9c1b06b455a5f41feb460ff0875962b6d6357.tar.gz
scummvm-rg350-c2d9c1b06b455a5f41feb460ff0875962b6d6357.tar.bz2
scummvm-rg350-c2d9c1b06b455a5f41feb460ff0875962b6d6357.zip
SCI: Added the ability to display original script bytecode in the "disasm" console command
svn-id: r54275
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/console.cpp19
-rw-r--r--engines/sci/console.h2
-rw-r--r--engines/sci/engine/scriptdebug.cpp6
3 files changed, 17 insertions, 10 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index 6ddc1afe0a..fe426d3489 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -1210,7 +1210,7 @@ bool Console::cmdClassTable(int argc, const char **argv) {
className,
PRINT_REG(temp.reg),
temp.script);
- }
+ } else DebugPrintf(" Class 0x%x (not loaded; can't get name) (script %d)\n", i, temp.script);
}
}
@@ -2609,13 +2609,17 @@ bool Console::cmdStepCallk(int argc, const char **argv) {
}
bool Console::cmdDisassemble(int argc, const char **argv) {
- if (argc != 3) {
+ if (argc < 3) {
DebugPrintf("Disassembles a method by name.\n");
- DebugPrintf("Usage: %s <object> <method>\n", argv[0]);
+ DebugPrintf("Usage: %s <object> <method> <print bytecode>\n", argv[0]);
+ DebugPrintf("The last parameter, <print bytecode> is optional. If true\n");
+ DebugPrintf("or 1 is specified, the associated bytecode is shown next to\n");
+ DebugPrintf("each dissassembled command\n");
return true;
}
reg_t objAddr = NULL_REG;
+ bool printBytecode = false;
if (parse_reg_t(_engine->_gamestate, argv[1], &objAddr, false)) {
DebugPrintf("Invalid address passed.\n");
@@ -2642,8 +2646,11 @@ bool Console::cmdDisassemble(int argc, const char **argv) {
return true;
}
+ if (argc == 4 && (!strcmp(argv[3], "1") || !strcmp(argv[3], "true")))
+ printBytecode = true;
+
do {
- addr = disassemble(_engine->_gamestate, addr, 0, 0);
+ addr = disassemble(_engine->_gamestate, addr, 0, printBytecode);
} while (addr.offset > 0);
return true;
@@ -2663,7 +2670,7 @@ bool Console::cmdDisassembleAddress(int argc, const char **argv) {
reg_t vpc = NULL_REG;
int op_count = 1;
int do_bwc = 0;
- int do_bytes = 0;
+ bool do_bytes = false;
int size;
if (parse_reg_t(_engine->_gamestate, argv[1], &vpc, false)) {
@@ -2679,7 +2686,7 @@ bool Console::cmdDisassembleAddress(int argc, const char **argv) {
if (!scumm_stricmp(argv[i], "bwt"))
do_bwc = 1;
else if (!scumm_stricmp(argv[i], "bc"))
- do_bytes = 1;
+ do_bytes = true;
else if (toupper(argv[i][0]) == 'C')
op_count = atoi(argv[i] + 1);
else {
diff --git a/engines/sci/console.h b/engines/sci/console.h
index 68c2d21e38..269ff47099 100644
--- a/engines/sci/console.h
+++ b/engines/sci/console.h
@@ -36,7 +36,7 @@ namespace Sci {
class SciEngine;
struct List;
-reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecode);
+reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, bool printBytecode);
class Console : public GUI::Debugger {
public:
diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp
index d587db26b4..2f1e44f1cf 100644
--- a/engines/sci/engine/scriptdebug.cpp
+++ b/engines/sci/engine/scriptdebug.cpp
@@ -64,7 +64,7 @@ const char *opcodeNames[] = {
};
// Disassembles one command from the heap, returns address of next command or 0 if a ret was encountered.
-reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecode) {
+reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, bool printBytecode) {
SegmentObj *mobj = s->_segMan->getSegment(pos.segment, SEG_TYPE_SCRIPT);
Script *script_entity = NULL;
const byte *scr;
@@ -97,7 +97,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
debugN("%04x:%04x: ", PRINT_REG(pos));
- if (print_bytecode) {
+ if (printBytecode) {
if (pos.offset + bytecount > scr_size) {
warning("Operation arguments extend beyond end of script");
return retval;
@@ -335,7 +335,7 @@ void SciEngine::scriptDebug() {
}
debugN("Step #%d\n", s->scriptStepCounter);
- disassemble(s, s->xs->addr.pc, 0, 1);
+ disassemble(s, s->xs->addr.pc, 0, true);
if (_debugState.runningStep) {
_debugState.runningStep--;