aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2014-05-17 04:42:58 +0200
committerJohannes Schickel2014-05-17 04:42:58 +0200
commite0b82f0ced3ca965c490cea8d0bc060de7a8c4ba (patch)
treead96f276830c4148bf75bcbf0ff2f494471bd355
parent17b29e109d229f75069f9898b954fad493199496 (diff)
parentf7b5c500649f531de66abf7a9700254fe5527511 (diff)
downloadscummvm-rg350-e0b82f0ced3ca965c490cea8d0bc060de7a8c4ba.tar.gz
scummvm-rg350-e0b82f0ced3ca965c490cea8d0bc060de7a8c4ba.tar.bz2
scummvm-rg350-e0b82f0ced3ca965c490cea8d0bc060de7a8c4ba.zip
Merge pull request #462 from digitall/debugConsoleChangeLevel
Add command to change debug level to the Debugger base class.
-rw-r--r--engines/agos/agos.cpp25
-rw-r--r--engines/agos/agos.h14
-rw-r--r--engines/agos/debugger.cpp23
-rw-r--r--engines/agos/debugger.h1
-rw-r--r--engines/agos/gfx.cpp5
-rw-r--r--engines/agos/script.cpp3
-rw-r--r--engines/agos/subroutine.cpp8
-rw-r--r--engines/agos/vga.cpp8
-rw-r--r--engines/parallaction/debug.h1
-rw-r--r--engines/scumm/debugger.cpp34
-rw-r--r--engines/scumm/debugger.h4
-rw-r--r--engines/scumm/scumm.cpp4
-rw-r--r--engines/scumm/scumm.h2
-rw-r--r--engines/scumm/vars.cpp2
-rw-r--r--gui/debugger.cpp20
-rw-r--r--gui/debugger.h1
16 files changed, 69 insertions, 86 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 */
diff --git a/engines/parallaction/debug.h b/engines/parallaction/debug.h
index 887d08e945..551d746edf 100644
--- a/engines/parallaction/debug.h
+++ b/engines/parallaction/debug.h
@@ -22,7 +22,6 @@ private:
Parallaction *_vm;
MouseTriState _mouseState;
- bool Cmd_DebugLevel(int argc, const char **argv);
bool Cmd_Location(int argc, const char **argv);
bool Cmd_Give(int argc, const char **argv);
bool Cmd_Zones(int argc, const char **argv);
diff --git a/engines/scumm/debugger.cpp b/engines/scumm/debugger.cpp
index a792d63149..3dd7b4caf5 100644
--- a/engines/scumm/debugger.cpp
+++ b/engines/scumm/debugger.cpp
@@ -89,7 +89,6 @@ ScummDebugger::ScummDebugger(ScummEngine *s)
DCmd_Register("loadgame", WRAP_METHOD(ScummDebugger, Cmd_LoadGame));
DCmd_Register("savegame", WRAP_METHOD(ScummDebugger, Cmd_SaveGame));
- DCmd_Register("level", WRAP_METHOD(ScummDebugger, Cmd_DebugLevel));
DCmd_Register("debug", WRAP_METHOD(ScummDebugger, Cmd_Debug));
DCmd_Register("show", WRAP_METHOD(ScummDebugger, Cmd_Show));
@@ -104,6 +103,18 @@ ScummDebugger::~ScummDebugger() {
// we need this destructor, even if it is empty, for __SYMBIAN32__
}
+void ScummDebugger::preEnter() {
+}
+
+void ScummDebugger::postEnter() {
+ // Runtime debug level change is dealt with by the base class "debuglevel" command
+ // but need to ensure that the _debugMode parameter is updated in sync.
+ _vm->_debugMode = (gDebugLevel >= 0);
+ // Boot params often need debugging switched on to work
+ if (_vm->_bootParam)
+ _vm->_debugMode = true;
+}
+
///////////////////////////////////////////////////
// Now the fun stuff:
@@ -523,27 +534,6 @@ bool ScummDebugger::Cmd_Debug(int argc, const char **argv) {
return true;
}
-bool ScummDebugger::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 (gDebugLevel >= 0) {
- _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\n");
- }
-
- return true;
-}
-
bool ScummDebugger::Cmd_Camera(int argc, const char **argv) {
DebugPrintf("Camera: cur (%d,%d) - dest (%d,%d) - accel (%d,%d) -- last (%d,%d)\n",
_vm->camera._cur.x, _vm->camera._cur.y, _vm->camera._dest.x, _vm->camera._dest.y,
diff --git a/engines/scumm/debugger.h b/engines/scumm/debugger.h
index 43bf9d6fd4..657f6be286 100644
--- a/engines/scumm/debugger.h
+++ b/engines/scumm/debugger.h
@@ -37,6 +37,9 @@ public:
private:
ScummEngine *_vm;
+ virtual void preEnter();
+ virtual void postEnter();
+
// Commands
bool Cmd_Room(int argc, const char **argv);
bool Cmd_LoadGame(int argc, const char **argv);
@@ -58,7 +61,6 @@ private:
bool Cmd_Passcode(int argc, const char **argv);
bool Cmd_Debug(int argc, const char **argv);
- bool Cmd_DebugLevel(int argc, const char **argv);
bool Cmd_Show(int argc, const char **argv);
bool Cmd_Hide(int argc, const char **argv);
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 54f22ecad3..34c231e5d4 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -205,7 +205,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
_lastInputScriptTime = 0;
_bootParam = 0;
_dumpScripts = false;
- _debugMode = 0;
+ _debugMode = false;
_objectOwnerTable = NULL;
_objectRoomTable = NULL;
_objectStateTable = NULL;
@@ -2281,7 +2281,7 @@ void ScummEngine::scummLoop_updateScummVars() {
VAR(VAR_MOUSE_Y) = _mouse.y;
if (VAR_DEBUGMODE != 0xFF) {
// This is NOT for the Mac version of Indy3/Loom
- VAR(VAR_DEBUGMODE) = _debugMode;
+ VAR(VAR_DEBUGMODE) = (_debugMode ? 1 : 0);
}
} else if (_game.version >= 1) {
// We use shifts below instead of dividing by V12_X_MULTIPLIER resp.
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index b4afa09bb2..be5a83d8c9 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -586,7 +586,7 @@ protected:
bool _dumpScripts;
bool _hexdumpScripts;
bool _showStack;
- uint16 _debugMode;
+ bool _debugMode;
// Save/Load class - some of this may be GUI
byte _saveLoadFlag, _saveLoadSlot;
diff --git a/engines/scumm/vars.cpp b/engines/scumm/vars.cpp
index 73028c8513..79d7ed03da 100644
--- a/engines/scumm/vars.cpp
+++ b/engines/scumm/vars.cpp
@@ -805,7 +805,7 @@ void ScummEngine::resetScummVars() {
}
if (VAR_DEBUGMODE != 0xFF) {
- VAR(VAR_DEBUGMODE) = _debugMode;
+ VAR(VAR_DEBUGMODE) = (_debugMode ? 1 : 0);
if (_game.heversion >= 80 && _debugMode)
VAR(85) = 1;
}
diff --git a/gui/debugger.cpp b/gui/debugger.cpp
index 2ec9937fdb..3cfa9f9803 100644
--- a/gui/debugger.cpp
+++ b/gui/debugger.cpp
@@ -61,6 +61,7 @@ Debugger::Debugger() {
DCmd_Register("help", WRAP_METHOD(Debugger, Cmd_Help));
DCmd_Register("openlog", WRAP_METHOD(Debugger, Cmd_OpenLog));
+ DCmd_Register("debuglevel", WRAP_METHOD(Debugger, Cmd_DebugLevel));
DCmd_Register("debugflag_list", WRAP_METHOD(Debugger, Cmd_DebugFlagsList));
DCmd_Register("debugflag_enable", WRAP_METHOD(Debugger, Cmd_DebugFlagEnable));
DCmd_Register("debugflag_disable", WRAP_METHOD(Debugger, Cmd_DebugFlagDisable));
@@ -501,6 +502,25 @@ bool Debugger::Cmd_OpenLog(int argc, const char **argv) {
}
+bool Debugger::Cmd_DebugLevel(int argc, const char **argv) {
+ if (argc == 1) { // print level
+ DebugPrintf("Debugging is currently %s (set at level %d)\n", (gDebugLevel >= 0) ? "enabled" : "disabled", gDebugLevel);
+ DebugPrintf("Usage: %s <n> where n is 0 to 10 or -1 to disable debugging\n", argv[0]);
+ } else { // set level
+ gDebugLevel = atoi(argv[1]);
+ if (gDebugLevel >= 0 && gDebugLevel < 11) {
+ DebugPrintf("Debug level set to level %d\n", gDebugLevel);
+ } else if (gDebugLevel < 0) {
+ DebugPrintf("Debugging is now disabled\n");
+ } else {
+ DebugPrintf("Invalid debug level value\n");
+ DebugPrintf("Usage: %s <n> where n is 0 to 10 or -1 to disable debugging\n", argv[0]);
+ }
+ }
+
+ return true;
+}
+
bool Debugger::Cmd_DebugFlagsList(int argc, const char **argv) {
const Common::DebugManager::DebugChannelList &debugLevels = DebugMan.listDebugChannels();
diff --git a/gui/debugger.h b/gui/debugger.h
index 4ce5481fbb..7481f89df2 100644
--- a/gui/debugger.h
+++ b/gui/debugger.h
@@ -193,6 +193,7 @@ protected:
bool Cmd_Exit(int argc, const char **argv);
bool Cmd_Help(int argc, const char **argv);
bool Cmd_OpenLog(int argc, const char **argv);
+ bool Cmd_DebugLevel(int argc, const char **argv);
bool Cmd_DebugFlagsList(int argc, const char **argv);
bool Cmd_DebugFlagEnable(int argc, const char **argv);
bool Cmd_DebugFlagDisable(int argc, const char **argv);