From 6856b09d5a0024397895984aeb8d79d4a77e9111 Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sun, 11 May 2014 12:27:38 +0100 Subject: AGOS: Switch opcode debugging to a debug flag, rather than level 2 hack. This is now set by --debugflags=opcode rather than -d 2, though it will still require a debug level greater than 0. --- engines/agos/agos.cpp | 5 +++-- engines/agos/agos.h | 5 ++++- engines/agos/script.cpp | 3 ++- engines/agos/subroutine.cpp | 3 +-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp index 2fc89771d3..8754b11065 100644 --- a/engines/agos/agos.cpp +++ b/engines/agos/agos.cpp @@ -21,6 +21,7 @@ */ #include "common/config-manager.h" +#include "common/debug-channels.h" #include "common/file.h" #include "common/fs.h" #include "common/textconsole.h" @@ -144,6 +145,8 @@ AGOSEngine_Elvira1::AGOSEngine_Elvira1(OSystem *system, const AGOSGameDescriptio AGOSEngine::AGOSEngine(OSystem *system, const AGOSGameDescription *gd) : Engine(system), _rnd("agos"), _gameDescription(gd) { + DebugMan.addDebugChannel(kDebugOpcode, "opcode", "Opcode debug level"); + _vcPtr = 0; _vcGetOutOfCode = 0; _gameOffsetsPtr = 0; @@ -244,7 +247,6 @@ AGOSEngine::AGOSEngine(OSystem *system, const AGOSGameDescription *gd) _backFlag = false; _dumpScripts = false; - _dumpOpcodes = false; _dumpVgaScripts = false; _dumpVgaOpcodes = false; _dumpImages = false; @@ -676,7 +678,6 @@ Common::Error AGOSEngine::init() { // TODO: Use special debug levels instead of the following hack. switch (gDebugLevel) { - case 2: _dumpOpcodes = true; break; case 3: _dumpVgaOpcodes = true; break; case 4: _dumpScripts = true; break; case 5: _dumpVgaScripts = true; break; diff --git a/engines/agos/agos.h b/engines/agos/agos.h index 5e49fce5ff..c23f16b690 100644 --- a/engines/agos/agos.h +++ b/engines/agos/agos.h @@ -61,6 +61,10 @@ struct Surface; namespace AGOS { +enum { + kDebugOpcode = 1 << 0 +}; + uint fileReadItemID(Common::SeekableReadStream *in); #define CHECK_BOUNDS(x, y) assert((uint)(x) < ARRAYSIZE(y)) @@ -329,7 +333,6 @@ protected: bool _copyProtection; bool _pause; bool _dumpScripts; - bool _dumpOpcodes; bool _dumpVgaScripts; bool _dumpVgaOpcodes; bool _dumpImages; diff --git a/engines/agos/script.cpp b/engines/agos/script.cpp index 6f809d9e2d..1dbb9c255a 100644 --- a/engines/agos/script.cpp +++ b/engines/agos/script.cpp @@ -22,6 +22,7 @@ // Item script opcodes for Simon1/Simon2 +#include "common/debug-channels.h" #include "common/endian.h" #include "common/system.h" #include "common/textconsole.h" @@ -987,7 +988,7 @@ int AGOSEngine::runScript() { return 1; do { - if (_dumpOpcodes) + if (DebugMan.isDebugChannelEnabled(kDebugOpcode)) dumpOpcode(_codePtr); if (getGameType() == GType_ELVIRA1) { diff --git a/engines/agos/subroutine.cpp b/engines/agos/subroutine.cpp index 39bc468dea..a54a6c3b49 100644 --- a/engines/agos/subroutine.cpp +++ b/engines/agos/subroutine.cpp @@ -564,8 +564,7 @@ restart: else _codePtr += 8; - if (_dumpOpcodes) - debug("; %d", sub->id); + debugC(kDebugOpcode, "; %d", sub->id); result = runScript(); if (result != 0) { break; -- cgit v1.2.3