[Scummvm-cvs-logs] CVS: scummvm/scumm palette.cpp,2.47,2.48

kirben kirben at users.sourceforge.net
Tue May 24 18:37:21 CEST 2005


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5320/scumm

Modified Files:
	palette.cpp 
Log Message:

Add cyx's patch for:
651077 - SAM: Bad Colors in first Room

Applied changes to SCUMM5 games too, which used the same code.


Index: palette.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/palette.cpp,v
retrieving revision 2.47
retrieving revision 2.48
diff -u -d -r2.47 -r2.48
--- palette.cpp	24 May 2005 17:18:37 -0000	2.47
+++ palette.cpp	25 May 2005 01:35:32 -0000	2.48
@@ -572,7 +572,6 @@
 	return 3 * red * red + 6 * green * green + 2 * blue * blue;
 }
 
-
 void ScummEngine::setupShadowPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor, int start, int end) {
 	const byte *basepal = getPalettePtr(_curPalIndex, _roomResource);
 	const byte *compareptr;
@@ -611,43 +610,21 @@
 	}
 
 	for (i = start; i < end; i++) {
-		int r = (int) (*pal++ * redScale) >> 8;
-		int g = (int) (*pal++ * greenScale) >> 8;
-		int b = (int) (*pal++ * blueScale) >> 8;
-
-		// The following functionality is similar to remapPaletteColor, except
-		// 1) we have to work off the original CLUT rather than the current palette, and
-		// 2) the target shadow palette entries must be bounded to the upper and lower
-		//    bounds provided by the opcode. (This becomes significant in Room 48, but
-		//    is not an issue in all other known case studies.)
-		int j;
-		int ar, ag, ab;
-		uint sum, bestsum, bestitem = 0;
-
-		if (r > max)
-			r = max;
-		if (g > max)
-			g = max;
-		if (b > max)
-			b = max;
-
-		bestsum = 0x7FFFFFFF;
+		int r = (int) ((pal[0] >> 2) * redScale) >> 8;
+		int g = (int) ((pal[1] >> 2) * greenScale) >> 8;
+		int b = (int) ((pal[2] >> 2) * blueScale) >> 8;
+		pal += 3;
 
-		r &= ~3;
-		g &= ~3;
-		b &= ~3;
+		uint8 bestitem = 0;
+		uint bestsum = 32000;
 
 		compareptr = basepal + startColor * 3;
-		for (j = startColor; j <= endColor; j++, compareptr += 3) {
-			ar = compareptr[0] & ~3;
-			ag = compareptr[1] & ~3;
-			ab = compareptr[2] & ~3;
-			if (ar == r && ag == g && ab == b) {
-				bestitem = j;
-				break;
-			}
-
-			sum = colorWeight(ar - r, ag - g, ab - b);
+		for (int j = startColor; j <= endColor; j++, compareptr += 3) {
+			int ar = compareptr[0] >> 2;
+			int ag = compareptr[1] >> 2;
+			int ab = compareptr[2] >> 2;
+		
+		uint sum = ABS(ar - r) + ABS(ag - g) + ABS(ab - b);
 
 			if (sum < bestsum) {
 				bestsum = sum;
@@ -656,6 +633,7 @@
 		}
 		*table++ = bestitem;
 	}
+
 }
 
 void ScummEngine::darkenPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor) {





More information about the Scummvm-git-logs mailing list