diff options
Diffstat (limited to 'engines/agos')
-rw-r--r-- | engines/agos/agos.cpp | 25 | ||||
-rw-r--r-- | engines/agos/agos.h | 14 | ||||
-rw-r--r-- | engines/agos/debugger.cpp | 23 | ||||
-rw-r--r-- | engines/agos/debugger.h | 1 | ||||
-rw-r--r-- | engines/agos/gfx.cpp | 5 | ||||
-rw-r--r-- | engines/agos/script.cpp | 3 | ||||
-rw-r--r-- | engines/agos/subroutine.cpp | 8 | ||||
-rw-r--r-- | engines/agos/vga.cpp | 8 |
8 files changed, 29 insertions, 58 deletions
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp index 7266c75474..6eda2eb9aa 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,14 @@ 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"); + DebugMan.addDebugChannel(kDebugVGAOpcode, "vga_opcode", "VGA Opcode debug level"); + DebugMan.addDebugChannel(kDebugSubroutine, "subroutine", "Subroutine debug level"); + DebugMan.addDebugChannel(kDebugVGAScript, "vga_script", "VGA Script debug level"); + //Image dumping command disabled as it doesn't work well +#if 0 + DebugMan.addDebugChannel(kDebugImageDump, "image_dump", "Enable dumping of images to files"); +#endif _vcPtr = 0; _vcGetOutOfCode = 0; _gameOffsetsPtr = 0; @@ -243,13 +252,6 @@ AGOSEngine::AGOSEngine(OSystem *system, const AGOSGameDescription *gd) _backFlag = false; - _debugMode = 0; - _dumpScripts = false; - _dumpOpcodes = false; - _dumpVgaScripts = false; - _dumpVgaOpcodes = false; - _dumpImages = false; - _copyProtection = false; _pause = false; _speech = false; @@ -675,15 +677,6 @@ Common::Error AGOSEngine::init() { _subtitles = true; } - // TODO: Use special debug levels instead of the following hack. - _debugMode = (gDebugLevel >= 0); - switch (gDebugLevel) { - case 2: _dumpOpcodes = true; break; - case 3: _dumpVgaOpcodes = true; break; - case 4: _dumpScripts = true; break; - case 5: _dumpVgaScripts = true; break; - } - return Common::kNoError; } diff --git a/engines/agos/agos.h b/engines/agos/agos.h index 5e49fce5ff..b6b5e427e1 100644 --- a/engines/agos/agos.h +++ b/engines/agos/agos.h @@ -61,6 +61,14 @@ struct Surface; namespace AGOS { +enum { + kDebugOpcode = 1 << 0, + kDebugVGAOpcode = 1 << 1, + kDebugSubroutine = 1 << 2, + kDebugVGAScript = 1 << 3, + kDebugImageDump = 1 << 4 +}; + uint fileReadItemID(Common::SeekableReadStream *in); #define CHECK_BOUNDS(x, y) assert((uint)(x) < ARRAYSIZE(y)) @@ -324,15 +332,9 @@ protected: bool _fastMode; bool _backFlag; - uint16 _debugMode; Common::Language _language; bool _copyProtection; bool _pause; - bool _dumpScripts; - bool _dumpOpcodes; - bool _dumpVgaScripts; - bool _dumpVgaOpcodes; - bool _dumpImages; bool _speech; bool _subtitles; bool _vgaVar9; diff --git a/engines/agos/debugger.cpp b/engines/agos/debugger.cpp index 512137b685..b5233bed0c 100644 --- a/engines/agos/debugger.cpp +++ b/engines/agos/debugger.cpp @@ -33,7 +33,6 @@ Debugger::Debugger(AGOSEngine *vm) _vm = vm; DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); - DCmd_Register("level", WRAP_METHOD(Debugger, Cmd_DebugLevel)); DCmd_Register("music", WRAP_METHOD(Debugger, Cmd_PlayMusic)); DCmd_Register("sound", WRAP_METHOD(Debugger, Cmd_PlaySound)); DCmd_Register("voice", WRAP_METHOD(Debugger, Cmd_PlayVoice)); @@ -48,28 +47,6 @@ Debugger::Debugger(AGOSEngine *vm) } - -bool Debugger::Cmd_DebugLevel(int argc, const char **argv) { - if (argc == 1) { - if (_vm->_debugMode == false) - DebugPrintf("Debugging is not enabled at this time\n"); - else - DebugPrintf("Debugging is currently set at level %d\n", gDebugLevel); - } else { // set level - gDebugLevel = atoi(argv[1]); - if (0 <= gDebugLevel && gDebugLevel < 11) { - _vm->_debugMode = true; - DebugPrintf("Debug level set to level %d\n", gDebugLevel); - } else if (gDebugLevel < 0) { - _vm->_debugMode = false; - DebugPrintf("Debugging is now disabled\n"); - } else - DebugPrintf("Not a valid debug level (0 - 10)\n"); - } - - return true; -} - bool Debugger::Cmd_PlayMusic(int argc, const char **argv) { if (argc > 1) { uint music = atoi(argv[1]); diff --git a/engines/agos/debugger.h b/engines/agos/debugger.h index caac6e2caf..026194410f 100644 --- a/engines/agos/debugger.h +++ b/engines/agos/debugger.h @@ -37,7 +37,6 @@ public: private: AGOSEngine *_vm; - bool Cmd_DebugLevel(int argc, const char **argv); bool Cmd_PlayMusic(int argc, const char **argv); bool Cmd_PlaySound(int argc, const char **argv); bool Cmd_PlayVoice(int argc, const char **argv); diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp index 6e97084811..33145b7d0d 100644 --- a/engines/agos/gfx.cpp +++ b/engines/agos/gfx.cpp @@ -20,6 +20,7 @@ * */ +#include "common/debug-channels.h" #include "common/endian.h" #include "common/system.h" #include "common/textconsole.h" @@ -1129,7 +1130,7 @@ void AGOSEngine::animate(uint16 windowNum, uint16 zoneNum, uint16 vgaSpriteId, i assert(READ_BE_UINT16(&((AnimationHeader_WW *) p)->id) == vgaSpriteId); } - if (_dumpVgaScripts) { + if (DebugMan.isDebugChannelEnabled(kDebugVGAScript)) { if (getGameType() == GType_FF || getGameType() == GType_PP) { dumpVgaScript(_curVgaFile1 + READ_LE_UINT16(&((AnimationHeader_Feeble*)p)->scriptOffs), zoneNum, vgaSpriteId); } else if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) { @@ -1235,7 +1236,7 @@ void AGOSEngine::setImage(uint16 vgaSpriteId, bool vgaScript) { } } - if (_dumpVgaScripts) { + if (DebugMan.isDebugChannelEnabled(kDebugVGAScript)) { if (getGameType() == GType_FF || getGameType() == GType_PP) { dumpVgaScript(_curVgaFile1 + READ_LE_UINT16(&((ImageHeader_Feeble*)b)->scriptOffs), zoneNum, vgaSpriteId); } else if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) { 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..1e6ecaa829 100644 --- a/engines/agos/subroutine.cpp +++ b/engines/agos/subroutine.cpp @@ -20,8 +20,7 @@ * */ - - +#include "common/debug-channels.h" #include "common/file.h" #include "common/textconsole.h" @@ -531,7 +530,7 @@ int AGOSEngine::startSubroutine(Subroutine *sub) { _classMode1 = 0; _classMode2 = 0; - if (_dumpScripts) + if (DebugMan.isDebugChannelEnabled(kDebugSubroutine)) dumpSubroutine(sub); if (++_recursionDepth > 40) @@ -564,8 +563,7 @@ restart: else _codePtr += 8; - if (_dumpOpcodes) - debug("; %d", sub->id); + debugC(kDebugOpcode, "; %d", sub->id); result = runScript(); if (result != 0) { break; diff --git a/engines/agos/vga.cpp b/engines/agos/vga.cpp index c656c0167a..f761c3fc3f 100644 --- a/engines/agos/vga.cpp +++ b/engines/agos/vga.cpp @@ -27,6 +27,7 @@ #include "agos/intern.h" #include "agos/vga.h" +#include "common/debug-channels.h" #include "common/endian.h" #include "common/system.h" #include "common/textconsole.h" @@ -152,7 +153,7 @@ void AGOSEngine::runVgaScript() { for (;;) { uint opcode; - if (_dumpVgaOpcodes) { + if (DebugMan.isDebugChannelEnabled(kDebugVGAOpcode)) { if (_vcPtr != (const byte *)&_vcGetOutOfCode) { debugN("%.5d %.5X: %5d %4d ", _vgaTickCounter, (unsigned int)(_vcPtr - _curVgaFile1), _vgaCurSpriteId, _vgaCurZoneNum); dumpVideoScript(_vcPtr, true); @@ -381,8 +382,7 @@ void AGOSEngine::vcSkipNextInstruction() { _vcPtr += opcodeParamLenPN[opcode]; } - if (_dumpVgaOpcodes) - debugN("; skipped\n"); + debugCN(kDebugVGAOpcode, "; skipped\n"); } // VGA Script commands @@ -648,7 +648,7 @@ void AGOSEngine::drawImage_init(int16 image, uint16 palette, int16 x, int16 y, u if (height == 0 || width == 0) return; - if (_dumpImages) + if (DebugMan.isDebugChannelEnabled(kDebugImageDump)) dumpSingleBitmap(_vgaCurZoneNum, state.image, state.srcPtr, width, height, state.palette); state.width = state.draw_width = width; /* cl */ |