diff options
author | Eugene Sandulenko | 2019-12-08 00:19:41 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2019-12-08 00:20:33 +0100 |
commit | b8a84f1507b840e36de666029e7b0673fd5c4e3c (patch) | |
tree | 0fe0067e572662c34351a5324a303088723b7f9c | |
parent | 254b48e1bd747f0d2d409ed8f10d490947a429db (diff) | |
download | scummvm-rg350-b8a84f1507b840e36de666029e7b0673fd5c4e3c.tar.gz scummvm-rg350-b8a84f1507b840e36de666029e7b0673fd5c4e3c.tar.bz2 scummvm-rg350-b8a84f1507b840e36de666029e7b0673fd5c4e3c.zip |
DIRECTOR: LINGO: Fix code decompilation offsets
-rw-r--r-- | engines/director/lingo/lingo-code.cpp | 3 | ||||
-rw-r--r-- | engines/director/lingo/lingo-codegen.cpp | 6 | ||||
-rw-r--r-- | engines/director/lingo/lingo.cpp | 6 |
3 files changed, 10 insertions, 5 deletions
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp index be4c10fcf8..20bf8ec195 100644 --- a/engines/director/lingo/lingo-code.cpp +++ b/engines/director/lingo/lingo-code.cpp @@ -1027,8 +1027,9 @@ void Lingo::c_whencode() { if (debugChannelSet(1, kDebugLingoExec)) { uint pc = 0; while (pc < sym->u.defn->size()) { + uint spc = pc; Common::String instr = g_lingo->decodeInstruction(sym->u.defn, pc, &pc); - debugC(1, kDebugLingoExec, "[%5d] %s", pc, instr.c_str()); + debugC(1, kDebugLingoExec, "[%5d] %s", spc, instr.c_str()); } } diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp index 16560efb7a..e1e77c990a 100644 --- a/engines/director/lingo/lingo-codegen.cpp +++ b/engines/director/lingo/lingo-codegen.cpp @@ -95,6 +95,7 @@ Common::String Lingo::decodeInstruction(ScriptData *sd, uint pc, uint *newPc) { res = _functions[(void *)sym.u.s]->name; const char *pars = _functions[(void *)sym.u.s]->proto; inst i; + uint start = pc; while (*pars) { switch (*pars++) { @@ -120,7 +121,7 @@ Common::String Lingo::decodeInstruction(ScriptData *sd, uint pc, uint *newPc) { i = (*sd)[pc++]; int v = READ_UINT32(&i); - res += Common::String::format(" [%5d]", v); + res += Common::String::format(" [%5d]", v + start - 1); break; } case 's': @@ -254,8 +255,9 @@ Symbol *Lingo::define(Common::String &name, int start, int nargs, Common::String if (debugChannelSet(1, kDebugLingoCompile)) { uint pc = 0; while (pc < sym->u.defn->size()) { + uint spc = pc; Common::String instr = g_lingo->decodeInstruction(sym->u.defn, pc, &pc); - debugC(1, kDebugLingoCompile, "[%5d] %s", pc, instr.c_str()); + debugC(1, kDebugLingoCompile, "[%5d] %s", spc, instr.c_str()); } debugC(1, kDebugLingoCompile, "<end define code>"); } diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp index cb6bd876a9..7a265babf6 100644 --- a/engines/director/lingo/lingo.cpp +++ b/engines/director/lingo/lingo.cpp @@ -178,8 +178,9 @@ void Lingo::addCode(const char *code, ScriptType type, uint16 id) { debugC(2, kDebugLingoCompile, "<current code>"); uint pc = 0; while (pc < _currentScript->size()) { + uint spc = pc; Common::String instr = decodeInstruction(_currentScript, pc, &pc); - debugC(2, kDebugLingoCompile, "[%5d] %s", pc, instr.c_str()); + debugC(2, kDebugLingoCompile, "[%5d] %s", spc, instr.c_str()); } debugC(2, kDebugLingoCompile, "<end code>"); } @@ -206,8 +207,9 @@ void Lingo::addCode(const char *code, ScriptType type, uint16 id) { debugC(2, kDebugLingoCompile, "<resulting code>"); uint pc = 0; while (pc < _currentScript->size()) { + uint spc = pc; Common::String instr = decodeInstruction(_currentScript, pc, &pc); - debugC(2, kDebugLingoCompile, "[%5d] %s", pc, instr.c_str()); + debugC(2, kDebugLingoCompile, "[%5d] %s", spc, instr.c_str()); } debugC(2, kDebugLingoCompile, "<end code>"); } |