Skip to content

Commit

Permalink
MOHAWK: Fix the drawing time simulation
Browse files Browse the repository at this point in the history
Was broken when adding transition support.
Fixes scripted card changes not displaying for a long enough time.
  • Loading branch information
bgK committed Feb 26, 2016
1 parent faff49d commit 5aeda50
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
10 changes: 6 additions & 4 deletions engines/mohawk/myst.cpp
Expand Up @@ -599,10 +599,12 @@ void MohawkEngine_Myst::changeToCard(uint16 card, TransitionType transition) {

// Make sure the screen is updated
if (transition != kNoTransition) {
if (!_gameState->_globals.transitions)
transition = kTransitionCopy;

_gfx->runTransition(transition, Common::Rect(544, 333), 10, 0);
if (_gameState->_globals.transitions) {
_gfx->runTransition(transition, Common::Rect(544, 333), 10, 0);
} else {
_gfx->copyBackBufferToScreen(Common::Rect(544, 333));
_needsUpdate = true;
}
}

// Make sure we have the right cursor showing
Expand Down
16 changes: 10 additions & 6 deletions engines/mohawk/myst_graphics.cpp
Expand Up @@ -227,9 +227,8 @@ void MystGraphics::copyBackBufferToScreen(Common::Rect r) {

void MystGraphics::runTransition(TransitionType type, Common::Rect rect, uint16 steps, uint16 delay) {

// Do not artificially delay during transitions
int oldEnableDrawingTimeSimulation = _enableDrawingTimeSimulation;
_enableDrawingTimeSimulation = 0;
// Transitions are barely visible without adding delays between the draw calls
enableDrawingTimeSimulation(true);

switch (type) {
case kTransitionLeftToRight: {
Expand Down Expand Up @@ -290,7 +289,10 @@ void MystGraphics::runTransition(TransitionType type, Common::Rect rect, uint16
debugC(kDebugView, "Dissolve");

for (int16 step = 0; step < 8; step++) {
simulatePreviousDrawDelay(rect);
// Only one eighth of the rect pixels are updated by a draw step,
// delay by one eighth of the regular time
simulatePreviousDrawDelay(Common::Rect(rect.width() / 8, rect.height()));

transitionDissolve(rect, step);
}
}
Expand Down Expand Up @@ -369,7 +371,7 @@ void MystGraphics::runTransition(TransitionType type, Common::Rect rect, uint16
error("Unknown transition %d", type);
}

_enableDrawingTimeSimulation = oldEnableDrawingTimeSimulation;
enableDrawingTimeSimulation(false);
}

void MystGraphics::transitionDissolve(Common::Rect rect, uint step) {
Expand Down Expand Up @@ -641,8 +643,10 @@ void MystGraphics::simulatePreviousDrawDelay(const Common::Rect &dest) {
// Do not draw anything new too quickly after the previous draw call
// so that images stay at least a little while on screen
// This is enabled only for scripted draw calls
if (time < _nextAllowedDrawTime)
if (time < _nextAllowedDrawTime) {
debugC(kDebugView, "Delaying draw call by %d ms", _nextAllowedDrawTime - time);
_vm->_system->delayMillis(_nextAllowedDrawTime - time);
}
}

// Next draw call allowed at DELAY + AERA * COEFF milliseconds from now
Expand Down

0 comments on commit 5aeda50

Please sign in to comment.