diff options
-rw-r--r-- | engines/director/lingo/lingo-codegen.cpp | 26 | ||||
-rw-r--r-- | engines/director/lingo/lingo.h | 1 |
2 files changed, 18 insertions, 9 deletions
diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp index 32ddea47ac..9f3b1e26fa 100644 --- a/engines/director/lingo/lingo-codegen.cpp +++ b/engines/director/lingo/lingo-codegen.cpp @@ -55,20 +55,28 @@ void Lingo::execute(int pc) { for(_pc = pc; (*_currentScript)[_pc] != STOP && !_returning;) { Common::String instr = decodeInstruction(_pc); - debugC(1, kDebugLingoExec, "[%3d]: %s", _pc, instr.c_str()); - - Common::String stack("Stack: "); + if (debugChannelSet(5, kDebugLingoExec)) + printStack("Stack before: "); - for (uint i = 0; i < _stack.size(); i++) { - Datum d = _stack[i]; - d.toString(); - stack += Common::String::format("<%s> ", d.u.s->c_str()); - } - debugC(5, kDebugLingoExec, "%s", stack.c_str()); + debugC(1, kDebugLingoExec, "[%3d]: %s", _pc, instr.c_str()); _pc++; (*((*_currentScript)[_pc - 1]))(); + + if (debugChannelSet(5, kDebugLingoExec)) + printStack("Stack after: "); + } +} + +void Lingo::printStack(const char *s) { + Common::String stack(s); + + for (uint i = 0; i < _stack.size(); i++) { + Datum d = _stack[i]; + d.toString(); + stack += Common::String::format("<%s> ", d.u.s->c_str()); } + debugC(5, kDebugLingoExec, "%s", stack.c_str()); } Common::String Lingo::decodeInstruction(int pc, int *newPc) { diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index 5f4eb78f78..b197abd9d7 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -175,6 +175,7 @@ public: void addCode(const char *code, ScriptType type, uint16 id); void executeScript(ScriptType type, uint16 id); + void printStack(const char *s); Common::String decodeInstruction(int pc, int *newPC = NULL); void processEvent(LEvent event, int entityId); |