From 0a21220707b879b5fcfe0cbed1774e808ddac68f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 29 Oct 2018 01:02:40 -0700 Subject: GLK: Add game frames to actually render the screen --- engines/gargoyle/events.cpp | 23 +++++++++++++++++++++++ engines/gargoyle/events.h | 12 +++++++++++- engines/gargoyle/window_mask.cpp | 2 ++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/engines/gargoyle/events.cpp b/engines/gargoyle/events.cpp index 23a8baf813..ef4c59df30 100644 --- a/engines/gargoyle/events.cpp +++ b/engines/gargoyle/events.cpp @@ -23,10 +23,28 @@ #include "gargoyle/events.h" #include "gargoyle/clipboard.h" #include "gargoyle/gargoyle.h" +#include "gargoyle/screen.h" #include "gargoyle/windows.h" namespace Gargoyle { +Events::Events() : _forceClick(false), _currentEvent(nullptr), _timeouts(false), + _priorFrameTime(0), _frameCounter(0) { +} + +bool Events::checkForNextFrameCounter() { + // Check for next game frame + uint32 milli = g_system->getMillis(); + if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) { + ++_frameCounter; + _priorFrameTime = milli; + + return true; + } + + return false; +} + void Events::getEvent(event_t *event, bool polled) { _currentEvent = event; event->clear(); @@ -89,6 +107,11 @@ void Events::dispatchEvent(Event &ev, bool polled) { void Events::pollEvents() { Common::Event event; + if (checkForNextFrameCounter()) { + // Update the screen + g_vm->_screen->update(); + } + do { g_system->getEventManager()->pollEvent(event); diff --git a/engines/gargoyle/events.h b/engines/gargoyle/events.h index f49ef35ac5..4d9e49b55d 100644 --- a/engines/gargoyle/events.h +++ b/engines/gargoyle/events.h @@ -28,6 +28,9 @@ namespace Gargoyle { +#define GAME_FRAME_RATE 100 +#define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE) + class Window; /** @@ -148,7 +151,14 @@ private: EventQueue _eventsLogged; ///< Custom events generated by game code Event *_currentEvent; ///< Event pointer passed during event retrieval bool _timeouts; ///< Timer timeouts flag + uint32 _priorFrameTime; ///< Time of prior game frame + uint32 _frameCounter; ///< Frame counter private: + /** + * Checks for whether it's time for the next game frame + */ + bool checkForNextFrameCounter(); + /** * Dispatches an event */ @@ -189,7 +199,7 @@ public: /** * Constructor */ - Events() : _forceClick(false), _currentEvent(nullptr), _timeouts(false) {} + Events(); /** * Get any pending event diff --git a/engines/gargoyle/window_mask.cpp b/engines/gargoyle/window_mask.cpp index b3b629b50f..6c857899d0 100644 --- a/engines/gargoyle/window_mask.cpp +++ b/engines/gargoyle/window_mask.cpp @@ -24,6 +24,7 @@ #include "gargoyle/conf.h" #include "gargoyle/gargoyle.h" #include "gargoyle/windows.h" +#include "common/system.h" namespace Gargoyle { @@ -32,6 +33,7 @@ int WindowMask::_lastY; WindowMask::WindowMask() : _hor(0), _ver(0), _links(nullptr) { _lastX = _lastY = 0; + resize(g_system->getWidth(), g_system->getHeight()); } void WindowMask::resize(size_t x, size_t y) { -- cgit v1.2.3