[Scummvm-cvs-logs] CVS: scummvm/scumm gfx.cpp,1.15,1.16 script_v1.cpp,1.8,1.9 script_v2.cpp,1.7,1.8 scumm.h,1.13,1.14

Max Horn fingolfin at users.sourceforge.net
Fri Sep 13 04:56:02 CEST 2002


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

Modified Files:
	gfx.cpp script_v1.cpp script_v2.cpp scumm.h 
Log Message:
patch #608138 (palManipulateInit code)

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- gfx.cpp	9 Sep 2002 11:23:25 -0000	1.15
+++ gfx.cpp	13 Sep 2002 11:54:59 -0000	1.16
@@ -2459,86 +2459,59 @@
 	}
 }
 
-void Scumm::palManipulateInit(int start, int end, int d, int time, int e)
+void Scumm::palManipulateInit(int start, int end, int string_id, int time)
 {
-	// TODO - correctly implement this function (see also bug #558245)
-	//
-	// There are two known places (both in FOA) where this function is being
-	// called. The fist is during the FOA extro, to change the color to match
-	// the sinking sun. The following three calls (with some pauses between them)
-	// are issued:
-	//
-	// palManipulateInit(16, 190, 32, 180, 1)
-	// palManipulateInit(16, 190, 32, 1, 1)
-	// palManipulateInit(16, 190, 32, 800, 1)
-	//
-	// The second place is in the Inner Sanctum after you used the stone discs,
-	// here it is used to give the scene a "lava glow".
-	//
-	// palManipulateInit(32, 65, 46, 20, 1): not implemented!
-	//
-	// The first two parameters seem to specify a palette range (as the colors
-	// from 16 to 190 are the ones that make up water & sky).
-	//
-	// Maybe the change has to be done over a period of time, possibly specified
-	// by the second last parameter - between call 1 and 2, about 17-18 seconds
-	// seem to pass (well using get_msecs, I measured 17155 ms, 17613 ms, 17815 ms).
-	//
-	// No clue about the third and fifth parameter right now, they just always
-	// are 32 and 1 - possibly finding another example of this function being
-	// used would help a lot. Also, I can't currently compare it with the original,
-	// doing that (and possibly, taking screenshots of it for analysis!) would 
-	// help a lot.
-	
-	warning("palManipulateInit(%d, %d, %d, %d, %d): not implemented", start, end, d, time, e);
-
-	// FIXME - is this right?
-	// It seems we already have had this "palManipulate" and "moveMemInPalRes"
-	// functions, only they were never used (somebody disassembled them and
-	// didn't disassmble the functions using them?).
-	//
-	// I 
 	_palManipStart = start;
 	_palManipEnd = end;
-	//_palManipCounter = ?
-	
-	{
-		int redScale = 0xFF;
-		int greenScale = 0xFF - d;
-		int blueScale = 0xFF - d;
-		byte *cptr;
-		byte *cur;
-		int num;
-		int color;
-	
-		cptr = _currentPalette + start * 3;
-		cur = _currentPalette + start * 3;
-		num = end - start + 1;
+	_palManipCounter = 0;
 
-		do {
-			color = *cptr++;
-			if (redScale != 0xFF)
-				color = color * redScale / 0xFF;
-			if (color > 255)
-				color = 255;
-			*cur++ = color;
+	byte *startptr = getResourceAddress(rtTemp, 4);
+	if (startptr)
+		nukeResource(rtTemp, 4);
+	startptr = createResource(rtTemp, 4, 256 * 6);
+	if (!startptr) {
+		warning("palManipulateInit(%d,%d,%d,%d): Cannot create rtTemp resource index 4\n", start, end, string_id, time);
+		return;
+	}
+	startptr += _palManipStart * 6;
 
-			color = *cptr++;
-			if (greenScale != 0xFF)
-				color = color * greenScale / 0xFF;
-			if (color > 255)
-				color = 255;
-			*cur++ = color;
+	byte *endptr = getResourceAddress(rtTemp, 5);
+	if (endptr)
+		nukeResource(rtTemp, 5);
+	endptr = createResource(rtTemp, 5, 256 * 6);
+	if (!endptr) {
+		warning("palManipulateInit(%d,%d,%d,%d): Cannot create rtTemp resource index 5\n", start, end, string_id, time);
+		return;
+	}
+	endptr += _palManipStart * 6;
 
-			color = *cptr++;
-			if (blueScale != 0xFF)
-				color = color * blueScale / 0xFF;
-			if (color > 255)
-				color = 255;
-			*cur++ = color;
-		} while (--num);
-		setDirtyColors(start, end);
+	byte *curptr = _currentPalette + _palManipStart * 3;
+	byte *string1ptr = getStringAddress(string_id) + _palManipStart;
+	byte *string2ptr = getStringAddress(string_id + 1) + _palManipStart;
+	byte *string3ptr = getStringAddress(string_id + 2) + _palManipStart;
+	if (!string1ptr || !string2ptr || !string3ptr) {
+		warning("palManipulateInit(%d,%d,%d,%d): Cannot obtain string resources %d, %d and %d\n",
+		        start, end, string_id, time, string_id, string_id + 1, string_id + 2);
+		return;
 	}
+
+	int i;
+	for (i = _palManipStart; i <= _palManipEnd; ++i) {
+		*((uint16 *)startptr) = ((uint16) *curptr++) << 8;
+		*((uint16 *)endptr) = ((uint16) *string1ptr++) << 8;
+		startptr += 2;
+		endptr += 2;
+		*((uint16 *)startptr) = ((uint16) *curptr++) << 8;
+		*((uint16 *)endptr) = ((uint16) *string2ptr++) << 8;
+		startptr += 2;
+		endptr += 2;
+		*((uint16 *)startptr) = ((uint16) *curptr++) << 8;
+		*((uint16 *)endptr) = ((uint16) *string3ptr++) << 8;
+		startptr += 2;
+		endptr += 2;
+	}
+
+	_palManipCounter = time;
 }
 
 void Scumm::palManipulate()
@@ -2559,17 +2532,17 @@
 
 	i = _palManipStart;
 	while (i < _palManipEnd) {
-		j = (*((uint16 *)srcptr) += *(uint16 *)destptr);
+		j = (*((uint16 *)srcptr) += (*(uint16 *)destptr - *((uint16 *)srcptr)) / _palManipCounter);
 		*pal++ = j >> 8;
 		srcptr += 2;
 		destptr += 2;
 
-		j = (*((uint16 *)srcptr) += *(uint16 *)destptr);
+		j = (*((uint16 *)srcptr) += (*(uint16 *)destptr - *((uint16 *)srcptr)) / _palManipCounter);
 		*pal++ = j >> 8;
 		srcptr += 2;
 		destptr += 2;
 
-		j = (*((uint16 *)srcptr) += *(uint16 *)destptr);
+		j = (*((uint16 *)srcptr) += (*(uint16 *)destptr - *((uint16 *)srcptr)) / _palManipCounter);
 		*pal++ = j >> 8;
 		srcptr += 2;
 		destptr += 2;

Index: script_v1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v1.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- script_v1.cpp	9 Sep 2002 04:54:54 -0000	1.8
+++ script_v1.cpp	13 Sep 2002 11:54:59 -0000	1.9
@@ -2063,7 +2063,7 @@
 		c = getVarOrDirectByte(0x40);
 		_opcode = fetchScriptByte();
 		d = getVarOrDirectByte(0x80);
-		palManipulateInit(b, c, a, d, 1);
+		palManipulateInit(b, c, a, d);
 		break;
 
 	case 16:

Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v2.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- script_v2.cpp	7 Sep 2002 19:55:16 -0000	1.7
+++ script_v2.cpp	13 Sep 2002 11:54:59 -0000	1.8
@@ -1879,7 +1879,7 @@
 		c = pop();
 		b = pop();
 		a = pop();
-		palManipulateInit(a, b, c, d, 1);
+		palManipulateInit(a, b, c, d);
 		break;
 
 	case 187:										/* color cycle delay */

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- scumm.h	10 Sep 2002 07:34:27 -0000	1.13
+++ scumm.h	13 Sep 2002 11:54:59 -0000	1.14
@@ -785,7 +785,7 @@
 	void swapPalColors(int a, int b);
 	void cyclePalette();
 	void stopCycle(int i);
-	void palManipulateInit(int a, int b, int c, int d, int e);
+	void palManipulateInit(int start, int end, int string_id, int time);
 	void palManipulate();
 	void unkRoomFunc3(int a, int b, int c, int d, int e);
 	int remapPaletteColor(int r, int g, int b, uint threshold);





More information about the Scummvm-git-logs mailing list