From ff5fde47ea11fb03007fc3a1f597d3202d5cd25e Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Mon, 20 Oct 2003 20:12:59 +0000 Subject: scrolling timing (copy/paste from SkyEngine) svn-id: r10919 --- queen/display.cpp | 21 ++++++++++++++++++++- queen/display.h | 5 +++++ queen/queen.cpp | 14 ++++++++++++++ queen/queen.h | 3 ++- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/queen/display.cpp b/queen/display.cpp index f11efd7fa5..a08ed60ee2 100644 --- a/queen/display.cpp +++ b/queen/display.cpp @@ -212,7 +212,7 @@ void Display::palSet(const uint8 *pal, int start, int end, bool updateScreen) { _system->set_palette(tempPal + start * 4, start, end - start + 1); if (updateScreen) { _system->update_screen(); - _system->delay_msecs(20); + waitForTimer(); } } @@ -785,6 +785,25 @@ void Display::horizontalScroll(int16 scroll) { } +void Display::handleTimer() { + + _gotTick = true; +} + + +void Display::waitForTimer() { + + _gotTick = false; + while (!_gotTick) { + OSystem::Event event; + + _system->delay_msecs(10); + while (_system->poll_event(&event)); + } +} + + + const uint8 TextRenderer::FONT[] = { 0xF8, 0xB0, 0xB0, 0x80, 0xB0, 0xB0, 0xC0, 0x00, 0xF8, 0xB0, 0xB0, 0x80, 0xB0, 0xB0, 0xC0, 0x00, 0xF8, 0xB0, 0xB0, 0x80, diff --git a/queen/display.h b/queen/display.h index df668cd4be..608133d861 100644 --- a/queen/display.h +++ b/queen/display.h @@ -100,6 +100,9 @@ public: bool fullscreen() const { return _fullscreen; } + void handleTimer(); + void waitForTimer(); + private: @@ -137,6 +140,8 @@ private: Common::RandomSource _randomizer; + bool _gotTick; + Dynalum _dynalum; OSystem *_system; diff --git a/queen/queen.cpp b/queen/queen.cpp index cb8d43ac92..1466bdb805 100644 --- a/queen/queen.cpp +++ b/queen/queen.cpp @@ -222,8 +222,22 @@ void QueenEngine::initialise(void) { _graphics = new Graphics(_display, _resource); _logic = new Logic(_resource, _graphics, _display); //_sound = new Sound(_mixer, _detector->_sfx_volume); + _timer->installTimerProc(&timerHandler, 1000000 / 50, this); //call 50 times per second } + +void QueenEngine::timerHandler(void *ptr) { + + ((QueenEngine *)ptr)->gotTimerTick(); +} + + +void QueenEngine::gotTimerTick() { + + _display->handleTimer(); +} + + void QueenEngine::delay(uint amount) { OSystem::Event event; diff --git a/queen/queen.h b/queen/queen.h index 51fc6fe2e2..71231fff76 100644 --- a/queen/queen.h +++ b/queen/queen.h @@ -74,7 +74,8 @@ protected: void initialise(); - static int CDECL game_thread_proc(void *param); + static void timerHandler(void *ptr); + void gotTimerTick(); }; // XXX: Temporary hack to allow Graphics to call delay() -- cgit v1.2.3