diff options
Diffstat (limited to 'engines/xeen')
-rw-r--r-- | engines/xeen/debugger.cpp | 2 | ||||
-rw-r--r-- | engines/xeen/events.cpp | 113 | ||||
-rw-r--r-- | engines/xeen/events.h | 66 | ||||
-rw-r--r-- | engines/xeen/module.mk | 2 | ||||
-rw-r--r-- | engines/xeen/screen.cpp | 38 | ||||
-rw-r--r-- | engines/xeen/screen.h | 45 | ||||
-rw-r--r-- | engines/xeen/xeen.cpp | 6 | ||||
-rw-r--r-- | engines/xeen/xeen.h | 4 |
8 files changed, 275 insertions, 1 deletions
diff --git a/engines/xeen/debugger.cpp b/engines/xeen/debugger.cpp index 0642498749..aa4516e3bc 100644 --- a/engines/xeen/debugger.cpp +++ b/engines/xeen/debugger.cpp @@ -53,4 +53,4 @@ bool Debugger::Cmd_LoadScene(int argc, const char **argv) { return true; } -} // End of namespace Access +} // End of namespace Xeen diff --git a/engines/xeen/events.cpp b/engines/xeen/events.cpp new file mode 100644 index 0000000000..e75744eb01 --- /dev/null +++ b/engines/xeen/events.cpp @@ -0,0 +1,113 @@ +/* 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/scummsys.h" +#include "graphics/cursorman.h" +#include "common/events.h" +#include "common/endian.h" +#include "engines/util.h" +#include "xeen/xeen.h" +#include "xeen/events.h" +#include "xeen/screen.h" + +namespace Xeen { + +/** + * Constructor + */ +EventsManager::EventsManager(XeenEngine *vm) : _vm(vm) { + _frameCounter = 0; + _priorFrameCounterTime = 0; + _gameCounter = 0; + _priorGameCounterTime = 0; +} + +/** + * Destructor + */ +EventsManager::~EventsManager() { +} + +/** + * Show the mouse cursor + */ +void EventsManager::showCursor() { + CursorMan.showMouse(true); +} + +/** + * Hide the mouse cursor + */ +void EventsManager::hideCursor() { + CursorMan.showMouse(false); +} + +/** + * Returns if the mouse cursor is visible + */ +bool EventsManager::isCursorVisible() { + return CursorMan.isVisible(); +} + +void EventsManager::pollEvents() { + uint32 timer = g_system->getMillis(); + if (timer >= (_priorFrameCounterTime + GAME_FRAME_TIME)) { + _priorFrameCounterTime = timer; + nextFrame(); + } + + Common::Event event; + while (g_system->getEventManager()->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_QUIT: + case Common::EVENT_RTL: + return; + default: + break; + } + } +} + +/** + * Updates the game counter to match the current frame counter + */ +void EventsManager::updateGameCounter() { + _gameCounter = _frameCounter; +} + +/** + * Returns the number of frames elapsed since the last call to + * updateGameCounter() + */ +uint32 EventsManager::timeElapsed() { + return _frameCounter - _gameCounter; +} + +/** + * Handles moving to the next game frame + */ +void EventsManager::nextFrame() { + ++_frameCounter; + _vm->_screen->update(); +} + +} // End of namespace Xeen diff --git a/engines/xeen/events.h b/engines/xeen/events.h new file mode 100644 index 0000000000..637d710364 --- /dev/null +++ b/engines/xeen/events.h @@ -0,0 +1,66 @@ +/* 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 XEEN_EVENTS_H +#define XEEN_EVENTS_H + +#include "common/scummsys.h" +#include "common/events.h" + +namespace Xeen { + +#define GAME_FRAME_RATE (1000 / 18.2) + +class XeenEngine; + +class EventsManager { +private: + XeenEngine *_vm; + uint32 _frameCounter; + uint32 _priorFrameCounterTime; + uint32 _gameCounter; + uint32 _priorGameCounterTime; + + void nextFrame(); +public: + EventsManager(XeenEngine *vm); + + ~EventsManager(); + + uint32 getFrameCounter() { return _frameCounter; } + + void showCursor(); + + void hideCursor(); + + bool isCursorVisible(); + + void pollEvents(); + + void updateGameCounter(); + + uint32 timeElapsed(); +}; + +} // End of namespace Xeen + +#endif /* XEEN_EVENTS_H */ diff --git a/engines/xeen/module.mk b/engines/xeen/module.mk index b02d26d58c..3b4529e73f 100644 --- a/engines/xeen/module.mk +++ b/engines/xeen/module.mk @@ -6,7 +6,9 @@ MODULE_OBJS := \ worldofxeen\worldofxeen_game.o \ debugger.o \ detection.o \ + events.o \ resources.o \ + screen.o \ xeen.o # This module can be built as a plugin diff --git a/engines/xeen/screen.cpp b/engines/xeen/screen.cpp new file mode 100644 index 0000000000..d17e01063d --- /dev/null +++ b/engines/xeen/screen.cpp @@ -0,0 +1,38 @@ +/* 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 "xeen/screen.h" + +namespace Xeen { + +/** + * Constructor + */ +Screen::Screen(XeenEngine *vm) : _vm(vm) { +} + +void Screen::update() { + g_system->copyRectToScreen(getPixels(), pitch, 0, 0, w, h); + g_system->updateScreen(); +} + +} // End of namespace Xeen diff --git a/engines/xeen/screen.h b/engines/xeen/screen.h new file mode 100644 index 0000000000..94dce60de9 --- /dev/null +++ b/engines/xeen/screen.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 XEEN_SCREEN_H +#define XEEN_SCREEN_H + +#include "common/scummsys.h" +#include "common/system.h" +#include "graphics/surface.h" + +namespace Xeen { + +class XeenEngine; + +class Screen: public Graphics::Surface { +private: + XeenEngine *_vm; +public: + Screen(XeenEngine *vm); + + void update(); +}; + +} // End of namespace Xeen + +#endif /* XEEN_SCREEN_H */ diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp index 73f0c24d9f..cf60aa4555 100644 --- a/engines/xeen/xeen.cpp +++ b/engines/xeen/xeen.cpp @@ -35,10 +35,14 @@ namespace Xeen { XeenEngine::XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc) : _gameDescription(gameDesc), Engine(syst), _randomSource("Xeen") { _debugger = nullptr; + _events = nullptr; + _screen = nullptr; } XeenEngine::~XeenEngine() { delete _debugger; + delete _events; + delete _screen; } void XeenEngine::initialize() { @@ -50,6 +54,8 @@ void XeenEngine::initialize() { // Create sub-objects of the engine _debugger = new Debugger(this); + _events = new EventsManager(this); + _screen = new Screen(this); Resources::init(this); // Set graphics mode diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h index e5122ce147..dba340e329 100644 --- a/engines/xeen/xeen.h +++ b/engines/xeen/xeen.h @@ -33,6 +33,8 @@ #include "engines/engine.h" #include "graphics/surface.h" #include "xeen/debugger.h" +#include "xeen/events.h" +#include "xeen/screen.h" /** * This is the namespace of the Xeen engine. @@ -104,6 +106,8 @@ private: virtual bool hasFeature(EngineFeature f) const; public: Debugger *_debugger; + EventsManager *_events; + Screen *_screen; public: XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc); virtual ~XeenEngine(); |