From c8affb54cca259f37522216bad739be085bf9caa Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Thu, 11 Aug 2016 20:46:17 -0500 Subject: SCI32: Fix KQ7 1.51 video background --- engines/sci/graphics/video32.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'engines/sci/graphics') diff --git a/engines/sci/graphics/video32.cpp b/engines/sci/graphics/video32.cpp index 0dde86a65d..380ab804d7 100644 --- a/engines/sci/graphics/video32.cpp +++ b/engines/sci/graphics/video32.cpp @@ -371,7 +371,25 @@ void AVIPlayer::renderFrame() const { return; } - bitmap.getBuffer().copyRectToSurface(*surface, 0, 0, Common::Rect(surface->w, surface->h)); + // KQ7 1.51 encodes videos with palette entry 0 as white, which makes + // the area around the video turn white too, since it is coded to use + // palette entry 0. This happens to work in the original game because + // the video is rendered by VfW, not in the engine itself. To fix this, + // we just modify the incoming pixel data from the video so if a pixel + // is using entry 0, we change it to use entry 255, which is guaranteed + // to always be white + if (getSciVersion() == SCI_VERSION_2_1_EARLY && g_sci->getGameId() == GID_KQ7) { + uint8 *target = bitmap.getPixels(); + uint8 *source = (uint8 *)surface->getPixels(); + uint8 *end = (uint8 *)surface->getPixels() + surface->w * surface->h; + + while (source != end) { + uint8 value = *source++; + *target++ = value == 0 ? 255 : value; + } + } else { + bitmap.getBuffer().copyRectToSurface(*surface, 0, 0, Common::Rect(surface->w, surface->h)); + } const bool dirtyPalette = _decoder->hasDirtyPalette(); if (dirtyPalette) { @@ -384,6 +402,9 @@ void AVIPlayer::renderFrame() const { palette.colors[i].used = true; } + // Prevent KQ7 1.51 from setting entry 0 to white + palette.colors[0].used = false; + g_sci->_gfxPalette32->submit(palette); } -- cgit v1.2.3