[Scummvm-cvs-logs] CVS: scummvm/scumm gfx.cpp,1.24,1.25 resource_v2.cpp,1.3,1.4 resource_v3.cpp,1.2,1.3 saveload.cpp,1.12,1.13 scumm.h,1.27,1.28

James Brown ender at users.sourceforge.net
Tue Sep 24 08:47:04 CEST 2002


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

Modified Files:
	gfx.cpp resource_v2.cpp resource_v3.cpp saveload.cpp scumm.h 
Log Message:
Patch 609334: PalManip save/load/init fixes.

Save/Load lines are commented out until the new save/load system is in place.


Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- gfx.cpp	23 Sep 2002 15:43:28 -0000	1.24
+++ gfx.cpp	24 Sep 2002 15:46:09 -0000	1.25
@@ -558,17 +558,14 @@
 	byte *startptr2, *endptr2;
 	int num;
 	byte tmp[6];
-	byte tmp2[6];
 
 	if (!_palManipCounter)
 		return;
 
-	startptr = getResourceAddress(rtTemp, 4) + start * 6;
-	endptr = getResourceAddress(rtTemp, 4) + end * 6;
-
-	startptr2 = getResourceAddress(rtTemp, 5) + start * 6;
-	endptr2 = getResourceAddress(rtTemp, 5) + end * 6;
-
+	startptr = _palManipPalette + start * 3;
+	endptr = _palManipPalette + end * 3;
+	startptr2 = _palManipIntermediatePal + start * 6;
+	endptr2 = _palManipIntermediatePal + end * 6;
 	num = end - start;
 
 	if (!endptr) {
@@ -577,19 +574,19 @@
 	}
 
 	if (!direction) {
-		memmove(tmp, endptr, 6);
-		memmove(startptr + 6, startptr, num * 6);
-		memmove(startptr, tmp, 6);
-		memmove(tmp2, endptr2, 6);
+		memmove(tmp, endptr, 3);
+		memmove(startptr + 3, startptr, num * 3);
+		memmove(startptr, tmp, 3);
+		memmove(tmp, endptr2, 6);
 		memmove(startptr2 + 6, startptr2, num * 6);
-		memmove(startptr2, tmp2, 6);
+		memmove(startptr2, tmp, 6);
 	} else {
-		memmove(tmp, startptr, 6);
-		memmove(startptr, startptr + 6, num * 6);
-		memmove(endptr, tmp, 6);
-		memmove(tmp2, startptr2, 6);
+		memmove(tmp, startptr, 3);
+		memmove(startptr, startptr + 3, num * 3);
+		memmove(endptr, tmp, 3);
+		memmove(tmp, startptr2, 6);
 		memmove(startptr2, startptr2 + 6, num * 6);
-		memmove(endptr2, tmp2, 6);
+		memmove(endptr2, tmp, 6);
 	}
 }
 
