[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.454,2.455 palette_he.cpp,1.14,1.15 script_v100he.cpp,2.136,2.137 script_v90he.cpp,2.236,2.237

Gregory Montoir cyx at users.sourceforge.net
Thu Apr 21 12:28:14 CEST 2005


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

Modified Files:
	intern.h palette_he.cpp script_v100he.cpp script_v90he.cpp 
Log Message:
cleanup

Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.454
retrieving revision 2.455
diff -u -d -r2.454 -r2.455
--- intern.h	21 Apr 2005 16:02:37 -0000	2.454
+++ intern.h	21 Apr 2005 19:27:13 -0000	2.455
@@ -1002,9 +1002,8 @@
 	
 	uint8 *getHEPaletteIndex(int palSlot);
 	int getHEPaletteColor(int palSlot, int color);
-	int getPaletteUnk1(int palSlot, int arg_4, int arg_8, int start, int end);
-	int getPaletteUnk2(int palSlot, int unk1, int unk2);
-
+	int getHEPaletteSimilarColor(int palSlot, int red, int green, int start, int end);
+	int getHEPaletteColorComponent(int palSlot, int color, int component);
 	void setHEPaletteColor(int palSlot, uint8 color, uint8 r, uint8 g, uint8 b);
 	void setHEPaletteFromPtr(int palSlot, const uint8 *palData);
 	void setHEPaletteFromCostume(int palSlot, int resId);

Index: palette_he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/palette_he.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- palette_he.cpp	21 Apr 2005 16:07:30 -0000	1.14
+++ palette_he.cpp	21 Apr 2005 19:27:16 -0000	1.15
@@ -78,64 +78,37 @@
 	}
 }
 
-int ScummEngine_v90he::getPaletteUnk1(int palSlot, int arg_4, int arg_8, int start, int end) {
+int ScummEngine_v90he::getHEPaletteSimilarColor(int palSlot, int red, int green, int start, int end) {
 	assert(palSlot >= 1 && palSlot <= _numPalettes);
 	assert(start >= 1 && start <= 255);
 	assert(end >= 1 && end <= 255);
 
-	int eax, edi, edp, edx, esi;
-	int sum, bestitem, bestsum;
-	uint8 *palPtr;
-
-	palPtr = _hePalettes + palSlot * 1024 + start * 3;
+	uint8 *pal = _hePalettes + palSlot * 1024 + start * 3;
 
-	bestsum = 0xFFFFFFFF;
-	bestitem = start;
-	edp = arg_8;
+	int bestsum = 0xFFFFFFFF;
+	int bestitem = start;
 
 	for (int i = start; i <= end; i++) {
-		esi = arg_4;
-
-		edi = *palPtr++;
-		edx = *palPtr;
-		esi -= edi;
-		eax = edx;
-
-		edi = edp;
-		eax = -eax;
-		eax <<= 31;
-		eax -= edx;		
-		edi -= edx;
-
-		eax += edp;
-
-		edx = esi;
-
-		eax *= edi;
-		edx *= esi;
-
-		sum = edx + eax * 2;
-
-		palPtr += 2;
-
+		int dr = red - pal[0];
+		int dg = green - pal[1];
+		int sum = dr * dr + dg * dg * 2;
+		if (sum == 0) {
+			return i;
+		}
 		if (sum < bestsum) {
-			if (sum == 0) {
-				return i;
-			}
-
 			bestsum = sum;
 			bestitem = i;
 		}
+		pal += 3;
 	}
-
 	return bestitem;
 }
 
-int ScummEngine_v90he::getPaletteUnk2(int palSlot, int unk1, int unk2) {
+int ScummEngine_v90he::getHEPaletteColorComponent(int palSlot, int color, int component) {
 	assert(palSlot >= 1 && palSlot <= _numPalettes);
-	assert(unk1 >= 1 && unk1 <= 255);
+	assert(color >= 1 && color <= 255);
 
-	return _hePalettes[palSlot * 1024 + unk1 * 3 + unk2 / 3];
+	return _hePalettes[palSlot * 1024 + color * 3 + component % 3];
 }
 
 int ScummEngine_v90he::getHEPaletteColor(int palSlot, int color) {

Index: script_v100he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v100he.cpp,v
retrieving revision 2.136
retrieving revision 2.137
diff -u -d -r2.136 -r2.137
--- script_v100he.cpp	21 Apr 2005 16:07:31 -0000	2.136
+++ script_v100he.cpp	21 Apr 2005 19:27:16 -0000	2.137
@@ -2397,7 +2397,7 @@
 	case 13:
 		c = pop();
 		b = pop();
-		push(getPaletteUnk2(1, b, c));
+		push(getHEPaletteColorComponent(1, b, c));
 		break;
 	case 20:
 		color = pop();
@@ -2411,7 +2411,7 @@
 		pop();
 		c = pop();
 		b = pop();
-		push(getPaletteUnk1(palSlot, b, c, d, e));
+		push(getHEPaletteSimilarColor(palSlot, b, c, d, e));
 		break;
 	case 53:
 		pop();
@@ -2421,13 +2421,13 @@
 		b = pop();
 		b = MAX(0, b);
 		b = MIN(b, 255);
-		push(getPaletteUnk1(1, b, c, 10, 245));
+		push(getHEPaletteSimilarColor(1, b, c, 10, 245));
 		break;
 	case 73:
 		c = pop();
 		b = pop();
 		palSlot = pop();
-		push(getPaletteUnk2(palSlot, b, c));
+		push(getHEPaletteColorComponent(palSlot, b, c));
 		break;
 	default:
 		error("o100_getPaletteData: Unknown case %d", subOp);

Index: script_v90he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v90he.cpp,v
retrieving revision 2.236
retrieving revision 2.237
diff -u -d -r2.236 -r2.237
--- script_v90he.cpp	21 Apr 2005 16:02:37 -0000	2.236
+++ script_v90he.cpp	21 Apr 2005 19:27:17 -0000	2.237
@@ -2270,13 +2270,13 @@
 		pop();
 		c = pop();
 		b = pop();
-		push(getPaletteUnk1(palSlot, b, c, d, e));
+		push(getHEPaletteSimilarColor(palSlot, b, c, d, e));
 		break;
 	case 7:
 		c = pop();
 		b = pop();
 		palSlot = pop();
-		push(getPaletteUnk2(palSlot, b, c));
+		push(getHEPaletteColorComponent(palSlot, b, c));
 		break;
 	case 21:
 		color = pop();
@@ -2286,7 +2286,7 @@
 	case 87:
 		c = pop();
 		b = pop();
-		push(getPaletteUnk2(1, b, c));
+		push(getHEPaletteColorComponent(1, b, c));
 		break;
 	case 172:
 		pop();
@@ -2296,7 +2296,7 @@
 		b = pop();
 		b = MAX(0, b);
 		b = MIN(b, 255);
-		push(getPaletteUnk1(1, b, c, 10, 245));
+		push(getHEPaletteSimilarColor(1, b, c, 10, 245));
 		break;
 	default:
 		error("o90_getPaletteData: Unknown case %d", subOp);





More information about the Scummvm-git-logs mailing list