[Scummvm-git-logs] scummvm master -> 336bf0dd3776e49530ea6e3362cd792d7ce0e528

sluicebox 22204938+sluicebox at users.noreply.github.com
Thu Jul 23 09:44:23 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:
452343a58e SCI32: Support late Mac composited VMD playback
336bf0dd37 SCI32: Translate Mac colors when drawing cels


Commit: 452343a58e92988a94bfa9e67d1c9323874f521b
    https://github.com/scummvm/scummvm/commit/452343a58e92988a94bfa9e67d1c9323874f521b
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2020-07-23T02:41:10-07:00

Commit Message:
SCI32: Support late Mac composited VMD playback

Fixes RAMA intro video

Changed paths:
    engines/sci/graphics/video32.h


diff --git a/engines/sci/graphics/video32.h b/engines/sci/graphics/video32.h
index 658f563a96..63ef4a7a67 100644
--- a/engines/sci/graphics/video32.h
+++ b/engines/sci/graphics/video32.h
@@ -543,7 +543,9 @@ private:
 	}
 
 	bool isNormallyComposited() const {
-		return getSciVersion() == SCI_VERSION_3;
+		return (getSciVersion() == SCI_VERSION_3) || 
+				(g_sci->getPlatform() == Common::kPlatformMacintosh &&
+				 getSciVersion() >= SCI_VERSION_2_1_LATE);
 	}
 
 	void initOverlay();


Commit: 336bf0dd3776e49530ea6e3362cd792d7ce0e528
    https://github.com/scummvm/scummvm/commit/336bf0dd3776e49530ea6e3362cd792d7ce0e528
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2020-07-23T02:41:10-07:00

Commit Message:
SCI32: Translate Mac colors when drawing cels

Fixes KQ7 credits, RAMA credits

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


diff --git a/engines/sci/graphics/celobj32.cpp b/engines/sci/graphics/celobj32.cpp
index 68dca3de36..30187c4565 100644
--- a/engines/sci/graphics/celobj32.cpp
+++ b/engines/sci/graphics/celobj32.cpp
@@ -436,14 +436,35 @@ public:
 #pragma mark -
 #pragma mark CelObj - Remappers
 
