aboutsummaryrefslogtreecommitdiff
path: root/engines/tony
diff options
context:
space:
mode:
Diffstat (limited to 'engines/tony')
-rw-r--r--engines/tony/debugger.cpp116
-rw-r--r--engines/tony/debugger.h42
-rw-r--r--engines/tony/input.cpp11
-rw-r--r--engines/tony/loc.h1
-rw-r--r--engines/tony/module.mk1
-rw-r--r--engines/tony/tony.cpp7
-rw-r--r--engines/tony/tony.h2
7 files changed, 179 insertions, 1 deletions
diff --git a/engines/tony/debugger.cpp b/engines/tony/debugger.cpp
new file mode 100644
index 0000000000..f358d51223
--- /dev/null
+++ b/engines/tony/debugger.cpp
@@ -0,0 +1,116 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/coroutines.h"
+#include "tony/debugger.h"
+#include "tony/globals.h"
+#include "tony/tony.h"
+
+namespace Tony {
+
+Debugger::Debugger() : GUI::Debugger() {
+ DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit));
+ DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_Scene));
+}
+
+static int strToInt(const char *s) {
+ if (!*s)
+ // No string at all
+ return 0;
+ else if (toupper(s[strlen(s) - 1]) != 'H')
+ // Standard decimal string
+ return atoi(s);
+
+ // Hexadecimal string
+ uint tmp = 0;
+ int read = sscanf(s, "%xh", &tmp);
+ if (read < 1)
+ error("strToInt failed on string \"%s\"", s);
+ return (int)tmp;
+}
+
+/**
+ * Support process for changing the scene
+ */
+struct ChangeSceneDetails {
+ int sceneNumber;
+ int x;
+ int y;
+};
+
+void DebugChangeScene(CORO_PARAM, const void *param) {
+ CORO_BEGIN_CONTEXT;
+ CORO_END_CONTEXT(_ctx);
+
+ uint32 result;
+ const ChangeSceneDetails *details = (const ChangeSceneDetails *)param;
+ RMPoint scenePos(details->x, details->y);
+
+ CORO_BEGIN_CODE(_ctx);
+
+ CORO_INVOKE_2(GLOBALS.UnloadLocation, false, &result);
+
+ GLOBALS.LoadLocation(details->sceneNumber, scenePos, RMPoint(-1, -1));
+
+ MainEnableGUI();
+
+ CORO_END_CODE;
+}
+
+
+/**
+ * This command loads up the specified new scene number
+ */
+bool Debugger::Cmd_Scene(int argc, const char **argv) {
+ if (argc < 2) {
+ DebugPrintf("Usage: %s <scene number> [<x> <y>]\n", argv[0]);
+ return true;
+ }
+
+ int sceneNumber = strToInt(argv[1]);
+ if (sceneNumber >= _vm->_theBoxes.GetLocBoxesCount()) {
+ DebugPrintf("Invalid scene\n");
+ return true;
+ }
+
+ RMPoint scenePos;
+ if (argc >= 4) {
+ scenePos.x = strToInt(argv[2]);
+ scenePos.y = strToInt(argv[3]);
+ } else {
+ // Get the box areas for the scene, and choose one so as to have a default
+ // position for Tony that will be in the walkable areas
+ RMBoxLoc *box = _vm->_theBoxes.GetBoxes(sceneNumber);
+ scenePos.Set(box->boxes[0].hotspot[0].hotx, box->boxes[0].hotspot[0].hoty);
+ }
+
+ // Set up a process to change the scene
+ ChangeSceneDetails details;
+ details.sceneNumber = sceneNumber;
+ details.x = scenePos.x;
+ details.y = scenePos.y;
+ CoroScheduler.createProcess(DebugChangeScene, &details, sizeof(ChangeSceneDetails));
+
+ return false;
+}
+
+} // End of namespace Tony
diff --git a/engines/tony/debugger.h b/engines/tony/debugger.h
new file mode 100644
index 0000000000..c5ed5e417e
--- /dev/null
+++ b/engines/tony/debugger.h
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TONY_DEBUGGER_H
+#define TONY_DEBUGGER_H
+
+#include "common/scummsys.h"
+#include "gui/debugger.h"
+
+namespace Tony {
+
+class Debugger : public GUI::Debugger {
+public:
+ Debugger();
+ virtual ~Debugger() {}
+
+protected:
+ bool Cmd_Scene(int argc, const char **argv);
+};
+
+} // End of namespace Tony
+
+#endif
diff --git a/engines/tony/input.cpp b/engines/tony/input.cpp
index 7663774ee4..c1104204b5 100644
--- a/engines/tony/input.cpp
+++ b/engines/tony/input.cpp
@@ -27,6 +27,7 @@
*/
#include "tony/gfxengine.h"
+#include "tony/tony.h"
namespace Tony {
@@ -79,7 +80,15 @@ void RMInput::Poll(void) {
return;
case Common::EVENT_KEYDOWN:
- _keyDown[(int)_event.kbd.keycode] = true;
+ // Check for debugger
+ if ((_event.kbd.keycode == Common::KEYCODE_d) && (_event.kbd.flags & Common::KBD_CTRL)) {
+ // Attach to the debugger
+ _vm->_debugger->attach();
+ _vm->_debugger->onFrame();
+ } else {
+ // Flag the given key as being down
+ _keyDown[(int)_event.kbd.keycode] = true;
+ }
return;
case Common::EVENT_KEYUP:
diff --git a/engines/tony/loc.h b/engines/tony/loc.h
index 4b9a18f406..7085c81dcb 100644
--- a/engines/tony/loc.h
+++ b/engines/tony/loc.h
@@ -353,6 +353,7 @@ public:
// Get binding boxes for a given location
RMBoxLoc *GetBoxes(int nLoc);
+ int GetLocBoxesCount() const { return m_nLocBoxes; }
// Return the box which contains a given point
int WhichBox(int nLoc, const RMPoint &pt);
diff --git a/engines/tony/module.mk b/engines/tony/module.mk
index 719a598ee4..d66cf6f065 100644
--- a/engines/tony/module.mk
+++ b/engines/tony/module.mk
@@ -2,6 +2,7 @@ MODULE := engines/tony
MODULE_OBJS := \
custom.o \
+ debugger.o \
detection.o \
font.o \
game.o \
diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp
index b60a196ed1..e5988e7c9b 100644
--- a/engines/tony/tony.cpp
+++ b/engines/tony/tony.cpp
@@ -28,6 +28,7 @@
#include "common/file.h"
#include "tony/tony.h"
#include "tony/custom.h"
+#include "tony/debugger.h"
#include "tony/game.h"
#include "tony/mpal/mpal.h"
@@ -40,6 +41,7 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng
_vm = this;
_loadSlotNumber = -1;
+ _debugger = new Debugger();
DebugMan.addDebugChannel(kTonyDebugAnimations, "animations", "Animations debugging");
DebugMan.addDebugChannel(kTonyDebugActions, "actions", "Actions debugging");
DebugMan.addDebugChannel(kTonyDebugSound, "sound", "Sound debugging");
@@ -60,6 +62,8 @@ TonyEngine::~TonyEngine() {
// Reset the coroutine scheduler
CoroScheduler.reset();
+
+ delete _debugger;
}
/**
@@ -529,6 +533,9 @@ void TonyEngine::PlayProcess(CORO_PARAM, const void *param) {
// Paint the frame onto the screen
_vm->_window.Repaint();
+
+ // Signal the ScummVM debugger
+ _vm->_debugger->onFrame();
}
CORO_END_CODE;
diff --git a/engines/tony/tony.h b/engines/tony/tony.h
index 23c235d058..bdaffee7c9 100644
--- a/engines/tony/tony.h
+++ b/engines/tony/tony.h
@@ -34,6 +34,7 @@
#include "tony/mpal/mpal.h"
#include "tony/mpal/memory.h"
+#include "tony/debugger.h"
#include "tony/gfxengine.h"
#include "tony/loc.h"
#include "tony/utils.h"
@@ -101,6 +102,7 @@ public:
Common::Array<VoiceHeader> _voices;
FPSOUND _theSound;
Globals _globals;
+ Debugger *_debugger;
enum DATADIR {
DD_BASE = 1,