diff options
| author | Fabio Battaglia | 2009-05-25 06:09:48 +0000 | 
|---|---|---|
| committer | Fabio Battaglia | 2009-05-25 06:09:48 +0000 | 
| commit | 910f43ffd883eed0dfa2d08deb3e7503675672ac (patch) | |
| tree | ae9d8f8f07581d443155f4d5e05fa7b99618f17d | |
| parent | 6982ce53c22a4690441536d7aa285199b2dd611d (diff) | |
| download | scummvm-rg350-910f43ffd883eed0dfa2d08deb3e7503675672ac.tar.gz scummvm-rg350-910f43ffd883eed0dfa2d08deb3e7503675672ac.tar.bz2 scummvm-rg350-910f43ffd883eed0dfa2d08deb3e7503675672ac.zip | |
tinsel: endianess fix Discworld PSX palette remapper
svn-id: r40876
| -rw-r--r-- | engines/tinsel/graphics.cpp | 2 | ||||
| -rw-r--r-- | engines/tinsel/palette.cpp | 10 | ||||
| -rw-r--r-- | engines/tinsel/palette.h | 8 | 
3 files changed, 11 insertions, 9 deletions
| diff --git a/engines/tinsel/graphics.cpp b/engines/tinsel/graphics.cpp index b6a7b1e08b..f66c57590b 100644 --- a/engines/tinsel/graphics.cpp +++ b/engines/tinsel/graphics.cpp @@ -770,7 +770,7 @@ void DrawObject(DRAWOBJECT *pObj) {  						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 diff --git a/engines/tinsel/palette.cpp b/engines/tinsel/palette.cpp index 1c5c69252a..6f7b5e5f6b 100644 --- a/engines/tinsel/palette.cpp +++ b/engines/tinsel/palette.cpp @@ -94,26 +94,28 @@ static int maxDACQ = 0;  /**   * 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; diff --git a/engines/tinsel/palette.h b/engines/tinsel/palette.h index 7a74424ba9..c887220840 100644 --- a/engines/tinsel/palette.h +++ b/engines/tinsel/palette.h @@ -39,9 +39,9 @@ typedef	uint32	COLORREF;  #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 ResetPalAllocator(void);	// wipe out all palettes  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 | 
