aboutsummaryrefslogtreecommitdiff
path: root/engines/gargoyle
diff options
context:
space:
mode:
authorPaul Gilbert2018-11-09 20:27:14 -0800
committerPaul Gilbert2018-12-08 19:05:59 -0800
commit601e1d486b038f121323e78ed68a154d6763c9f1 (patch)
treea80922d2fcd0a64c8f023928cabe588b902d1d0a /engines/gargoyle
parent43bee7a72783cd60b86249997bfdaf7af5e5d740 (diff)
downloadscummvm-rg350-601e1d486b038f121323e78ed68a154d6763c9f1.tar.gz
scummvm-rg350-601e1d486b038f121323e78ed68a154d6763c9f1.tar.bz2
scummvm-rg350-601e1d486b038f121323e78ed68a154d6763c9f1.zip
GLK: Add GLK timer intervals
Diffstat (limited to 'engines/gargoyle')
-rw-r--r--engines/gargoyle/events.cpp20
-rw-r--r--engines/gargoyle/events.h14
-rw-r--r--engines/gargoyle/glk.cpp2
3 files changed, 29 insertions, 7 deletions
diff --git a/engines/gargoyle/events.cpp b/engines/gargoyle/events.cpp
index bc56407ee8..520b6f22e5 100644
--- a/engines/gargoyle/events.cpp
+++ b/engines/gargoyle/events.cpp
@@ -53,8 +53,8 @@ const byte ARROW[] = {
4, 2, 5, 5
};
-Events::Events() : _forceClick(false), _currentEvent(nullptr), _timeouts(false),
- _priorFrameTime(0), _frameCounter(0), _cursorId(CURSOR_NONE) {
+Events::Events() : _forceClick(false), _currentEvent(nullptr), _cursorId(CURSOR_NONE),
+ _timerMilli(0), _timerTimeExpiry(0), _priorFrameTime(0), _frameCounter(0) {
initializeCursors();
}
@@ -118,7 +118,7 @@ void Events::getEvent(event_t *event, bool polled) {
dispatchEvent(*_currentEvent, polled);
if (!polled) {
- while (!g_vm->shouldQuit() && _currentEvent->type == evtype_None && !_timeouts) {
+ while (!g_vm->shouldQuit() && _currentEvent->type == evtype_None && !isTimerExpired()) {
pollEvents();
g_system->delayMillis(10);
@@ -129,10 +129,11 @@ void Events::getEvent(event_t *event, bool polled) {
_currentEvent->type = evtype_Quit;
}
- if (_currentEvent->type == evtype_None && _timeouts) {
+ if (_currentEvent->type == evtype_None && isTimerExpired()) {
store(evtype_Timer, nullptr, 0, 0);
dispatchEvent(*_currentEvent, polled);
- _timeouts = false;
+
+ _timerTimeExpiry = g_system->getMillis() + _timerMilli;
}
_currentEvent = nullptr;
@@ -338,4 +339,13 @@ void Events::setCursor(CursorId cursorId) {
}
}
+void Events::setTimerInterval(uint milli) {
+ _timerMilli = milli;
+ _timerTimeExpiry = g_system->getMillis() + milli;
+}
+
+bool Events::isTimerExpired() const {
+ return _timerMilli && g_system->getMillis() >= _timerTimeExpiry;
+}
+
} // End of namespace Gargoyle
diff --git a/engines/gargoyle/events.h b/engines/gargoyle/events.h
index 5da4e53a14..f91c91b242 100644
--- a/engines/gargoyle/events.h
+++ b/engines/gargoyle/events.h
@@ -164,12 +164,13 @@ private:
EventQueue _eventsPolled; ///< User generated events
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
bool _redraw; ///< Screen needed redrawing
CursorId _cursorId; ///< Current cursor Id
Surface _cursors[4]; ///< Cursor pixel data
+ uint _timerMilli; ///< Time in milliseconds between timer events
+ uint _timerTimeExpiry; ///< When to trigger next timer event
private:
/**
* Initialize the cursor graphics
@@ -262,6 +263,17 @@ public:
* Sets the current cursor
*/
void setCursor(CursorId cursorId);
+
+ /**
+ * Set a timer interval
+ * @param milli Time in millieseconds for intervals, or 0 for off
+ */
+ void setTimerInterval(uint milli);
+
+ /**
+ * Returns true if it's time for a timer event
+ */
+ bool isTimerExpired() const;
};
} // End of namespace Gargoyle
diff --git a/engines/gargoyle/glk.cpp b/engines/gargoyle/glk.cpp
index 43b6d0a2e8..fe82edc2d4 100644
--- a/engines/gargoyle/glk.cpp
+++ b/engines/gargoyle/glk.cpp
@@ -709,7 +709,7 @@ void Glk::glk_select_poll(event_t *event) {
}
void Glk::glk_request_timer_events(glui32 millisecs) {
- // TODO
+ _events->setTimerInterval(millisecs);
}
void Glk::glk_request_line_event(winid_t win, char *buf, glui32 maxlen, glui32 initlen) {