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

Hkz at users.sourceforge.net Hkz at users.sourceforge.net
Mon May 25 08:09:48 CEST 2009


Revision: 40876
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40876&view=rev
Author:   Hkz
Date:     2009-05-25 06:09:48 +0000 (Mon, 25 May 2009)

Log Message:
-----------
tinsel: endianess fix Discworld PSX palette remapper

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

Modified: scummvm/trunk/engines/tinsel/graphics.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/graphics.cpp	2009-05-24 23:06:39 UTC (rev 40875)
+++ scummvm/trunk/engines/tinsel/graphics.cpp	2009-05-25 06:09:48 UTC (rev 40876)
@@ -770,7 +770,7 @@
 						break;
 					case 0x44: // PSX 4-bit CLUT
 						memset(psxMapperTable, 0, 16);
-						psxPaletteMapper(pObj->pPal, (uint16*)(srcPtr + sizeof(uint16)), psxMapperTable);
+						psxPaletteMapper(pObj->pPal, srcPtr + sizeof(uint16), psxMapperTable);
 
 						psxFourBitClut = true;
 						psxSkipBytes = READ_LE_UINT32(p + sizeof(uint32) * 5) << 4; // Fetch number of bytes we have to skip

Modified: scummvm/trunk/engines/tinsel/palette.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/palette.cpp	2009-05-24 23:06:39 UTC (rev 40875)
+++ scummvm/trunk/engines/tinsel/palette.cpp	2009-05-25 06:09:48 UTC (rev 40876)
@@ -94,26 +94,28 @@
 /**
  * Map PSX palettes to original palette from resource file
  */
-void psxPaletteMapper(PALQ *originalPal, uint16 *psxClut, byte *mapperTable) {
+void psxPaletteMapper(PALQ *originalPal, uint8 *psxClut, byte *mapperTable) {
 	PALETTE *pal = (PALETTE *)LockMem(originalPal->hPal);
 	bool colorFound = false;
+	uint16 clutEntry = 0;
 
 	for (int j = 0; j < 16; j++) {
-		if(!(psxClut[j] & 0x8000)) {
+		clutEntry = READ_LE_UINT16(psxClut + (sizeof(uint16) * j));
+		if(clutEntry) {
 			for (int i = 0; (i < pal->numColours) && !colorFound; i++) {
 				// get R G B values in the same way as psx format converters
 				uint16 psxEquivalent = (uint16)((uint32)(PSXGetRValue(pal->palRGB[i]) >> 3) | 
 									((PSXGetGValue(pal->palRGB[i]) >> 3) << 5) |
 									((PSXGetBValue(pal->palRGB[i]) >> 3) << 10));
 
-				if (psxEquivalent == psxClut[j]) {
+				if (psxEquivalent == clutEntry) {
 					mapperTable[j] = i + 1;
 					colorFound = true;
 				}
 			}
 			// FIXME: This is just to hack around a bug that causes some text to appear
 			// black, i still have to find the correct fix for this.
-			if(psxClut[j] == 0x7EC0 && !colorFound) mapperTable[j] = 197; 
+			if(clutEntry == 0x7EC0 && !colorFound) mapperTable[j] = 197;
 			colorFound = false;
 		} else {
 			mapperTable[j] = 0;

Modified: scummvm/trunk/engines/tinsel/palette.h
===================================================================
--- scummvm/trunk/engines/tinsel/palette.h	2009-05-24 23:06:39 UTC (rev 40875)
+++ scummvm/trunk/engines/tinsel/palette.h	2009-05-25 06:09:48 UTC (rev 40876)
@@ -39,9 +39,9 @@
 #define TINSEL_GetGValue(rgb)	((uint8)(((uint16)(FROM_LE_32(rgb))) >> 8))
 #define TINSEL_GetBValue(rgb)	((uint8)((FROM_LE_32(rgb))>>16))
 
-#define PSXGetRValue(rgb)	(FROM_LE_32(rgb) & 0x000000f8)
-#define PSXGetGValue(rgb)	(FROM_LE_32((rgb) >> 8) & 0x000000f8)
-#define PSXGetBValue(rgb)	(FROM_LE_32((rgb) >> 16) & 0x000000f8)
+#define PSXGetRValue(rgb)	((uint8)(FROM_LE_32(rgb) & 0x000000f8))
+#define PSXGetGValue(rgb)	((uint8)(FROM_LE_32((rgb) >> 8) & 0x000000f8))
+#define PSXGetBValue(rgb)	((uint8)(FROM_LE_32((rgb) >> 16) & 0x000000f8))
 
 enum {
 	MAX_COLOURS		= 256,	//!< maximum number of colours - for VGA 256
@@ -111,7 +111,7 @@
 void PaletteStats(void);	// Shows the maximum number of palettes used at once
 #endif
 
-void psxPaletteMapper(PALQ *originalPal, uint16 *psxClut, byte *mapperTable); // Maps PSX CLUTs to original palette in resource file
+void psxPaletteMapper(PALQ *originalPal, uint8 *psxClut, byte *mapperTable); // Maps PSX CLUTs to original palette in resource file
 
 void PalettesToVideoDAC(void);	// Update the video DAC with palettes currently the the DAC queue
 


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