From f70fd947327495b8c4ff9e595c1371dbcd43cd3f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 1 Jun 2013 22:14:59 -0400 Subject: VOYEUR: Added in debugger and adding event manager methods --- engines/voyeur/debugger.cpp | 34 +++++++++++++++++++++++++++ engines/voyeur/debugger.h | 45 ++++++++++++++++++++++++++++++++++++ engines/voyeur/events.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++ engines/voyeur/events.h | 13 +++++++++++ engines/voyeur/module.mk | 1 + engines/voyeur/voyeur.cpp | 1 + engines/voyeur/voyeur.h | 2 ++ 7 files changed, 152 insertions(+) create mode 100644 engines/voyeur/debugger.cpp create mode 100644 engines/voyeur/debugger.h (limited to 'engines') 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; -- cgit v1.2.3