Skip to content

Commit

Permalink
DIRECTOR: Lingo: Added generated script decompilation
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Aug 19, 2016
1 parent 1abbe6b commit 21d4d0a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
5 changes: 4 additions & 1 deletion engines/director/lingo/lingo-codegen.cpp
Expand Up @@ -71,7 +71,7 @@ void Lingo::execute(int pc) {
}
}

Common::String Lingo::decodeInstruction(int pc) {
Common::String Lingo::decodeInstruction(int pc, int *newPc) {
Symbol sym;
Common::String res;

Expand Down Expand Up @@ -118,6 +118,9 @@ Common::String Lingo::decodeInstruction(int pc) {
res = "<unknown>";
}

if (newPc)
*newPc = pc;

return res;
}

Expand Down
14 changes: 14 additions & 0 deletions engines/director/lingo/lingo.cpp
Expand Up @@ -181,6 +181,14 @@ void Lingo::addCode(const char *code, ScriptType type, uint16 id) {

parse(chunk.c_str());

if (debugChannelSet(3, kDebugLingoCompile)) {
int pc = 0;
while (pc < _currentScript->size()) {
Common::String instr = decodeInstruction(pc, &pc);
debugC(3, kDebugLingoCompile, "[%5d] %s", pc, instr.c_str());
}
}

_currentScript->clear();

begin = end;
Expand All @@ -201,6 +209,12 @@ void Lingo::addCode(const char *code, ScriptType type, uint16 id) {
if (debugChannelSet(3, kDebugLingoCompile)) {
if (_currentScript->size() && !_hadError)
Common::hexdump((byte *)&_currentScript->front(), _currentScript->size() * sizeof(inst));

int pc = 0;
while (pc < _currentScript->size()) {
Common::String instr = decodeInstruction(pc, &pc);
debugC(3, kDebugLingoCompile, "[%5d] %s", pc, instr.c_str());
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion engines/director/lingo/lingo.h
Expand Up @@ -180,7 +180,7 @@ class Lingo {

void addCode(const char *code, ScriptType type, uint16 id);
void executeScript(ScriptType type, uint16 id);
Common::String decodeInstruction(int pc);
Common::String decodeInstruction(int pc, int *newPC = NULL);

void processEvent(LEvent event, int entityId);

Expand Down

0 comments on commit 21d4d0a

Please sign in to comment.