+/**
+ * Translation for pixels from Mac pic and view cels to the PC palette.
+ * The Mac OS palette required 0 to be white and 255 to be black, which is the
+ * opposite of the PC palette. Mac cels use the Mac palette but the colors in
+ * scripts are constant between versions. SSCI handles this with many Mac-only
+ * translations throughout the interpreter. We use the PC palette and translate
+ * the cel pixels here, similar to the SCI16 code in GfxView::unpackCel. The
+ * difference is that in SCI32 we decompress while drawing, while in SCI16 cels
+ * are unpacked to a buffer first, making that translation code simpler.
+ */
+inline byte translateMacColor(bool isMacSource, byte color) {
+	if (isMacSource) {
+		if (color == 0) {
+			return 255;
+		} else if (color == 255) {
+			return 0;
+		}
+	}
+	return color;
+}
+
 /**
  * Pixel mapper for a CelObj with transparent pixels and no
  * remapping data.
  */
 struct MAPPER_NoMD {
-	inline void draw(byte *target, const byte pixel, const uint8 skipColor) const {
+	inline void draw(byte *target, const byte pixel, const uint8 skipColor, const bool isMacSource) const {
 		if (pixel != skipColor) {
-			*target = pixel;
+			*target = translateMacColor(isMacSource, pixel);
 		}
 	}
 };
@@ -453,8 +474,8 @@ struct MAPPER_NoMD {
  * no remapping data.
  */
 struct MAPPER_NoMDNoSkip {
-	inline void draw(byte *target, const byte pixel, const uint8) const {
-		*target = pixel;
+	inline void draw(byte *target, const byte pixel, const uint8, const bool isMacSource) const {
+		*target = translateMacColor(isMacSource, pixel);
 	}
 };
 
@@ -463,14 +484,14 @@ struct MAPPER_NoMDNoSkip {
  * remapping data, and remapping enabled.
  */
 struct MAPPER_Map {
-	inline void draw(byte *target, const byte pixel, const uint8 skipColor) const {
+	inline void draw(byte *target, const byte pixel, const uint8 skipColor, const bool isMacSource) const {
 		if (pixel != skipColor) {
 			// For some reason, SSCI never checks if the source pixel is *above*
 			// the range of remaps, so we do not either.
 			if (pixel < g_sci->_gfxRemap32->getStartColor()) {
-				*target = pixel;
+				*target = translateMacColor(isMacSource, pixel);
 			} else if (g_sci->_gfxRemap32->remapEnabled(pixel)) {
-				*target = g_sci->_gfxRemap32->remapColor(pixel, *target);
+				*target = g_sci->_gfxRemap32->remapColor(translateMacColor(isMacSource, pixel), *target);
 			}
 		}
 	}
@@ -481,11 +502,11 @@ struct MAPPER_Map {
  * remapping data, and remapping disabled.
  */
 struct MAPPER_NoMap {
-	inline void draw(byte *target, const byte pixel, const uint8 skipColor) const {
+	inline void draw(byte *target, const byte pixel, const uint8 skipColor, const bool isMacSource) const {
 		// For some reason, SSCI never checks if the source pixel is *above* the
 		// range of remaps, so we do not either.
 		if (pixel != skipColor && pixel < g_sci->_gfxRemap32->getStartColor()) {
-			*target = pixel;
+			*target = translateMacColor(isMacSource, pixel);
 		}
 	}
 };
@@ -713,11 +734,13 @@ struct RENDERER {
 	MAPPER &_mapper;
 	SCALER &_scaler;
 	const uint8 _skipColor;
+	const bool _isMacSource;
 
-	RENDERER(MAPPER &mapper, SCALER &scaler, const uint8 skipColor) :
+	RENDERER(MAPPER &mapper, SCALER &scaler, const uint8 skipColor, const bool isMacSource) :
 	_mapper(mapper),
 	_scaler(scaler),
-	_skipColor(skipColor) {}
+	_skipColor(skipColor),
+	_isMacSource(isMacSource) {}
 
 	inline void draw(Buffer &target, const Common::Rect &targetRect, const Common::Point &scaledPosition) const {
 		byte *targetPixel = (byte *)target.getPixels() + target.w * targetRect.top + targetRect.left;
@@ -735,7 +758,7 @@ struct RENDERER {
 			_scaler.setTarget(targetRect.left, targetRect.top + y);
 
 			for (int16 x = 0; x < targetWidth; ++x) {
-				_mapper.draw(targetPixel++, _scaler.read(), _skipColor);
+				_mapper.draw(targetPixel++, _scaler.read(), _skipColor, _isMacSource);
 			}
 
 			targetPixel += skipStride;
@@ -748,7 +771,7 @@ void CelObj::render(Buffer &target, const Common::Rect &targetRect, const Common
 
 	MAPPER mapper;
 	SCALER scaler(*this, targetRect.left - scaledPosition.x + targetRect.width(), scaledPosition);
-	RENDERER<MAPPER, SCALER, false> renderer(mapper, scaler, _skipColor);
+	RENDERER<MAPPER, SCALER, false> renderer(mapper, scaler, _skipColor, _isMacSource);
 	renderer.draw(target, targetRect, scaledPosition);
 }
 
@@ -758,10 +781,10 @@ void CelObj::render(Buffer &target, const Common::Rect &targetRect, const Common
 	MAPPER mapper;
 	SCALER scaler(*this, targetRect, scaledPosition, scaleX, scaleY);
 	if (_drawBlackLines) {
-		RENDERER<MAPPER, SCALER, true> renderer(mapper, scaler, _skipColor);
+		RENDERER<MAPPER, SCALER, true> renderer(mapper, scaler, _skipColor, _isMacSource);
 		renderer.draw(target, targetRect, scaledPosition);
 	} else {
-		RENDERER<MAPPER, SCALER, false> renderer(mapper, scaler, _skipColor);
+		RENDERER<MAPPER, SCALER, false> renderer(mapper, scaler, _skipColor, _isMacSource);
 		renderer.draw(target, targetRect, scaledPosition);
 	}
 }
@@ -943,6 +966,7 @@ CelObjView::CelObjView(const GuiResourceId viewId, const int16 loopNo, const int
 	_info.loopNo = loopNo;
 	_info.celNo = celNo;
 	_mirrorX = false;
+	_isMacSource = (g_sci->getPlatform() == Common::kPlatformMacintosh);
 	_compressionType = kCelCompressionInvalid;
 	_transparent = true;
 
@@ -1149,6 +1173,7 @@ CelObjPic::CelObjPic(const GuiResourceId picId, const int16 celNo) {
 	_info.loopNo = 0;
 	_info.celNo = celNo;
 	_mirrorX = false;
+	_isMacSource = (g_sci->getPlatform() == Common::kPlatformMacintosh);
 	_compressionType = kCelCompressionInvalid;
 	_transparent = true;
 	_remap = false;
@@ -1274,6 +1299,7 @@ CelObjMem::CelObjMem(const reg_t bitmapObject) {
 	_info.type = kCelTypeMem;
 	_info.bitmap = bitmapObject;
 	_mirrorX = false;
+	_isMacSource = false;
 	_compressionType = kCelCompressionNone;
 	_celHeaderOffset = 0;
 	_transparent = true;
@@ -1317,6 +1343,7 @@ CelObjColor::CelObjColor(const uint8 color, const int16 width, const int16 heigh
 	_yResolution = g_sci->_gfxFrameout->getScriptHeight();
 	_hunkPaletteOffset = 0;
 	_mirrorX = false;
+	_isMacSource = false;
 	_remap = false;
 	_width = width;
 	_height = height;
diff --git a/engines/sci/graphics/celobj32.h b/engines/sci/graphics/celobj32.h
index 69da8d4c9f..df08bc38e3 100644
--- a/engines/sci/graphics/celobj32.h
+++ b/engines/sci/graphics/celobj32.h
@@ -335,6 +335,12 @@ public:
 	 */
 	bool _mirrorX;
 
+	/**
+	 * If true, the source for this cel is a Mac pic or view whose pixels for
+	 * entries 0 and 255 must be swapped when drawing since we use the PC palette.
+	 */
+	bool _isMacSource;
+
 	/**
 	 * Initialises static CelObj members.
 	 */
diff --git a/engines/sci/graphics/palette32.cpp b/engines/sci/graphics/palette32.cpp
index a035c6838a..33ffbeb1b7 100644
--- a/engines/sci/graphics/palette32.cpp
+++ b/engines/sci/graphics/palette32.cpp
@@ -535,16 +535,10 @@ void GfxPalette32::updateHardware() {
 	memset(bpal + (maxIndex + 1) * 3, 0, (255 - maxIndex - 1) * 3);
 #endif
 
-	if (g_sci->getPlatform() == Common::kPlatformMacintosh) {
-		bpal[255 * 3    ] = 0;
-		bpal[255 * 3 + 1] = 0;
-		bpal[255 * 3 + 2] = 0;
-	} else {
-		// The last color must always be white
-		bpal[255 * 3    ] = 255;
-		bpal[255 * 3 + 1] = 255;
-		bpal[255 * 3 + 2] = 255;
-	}
+	// The last color must always be white
+	bpal[255 * 3    ] = 255;
+	bpal[255 * 3 + 1] = 255;
+	bpal[255 * 3 + 2] = 255;
 
 	// If the system is in a high color mode, which can happen during video
 	// playback, attempting to send the palette to OSystem is illegal and will




More information about the Scummvm-git-logs mailing list