aboutsummaryrefslogtreecommitdiff
path: root/engines/made
diff options
context:
space:
mode:
authorFilippos Karapetis2008-05-17 13:35:57 +0000
committerFilippos Karapetis2008-05-17 13:35:57 +0000
commit25e7e1999a41bd58680933d1435a6b50f83c5788 (patch)
tree228c70a9232af9341a6317e4dd294fa0be1909af /engines/made
parentf4cc7dfa85871575a50553dda3ee4f601cc603cf (diff)
downloadscummvm-rg350-25e7e1999a41bd58680933d1435a6b50f83c5788.tar.gz
scummvm-rg350-25e7e1999a41bd58680933d1435a6b50f83c5788.tar.bz2
scummvm-rg350-25e7e1999a41bd58680933d1435a6b50f83c5788.zip
Initial incomplete version of a MADE script dumper
svn-id: r32150
Diffstat (limited to 'engines/made')
-rw-r--r--engines/made/script.cpp58
-rw-r--r--engines/made/script.h1
2 files changed, 58 insertions, 1 deletions
diff --git a/engines/made/script.cpp b/engines/made/script.cpp
index 8b5a48cdd7..37e6f8536c 100644
--- a/engines/made/script.cpp
+++ b/engines/made/script.cpp
@@ -183,7 +183,6 @@ ScriptInterpreter::~ScriptInterpreter() {
}
void ScriptInterpreter::runScript(int16 scriptObjectIndex) {
-
_vm->_quit = false;
_runningScriptObjectIndex = scriptObjectIndex;
@@ -201,7 +200,64 @@ void ScriptInterpreter::runScript(int16 scriptObjectIndex) {
warning("ScriptInterpreter::runScript(%d) Unknown opcode %02X", _runningScriptObjectIndex, opcode);
}
}
+}
+void ScriptInterpreter::dumpScript(int16 scriptObjectIndex) {
+ _codeBase = _vm->_dat->getObject(scriptObjectIndex)->getData();
+ _codeIp = _codeBase;
+ int16 val = 0;
+
+ // TODO: script size
+ while (true) {
+ byte opcode = readByte();
+ if (opcode >= 1 && opcode <= _commandsMax) {
+ printf("[%04X:%04X] %s\n", _runningScriptObjectIndex, (uint) (_codeIp - _codeBase), _commands[opcode - 1].desc);
+ //(this->*_commands[opcode - 1].proc)();
+
+ // Handle command data
+ if (!strcmp(_commands[opcode - 1].desc, "cmd_branchTrue")) {
+ val = readInt16();
+ printf("Offset = %04X\n", val);
+ } else if (!strcmp(_commands[opcode - 1].desc, "cmd_branchFalse")) {
+ val = readInt16();
+ printf("Offset = %04X\n", val);
+ } else if (!strcmp(_commands[opcode - 1].desc, "cmd_branch")) {
+ val = readInt16();
+ printf("Offset = %04X\n", val);
+ } else if (!strcmp(_commands[opcode - 1].desc, "cmd_loadConstant")) {
+ val = readInt16();
+ printf("Constant = %04X\n", val);
+ } else if (!strcmp(_commands[opcode - 1].desc, "cmd_loadVariable")) {
+ val = readInt16();
+ printf("Variable = %04X\n", val);
+ } else if (!strcmp(_commands[opcode - 1].desc, "cmd_set")) {
+ val = readInt16();
+ printf("Variable = %04X\n", val);
+ } else if (!strcmp(_commands[opcode - 1].desc, "cmd_call")) {
+ // TODO
+ printf("TODO\n");
+ } else if (!strcmp(_commands[opcode - 1].desc, "cmd_arg") ||
+ !strcmp(_commands[opcode - 1].desc, "cmd_aset") ||
+ !strcmp(_commands[opcode - 1].desc, "cmd_tmp") ||
+ !strcmp(_commands[opcode - 1].desc, "cmd_tset") ||
+ !strcmp(_commands[opcode - 1].desc, "cmd_tspace")) {
+ val = readByte();
+ printf("argIndex = %d\n", val);
+ } else if (!strcmp(_commands[opcode - 1].desc, "cmd_send")) {
+ /*byte argc = */readByte();
+ // TODO
+ printf("TODO\n");
+ } else if (!strcmp(_commands[opcode - 1].desc, "cmd_extend")) {
+ /*byte func = */readByte();
+
+ /*byte argc = */readByte();
+ // TODO
+ printf("TODO\n");
+ }
+ } else {
+ warning("ScriptInterpreter::runScript(%d) Unknown opcode %02X", _runningScriptObjectIndex, opcode);
+ }
+ }
}
byte ScriptInterpreter::readByte() {
diff --git a/engines/made/script.h b/engines/made/script.h
index 6c031f8708..f2c49bd818 100644
--- a/engines/made/script.h
+++ b/engines/made/script.h
@@ -63,6 +63,7 @@ public:
ScriptInterpreter(MadeEngine *vm);
~ScriptInterpreter();
void runScript(int16 scriptObjectIndex);
+ void dumpScript(int16 scriptObjectIndex);
protected:
MadeEngine *_vm;