aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2009-05-26 15:06:21 +0000
committerMax Horn2009-05-26 15:06:21 +0000
commit099a29b6bf5dff9a02100aaff2b70146dc1de674 (patch)
tree98b13ec2bbd0ade68265984cae5b7cd51ac5c566 /engines
parentae480e2903cb650b1f04975207ed81dfdb8e95f1 (diff)
downloadscummvm-rg350-099a29b6bf5dff9a02100aaff2b70146dc1de674.tar.gz
scummvm-rg350-099a29b6bf5dff9a02100aaff2b70146dc1de674.tar.bz2
scummvm-rg350-099a29b6bf5dff9a02100aaff2b70146dc1de674.zip
SCI: Added 'opcodes' command to the debugger; fixed output wrapping in the selectors & kernelnames debugger commands
svn-id: r40919
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/console.cpp27
-rw-r--r--engines/sci/console.h2
-rw-r--r--engines/sci/engine/scriptdebug.cpp4
-rw-r--r--engines/sci/vocabulary.cpp14
-rw-r--r--engines/sci/vocabulary.h6
5 files changed, 37 insertions, 16 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index 386216607d..6a6ad672e7 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -79,6 +79,8 @@ Console::Console(SciEngine *vm) : GUI::Debugger() {
_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 @@ bool Console::cmdGetVersion(int argc, const char **argv) {
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 @@ bool Console::cmdSelectors(int argc, const char **argv) {
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 @@ bool Console::cmdKernelNames(int argc, const char **argv) {
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");
}
diff --git a/engines/sci/console.h b/engines/sci/console.h
index fe88388de9..6e2e13d951 100644
--- a/engines/sci/console.h
+++ b/engines/sci/console.h
@@ -44,6 +44,8 @@ public:
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);
diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp
index 0b86a411cf..ba75d0a854 100644
--- a/engines/sci/engine/scriptdebug.cpp
+++ b/engines/sci/engine/scriptdebug.cpp
@@ -1221,7 +1221,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
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 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
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]) {
diff --git a/engines/sci/vocabulary.cpp b/engines/sci/vocabulary.cpp
index 0f8eef5acc..cfac4b0ebf 100644
--- a/engines/sci/vocabulary.cpp
+++ b/engines/sci/vocabulary.cpp
@@ -122,7 +122,7 @@ bool vocab_get_snames(ResourceManager *resmgr, bool isOldSci0, Common::StringLis
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 @@ void vocab_get_opcodes(ResourceManager *resmgr, Common::Array<opcode> &o) {
// 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) {
diff --git a/engines/sci/vocabulary.h b/engines/sci/vocabulary.h
index 9276a399d6..3f121fcbfb 100644
--- a/engines/sci/vocabulary.h
+++ b/engines/sci/vocabulary.h
@@ -48,7 +48,6 @@ class ResourceManager;
struct opcode {
int type;
- int number;
Common::String name;
};
@@ -186,14 +185,15 @@ struct parse_tree_node_t {
/**
* 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.