[Scummvm-cvs-logs] SF.net SVN: scummvm: [26672] scummvm/trunk/engines/cruise

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Sun Apr 29 03:07:19 CEST 2007


Revision: 26672
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26672&view=rev
Author:   eriktorbjorn
Date:     2007-04-28 18:07:19 -0700 (Sat, 28 Apr 2007)

Log Message:
-----------
Only update the backend's palette when necessary, since doing this triggers a
full redraw. (We still do that by updating the entire screen every frame, but
that could possibly change in the future.)

As an added bonus, I can now see all the glitches of the English version's
intro in full ScummTechniVMColor. :-)

Modified Paths:
--------------
    scummvm/trunk/engines/cruise/function.cpp
    scummvm/trunk/engines/cruise/gfxModule.cpp
    scummvm/trunk/engines/cruise/gfxModule.h

Modified: scummvm/trunk/engines/cruise/function.cpp
===================================================================
--- scummvm/trunk/engines/cruise/function.cpp	2007-04-29 00:18:54 UTC (rev 26671)
+++ scummvm/trunk/engines/cruise/function.cpp	2007-04-29 01:07:19 UTC (rev 26672)
@@ -879,14 +879,9 @@
 
 		if (CVTLoaded) {
 			int colorIdx = cvtPalette[i];
-			
-			lpalette[colorIdx].R = R;
-			lpalette[colorIdx].G = G;
-			lpalette[colorIdx].B = B;
+			gfxModuleData_setPalColor(colorIdx, R, G, B);
 		} else {
-			lpalette[i].R = R;
-			lpalette[i].G = G;
-			lpalette[i].B = B;
+			gfxModuleData_setPalColor(i, R, G, B);
 		}
 	}
 

Modified: scummvm/trunk/engines/cruise/gfxModule.cpp
===================================================================
--- scummvm/trunk/engines/cruise/gfxModule.cpp	2007-04-29 00:18:54 UTC (rev 26671)
+++ scummvm/trunk/engines/cruise/gfxModule.cpp	2007-04-29 01:07:19 UTC (rev 26672)
@@ -36,6 +36,9 @@
 palEntry lpalette[256];
 short globalAtariScreen[320 * 200 / 4];
 
+int palDirtyMin = 256;
+int palDirtyMax = -1;
+
 gfxModuleDataStruct gfxModuleData = {
 	0,			// field_1
 	0,			// use Tandy
@@ -533,6 +536,20 @@
 	}*/
 }
 
+void gfxModuleData_setDirtyColors(int min, int max) {
+	if (min < palDirtyMin)
+		palDirtyMin = min;
+	if (max > palDirtyMax)
+		palDirtyMax = max;
+}
+
+void gfxModuleData_setPalColor(int idx, int r, int g, int b) {
+	lpalette[idx].R = r;
+	lpalette[idx].G = g;
+	lpalette[idx].B = b;
+	gfxModuleData_setDirtyColors(idx, idx);
+}
+
 void gfxModuleData_setPal256(int16 *ptr) {
 	int R;
 	int G;
@@ -549,6 +566,8 @@
 		lpalette[i].B = B;
 		lpalette[i].A = 255;
 	}
+
+	gfxModuleData_setDirtyColors(0, 255);
 }
 
 void gfxModuleData_setPal(uint8 *ptr) {
@@ -578,8 +597,9 @@
 		lpalette[i].G = G;
 		lpalette[i].B = B;
 		lpalette[i].A = 255;
+	}
 
-	}
+	gfxModuleData_setDirtyColors(0, 16);
 }
 
 void gfxModuleData_field_90(void) {
@@ -619,13 +639,17 @@
 	//uint8* outPtr = scaledScreen;
 	//uint8* inPtr  = globalScreen;
 
-	for (i = 0; i < 256; i++) {
-		paletteRGBA[i * 4 + 0] = lpalette[i].R;
-		paletteRGBA[i * 4 + 1] = lpalette[i].G;
-		paletteRGBA[i * 4 + 2] = lpalette[i].B;
-		paletteRGBA[i * 4 + 3] = 0xFF;
+	if (palDirtyMax != -1) {
+		for (i = palDirtyMin; i < palDirtyMax; i++) {
+			paletteRGBA[i * 4 + 0] = lpalette[i].R;
+			paletteRGBA[i * 4 + 1] = lpalette[i].G;
+			paletteRGBA[i * 4 + 2] = lpalette[i].B;
+			paletteRGBA[i * 4 + 3] = 0xFF;
+		}
+		g_system->setPalette(paletteRGBA, palDirtyMin, palDirtyMax - palDirtyMin + 1);
+		palDirtyMin = 256;
+		palDirtyMax = -1;
 	}
-	g_system->setPalette(paletteRGBA, 0, 16);
 
 	g_system->copyRectToScreen(globalScreen, 320, 0, 0, 320, 200);
 	g_system->updateScreen();

Modified: scummvm/trunk/engines/cruise/gfxModule.h
===================================================================
--- scummvm/trunk/engines/cruise/gfxModule.h	2007-04-29 00:18:54 UTC (rev 26671)
+++ scummvm/trunk/engines/cruise/gfxModule.h	2007-04-29 01:07:19 UTC (rev 26672)
@@ -48,10 +48,11 @@
 typedef struct palEntry palEntry;
 
 extern gfxModuleDataStruct gfxModuleData;
-extern palEntry lpalette[256];
 extern short globalAtariScreen[320 * 200 / 4];
 
 void gfxModuleData_gfxClearFrameBuffer(uint8 * ptr);
+void gfxModuleData_setDirtyColors(int min, int max);
+void gfxModuleData_setPalColor(int idx, int r, int g, int b);
 void gfxModuleData_setPal(uint8 * ptr);
 void gfxModuleData_field_90(void);
 void gfxModuleData_gfxWaitVSync(void);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list