[Scummvm-cvs-logs] SF.net SVN: scummvm:[40151] scummvm/trunk/engines/tinsel/palette.cpp

Hkz at users.sourceforge.net Hkz at users.sourceforge.net
Sun Apr 26 12:25:41 CEST 2009


Revision: 40151
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40151&view=rev
Author:   Hkz
Date:     2009-04-26 10:25:41 +0000 (Sun, 26 Apr 2009)

Log Message:
-----------
tinsel: changed PSX CLUT converter to report effective number of colours used in the palette

Modified Paths:
--------------
    scummvm/trunk/engines/tinsel/palette.cpp

Modified: scummvm/trunk/engines/tinsel/palette.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/palette.cpp	2009-04-26 02:00:36 UTC (rev 40150)
+++ scummvm/trunk/engines/tinsel/palette.cpp	2009-04-26 10:25:41 UTC (rev 40151)
@@ -94,9 +94,10 @@
 /**
  * Convert Discworld PSX 555 CLUTs to compatible 888 palette
  */
-COLORREF* psxClutToRGBPal(uint8 *srcClut) {
+COLORREF* psxClutToRGBPal(uint8 *srcClut, int *colours) {
 	uint8 red, green, blue;
 	uint16 clutEntry;
+	int coloursInPalette = 0;
 
 	// Allocate space for the 16 colour destination palette
 	COLORREF *dstPal = (COLORREF*)calloc(sizeof(COLORREF), MAX_COLOURS);
@@ -105,7 +106,15 @@
 	for (int idx = 0; idx < 0x10; idx++) {
 		clutEntry = READ_LE_UINT16(srcClut); // Read PSX CLUT entry
 		srcClut += sizeof(uint16);
-		
+
+		if ((clutEntry == 0) && (coloursInPalette == 0)) 
+			coloursInPalette++;
+		else if ((clutEntry == 0) && (coloursInPalette != 0)) {
+			*colours = coloursInPalette;
+			return dstPal;
+		} else 
+			coloursInPalette++;
+
 		// Extract color data
 		red = ((clutEntry & 0x1F) * 255) / 31;
 		green =  (((clutEntry & 0x3E0) >> 5) * 255) / 31;
@@ -115,6 +124,7 @@
 		dstPal[idx] = TINSEL_RGB(red, green, blue);
 	}
 
+	*colours = coloursInPalette;
 	return dstPal;
 }
 


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