#14061 closed defect (fixed)

OPENGL: Vertical position of cursor during screen shake appears to be miscalculated

Reported by: AndywinXp Owned by: lephilousophe
Priority: high Component: Graphics
Version: Keywords: cursor screen shake
Cc: Game: Day of the Tentacle

Description (last modified by AndywinXp)

How to reproduce:

Start up Day Of The Tentacle, go to Green Tentacle's room and turn on the stereo. The screen should begin shaking. Or just load the savegame I attached :-)

What should happen:

The cursor should stay visible during the screen effect.

What happens instead:

During the screen shake effect, whenever the screen position is different from the origin one (0, 0), the cursor coordinates get recalculated to send the cursor texture elsewhere (out of bounds), effectively making the cursor invisible during the shake frames, producing a flicker effect.

This seems to be a regression produced by this commit and apparently it only affects the OpenGL backend: https://github.com/scummvm/scummvm/commit/87bad2cc7d602488ba3fbdf8ff067d3d74fc2b85

In particular, in the following function:

void OpenGLGraphicsManager::recalculateDisplayAreas()

the responsible line for the offset recalculation seems to be the following:

_shakeOffsetScaled = Common::Point(
    _gameScreenShakeXOffset * _gameDrawRect.width() / _currentState.gameWidth,
    _gameScreenShakeYOffset * _gameDrawRect.height() / _currentState.gameHeight

in which _shakeOffsetScaled is calculated. The result of this calculation will then be used in OpenGLGraphicsManager::updateScreen() to calculate the position of the cursor texture:

    _cursorX - _cursorHotspotXScaled + _shakeOffsetScaled.x,
    _cursorY - _cursorHotspotYScaled + _shakeOffsetScaled.y,									 
    _cursorWidthScaled, _cursorHeightScaled

When debugging the issue I noticed that (for the case at hand, DOTT, which shakes the screen vertically only), the y component of _shakeOffsetScaled contained garbage values (e.g. -20990) when the screen Y offset was not zero.

Just for the sake of it, when calculating _shakeOffsetScaled I tried substituting _gameScreenShakeYOffset with 1, and the cursor worked properly. Of course that's not the correct solution to the issue, but I hope that this can be helpful for resolving it.

I'll attach a DOTT savegame for that particular scene, in which the screen is already shaking.

Attachments (1)

tentacle.s02 (21.6 KB ) - added by AndywinXp 14 months ago.

Download all attachments as: .zip

Change History (3)

by AndywinXp, 14 months ago

Attachment: tentacle.s02 added

comment:1 by AndywinXp, 14 months ago

Description: modified (diff)

comment:2 by AndywinXp, 14 months ago

Owner: set to lephilousophe
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.