diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/tinsel/palette.cpp | 27 | ||||
-rw-r--r-- | engines/tinsel/palette.h | 2 |
2 files changed, 29 insertions, 0 deletions
diff --git a/engines/tinsel/palette.cpp b/engines/tinsel/palette.cpp index e3b2bd4f88..22c913a8a1 100644 --- a/engines/tinsel/palette.cpp +++ b/engines/tinsel/palette.cpp @@ -92,6 +92,33 @@ static int maxDACQ = 0; #endif /** + * Convert Discworld PSX 555 CLUTs to compatible 888 palette + */ +COLORREF* psxClutToRGBPal(uint8 *srcClut) { + uint8 red, green, blue; + uint16 clutEntry; + + // Allocate space for the 16 colour destination palette + COLORREF *dstPal = (COLORREF*)calloc(sizeof(COLORREF), MAX_COLOURS); + memset(dstPal, 0, MAX_COLOURS * sizeof(COLORREF)); + + for (int idx = 0; idx < 0x10; idx++) { + clutEntry = READ_LE_UINT16(srcClut); // Read PSX CLUT entry + srcClut += sizeof(uint16); + + // Extract color data + red = ((clutEntry & 0x1F) * 255) / 31; + green = (((clutEntry & 0x3E0) >> 5) * 255) / 31; + blue = (((clutEntry & 0x7C00) >> 10) * 255) / 31; + + // Write the palette + dstPal[idx] = TINSEL_RGB(red, green, blue); + } + + return dstPal; +} + +/** * Transfer palettes in the palette Q to Video DAC. */ void PalettesToVideoDAC(void) { diff --git a/engines/tinsel/palette.h b/engines/tinsel/palette.h index 90edfbb19a..ff5ff13f2a 100644 --- a/engines/tinsel/palette.h +++ b/engines/tinsel/palette.h @@ -107,6 +107,8 @@ void ResetPalAllocator(void); // wipe out all palettes void PaletteStats(void); // Shows the maximum number of palettes used at once #endif +COLORREF* psxClutToRGBPal(uint8 *srcClut); // Convert Discworld PSX 555 CLUTs to compatible 888 palette + void PalettesToVideoDAC(void); // Update the video DAC with palettes currently the the DAC queue void UpdateDACqueueHandle( |