aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/kyra/debugger.cpp61
-rw-r--r--engines/kyra/debugger.h20
-rw-r--r--engines/kyra/lol.cpp4
-rw-r--r--engines/kyra/lol.h1
4 files changed, 80 insertions, 6 deletions
diff --git a/engines/kyra/debugger.cpp b/engines/kyra/debugger.cpp
index dc8dfb0a2c..186696edc9 100644
--- a/engines/kyra/debugger.cpp
+++ b/engines/kyra/debugger.cpp
@@ -33,6 +33,7 @@
#include "kyra/screen.h"
#include "kyra/timer.h"
#include "kyra/resource.h"
+#include "kyra/lol.h"
namespace Kyra {
@@ -132,10 +133,12 @@ bool Debugger::cmd_gameSpeed(int argc, const char **argv) {
}
bool Debugger::cmd_listFlags(int argc, const char **argv) {
- for (int i = 0; i < (int)sizeof(_vm->_flagsTable)*8; i++) {
- DebugPrintf("(%-3i): %-5i", i, _vm->queryGameFlag(i));
- if (!(i % 10))
+ for (int i = 0, p = 0; i < (int)sizeof(_vm->_flagsTable)*8; i++, ++p) {
+ DebugPrintf("(%-3i): %-2i", i, _vm->queryGameFlag(i));
+ if (p == 5) {
DebugPrintf("\n");
+ p -= 6;
+ }
}
DebugPrintf("\n");
return true;
@@ -457,5 +460,57 @@ bool Debugger_HoF::cmd_passcodes(int argc, const char **argv) {
return true;
}
+#pragma mark -
+
+Debugger_LoL::Debugger_LoL(LoLEngine *vm) : Debugger(vm), _vm(vm) {
+}
+
+bool Debugger_LoL::cmd_listFlags(int argc, const char **argv) {
+ for (int i = 0, p = 0; i < (int)sizeof(_vm->_gameFlags)*8; ++i, ++p) {
+ const uint8 index = (i >> 4);
+ const uint8 offset = i & 0xF;
+
+ DebugPrintf("(%-3i): %-2i", i, (_vm->_gameFlags[index] >> offset) & 1);
+ if (p == 5) {
+ DebugPrintf("\n");
+ p -= 6;
+ }
+ }
+ DebugPrintf("\n");
+ return true;
+}
+
+bool Debugger_LoL::cmd_toggleFlag(int argc, const char **argv) {
+ if (argc > 1) {
+ uint flag = atoi(argv[1]);
+
+ const uint8 index = (flag >> 4);
+ const uint8 offset = flag & 0xF;
+
+ _vm->_gameFlags[index] ^= _vm->_gameFlags[index] & (1 << offset);
+
+ DebugPrintf("Flag %i is now %i\n", flag, (_vm->_gameFlags[index] >> offset) & 1);
+ } else {
+ DebugPrintf("Syntax: toggleflag <flag>\n");
+ }
+
+ return true;
+}
+
+bool Debugger_LoL::cmd_queryFlag(int argc, const char **argv) {
+ if (argc > 1) {
+ uint flag = atoi(argv[1]);
+
+ const uint8 index = (flag >> 4);
+ const uint8 offset = flag & 0xF;
+
+ DebugPrintf("Flag %i is %i\n", flag, (_vm->_gameFlags[index] >> offset) & 1);
+ } else {
+ DebugPrintf("Syntax: queryflag <flag>\n");
+ }
+
+ return true;
+}
+
} // End of namespace Kyra
diff --git a/engines/kyra/debugger.h b/engines/kyra/debugger.h
index 601d12018e..04f138b491 100644
--- a/engines/kyra/debugger.h
+++ b/engines/kyra/debugger.h
@@ -47,9 +47,9 @@ protected:
bool cmd_loadPalette(int argc, const char **argv);
bool cmd_showFacings(int argc, const char **argv);
bool cmd_gameSpeed(int argc, const char **argv);
- bool cmd_listFlags(int argc, const char **argv);
- bool cmd_toggleFlag(int argc, const char **argv);
- bool cmd_queryFlag(int argc, const char **argv);
+ virtual bool cmd_listFlags(int argc, const char **argv);
+ virtual bool cmd_toggleFlag(int argc, const char **argv);
+ virtual bool cmd_queryFlag(int argc, const char **argv);
bool cmd_listTimers(int argc, const char **argv);
bool cmd_setTimerCountdown(int argc, const char **argv);
};
@@ -97,6 +97,20 @@ protected:
bool cmd_passcodes(int argc, const char **argv);
};
+class LoLEngine;
+
+class Debugger_LoL : public Debugger {
+public:
+ Debugger_LoL(LoLEngine *vm);
+
+protected:
+ LoLEngine *_vm;
+
+ bool cmd_listFlags(int argc, const char **argv);
+ bool cmd_toggleFlag(int argc, const char **argv);
+ bool cmd_queryFlag(int argc, const char **argv);
+};
+
} // End of namespace Kyra
#endif
diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp
index e504fc5bad..d4a7289a95 100644
--- a/engines/kyra/lol.cpp
+++ b/engines/kyra/lol.cpp
@@ -32,6 +32,7 @@
#include "kyra/sound.h"
#include "kyra/timer.h"
#include "kyra/util.h"
+#include "kyra/debugger.h"
#include "sound/voc.h"
#include "sound/audiostream.h"
@@ -541,6 +542,9 @@ Common::Error LoLEngine::init() {
_spellProcs.push_back(new SpellProc(this, 0));
_spellProcs.push_back(new SpellProc(this, &LoLEngine::castGuardian));
+ _debugger = new Debugger_LoL(this);
+ assert(_debugger);
+
return Common::kNoError;
}
diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h
index 682060c52d..53671fd837 100644
--- a/engines/kyra/lol.h
+++ b/engines/kyra/lol.h
@@ -292,6 +292,7 @@ class LoLEngine : public KyraEngine_v1 {
friend class GUI_LoL;
friend class TextDisplayer_LoL;
friend class TIMInterpreter_LoL;
+friend class Debugger_LoL;
public:
LoLEngine(OSystem *system, const GameFlags &flags);
~LoLEngine();