aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Kiehl2004-01-27 16:28:39 +0000
committerOliver Kiehl2004-01-27 16:28:39 +0000
commit832155b8cfbe2c99c704bae5b01dd2303c8b7763 (patch)
tree3388911ba48d48944368ddcdf717b2cc597ccd9b
parent0b344350704c4a7ccb0010c643adc7ef3a2e1785 (diff)
downloadscummvm-rg350-832155b8cfbe2c99c704bae5b01dd2303c8b7763.tar.gz
scummvm-rg350-832155b8cfbe2c99c704bae5b01dd2303c8b7763.tar.bz2
scummvm-rg350-832155b8cfbe2c99c704bae5b01dd2303c8b7763.zip
add in-game debugger
svn-id: r12634
-rw-r--r--simon/debugger.cpp65
-rw-r--r--simon/debugger.h47
-rw-r--r--simon/module.mk1
-rw-r--r--simon/simon.cpp8
-rw-r--r--simon/simon.h6
5 files changed, 127 insertions, 0 deletions
diff --git a/simon/debugger.cpp b/simon/debugger.cpp
new file mode 100644
index 0000000000..442db2e700
--- /dev/null
+++ b/simon/debugger.cpp
@@ -0,0 +1,65 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2003-2004 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#include "stdafx.h"
+#include "common/debugger.cpp"
+#include "simon/debugger.h"
+#include "simon/simon.h"
+
+namespace Simon {
+
+Debugger::Debugger(SimonEngine *vm)
+ : Common::Debugger<Debugger>() {
+ _vm = vm;
+
+ DCmd_Register("exit", &Debugger::Cmd_Exit);
+ DCmd_Register("quit", &Debugger::Cmd_Exit);
+ DCmd_Register("playVoice", &Debugger::Cmd_PlayVoice);
+}
+
+
+void Debugger::preEnter() {
+ _vm->midi.pause(1);
+}
+
+
+void Debugger::postEnter() {
+ _vm->midi.pause(0);
+}
+
+
+bool Debugger::Cmd_Exit(int argc, const char **argv) {
+ _detach_now = true;
+ return false;
+}
+
+bool Debugger::Cmd_PlayVoice(int argc, const char **argv) {
+ if (argc > 1) {
+ uint voice = atoi(argv[1]);
+ _vm->_sound->playVoice(voice);
+ } else
+ DebugPrintf("Syntax: playvoice <soundnum>\n");
+
+ return true;
+}
+
+} // End of namespace Simon
+
diff --git a/simon/debugger.h b/simon/debugger.h
new file mode 100644
index 0000000000..f1c82db1e4
--- /dev/null
+++ b/simon/debugger.h
@@ -0,0 +1,47 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2003-2004 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Header$
+ *
+ */
+
+#ifndef SIMON_DEBUGGER_H
+#define SIMON_DEBUGGER_H
+
+#include "common/debugger.h"
+
+namespace Simon {
+
+class SimonEngine;
+
+class Debugger : public Common::Debugger<Debugger> {
+public:
+ Debugger(SimonEngine *vm);
+
+protected:
+ SimonEngine *_vm;
+
+ virtual void preEnter();
+ virtual void postEnter();
+
+ bool Cmd_Exit(int argc, const char **argv);
+ bool Cmd_PlayVoice(int argc, const char **argv);
+};
+
+} // End of namespace Simon
+
+#endif
diff --git a/simon/module.mk b/simon/module.mk
index b671ff0e39..c3724794d0 100644
--- a/simon/module.mk
+++ b/simon/module.mk
@@ -3,6 +3,7 @@ MODULE := simon
MODULE_OBJS := \
simon/charset.o \
simon/debug.o \
+ simon/debugger.o \
simon/items.o \
simon/midi.o \
simon/midiparser_s1d.o \
diff --git a/simon/simon.cpp b/simon/simon.cpp
index 12723dd434..465fff7a69 100644
--- a/simon/simon.cpp
+++ b/simon/simon.cpp
@@ -36,6 +36,7 @@
#include "simon/simon.h"
#include "simon/intern.h"
#include "simon/vga.h"
+#include "simon/debugger.h"
#include "sound/mididrv.h"
@@ -599,6 +600,7 @@ SimonEngine::~SimonEngine() {
delete [] _fcs_list;
delete _sound;
+ delete _debugger;
}
void SimonEngine::errorString(const char *buf1, char *buf2) {
@@ -4785,6 +4787,7 @@ void SimonEngine::go() {
setup_vga_file_buf_pointers();
_sound = new Sound(_game, gss, _gameDataPath, _mixer);
+ _debugger = new Debugger(this);
if (ConfMan.hasKey("sfx_mute") && ConfMan.getBool("sfx_mute") == 1) {
if (_game == GAME_SIMON1DOS)
@@ -4896,6 +4899,9 @@ void SimonEngine::delay(uint amount) {
uint32 cur = start;
uint this_delay, vga_period;
+ if (_debugger->isAttached())
+ _debugger->onFrame();
+
if (_fast_mode)
vga_period = 10;
else if (_game & GF_SIMON2)
@@ -4944,6 +4950,8 @@ void SimonEngine::delay(uint amount) {
_aboutDialog->runModal();
} else if (event.kbd.keycode == 'f')
_fast_mode ^= 1;
+ else if (event.kbd.keycode == 'd')
+ _debugger->attach();
}
// Make sure backspace works right (this fixes a small issue on OS X)
if (event.kbd.keycode == 8)
diff --git a/simon/simon.h b/simon/simon.h
index 8b4e3a5360..e7582aa7b3 100644
--- a/simon/simon.h
+++ b/simon/simon.h
@@ -102,8 +102,12 @@ struct VgaTimerEntry {
};
struct GameSpecificSettings;
+
+class Debugger;
class SimonEngine : public Engine {
+ friend class Debugger;
+
void errorString(const char *buf_input, char *buf_output);
protected:
void playSting(uint a);
@@ -344,6 +348,8 @@ protected:
bool _ambient_paused;
bool _music_paused;
+ Debugger *_debugger;
+
int _timer_id;
FILE *_dump_file;