diff options
author | Eugene Sandulenko | 2016-08-16 18:48:09 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-16 19:10:19 +0200 |
commit | 289d10c26be65307f39f3cd23cf4df27533cc43c (patch) | |
tree | 77005e1ccf7330592a90a831da0094137b4b595d /engines | |
parent | 09138c9e9ffb70e4831e9ca377632cdd13d4ec5e (diff) | |
download | scummvm-rg350-289d10c26be65307f39f3cd23cf4df27533cc43c.tar.gz scummvm-rg350-289d10c26be65307f39f3cd23cf4df27533cc43c.tar.bz2 scummvm-rg350-289d10c26be65307f39f3cd23cf4df27533cc43c.zip |
DIRECTOR: Lingo: Start of script execution trace code
Diffstat (limited to 'engines')
-rw-r--r-- | engines/director/lingo/lingo-builtins.cpp | 2 | ||||
-rw-r--r-- | engines/director/lingo/lingo-codegen.cpp | 15 | ||||
-rw-r--r-- | engines/director/lingo/lingo.h | 27 |
3 files changed, 42 insertions, 2 deletions
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp index 70092d873b..e366356951 100644 --- a/engines/director/lingo/lingo-builtins.cpp +++ b/engines/director/lingo/lingo-builtins.cpp @@ -136,6 +136,8 @@ void Lingo::initBuiltIns() { sym->u.bltin = blt->func; _handlers[blt->name] = sym; + + _functions[(void *)sym->u.s] = new FuncDesc(blt->name, ""); } } diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp index bf96802bb7..d84d5c7081 100644 --- a/engines/director/lingo/lingo-codegen.cpp +++ b/engines/director/lingo/lingo-codegen.cpp @@ -53,17 +53,28 @@ namespace Director { void Lingo::execute(int pc) { for(_pc = pc; (*_currentScript)[_pc] != STOP && !_returning;) { + Common::String instr = decodeInstruction(_pc); + + debugC(1, kDebugLingoExec, "%s", instr.c_str()); for (uint i = 0; i < _stack.size(); i++) { - debugN(5, "%d ", _stack[i].u.i); + debugCN(5, kDebugLingoExec, "%d ", _stack[i].u.i); } - debug(5, "%s", ""); + debugCN(5, kDebugLingoExec, "%s", ""); _pc++; (*((*_currentScript)[_pc - 1]))(); } } +Common::String Lingo::decodeInstruction(int pc) { + if (_functions.contains((void *)(*_currentScript)[pc])) { + return _functions[(void *)(*_currentScript)[pc]]->name; + } else { + return "<unknown>"; + } +} + Symbol *Lingo::lookupVar(const char *name, bool create, bool putInGlobalList) { Symbol *sym; diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index 33dd0255ac..7a5fba064d 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -83,6 +83,30 @@ typedef void (*inst)(void); typedef Common::Array<inst> ScriptData; typedef Common::Array<double> FloatArray; +struct FuncDesc { + Common::String name; + const char *proto; + + FuncDesc(Common::String n, const char *p) { name = n; proto = p; } +}; + +struct Pointer_EqualTo { + bool operator()(const void *x, const void *y) const { return x == y; } +}; + +struct Pointer_Hash { + uint operator()(const void *x) const { +#ifdef SCUMM_64BITS + uint64 v = (uint64)x; + return (v >> 32) ^ (v & 0xffffffff); +#else + return (uint)x; +#endif + } +}; + +typedef Common::HashMap<void *, FuncDesc *, Pointer_Hash, Pointer_EqualTo> FuncHash; + struct Symbol { /* symbol table entry */ char *name; int type; @@ -156,6 +180,7 @@ public: void addCode(const char *code, ScriptType type, uint16 id); void executeScript(ScriptType type, uint16 id); + Common::String decodeInstruction(int pc); void processEvent(LEvent event, int entityId); @@ -403,6 +428,8 @@ private: SymbolHash _globalvars; SymbolHash *_localvars; + FuncHash _functions; + int _pc; StackData _stack; |