@@ -2465,54 +2462,42 @@
 
 void Scumm::palManipulateInit(int start, int end, int string_id, int time)
 {
+	byte *pal, *target, *between;
+	byte *string1, *string2, *string3;
+	int i;
+
 	_palManipStart = start;
 	_palManipEnd = end;
 	_palManipCounter = 0;
+	
+	if (!_palManipPalette)
+		_palManipPalette = (byte *)calloc(0x300, 1);
+	if (!_palManipIntermediatePal)
+		_palManipIntermediatePal = (byte *)calloc(0x600, 1);
 
-	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;
-
-	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;
+	pal = _currentPalette + start * 3;
+	target = _palManipPalette + start * 3;
+	between = _palManipIntermediatePal + start * 6;
 
-	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) {
+	string1 = getStringAddress(string_id) + start;
+	string2 = getStringAddress(string_id + 1) + start;
+	string3 = getStringAddress(string_id + 2) + start;
+	if (!string1 || !string2 || !string3) {
 		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;
+	for (i = start; i < end; ++i) {
+		*target++ = *string1++;
+		*target++ = *string2++;
+		*target++ = *string3++;
+		*(uint16*)between = ((uint16) *pal++) << 8;
+		between += 2;
+		*(uint16*)between = ((uint16) *pal++) << 8;
+		between += 2;
+		*(uint16*)between = ((uint16) *pal++) << 8;
+		between += 2;
 	}
 
 	_palManipCounter = time;
@@ -2520,45 +2505,29 @@
 
 void Scumm::palManipulate()
 {
-	byte *srcptr, *destptr;
-	byte *pal;
+	byte *target, *pal, *between;
 	int i, j;
 
-	if (!_palManipCounter)
-		return;
-	
-	srcptr = getResourceAddress(rtTemp, 4) + _palManipStart * 6;
-	destptr = getResourceAddress(rtTemp, 5) + _palManipStart * 6;
-	if (!srcptr || !destptr)
+	if (!_palManipCounter || !_palManipPalette || !_palManipIntermediatePal)
 		return;
 	
+	target = _palManipPalette + _palManipStart * 3;
 	pal = _currentPalette + _palManipStart * 3;
+	between = _palManipIntermediatePal + _palManipStart * 6;
 
-	i = _palManipStart;
-	while (i < _palManipEnd) {
-		j = (*((uint16 *)srcptr) += (*(uint16 *)destptr - *((uint16 *)srcptr)) / _palManipCounter);
+	for (i = _palManipStart; i < _palManipEnd; ++i) {
+		j = (*((uint16 *)between) += ((*target++ << 8) - *((uint16 *)between)) / _palManipCounter);
 		*pal++ = j >> 8;
-		srcptr += 2;
-		destptr += 2;
-
-		j = (*((uint16 *)srcptr) += (*(uint16 *)destptr - *((uint16 *)srcptr)) / _palManipCounter);
+		between += 2;
+		j = (*((uint16 *)between) += ((*target++ << 8) - *((uint16 *)between)) / _palManipCounter);
 		*pal++ = j >> 8;
-		srcptr += 2;
-		destptr += 2;
-
-		j = (*((uint16 *)srcptr) += (*(uint16 *)destptr - *((uint16 *)srcptr)) / _palManipCounter);
+		between += 2;
+		j = (*((uint16 *)between) += ((*target++ << 8) - *((uint16 *)between)) / _palManipCounter);
 		*pal++ = j >> 8;
-		srcptr += 2;
-		destptr += 2;
-
-		i++;
+		between += 2;
 	}
 	setDirtyColors(_palManipStart, _palManipEnd);
 	_palManipCounter--;
-	if (!_palManipCounter) {
-		nukeResource(rtTemp, 4);
-		nukeResource(rtTemp, 5);
-	}
 }
 
 void Scumm::unkRoomFunc3(int palstart, int palend, int rfact, int gfact, int bfact)

Index: resource_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource_v2.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- resource_v2.cpp	13 Sep 2002 23:29:38 -0000	1.3
+++ resource_v2.cpp	24 Sep 2002 15:46:09 -0000	1.4
@@ -62,6 +62,12 @@
 
 	_shadowPaletteSize = 256;
 	_shadowPalette = (byte *) calloc(_shadowPaletteSize, 1);	// FIXME - needs to be removed later
+
+	// Jamieson630: palManipulate variable initialization
+	_palManipCounter = 0;
+	_palManipPalette = 0; // Will allocate when needed
+	_palManipIntermediatePal = 0; // Will allocate when needed
+
 	_numFlObject = 50;
 	allocateArrays();
 

Index: resource_v3.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource_v3.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- resource_v3.cpp	10 Sep 2002 07:34:27 -0000	1.2
+++ resource_v3.cpp	24 Sep 2002 15:46:09 -0000	1.3
@@ -84,6 +84,12 @@
 
 	_shadowPaletteSize = 256;
 	_shadowPalette = (byte *) calloc(_shadowPaletteSize, 1);	// stupid for now. Need to be removed later
+
+	// Jamieson630: palManipulate variable initialization
+	_palManipCounter = 0;
+	_palManipPalette = 0; // Will allocate when needed
+	_palManipIntermediatePal = 0; // Will allocate when needed
+
 	_numFlObject = 50;
 	allocateArrays();
 

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- saveload.cpp	22 Sep 2002 03:53:52 -0000	1.12
+++ saveload.cpp	24 Sep 2002 15:46:09 -0000	1.13
@@ -397,6 +397,12 @@
 		MKLINE(Scumm, _switchRoomEffect2, sleByte),
 		MKLINE(Scumm, _BgNeedsRedraw, sleByte),
 
+		// Jamieson630: variables for palManipulate
+		// TODO: Add these next time save game format changes.
+		// MKLINE(Scumm, _palManipStart, sleByte),
+		// MKLINE(Scumm, _palManipEnd, sleByte),
+		// MKLINE(Scumm, _palManipCounter, sleUint16),
+
 		MKARRAY(Scumm, gfxUsageBits[0], sleUint32, 200),
 		MKLINE(Scumm, gdi._transparency, sleByte),
 		MKARRAY(Scumm, _currentPalette[0], sleByte, 768),
@@ -502,6 +508,12 @@
 		MKLINE(Scumm, _switchRoomEffect2, sleByte),
 		MKLINE(Scumm, _BgNeedsRedraw, sleByte),
 
+		// Jamieson630: variables for palManipulate
+		// TODO: Add these next time save game format changes.
+		// MKLINE(Scumm, _palManipStart, sleByte),
+		// MKLINE(Scumm, _palManipEnd, sleByte),
+		// MKLINE(Scumm, _palManipCounter, sleUint16),
+
 		MKARRAY(Scumm, gfxUsageBits[0], sleUint32, 200),
 		MKLINE(Scumm, gdi._transparency, sleByte),
 		MKARRAY(Scumm, _currentPalette[0], sleByte, 768),
@@ -632,6 +644,16 @@
 
 	if (_shadowPaletteSize)
 		s->saveLoadArrayOf(_shadowPalette, _shadowPaletteSize, 1, sleByte);
+
+	_palManipCounter = 0; // TODO: Remove this once it's being loaded from disk
+	if (_palManipCounter) {
+		if (!_palManipPalette)
+			_palManipPalette = (byte *)calloc(0x300, 1);
+		if (!_palManipIntermediatePal)
+			_palManipPalette = (byte *)calloc(0x300, 1);
+		s->saveLoadArrayOf(_palManipPalette, 0x300, 1, sleByte);
+		s->saveLoadArrayOf(_palManipIntermediatePal, 0x600, 1, sleByte);
+	}
 
 	s->saveLoadArrayOf(_classData, _numGlobalObjects, sizeof(_classData[0]), sleUint32);
 

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- scumm.h	23 Sep 2002 15:43:29 -0000	1.27
+++ scumm.h	24 Sep 2002 15:46:09 -0000	1.28
@@ -868,7 +868,10 @@
 
 	int _drawObjectQueNr;
 	byte _drawObjectQue[200];
-	int16 _palManipStart, _palManipEnd, _palManipCounter;
+	byte _palManipStart, _palManipEnd;
+	uint16 _palManipCounter;
+	byte *_palManipPalette;
+	byte *_palManipIntermediatePal;
 	uint32 gfxUsageBits[200];
 	byte *_shadowPalette;
 	int _shadowPaletteSize;





More information about the Scummvm-git-logs mailing list