From 9d5bfdd01518f9bf1156b859894efbbb7d9f46ec Mon Sep 17 00:00:00 2001 From: Peter Kohaut Date: Wed, 9 Jan 2019 23:06:10 +0100 Subject: BLADERUNNER: Fixed scene video resume Video in the back was always reset to the 1st frame. Now it is working properly. Also added game pause when the debugger is opened. --- engines/bladerunner/bladerunner.cpp | 9 ++++++++- engines/bladerunner/scene.cpp | 8 ++++---- engines/bladerunner/scene.h | 2 +- engines/bladerunner/vqa_player.cpp | 16 +++++++++------- engines/bladerunner/vqa_player.h | 2 +- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp index 08de96766c..08848190f3 100644 --- a/engines/bladerunner/bladerunner.cpp +++ b/engines/bladerunner/bladerunner.cpp @@ -911,7 +911,6 @@ void BladeRunnerEngine::gameTick() { _sceneScript->sceneFrameAdvanced(frame); backgroundChanged = true; } - (void)backgroundChanged; blit(_surfaceBack, _surfaceFront); _overlays->tick(); @@ -1112,8 +1111,16 @@ void BladeRunnerEngine::handleKeyUp(Common::Event &event) { void BladeRunnerEngine::handleKeyDown(Common::Event &event) { if ((event.kbd.keycode == Common::KEYCODE_d) && (event.kbd.flags & Common::KBD_CTRL)) { + _time->pause(); getDebugger()->attach(); getDebugger()->onFrame(); + + _time->resume(); + + if (!_kia->isOpen() && !_spinner->isOpen() && !_elevator->isOpen() && !_esper->isOpen() && !_dialogueMenu->isOpen() && !_scores->isOpen()) { + _scene->resume(); + } + return; } diff --git a/engines/bladerunner/scene.cpp b/engines/bladerunner/scene.cpp index 09764c9e50..78b1bb6da4 100644 --- a/engines/bladerunner/scene.cpp +++ b/engines/bladerunner/scene.cpp @@ -209,8 +209,8 @@ bool Scene::close(bool isLoadingGame) { return result; } -int Scene::advanceFrame() { - int frame = _vqaPlayer->update(); +int Scene::advanceFrame(bool useTime) { + int frame = _vqaPlayer->update(false, true, useTime); if (frame >= 0) { blit(_vm->_surfaceBack, _vm->_surfaceFront); _vqaPlayer->updateZBuffer(_vm->_zbuffer); @@ -268,7 +268,7 @@ void Scene::resume(bool isLoadingGame) { if (_defaultLoopPreloadedSet) { _specialLoopMode = kSceneLoopModeNone; startDefaultLoop(); - advanceFrame(); + advanceFrame(false); loopStartSpecial(_specialLoopMode, _specialLoop, false); } else { _defaultLoopPreloadedSet = true; @@ -285,7 +285,7 @@ void Scene::resume(bool isLoadingGame) { int frame; do { - frame = advanceFrame(); + frame = advanceFrame(false); } while (frame >= 0 && frame != targetFrame); if (!isLoadingGame) { diff --git a/engines/bladerunner/scene.h b/engines/bladerunner/scene.h index 0403cd331e..94de5755a1 100644 --- a/engines/bladerunner/scene.h +++ b/engines/bladerunner/scene.h @@ -71,7 +71,7 @@ public: bool open(int setId, int sceneId, bool isLoadingGame); bool close(bool isLoadingGame); - int advanceFrame(); + int advanceFrame(bool useTime = true); void resume(bool isLoadingGame = false); void startDefaultLoop(); void setActorStart(Vector3 position, int facing); diff --git a/engines/bladerunner/vqa_player.cpp b/engines/bladerunner/vqa_player.cpp index 68a4e9491d..d4038ec4f8 100644 --- a/engines/bladerunner/vqa_player.cpp +++ b/engines/bladerunner/vqa_player.cpp @@ -71,7 +71,7 @@ void VQAPlayer::close() { _s = nullptr; } -int VQAPlayer::update(bool forceDraw, bool advanceFrame, Graphics::Surface *customSurface) { +int VQAPlayer::update(bool forceDraw, bool advanceFrame, bool useTime, Graphics::Surface *customSurface) { uint32 now = 60 * _vm->_system->getMillis(); int result = -1; @@ -106,7 +106,7 @@ int VQAPlayer::update(bool forceDraw, bool advanceFrame, Graphics::Surface *cust result = -1; } else if (_frameNext > _frameEnd) { result = -3; - } else if (now < _frameNextTime) { + } else if (useTime && (now < _frameNextTime)) { result = -1; } else if (advanceFrame) { _frame = _frameNext; @@ -131,11 +131,13 @@ int VQAPlayer::update(bool forceDraw, bool advanceFrame, Graphics::Surface *cust queueAudioFrame(_decoder.decodeAudioFrame()); } } - if (_frameNextTime == 0) { - _frameNextTime = now + 60000 / 15; - } - else { - _frameNextTime += 60000 / 15; + if (useTime) { + if (_frameNextTime == 0) { + _frameNextTime = now + 60000 / 15; + } + else { + _frameNextTime += 60000 / 15; + } } _frameNext++; result = _frame; diff --git a/engines/bladerunner/vqa_player.h b/engines/bladerunner/vqa_player.h index c4dd182697..a51f39cc31 100644 --- a/engines/bladerunner/vqa_player.h +++ b/engines/bladerunner/vqa_player.h @@ -108,7 +108,7 @@ public: bool open(); void close(); - int update(bool forceDraw = false, bool advanceFrame = true, Graphics::Surface *customSurface = nullptr); + int update(bool forceDraw = false, bool advanceFrame = true, bool useTime = true, Graphics::Surface *customSurface = nullptr); void updateZBuffer(ZBuffer *zbuffer); void updateView(View *view); void updateScreenEffects(ScreenEffects *screenEffects); -- cgit v1.2.3