diff options
author | Max Horn | 2007-02-04 12:41:49 +0000 |
---|---|---|
committer | Max Horn | 2007-02-04 12:41:49 +0000 |
commit | 5b65897cd3d4a197fe167b19afb4d931359c2462 (patch) | |
tree | 08630c50987051a96bc8b7a224a1d1ec6dfbd65b /engines | |
parent | 5007d82ec7b771579df86c050eba75caddd3931f (diff) | |
download | scummvm-rg350-5b65897cd3d4a197fe167b19afb4d931359c2462.tar.gz scummvm-rg350-5b65897cd3d4a197fe167b19afb4d931359c2462.tar.bz2 scummvm-rg350-5b65897cd3d4a197fe167b19afb4d931359c2462.zip |
Switch SCUMM engine to use the common special debug flags support (thus making it possible to use --debugflags with it)
svn-id: r25381
Diffstat (limited to 'engines')
-rw-r--r-- | engines/scumm/debugger.cpp | 52 | ||||
-rw-r--r-- | engines/scumm/scumm.cpp | 28 | ||||
-rw-r--r-- | engines/scumm/scumm.h | 8 |
3 files changed, 47 insertions, 41 deletions
diff --git a/engines/scumm/debugger.cpp b/engines/scumm/debugger.cpp index c8d0276693..421d8a0b2d 100644 --- a/engines/scumm/debugger.cpp +++ b/engines/scumm/debugger.cpp @@ -38,27 +38,13 @@ namespace Scumm { -// Debug channel lookup table for Debugger console -static const dbgChannelDesc debugChannels[] = { - {"SCRIPTS", "Track script execution", DEBUG_SCRIPTS}, - {"OPCODES", "Track opcode execution", DEBUG_OPCODES}, - {"IMUSE", "Track iMUSE events", DEBUG_IMUSE}, - {"RESOURCE", "Track resource loading/management", DEBUG_RESOURCE}, - {"VARS", "Track variable changes", DEBUG_VARS}, - {"ACTORS", "Actor-related debug", DEBUG_ACTORS}, - {"SOUND", "Sound related debug", DEBUG_SOUND}, - {"INSANE", "Track INSANE", DEBUG_INSANE}, - {"SMUSH", "Track SMUSH", DEBUG_SMUSH} -}; - - void CDECL debugC(int channel, const char *s, ...) { char buf[STRINGBUFLEN]; va_list va; // FIXME: Still spew all debug at -d9, for crashes in startup etc. // Add setting from commandline ( / abstract channel interface) - if (!(g_scumm->_debugFlags & channel) && (gDebugLevel < 9)) + if (!(Common::getEnabledSpecialDebugLevels() & channel) && (gDebugLevel < 9)) return; va_start(va, s); @@ -112,7 +98,9 @@ ScummDebugger::ScummDebugger(ScummEngine *s) DCmd_Register("imuse", WRAP_METHOD(ScummDebugger, Cmd_IMuse)); } -ScummDebugger::~ScummDebugger() {} // we need this here for __SYMBIAN32__ +ScummDebugger::~ScummDebugger() { + // we need this destructor, even if it is empty, for __SYMBIAN32__ +} void ScummDebugger::preEnter() { // Pause sound output @@ -505,25 +493,25 @@ bool ScummDebugger::Cmd_Object(int argc, const char **argv) { } bool ScummDebugger::Cmd_Debug(int argc, const char **argv) { - int numChannels = sizeof(debugChannels) / sizeof(dbgChannelDesc); + Common::Array<Common::EngineDebugLevel> lvls = Common::listSpecialDebugLevels(); bool setFlag = false; // Remove or add debug channel? - if ((argc == 1) && (_vm->_debugFlags == 0)) { + if ((argc == 1) && (Common::getEnabledSpecialDebugLevels() == 0)) { DebugPrintf("No debug flags are enabled\n"); DebugPrintf("Available Channels: "); - for (int i = 0; i < numChannels; i++) { - DebugPrintf("%s, ", debugChannels[i].channel); + for (uint i = 0; i < lvls.size(); i++) { + DebugPrintf("%s, ", lvls[i].option.c_str()); } DebugPrintf("\n"); return true; } - if ((argc == 1) && (_vm->_debugFlags > 0)) { - for (int i = 0; i < numChannels; i++) { - if (_vm->_debugFlags & debugChannels[i].flag) - DebugPrintf("%s - %s\n", debugChannels[i].channel, - debugChannels[i].desc); + if ((argc == 1) && (Common::getEnabledSpecialDebugLevels() > 0)) { + for (uint i = 0; i < lvls.size(); i++) { + if (lvls[i].enabled) + DebugPrintf("%s - %s\n", lvls[i].option.c_str(), + lvls[i].description.c_str()); } return true; } @@ -536,25 +524,25 @@ bool ScummDebugger::Cmd_Debug(int argc, const char **argv) { } else { DebugPrintf("Syntax: Debug +CHANNEL, or Debug -CHANNEL\n"); DebugPrintf("Available Channels: "); - for (int i = 0; i < numChannels; i++) { - DebugPrintf("%s, ", debugChannels[i].channel); + for (uint i = 0; i < lvls.size(); i++) { + DebugPrintf("%s, ", lvls[i].option.c_str()); DebugPrintf("\n"); } } // Identify flag const char *realFlag = argv[1] + 1; - for (int i = 0; i < numChannels; i++) { - if ((scumm_stricmp(debugChannels[i].channel, realFlag)) == 0) { + for (uint i = 0; i < lvls.size(); i++) { + if ((scumm_stricmp(lvls[i].option.c_str(), realFlag)) == 0) { if (setFlag) { - _vm->_debugFlags |= debugChannels[i].flag; + enableSpecialDebugLevel(lvls[i].option); DebugPrintf("Enable "); } else { - _vm->_debugFlags &= ~debugChannels[i].flag; + disableSpecialDebugLevel(lvls[i].option); DebugPrintf("Disable "); } - DebugPrintf("%s\n", debugChannels[i].desc); + DebugPrintf("%s\n", lvls[i].description.c_str()); return true; } } diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 622a33b591..c8434029be 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -80,6 +80,25 @@ namespace Scumm { ScummEngine *g_scumm = 0; +struct dbgChannelDesc { + const char *channel, *desc; + uint32 flag; +}; + + +// Debug channel lookup table for Debugger console +static const dbgChannelDesc debugChannels[] = { + {"SCRIPTS", "Track script execution", DEBUG_SCRIPTS}, + {"OPCODES", "Track opcode execution", DEBUG_OPCODES}, + {"IMUSE", "Track iMUSE events", DEBUG_IMUSE}, + {"RESOURCE", "Track resource loading/management", DEBUG_RESOURCE}, + {"VARS", "Track variable changes", DEBUG_VARS}, + {"ACTORS", "Actor-related debug", DEBUG_ACTORS}, + {"SOUND", "Sound related debug", DEBUG_SOUND}, + {"INSANE", "Track INSANE", DEBUG_INSANE}, + {"SMUSH", "Track SMUSH", DEBUG_SMUSH} +}; + ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) : Engine(syst), _game(dr.game), @@ -112,7 +131,6 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _musicEngine = NULL; _verbs = NULL; _objs = NULL; - _debugFlags = 0; _sound = NULL; memset(&vm, 0, sizeof(vm)); _quit = false; @@ -502,9 +520,16 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { _herculesBuf = (byte *)malloc(Common::kHercW * Common::kHercH); } + + // Add debug levels + for (int i = 0; i < ARRAYSIZE(debugChannels); ++i) + Common::addSpecialDebugLevel(debugChannels[i].flag, debugChannels[i].channel, debugChannels[i].desc); } + ScummEngine::~ScummEngine() { + Common::clearAllSpecialDebugLevels(); + if (_musicEngine) { _musicEngine->terminate(); delete _musicEngine; @@ -558,6 +583,7 @@ ScummEngine::~ScummEngine() { delete _gdi; } + ScummEngine_v5::ScummEngine_v5(OSystem *syst, const DetectorResult &dr) : ScummEngine(syst, dr) { diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 416d1a2de5..6a0c1ded5b 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -135,11 +135,6 @@ enum GameFeatures { /* SCUMM Debug Channels */ void CDECL debugC(int level, const char *s, ...); -struct dbgChannelDesc { - const char *channel, *desc; - uint32 flag; -}; - enum { DEBUG_GENERAL = 1 << 0, // General debug DEBUG_SCRIPTS = 1 << 2, // Track script execution (start/stop/pause) @@ -440,9 +435,6 @@ public: /** Central resource data. */ ResourceManager *_res; - // Misc utility functions - uint32 _debugFlags; // Used by the debugger - protected: VirtualMachineState vm; |