From 5b31fe75d4cf8cc7c6c0272d660ebf07a49916bd Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 17 Feb 2008 14:14:26 +0000 Subject: Print instruction offset of script commands for debug output. svn-id: r30895 --- engines/kyra/script.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engines/kyra/script.cpp b/engines/kyra/script.cpp index 9f241c3d00..5558a397e4 100644 --- a/engines/kyra/script.cpp +++ b/engines/kyra/script.cpp @@ -186,6 +186,9 @@ bool ScriptHelper::runScript(ScriptState *script) { if (!script->ip) return false; + // Should be no Problem at all to cast to uint32 here, since that's the biggest ptrdiff the original + // would allow, of course that's not realistic to happen to be somewhere near the limit of uint32 anyway. + const uint32 instOffset = (uint32)((const byte*)script->ip - (const byte*)script->dataPtr->data); int16 code = *script->ip++; int16 opcode = (code >> 8) & 0x1F; @@ -203,7 +206,7 @@ bool ScriptHelper::runScript(ScriptState *script) { if (opcode > 18) { error("Script unknown command: %d", opcode); } else { - debugC(5, kDebugLevelScript, "%s([%d/%u])", _commands[opcode].desc, _parameter, (uint)_parameter); + debugC(5, kDebugLevelScript, "[0x%.08X] %s([%d/%u])", instOffset, _commands[opcode].desc, _parameter, (uint)_parameter); (this->*(_commands[opcode].proc))(script); } -- cgit v1.2.3