aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2013-06-01 22:14:59 -0400
committerPaul Gilbert2013-06-01 22:14:59 -0400
commitf70fd947327495b8c4ff9e595c1371dbcd43cd3f (patch)
tree068be982810212c85bbc4849bda5f1f9c13a8632 /engines
parente9e596e741b70a9a6b3481732ca2dd37adefe8f6 (diff)
downloadscummvm-rg350-f70fd947327495b8c4ff9e595c1371dbcd43cd3f.tar.gz
scummvm-rg350-f70fd947327495b8c4ff9e595c1371dbcd43cd3f.tar.bz2
scummvm-rg350-f70fd947327495b8c4ff9e595c1371dbcd43cd3f.zip
VOYEUR: Added in debugger and adding event manager methods
Diffstat (limited to 'engines')
-rw-r--r--engines/voyeur/debugger.cpp34
-rw-r--r--engines/voyeur/debugger.h45
-rw-r--r--engines/voyeur/events.cpp56
-rw-r--r--engines/voyeur/events.h13
-rw-r--r--engines/voyeur/module.mk1
-rw-r--r--engines/voyeur/voyeur.cpp1
-rw-r--r--engines/voyeur/voyeur.h2
7 files changed, 152 insertions, 0 deletions
diff --git a/engines/voyeur/debugger.cpp b/engines/voyeur/debugger.cpp
new file mode 100644
index 0000000000..8407ead22f
--- /dev/null
+++ b/engines/voyeur/debugger.cpp
@@ -0,0 +1,34 @@
+/* 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 "voyeur/debugger.h"
+
+#include "voyeur/graphics.h"
+#include "voyeur/voyeur.h"
+
+namespace Voyeur {
+
+Debugger::Debugger() : GUI::Debugger() {
+ DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit));
+}
+
+} // End of namespace Voyeur
diff --git a/engines/voyeur/debugger.h b/engines/voyeur/debugger.h
new file mode 100644
index 0000000000..302008716b
--- /dev/null
+++ b/engines/voyeur/debugger.h
@@ -0,0 +1,45 @@
+/* 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 VOYEUR_DEBUGGER_H
+#define VOYEUR_DEBUGGER_H
+
+#include "common/scummsys.h"
+#include "gui/debugger.h"
+
+namespace Voyeur {
+
+class VoyeurEngine;
+
+class Debugger : public GUI::Debugger {
+private:
+ VoyeurEngine *_vm;
+
+public:
+ Debugger();
+ virtual ~Debugger() {}
+ void setVm(VoyeurEngine *vm) { _vm = vm; }
+};
+
+} // End of namespace Voyeur
+
+#endif
diff --git a/engines/voyeur/events.cpp b/engines/voyeur/events.cpp
index c43c810b88..3202cb3b1f 100644
--- a/engines/voyeur/events.cpp
+++ b/engines/voyeur/events.cpp
@@ -27,6 +27,9 @@ namespace Voyeur {
EventsManager::EventsManager() {
_cycleStatus = 0;
+ _mouseButton = 0;
+ _priorFrameTime = g_system->getMillis();
+ Common::fill(&_keyState[0], &_keyState[256], false);
}
void EventsManager::resetMouse() {
@@ -71,4 +74,57 @@ void EventsManager::sWaitFlip() {
}
}
+void EventsManager::checkForNextFrameCounter() {
+ // Check for next game frame
+ uint32 milli = g_system->getMillis();
+ if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) {
+ ++_gameCounter;
+ _priorFrameTime = milli;
+
+ // Signal the ScummVM debugger
+ _vm->_debugger.onFrame();
+ }
+}
+
+void EventsManager::delay(int totalMilli) {
+ uint32 delayEnd = g_system->getMillis() + totalMilli;
+
+ while (!_vm->shouldQuit() && g_system->getMillis() < delayEnd) {
+ g_system->delayMillis(10);
+ }
+}
+
+void EventsManager::pollEvents() {
+ checkForNextFrameCounter();
+
+ Common::Event event;
+ while (g_system->getEventManager()->pollEvent(event)) {
+ // Handle keypress
+ switch (event.type) {
+ case Common::EVENT_QUIT:
+ case Common::EVENT_RTL:
+ return;
+
+ case Common::EVENT_KEYDOWN:
+ _keyState[(byte)toupper(event.kbd.ascii)] = true;
+ return;
+ case Common::EVENT_KEYUP:
+ _keyState[(byte)toupper(event.kbd.ascii)] = false;
+ return;
+ case Common::EVENT_LBUTTONDOWN:
+ _mouseButton = 1;
+ return;
+ case Common::EVENT_RBUTTONDOWN:
+ _mouseButton = 2;
+ return;
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_RBUTTONUP:
+ _mouseButton = 0;
+ return;
+ default:
+ break;
+ }
+ }
+}
+
} // End of namespace Voyeur
diff --git a/engines/voyeur/events.h b/engines/voyeur/events.h
index 98e491a56a..249db4a1fd 100644
--- a/engines/voyeur/events.h
+++ b/engines/voyeur/events.h
@@ -30,11 +30,21 @@ namespace Voyeur {
class VoyeurEngine;
+#define GAME_FRAME_RATE 50
+#define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE)
+
class EventsManager {
private:
VoyeurEngine *_vm;
+ uint32 _priorFrameTime;
+ uint32 _gameCounter;
+ bool _keyState[256];
+ int _mouseButton;
static void mainVoyeurIntFunc();
+private:
+ void checkForNextFrameCounter();
+
public:
IntData _intPtr;
IntNode _fadeIntNode;
@@ -50,6 +60,9 @@ public:
void startMainClockInt();
void vStopCycle();
void sWaitFlip();
+
+ void delay(int totalMilli);
+ void pollEvents();
};
} // End of namespace Voyeur
diff --git a/engines/voyeur/module.mk b/engines/voyeur/module.mk
index b13c414b92..bbe3d2e5e9 100644
--- a/engines/voyeur/module.mk
+++ b/engines/voyeur/module.mk
@@ -1,6 +1,7 @@
MODULE := engines/voyeur
MODULE_OBJS := \
+ debugger.o \
detection.o \
events.o \
game.o \
diff --git a/engines/voyeur/voyeur.cpp b/engines/voyeur/voyeur.cpp
index 82ee1a87af..ea3e3ceb9a 100644
--- a/engines/voyeur/voyeur.cpp
+++ b/engines/voyeur/voyeur.cpp
@@ -93,6 +93,7 @@ int VoyeurEngine::getRandomNumber(int maxNumber) {
}
void VoyeurEngine::initialiseManagers() {
+ _debugger.setVm(this);
_eventsManager.setVm(this);
_filesManager.setVm(this);
_graphicsManager.setVm(this);
diff --git a/engines/voyeur/voyeur.h b/engines/voyeur/voyeur.h
index 818615faaa..346d7fbc13 100644
--- a/engines/voyeur/voyeur.h
+++ b/engines/voyeur/voyeur.h
@@ -23,6 +23,7 @@
#ifndef VOYEUR_VOYEUR_H
#define VOYEUR_VOYEUR_H
+#include "voyeur/debugger.h"
#include "voyeur/events.h"
#include "voyeur/files.h"
#include "voyeur/game.h"
@@ -79,6 +80,7 @@ protected:
virtual Common::Error run();
virtual bool hasFeature(EngineFeature f) const;
public:
+ Debugger _debugger;
EventsManager _eventsManager;
FilesManager _filesManager;
GraphicsManager _graphicsManager;