From 2f16ddc982f7267a2361ee437a3b3330b5493b3e Mon Sep 17 00:00:00 2001 From: athrxx Date: Mon, 6 Jan 2020 23:17:05 +0100 Subject: KYRA: (LOK) - fix shakeScreen This has become too fast for modern systems and needs an extra delay. Otherwise the screen shake won't be actually noticed. There seem to be other issues with shakeScreen outside the Kyra code that have to be addressed separately (improper scaling of the shake offsets). --- engines/kyra/graphics/screen.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/engines/kyra/graphics/screen.cpp b/engines/kyra/graphics/screen.cpp index 148f2d8f37..7d8c1b1535 100644 --- a/engines/kyra/graphics/screen.cpp +++ b/engines/kyra/graphics/screen.cpp @@ -3171,12 +3171,25 @@ void Screen::rectClip(int &x, int &y, int w, int h) { void Screen::shakeScreen(int times) { while (times--) { + // The original did not need an artificial delay, but we do. + // Or the shake will be too fast to be actually seen. + uint32 delayuntil = _system->getMillis() + 16; + // seems to be 1 line (320 pixels) offset in the original - // 4 looks more like dosbox though, maybe check this again - _system->setShakePos(0, 4); + // -4 looks more like dosbox though, maybe check this again + _system->setShakePos(0, -4); _system->updateScreen(); + + int diff = delayuntil - _system->getMillis(); + if (diff > 0) + _system->delayMillis(diff); + delayuntil = _system->getMillis() + 16; _system->setShakePos(0, 0); _system->updateScreen(); + + diff = delayuntil - _system->getMillis(); + if (diff > 0) + _system->delayMillis(diff); } } -- cgit v1.2.3