diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/kmisc.cpp | 7 | ||||
-rw-r--r-- | engines/sci/gui/gui.cpp | 32 | ||||
-rw-r--r-- | engines/sci/gui/gui.h | 5 | ||||
-rw-r--r-- | engines/sci/gui/gui_palette.cpp | 6 | ||||
-rw-r--r-- | engines/sci/gui32/gui32.cpp | 6 | ||||
-rw-r--r-- | engines/sci/gui32/gui32.h | 1 |
6 files changed, 20 insertions, 37 deletions
diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index 6650810dc6..dbe562b25a 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -116,11 +116,11 @@ enum { reg_t kGetTime(EngineState *s, int argc, reg_t *argv) { tm loc_time; - uint32 start_time; + uint32 elapsedTime; int retval = 0; // Avoid spurious warning g_system->getTimeAndDate(loc_time); - start_time = g_system->getMillis() - s->game_start_time; + elapsedTime = g_system->getMillis() - s->game_start_time; if ((s->_flags & GF_SCI0_OLDGETTIME) && argc) { // Use old semantics retval = (loc_time.tm_hour % 12) * 3600 + loc_time.tm_min * 60 + loc_time.tm_sec; @@ -132,8 +132,7 @@ reg_t kGetTime(EngineState *s, int argc, reg_t *argv) { switch (mode) { case K_NEW_GETTIME_TICKS : - retval = s->gui->getTimeTicks(); // FIXME - //retval = start_time * 60 / 1000; + retval = elapsedTime * 60 / 1000; debugC(2, kDebugLevelTime, "GetTime(elapsed) returns %d", retval); break; case K_NEW_GETTIME_TIME_12HOUR : diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp index 6257ad8a84..898de3d0a3 100644 --- a/engines/sci/gui/gui.cpp +++ b/engines/sci/gui/gui.cpp @@ -27,6 +27,7 @@ #include "common/util.h" #include "sci/sci.h" +#include "sci/debug.h" // for g_debug_sleeptime_factor #include "sci/engine/state.h" #include "sci/tools.h" #include "sci/gui/gui.h" @@ -43,7 +44,6 @@ namespace Sci { SciGui::SciGui(OSystem *system, EngineState *state, SciGuiScreen *screen) : _system(system), _s(state), _screen(screen) { _picNotValid = 0; - _sysTicks = 0; _palette = new SciGuiPalette(_s, this, _screen); _gfx = new SciGuiGfx(_s, _screen, _palette); @@ -54,30 +54,26 @@ SciGui::SciGui() { } SciGui::~SciGui() { - _system->getTimerManager()->removeTimerProc(&timerHandler); } void SciGui::init(bool usesOldGfxFunctions) { - _sysSpeed = 1000000 / 60; - Common::TimerManager *tm = _system->getTimerManager(); - tm->removeTimerProc(&timerHandler); - tm->installTimerProc(&timerHandler, _sysSpeed, this); } -void SciGui::timerHandler(void *ref) { - ((SciGui *)ref)->_sysTicks++; -} - -int16 SciGui::getTimeTicks() { - return _sysTicks; -} void SciGui::wait(int16 ticks) { - uint32 waitto = _sysTicks + ticks; - do { - //eventMgr->pollEvents(); - _system->delayMillis(_sysSpeed >> 11); - } while (_sysTicks < waitto); + uint32 time; + + time = g_system->getMillis(); + _s->r_acc = make_reg(0, ((long)time - (long)_s->last_wait_time) * 60 / 1000); + _s->last_wait_time = time; + + ticks *= g_debug_sleeptime_factor; + gfxop_sleep(_s->gfx_state, ticks * 1000 / 60); + + + // Reset speed throttler: Game is playing along nicely anyway + if (ticks > 0) + _s->speedThrottler->reset(); } void SciGui::setPort(uint16 portPtr) { diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h index a6262771a9..cbd1f315ef 100644 --- a/engines/sci/gui/gui.h +++ b/engines/sci/gui/gui.h @@ -46,7 +46,6 @@ public: virtual void init(bool usesOldGfxFunctions); - virtual int16 getTimeTicks(); virtual void wait(int16 ticks); virtual void setPort(uint16 portPtr); virtual void setPortPic(Common::Rect rect, int16 picTop, int16 picLeft); @@ -93,8 +92,6 @@ public: int _picNotValid; // possible values 0, 1 and 2 private: - static void timerHandler(void*ref); - OSystem *_system; EngineState *_s; SciGuiScreen *_screen; @@ -102,8 +99,6 @@ private: SciGuiGfx *_gfx; SciGuiresources *_resources; SciGuiWindowMgr *_windowMgr; - uint32 _sysTicks; - int32 _sysSpeed; // ticker timer in ms }; } // End of namespace Sci diff --git a/engines/sci/gui/gui_palette.cpp b/engines/sci/gui/gui_palette.cpp index ec4e127814..953ed93121 100644 --- a/engines/sci/gui/gui_palette.cpp +++ b/engines/sci/gui/gui_palette.cpp @@ -229,10 +229,10 @@ void SciGuiPalette::merge(GuiPalette *pFrom, GuiPalette *pTo, uint16 flag) { pTo->colors[res & 0xFF].used |= 0x10; } } - pTo->timestamp = _gui->getTimeTicks(); + pTo->timestamp = (g_system->getMillis() - _s->game_start_time) * 60 / 1000;; } -uint16 SciGuiPalette::matchColor(GuiPalette*pPal, byte r, byte g, byte b) { +uint16 SciGuiPalette::matchColor(GuiPalette *pPal, byte r, byte g, byte b) { byte found = 0xFF; int diff = 0x2FFFF, cdiff; int16 dr,dg,db; @@ -275,7 +275,7 @@ void SciGuiPalette::setIntensity(int fromColor, int toColor, int intensity, GuiP void SciGuiPalette::animate(byte fromColor, byte toColor, int speed) { GuiColor col; int len = toColor - fromColor - 1; - uint32 now = _gui->getTimeTicks(); + uint32 now = (g_system->getMillis() - _s->game_start_time) * 60 / 1000;; // search for sheduled animations with the same 'from' value int sz = _palSchedules.size(); for (int i = 0; i < sz; i++) { diff --git a/engines/sci/gui32/gui32.cpp b/engines/sci/gui32/gui32.cpp index 9e91f2b0c5..6f86f8a309 100644 --- a/engines/sci/gui32/gui32.cpp +++ b/engines/sci/gui32/gui32.cpp @@ -79,12 +79,6 @@ void SciGui32::init(bool oldGfxFunctions) { port_origin_y = 0; } -int16 SciGui32::getTimeTicks() { - uint32 start_time; - start_time = _system->getMillis() - s->game_start_time; - return start_time * 60 / 1000; -} - void SciGui32::wait(int16 ticks) { uint32 time; diff --git a/engines/sci/gui32/gui32.h b/engines/sci/gui32/gui32.h index 38a3feb221..8f6981dd88 100644 --- a/engines/sci/gui32/gui32.h +++ b/engines/sci/gui32/gui32.h @@ -40,7 +40,6 @@ public: void init(bool oldGfxFunctions); - int16 getTimeTicks(); void wait(int16 ticks); void setPort(uint16 portPtr); void setPortPic(Common::Rect rect, int16 picTop, int16 picLeft); |