[Scummvm-cvs-logs] CVS: scummvm/scumm palette.cpp,2.9,2.10 saveload.cpp,1.161,1.162 script_v5.cpp,1.245,1.246 script_v6.cpp,1.362,1.363 script_v6he.cpp,2.78,2.79 scumm.h,1.430,1.431

Travis Howell kirben at users.sourceforge.net
Sun Jul 25 04:30:04 CEST 2004


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

Modified Files:
	palette.cpp saveload.cpp script_v5.cpp script_v6.cpp 
	script_v6he.cpp scumm.h 
Log Message:

Merge palette functions.


Index: palette.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/palette.cpp,v
retrieving revision 2.9
retrieving revision 2.10
diff -u -d -r2.9 -r2.10
--- palette.cpp	25 Jul 2004 09:21:57 -0000	2.9
+++ palette.cpp	25 Jul 2004 11:29:37 -0000	2.10
@@ -452,7 +452,7 @@
 }
 
 
-void ScummEngine::setupShadowPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor) {
+void ScummEngine::setupShadowPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor, int start, int end) {
 	const byte *basepal = getPalettePtr(_curPalIndex);
 	const byte *pal = basepal;
 	const byte *compareptr;
@@ -477,7 +477,12 @@
 	// from within Room 23 (the big machine), as it has no shadow effects
 	// and thus doesn't result in any visual differences.
 
-	for (i = 0; i <= 255; i++) {
+	if (_gameId == GID_SAMNMAX) {
+		for (i = 0; i < 256; i++)
+			_shadowPalette[i] = i;
+	}
+
+	for (i = start; i < end; i++) {
 		int r = (int) (*pal++ * redScale) >> 8;
 		int g = (int) (*pal++ * greenScale) >> 8;
 		int b = (int) (*pal++ * blueScale) >> 8;
@@ -525,58 +530,6 @@
 	}
 }
 
-/** This function create the specialPalette used for semi-transparency in SamnMax */
-void ScummEngine::setupShadowPalette(int16 from, int16 to, int16 redScale, int16 greenScale, int16 blueScale,
-			int16 startColor, int16 endColor) {
-	const byte *palPtr, *curPtr;
-	const byte *searchPtr;
-
-	uint bestResult;
-	uint currentResult;
-
-	byte currentIndex;
-
-	int i, j;
-
-	palPtr = getPalettePtr(_curPalIndex);
-
-	for (i = 0; i < 256; i++)
-		_shadowPalette[i] = i;
-
-	curPtr = palPtr + startColor * 3;
-
-	for (i = startColor; i < endColor; i++) {
-		int r = (int) (*curPtr++ * redScale) >> 8;
-		int g = (int) (*curPtr++ * greenScale) >> 8;
-		int b = (int) (*curPtr++ * blueScale) >> 8;
-
-		if (r > 255)
-			r = 255;
-		if (g > 255)
-			g = 255;
-		if (b > 255)
-			b = 255;
-
-		searchPtr = palPtr + from * 3;
-		bestResult = (uint)-1;
-		currentIndex = (byte) from;
-
-		for (j = from; j <= to; j++) {
-			int ar = (*searchPtr++);
-			int ag = (*searchPtr++);
-			int ab = (*searchPtr++);
-
-			currentResult = colorWeight(ar - r, ag - g, ab - b);
-
-			if (currentResult < bestResult) {
-				_shadowPalette[i] = currentIndex;
-				bestResult = currentResult;
-			}
-			currentIndex++;
-		}
-	}
-}
-
 void ScummEngine::darkenPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor) {
 	if (_roomResource == 0) // FIXME - HACK to get COMI demo working
 		return;

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.161
retrieving revision 1.162
diff -u -d -r1.161 -r1.162
--- saveload.cpp	18 Jul 2004 05:04:30 -0000	1.161
+++ saveload.cpp	25 Jul 2004 11:29:38 -0000	1.162
@@ -524,6 +524,7 @@
 		MKLINE(ScummEngine, gdi._transparentColor, sleByte, VER(8)),
 		MKARRAY(ScummEngine, _currentPalette[0], sleByte, 768, VER(8)),
 
+		// Should be made obsolete in next save game version.
 		MKARRAY(ScummEngine, _proc_special_palette[0], sleByte, 256, VER(8)),
 
 		MKARRAY(ScummEngine, _charsetBuffer[0], sleByte, 256, VER(8)),

Index: script_v5.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v5.cpp,v
retrieving revision 1.245
retrieving revision 1.246
diff -u -d -r1.245 -r1.246
--- script_v5.cpp	24 Jul 2004 07:18:18 -0000	1.245
+++ script_v5.cpp	25 Jul 2004 11:29:38 -0000	1.246
@@ -1926,7 +1926,7 @@
 		_opcode = fetchScriptByte();
 		d = getVarOrDirectByte(PARAM_1);
 		e = getVarOrDirectByte(PARAM_2);
-		setupShadowPalette(a, b, c, d, e);
+		setupShadowPalette(a, b, c, d, e, 0, 256);
 		break;
 
 	case 13:	// SO_SAVE_STRING

Index: script_v6.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6.cpp,v
retrieving revision 1.362
retrieving revision 1.363
diff -u -d -r1.362 -r1.363
--- script_v6.cpp	25 Jul 2004 09:21:57 -0000	1.362
+++ script_v6.cpp	25 Jul 2004 11:29:38 -0000	1.363
@@ -1710,7 +1710,7 @@
 		c = pop();
 		b = pop();
 		a = pop();
-		setupShadowPalette(a, b, c, d, e);
+		setupShadowPalette(a, b, c, d, e, 0, 256);
 		break;
 
 	case 184:		// SO_SAVE_STRING
@@ -2615,7 +2615,7 @@
 			// Case 108 and 109 share the same function
 			if (num != 6)
 				warning("o6_kernelSetFunctions sub op %d: expected 6 params but got %d", args[0], num);
-			setupShadowPalette(args[1], args[2], args[3], args[4], args[5], 0, 256);
+			setupShadowPalette(args[3], args[4], args[5], args[1], args[2], 0, 256);
 			break;
 		case 110:
 			_charset->clearCharsetMask();
@@ -2625,7 +2625,7 @@
 			a->shadow_mode = args[2] + args[3];
 			break;
 		case 112:									/* palette shift? */
-			setupShadowPalette(args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
+			setupShadowPalette(args[3], args[4], args[5], args[1], args[2], args[6], args[7]);
 			break;
 		case 114:
 			// Sam & Max film noir mode

Index: script_v6he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6he.cpp,v
retrieving revision 2.78
retrieving revision 2.79
diff -u -d -r2.78 -r2.79
--- script_v6he.cpp	15 Jul 2004 05:53:36 -0000	2.78
+++ script_v6he.cpp	25 Jul 2004 11:29:38 -0000	2.79
@@ -486,7 +486,7 @@
 		b = pop();
 		a = pop();
 		if (_heversion == 60)
-			setupShadowPalette(a, b, c, d, e);
+			setupShadowPalette(a, b, c, d, e, 0, 256);
 		break;
 
 	case 184:		// SO_SAVE_STRING

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.430
retrieving revision 1.431
diff -u -d -r1.430 -r1.431
--- scumm.h	25 Jul 2004 09:21:58 -0000	1.430
+++ scumm.h	25 Jul 2004 11:29:38 -0000	1.431
@@ -877,7 +877,7 @@
 	void initBGBuffers(int height);
 	void initCycl(const byte *ptr);	// Color cycle
 
-	void setupShadowPalette(int16 a, int16 b, int16 c, int16 d, int16 e, int16 colorMin, int16 colorMax);
+	void setupShadowPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor, int start, int end);
 
 	void drawObject(int obj, int arg);	
 	void drawRoomObjects(int arg);
@@ -919,7 +919,6 @@
 protected:
 	void moveMemInPalRes(int start, int end, byte direction);
 	void setupShadowPalette(int slot, int redScale, int greenScale, int blueScale, int startColor, int endColor);
-	void setupShadowPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor);
 	void darkenPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor);
 	void desaturatePalette(int hueScale, int satScale, int lightScale, int startColor, int endColor);
 





More information about the Scummvm-git-logs mailing list