[Scummvm-git-logs] scummvm master -> bfb929013833c203868efba95af23ea57e4ac91b

sluicebox 22204938+sluicebox at users.noreply.github.com
Fri Apr 17 00:10:36 UTC 2020


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
acfe23b42c SCI32: Handle Mac color remapping range
bfb9290138 SCI32: Handle Mac black palette entry


Commit: acfe23b42cad3d3ef55cf33db53a252785d656ae
    https://github.com/scummvm/scummvm/commit/acfe23b42cad3d3ef55cf33db53a252785d656ae
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2020-04-16T17:07:49-07:00

Commit Message:
SCI32: Handle Mac color remapping range

Changed paths:
    engines/sci/graphics/remap32.cpp
    engines/sci/graphics/remap32.h


diff --git a/engines/sci/graphics/remap32.cpp b/engines/sci/graphics/remap32.cpp
index 6fe0a53f71..dd506a3a9b 100644
--- a/engines/sci/graphics/remap32.cpp
+++ b/engines/sci/graphics/remap32.cpp
@@ -189,8 +189,8 @@ bool SingleRemap::apply() {
 	const uint8 remapStartColor = gfxRemap32->getStartColor();
 
 	// Blocked colors are not allowed to be used as target colors for the remap
-	bool blockedColors[236];
-	Common::fill(blockedColors, blockedColors + remapStartColor, false);
+	bool blockedColors[237];
+	Common::fill(blockedColors, &blockedColors[237], false);
 
 	const bool *const paletteCycleMap = g_sci->_gfxPalette32->getCycleMap();
 
@@ -291,12 +291,17 @@ GfxRemap32::GfxRemap32() :
 	_needsUpdate(false),
 	_blockedRangeStart(0),
 	_blockedRangeCount(0),
-	_remapStartColor(236),
 	_numActiveRemaps(0) {
-	// The `_remapStartColor` seems to always be 236 in SSCI, but if it is ever
-	// changed then the various C-style member arrays hard-coded to 236 need to
-	// be changed to match the highest possible value of `_remapStartColor`
-	assert(_remapStartColor == 236);
+
+	// Mac SSCI has one less remap entry than PC. Mac games expand the normal
+	//  range from 236 entries to 237 and uses the extra entry (236) for black
+	//  instead of 0. This was done to avoid conflicting with the operating
+	//  system's palette which always uses entry 0 for white.
+	if (g_sci->getPlatform() == Common::kPlatformMacintosh) {
+		_remapStartColor = 237;
+	} else {
+		_remapStartColor = 236;
+	}
 
 	if (g_sci->_features->hasMidPaletteCode()) {
 		_remaps.resize(9);
@@ -304,7 +309,7 @@ GfxRemap32::GfxRemap32() :
 		_remaps.resize(19);
 	}
 
-	_remapEndColor = _remapStartColor + _remaps.size() - 1;
+	_remapEndColor = 236 + _remaps.size() - 1;
 }
 
 void GfxRemap32::remapOff(const uint8 color) {
diff --git a/engines/sci/graphics/remap32.h b/engines/sci/graphics/remap32.h
index 4ccfb56963..81f382e10c 100644
--- a/engines/sci/graphics/remap32.h
+++ b/engines/sci/graphics/remap32.h
@@ -100,8 +100,12 @@ public:
 	 * is looked up in this array using the target's pixel color. In other
 	 * words,
 	 * `target = _remaps[remapEndColor - source].remapColors[target]`.
+	 *
+	 * Mac SSCI includes entry 236 in the non-remapped range at the cost of one
+	 * remap entry and so the Mac remap range starts at 237. The final entry in
+	 * this array, and the others in this class, is not used by PC games.
 	 */
-	uint8 _remapColors[236];
+	uint8 _remapColors[237];
 
 	/**
 	 * Resets this SingleRemap's color information to default values.
@@ -130,26 +134,26 @@ private:
 	 * The colors from the current GfxPalette32 palette before this SingleRemap
 	 * is applied.
 	 */
-	Color _originalColors[236];
+	Color _originalColors[237];
 
 	/**
 	 * Map of colors that changed in `_originalColors` when this SingleRemap was
 	 * updated. This map is transient and gets reset to `false` after the
 	 * SingleRemap finishes updating.
 	 */
-	bool _originalColorsChanged[236];
+	bool _originalColorsChanged[237];
 
 	/**
 	 * The ideal target RGB color values for each generated remap color.
 	 */
-	Color _idealColors[236];
+	Color _idealColors[237];
 
 	/**
 	 * Map of colors that changed in `_idealColors` when this SingleRemap was
 	 * updated. This map is transient and gets reset to `false` after the
 	 * SingleRemap finishes applying.
 	 */
-	bool _idealColorsChanged[236];
+	bool _idealColorsChanged[237];
 
 	/**
 	 * When applying a SingleRemap, finding an appropriate color in the palette
@@ -159,7 +163,7 @@ private:
 	 * application and avoid triggering an expensive redraw of the entire screen
 	 * if the new palette value only changed slightly.
 	 */
-	int _matchDistances[236];
+	int _matchDistances[237];
 
 	/**
 	 * Computes the final target values for a range remap and applies them
@@ -322,7 +326,7 @@ public:
 		// surface filled with a skip color of 255. In SSCI, this causes the
 		// remapped color to be read from some statically allocated, never
 		// written memory and so always ends up being 0 (black).
-		if (targetColor >= ARRAYSIZE(singleRemap._remapColors)) {
+		if (targetColor >= _remapStartColor) {
 			return 0;
 		}
 		return singleRemap._remapColors[targetColor];
@@ -343,7 +347,7 @@ private:
 	/**
 	 * The first index of the remap area in the system palette.
 	 */
-	const uint8 _remapStartColor;
+	uint8 _remapStartColor;
 
 	/**
 	 * The last index of the remap area in the system palette.


Commit: bfb929013833c203868efba95af23ea57e4ac91b
    https://github.com/scummvm/scummvm/commit/bfb929013833c203868efba95af23ea57e4ac91b
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2020-04-16T17:08:49-07:00

Commit Message:
SCI32: Handle Mac black palette entry

Changed paths:
    engines/sci/graphics/palette32.cpp


diff --git a/engines/sci/graphics/palette32.cpp b/engines/sci/graphics/palette32.cpp
index e139a05188..a035c6838a 100644
--- a/engines/sci/graphics/palette32.cpp
+++ b/engines/sci/graphics/palette32.cpp
@@ -499,9 +499,13 @@ void GfxPalette32::updateHardware() {
 	// to the backend. This makes those high pixels render black, which seems to
 	// match what would happen in the original interpreter, and saves us from
 	// having to clutter up the engine with a bunch of palette shifting garbage.
+	//
+	// This workaround also handles Mac games, as they use 236 for black to avoid
+	//  conflicting with the operating system's palette which uses 0 for white.
 	int maxIndex = ARRAYSIZE(_currentPalette.colors) - 2;
 	if (g_sci->getGameId() == GID_HOYLE5 ||
-		(g_sci->getGameId() == GID_GK2 && g_sci->isDemo())) {
+		(g_sci->getGameId() == GID_GK2 && g_sci->isDemo()) ||
+		g_sci->getPlatform() == Common::kPlatformMacintosh) {
 		maxIndex = 235;
 	}
 




More information about the Scummvm-git-logs mailing list