aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Snover2016-07-09 19:30:29 -0500
committerColin Snover2016-07-11 10:39:50 -0500
commit8fb55564a68078ab2e320b64c2fc63552316d8ae (patch)
tree1f9c945ae77fe7d19eeb7300f710b5dd7df81db2
parent6a13adb638395858882555c23f38451c3a0b55e1 (diff)
downloadscummvm-rg350-8fb55564a68078ab2e320b64c2fc63552316d8ae.tar.gz
scummvm-rg350-8fb55564a68078ab2e320b64c2fc63552316d8ae.tar.bz2
scummvm-rg350-8fb55564a68078ab2e320b64c2fc63552316d8ae.zip
SCI32: Fix bad output caused by missing palette copies
Sometimes, games accidentally use palette entries that are not marked as used and expect them to be a particular colour, like the Phantasmagoria title screen, or the white palette entry (always 255 in DOS/Win).
-rw-r--r--engines/sci/graphics/palette32.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/engines/sci/graphics/palette32.cpp b/engines/sci/graphics/palette32.cpp
index 3a321bf0b1..a43ac27e2e 100644
--- a/engines/sci/graphics/palette32.cpp
+++ b/engines/sci/graphics/palette32.cpp
@@ -259,7 +259,7 @@ void GfxPalette32::updateHardware() {
byte bpal[3 * 256];
- for (int i = 0; i < ARRAYSIZE(_currentPalette.colors); ++i) {
+ for (int i = 0; i < ARRAYSIZE(_currentPalette.colors) - 1; ++i) {
_currentPalette.colors[i] = _nextPalette.colors[i];
// NOTE: If the brightness option in the user configuration file is set,
@@ -267,12 +267,22 @@ void GfxPalette32::updateHardware() {
// in some hard-coded brightness tables. There is no reason on modern hardware
// to implement this, unless it is discovered that some game uses a non-standard
// brightness setting by default
- if (_currentPalette.colors[i].used) {
- bpal[i * 3 ] = _currentPalette.colors[i].r;
- bpal[i * 3 + 1] = _currentPalette.colors[i].g;
- bpal[i * 3 + 2] = _currentPalette.colors[i].b;
- }
- }
+
+ // All color entries MUST be copied, not just "used" entries, otherwise
+ // uninitialised memory from bpal makes its way into the system palette.
+ // This would not normally be a problem, except that games sometimes use
+ // unused palette entries. e.g. Phant1 title screen references palette
+ // entries outside its own palette, so will render garbage colors where
+ // the game expects them to be black
+ bpal[i * 3 ] = _currentPalette.colors[i].r;
+ bpal[i * 3 + 1] = _currentPalette.colors[i].g;
+ bpal[i * 3 + 2] = _currentPalette.colors[i].b;
+ }
+
+ // The last color must always be white
+ bpal[255 * 3 ] = 255;
+ bpal[255 * 3 + 1] = 255;
+ bpal[255 * 3 + 2] = 255;
g_system->getPaletteManager()->setPalette(bpal, 0, 256);
g_sci->getEventManager()->updateScreen();