Skip to content

Commit

Permalink
BLADERUNNER: Fixed scene video resume
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
peterkohaut committed Jan 9, 2019
1 parent 03319bc commit 9d5bfdd
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
9 changes: 8 additions & 1 deletion engines/bladerunner/bladerunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,6 @@ void BladeRunnerEngine::gameTick() {
_sceneScript->sceneFrameAdvanced(frame);
backgroundChanged = true;
}
(void)backgroundChanged;
blit(_surfaceBack, _surfaceFront);

_overlays->tick();
Expand Down Expand Up @@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions engines/bladerunner/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -268,7 +268,7 @@ void Scene::resume(bool isLoadingGame) {
if (_defaultLoopPreloadedSet) {
_specialLoopMode = kSceneLoopModeNone;
startDefaultLoop();
advanceFrame();
advanceFrame(false);
loopStartSpecial(_specialLoopMode, _specialLoop, false);
} else {
_defaultLoopPreloadedSet = true;
Expand All @@ -285,7 +285,7 @@ void Scene::resume(bool isLoadingGame) {

int frame;
do {
frame = advanceFrame();
frame = advanceFrame(false);
} while (frame >= 0 && frame != targetFrame);

if (!isLoadingGame) {
Expand Down
2 changes: 1 addition & 1 deletion engines/bladerunner/scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Scene {

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);
Expand Down
16 changes: 9 additions & 7 deletions engines/bladerunner/vqa_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion engines/bladerunner/vqa_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class VQAPlayer {
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);
Expand Down

0 comments on commit 9d5bfdd

Please sign in to comment.