diff options
author | sluicebox | 2019-07-14 18:46:34 -0700 |
---|---|---|
committer | Filippos Karapetis | 2019-07-21 18:20:07 +0300 |
commit | 954f5142cb9b1f8b6ea4e608a71b07fdfcc4e8ca (patch) | |
tree | 9788aa1977f6a5dd3f00065104c36c1c29e01292 /engines | |
parent | 39551526b18f0f8b4ed0e460ead96f0b8b9d62c8 (diff) | |
download | scummvm-rg350-954f5142cb9b1f8b6ea4e608a71b07fdfcc4e8ca.tar.gz scummvm-rg350-954f5142cb9b1f8b6ea4e608a71b07fdfcc4e8ca.tar.bz2 scummvm-rg350-954f5142cb9b1f8b6ea4e608a71b07fdfcc4e8ca.zip |
SCI: Implement full kWait behavior
Fixes PQ3 bug #11020
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/state.cpp | 18 | ||||
-rw-r--r-- | engines/sci/engine/state.h | 3 | ||||
-rw-r--r-- | engines/sci/graphics/frameout.cpp | 4 | ||||
-rw-r--r-- | engines/sci/graphics/portrait.cpp | 6 | ||||
-rw-r--r-- | engines/sci/graphics/screen.cpp | 4 | ||||
-rw-r--r-- | engines/sci/graphics/transitions.cpp | 4 |
7 files changed, 28 insertions, 15 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 1e380e2573..a05031059c 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -394,9 +394,9 @@ reg_t kTextSize(EngineState *s, int argc, reg_t *argv) { } reg_t kWait(EngineState *s, int argc, reg_t *argv) { - int sleep_time = argv[0].toUint16(); + uint16 ticks = argv[0].toUint16(); - const int delta = s->wait(sleep_time); + const uint16 delta = s->wait(ticks); if (g_sci->_guestAdditions->kWaitHook()) { return NULL_REG; diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index f1c656688c..65d5562ab9 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -134,14 +134,26 @@ void EngineState::speedThrottler(uint32 neededSleep) { } } -int EngineState::wait(int16 ticks) { +uint16 EngineState::wait(uint16 ticks) { uint32 time = g_system->getMillis(); - const int tickDelta = ((long)time - (long)lastWaitTime) * 60 / 1000; + + uint32 ms = ticks * 1000 / 60; + uint32 duration = time - lastWaitTime; + if (ms > duration) { + uint32 sleepTime = ms - duration; + sleepTime *= g_debug_sleeptime_factor; + g_sci->sleep(sleepTime); + time += sleepTime; + } + + uint16 tickDelta = (uint16)(((long)time - lastWaitTime) * 60 / 1000); lastWaitTime = time; + return tickDelta; +} +void EngineState::sleep(uint16 ticks) { ticks *= g_debug_sleeptime_factor; g_sci->sleep(ticks * 1000 / 60); - return tickDelta; } void EngineState::initGlobals() { diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h index a299d89446..0ad50a6818 100644 --- a/engines/sci/engine/state.h +++ b/engines/sci/engine/state.h @@ -114,7 +114,8 @@ public: uint32 _screenUpdateTime; /**< The last time the game updated the screen */ void speedThrottler(uint32 neededSleep); - int wait(int16 ticks); + uint16 wait(uint16 ticks); + void sleep(uint16 ticks); #ifdef ENABLE_SCI32 uint32 _eventCounter; /**< total times kGetEvent was invoked since the last call to kFrameOut */ diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp index 505e2063f3..99fd8e62cb 100644 --- a/engines/sci/graphics/frameout.cpp +++ b/engines/sci/graphics/frameout.cpp @@ -1182,14 +1182,14 @@ void GfxFrameout::shakeScreen(int16 numShakes, const ShakeDirection direction) { } updateScreen(); - g_sci->getEngineState()->wait(3); + g_sci->getEngineState()->sleep(3); if (direction & kShakeVertical) { g_system->setShakePos(0); } updateScreen(); - g_sci->getEngineState()->wait(3); + g_sci->getEngineState()->sleep(3); } } diff --git a/engines/sci/graphics/portrait.cpp b/engines/sci/graphics/portrait.cpp index 8c41dabb11..b191cb1ab1 100644 --- a/engines/sci/graphics/portrait.cpp +++ b/engines/sci/graphics/portrait.cpp @@ -301,7 +301,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint // Wait till syncTime passed, then show specific animation bitmap if (timerPosition > 0) { do { - g_sci->getEngineState()->wait(1); + g_sci->getEngineState()->sleep(1); curEvent = _event->getSciEvent(kSciEventAny); if (curEvent.type == kSciEventMousePress || (curEvent.type == kSciEventKeyDown && curEvent.character == kSciKeyEsc) || @@ -324,7 +324,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint timerPositionWithin += raveLipSyncTicks; do { - g_sci->getEngineState()->wait(1); + g_sci->getEngineState()->sleep(1); curEvent = _event->getSciEvent(kSciEventAny); if (curEvent.type == kSciEventMousePress || (curEvent.type == kSciEventKeyDown && curEvent.character == kSciKeyEsc) || @@ -383,7 +383,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint // Wait till syncTime passed, then show specific animation bitmap do { - g_sci->getEngineState()->wait(1); + g_sci->getEngineState()->sleep(1); curEvent = _event->getSciEvent(kSciEventAny); if (curEvent.type == kSciEventMousePress || (curEvent.type == kSciEventKeyboard && curEvent.data == kSciKeyEsc) || diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp index b9cef360dc..c6f6c4043d 100644 --- a/engines/sci/graphics/screen.cpp +++ b/engines/sci/graphics/screen.cpp @@ -608,13 +608,13 @@ void GfxScreen::kernelShakeScreen(uint16 shakeCount, uint16 directions) { setVerticalShakePos(10); // TODO: horizontal shakes g_system->updateScreen(); - g_sci->getEngineState()->wait(3); + g_sci->getEngineState()->sleep(3); if (directions & kShakeVertical) setVerticalShakePos(0); g_system->updateScreen(); - g_sci->getEngineState()->wait(3); + g_sci->getEngineState()->sleep(3); } } diff --git a/engines/sci/graphics/transitions.cpp b/engines/sci/graphics/transitions.cpp index c75580a077..78f465ca3a 100644 --- a/engines/sci/graphics/transitions.cpp +++ b/engines/sci/graphics/transitions.cpp @@ -323,7 +323,7 @@ void GfxTransitions::fadeOut() { } } g_system->getPaletteManager()->setPalette(workPalette + 3, 1, tillColorNr); - g_sci->getEngineState()->wait(2); + g_sci->getEngineState()->sleep(2); } } @@ -337,7 +337,7 @@ void GfxTransitions::fadeIn() { for (stepNr = 0; stepNr <= 100; stepNr += 10) { _palette->kernelSetIntensity(1, tillColorNr + 1, stepNr, true); - g_sci->getEngineState()->wait(2); + g_sci->getEngineState()->sleep(2); } } |