[Scummvm-git-logs] scummvm master -> 49a5fd6ebe5919c712591e7abc33b9ca95ee2b1b

dreammaster dreammaster at scummvm.org
Sun Aug 15 02:46:37 UTC 2021


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

Summary:
49a5fd6ebe AGS: Fix broken calendar puzzle in Lamplight City


Commit: 49a5fd6ebe5919c712591e7abc33b9ca95ee2b1b
    https://github.com/scummvm/scummvm/commit/49a5fd6ebe5919c712591e7abc33b9ca95ee2b1b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-08-14T19:46:15-07:00

Commit Message:
AGS: Fix broken calendar puzzle in Lamplight City

Changed paths:
    engines/ags/lib/allegro/surface.h


diff --git a/engines/ags/lib/allegro/surface.h b/engines/ags/lib/allegro/surface.h
index a1850e145f..bb5cffd25a 100644
--- a/engines/ags/lib/allegro/surface.h
+++ b/engines/ags/lib/allegro/surface.h
@@ -134,18 +134,23 @@ public:
 
 
 	inline void rgbBlend(uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &rDest, uint8 &gDest, uint8 &bDest, uint32 alpha) const {
-		// Original logic has uint32 src and dst colors as RGB888
-		// if (alpha)
-		//     ++alpha;
-		// uint32 res = ((src & 0xFF00FF) - (dst & 0xFF00FF)) * alpha / 256 + dst;
-		// dst &= 0x00FF00;
-		// src &= 0x00FF00;
-		// uint32 g = (src - dst) * alpha / 256 + dst;
-		// return (res & 0xFF00FF) | (g & 0x00FF00)
-		double sAlpha = (double)(alpha & 0xff) / 255.0;
-		rDest = static_cast<uint8>(rSrc * sAlpha + rDest * (1. - sAlpha));
-		gDest = static_cast<uint8>(gSrc * sAlpha + gDest * (1. - sAlpha));
-		bDest = static_cast<uint8>(bSrc * sAlpha + bDest * (1. - sAlpha));
+		// Note: the original's handling varies slightly for R & B vs G.
+		// We need to exactly replicate it to ensure Lamplight City's
+		// calendar puzzle works correctly
+		if (alpha)
+			alpha++;
+
+		uint32 x = ((uint32)rSrc << 16) | ((uint32)gSrc << 8) | (uint32)bSrc;
+		uint32 y = ((uint32)rDest << 16) | ((uint32)gDest << 8) | (uint32)bDest;
+
+		uint32 res = ((x & 0xFF00FF) - (y & 0xFF00FF)) * alpha / 256 + y;
+		y &= 0xFF00;
+		x &= 0xFF00;
+		uint32 g = (x - y) * alpha / 256 + y;
+
+		rDest = (res >> 16) & 0xff;
+		gDest = (g >> 8) & 0xff;
+		bDest = res & 0xff;
 	}
 
 	inline void argbBlend(uint32 aSrc, uint8 rSrc, uint8 gSrc, uint8 bSrc, uint8 &aDest, uint8 &rDest, uint8 &gDest, uint8 &bDest) const {




More information about the Scummvm-git-logs mailing list