Skip to content

Commit

Permalink
SCI32: Disable VMD kPlayFlagBlackPalette flag
Browse files Browse the repository at this point in the history
Videos in GK2 use this flag (e.g. the chapter 6 intro).

Now that GfxPalette32::updateHardware no longer calls
OSystem::updateScreen (only GfxFrameout::frameOut does this now),
every time a palette swap occurs during playback, there is a frame
of blackness that should not exist. This is because the order of
operation is:

1. Send black palette
2. Call frameOut (which updates the screen)
3. Send new, correct palette
4. No frameOut (so the screen is not updated with the correct
   palette)

OSystem::updateScreen cannot be called multiple times for the same
frame due to vsync, but also, there does not appear to be any
reason to send a black palette, since it seems to be intended to
avoid temporarily rendering video frames with the wrong palette on
a hardware device that cannot guarantee simultaneous application
of a new palette and new pixel data. ScummVM does not have such
a problem, so this feature appears to be unnecessary for us.

For the moment, this 'feature' remains hidden behind an ifdef,
instead of being removed entirely, to avoid potential confusion
when comparing VMD code from SSCI.
  • Loading branch information
csnover committed May 6, 2017
1 parent 8b49313 commit 8a590e6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 9 additions & 3 deletions engines/sci/graphics/video32.cpp
Expand Up @@ -531,8 +531,9 @@ VMDPlayer::VMDPlayer(SegManager *segMan, EventManager *eventMan) :

_startColor(0),
_endColor(255),
#ifdef SCI_VMD_BLACK_PALETTE
_blackPalette(false),

#endif
_boostPercent(100),
_boostStartColor(0),
_boostEndColor(255),
Expand Down Expand Up @@ -594,7 +595,9 @@ void VMDPlayer::init(const int16 x, const int16 y, const PlayFlags flags, const
_boostEndColor = CLIP<int16>(boostEndColor, 0, 255);
_leaveScreenBlack = flags & kPlayFlagLeaveScreenBlack;
_leaveLastFrame = flags & kPlayFlagLeaveLastFrame;
#ifdef SCI_VMD_BLACK_PALETTE
_blackPalette = flags & kPlayFlagBlackPalette;
#endif
_stretchVertical = flags & kPlayFlagStretchVertical;
}

Expand Down Expand Up @@ -869,25 +872,28 @@ void VMDPlayer::renderFrame() const {
for (uint16 i = _endColor; i < 256; ++i) {
palette.colors[i].used = false;
}
#if SCI_VMD_BLACK_PALETTE
if (_blackPalette) {
for (uint16 i = _startColor; i <= _endColor; ++i) {
palette.colors[i].r = palette.colors[i].g = palette.colors[i].b = 0;
palette.colors[i].used = true;
}
} else {
} else
#endif
fillPalette(palette);
}

g_sci->_gfxPalette32->submit(palette);
g_sci->_gfxFrameout->updateScreenItem(*_screenItem);
g_sci->_gfxFrameout->frameOut(true);

#if SCI_VMD_BLACK_PALETTE
if (_blackPalette) {
fillPalette(palette);
g_sci->_gfxPalette32->submit(palette);
g_sci->_gfxPalette32->updateForFrame();
g_sci->_gfxPalette32->updateHardware();
}
#endif
} else {
g_sci->_gfxFrameout->updateScreenItem(*_screenItem);
g_sci->_gfxFrameout->frameOut(true);
Expand Down
12 changes: 11 additions & 1 deletion engines/sci/graphics/video32.h
Expand Up @@ -498,8 +498,18 @@ class VMDPlayer {
* palette is submitted to the palette manager,
* which is then restored after the video pixels
* have already been rendered.
*/
*
* This functionality is currently disabled because it seems like
* it was designed for a different graphics architecture where
* pixel data could be rendered before the video card's palette
* had been updated. This is not possible in ScummVM because the
* palette & pixel data are rendered simultaneously when
* OSystem::updateScreen is called, rather than immediately
* after they are sent to the backend.
*/
#ifdef SCI_VMD_BLACK_PALETTE
bool _blackPalette;
#endif

#pragma mark -
#pragma mark VMDPlayer - Brightness boost
Expand Down

0 comments on commit 8a590e6

Please sign in to comment.