[Scummvm-cvs-logs] CVS: scummvm/scumm gfx.cpp,1.31,1.32 script_v2.cpp,1.34,1.35 scumm.h,1.40,1.41 scummvm.cpp,1.57,1.58

Jonathan Gray khalek at users.sourceforge.net
Sat Oct 19 15:36:02 CEST 2002


Update of /cvsroot/scummvm/scummvm/scumm
In directory usw-pr-cvs1:/tmp/cvs-serv15877

Modified Files:
	gfx.cpp script_v2.cpp scumm.h scummvm.cpp 
Log Message:
patch #625603 film noir mode bugfix

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- gfx.cpp	13 Oct 2002 18:14:48 -0000	1.31
+++ gfx.cpp	19 Oct 2002 22:35:21 -0000	1.32
@@ -2833,41 +2833,6 @@
 	}
 }
 
-void Scumm::desaturatePalette()
-{
-	// FIXME: Should this be made to take a range of colors instead?
-
-	byte *cur;
-	int i;
-
-	cur = _currentPalette;
-
-	for (i = 0; i <= 255; i++)
-	{
-		int max, min;
-		int brightness;
-
-		// An algorithm that is good enough for The GIMP should be
-		// good enough for us...
-
-		max = (cur[0] > cur[1]) ? cur[0] : cur[1];
-		if (cur[2] > max)
-			max = cur[2];
-
-		min = (cur[0] < cur[1]) ? cur[0] : cur[1];
-		if (cur[2] < min)
-			min = cur[2];
-
-		brightness = (min + max) / 2;
-
-		*cur++ = brightness;
-		*cur++ = brightness;
-		*cur++ = brightness;
-	}
-
-	setDirtyColors(0, 255);
-}
-
 void Scumm::grabCursor(int x, int y, int w, int h)
 {
 	VirtScreen *vs = findVirtScreen(y);

Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v2.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- script_v2.cpp	18 Oct 2002 11:52:51 -0000	1.34
+++ script_v2.cpp	19 Oct 2002 22:35:22 -0000	1.35
@@ -2936,17 +2936,13 @@
 				// At this point ScummVM will already have set
 				// variable 0x8000 to indicate that the game is
 				// in film noir mode. All we have to do here is
-				// to mark the palette as "dirty", and the next
-				// call to updatePalette() will take care of
-				// the rest.
+				// to mark the palette as "dirty", because
+				// updatePalette() will desaturate the colors
+				// as they are uploaded to the backend.
 				//
-				// Actually, for extra bug-compatibility we
-				// should call desaturatePalette() here only,
-				// instead of in updatePalette(). To see the
-				// difference in behaviour, try turning on film
-				// noir mode in Sam & Max's office. The
-				// background will be grayscale, but Sam and
-				// Max themselves will be in color.
+				// This actually works better than the original
+				// interpreter, where actors would sometimes
+				// still be drawn in color.
 				setDirtyColors(0, 255);
 			} else
 				warning("stub o6_miscOps_114()");

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- scumm.h	16 Oct 2002 10:59:29 -0000	1.40
+++ scumm.h	19 Oct 2002 22:35:22 -0000	1.41
@@ -816,7 +816,6 @@
 	void moveMemInPalRes(int start, int end, byte direction);
 	void setupShadowPalette(int slot, int rfact, int gfact, int bfact, int from, int to);
 	void darkenPalette(int a, int b, int c, int d, int e);
-	void desaturatePalette();
 
 	void setShake(int mode);
 

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- scummvm.cpp	16 Oct 2002 17:37:30 -0000	1.57
+++ scummvm.cpp	19 Oct 2002 22:35:22 -0000	1.58
@@ -1426,17 +1426,14 @@
 void Scumm::updatePalette() {
 	if (_palDirtyMax == -1)
 		return;
-	
+
+	bool noir_mode = (_gameId == GID_SAMNMAX && readVar(0x8000));
 	int first = _palDirtyMin;
 	int num = _palDirtyMax - first + 1;
 	int i;
 
 	byte palette_colors[1024],*p = palette_colors;
 
-	// Sam & Max film noir mode
-	if (_gameId == GID_SAMNMAX && readVar(0x8000))
-		desaturatePalette();
-
 	for (i = _palDirtyMin; i <= _palDirtyMax; i++) {
 		byte *data;
 
@@ -1445,11 +1442,29 @@
 		else
 			data = _currentPalette + i * 3;
 
-		*p++ = data[0];
-		*p++ = data[1];
-		*p++ = data[2];
-		*p++ = 0;
+		// Sam & Max film noir mode. Convert the colours to grayscale
+		// before uploading them to the backend.
+
+		if (noir_mode) {
+			double r, g, b;
+			double brightness;
 
+			r = (double) data[0];
+			g = (double) data[1];
+			b = (double) data[2];
+
+			brightness = (0.299 * r + 0.587 * g + 0.114 * b) + 0.5;
+
+			*p++ = (byte) brightness;
+			*p++ = (byte) brightness;
+			*p++ = (byte) brightness;
+			*p++ = 0;
+		} else {
+			*p++ = data[0];
+			*p++ = data[1];
+			*p++ = data[2];
+			*p++ = 0;
+		}
 	}
 	
 	_system->set_palette(palette_colors, first, num);





More information about the Scummvm-git-logs mailing list