diff options
author | Fabio Battaglia | 2009-04-24 11:54:10 +0000 |
---|---|---|
committer | Fabio Battaglia | 2009-04-24 11:54:10 +0000 |
commit | df81ef750c819a483514f423599366c155057b90 (patch) | |
tree | eaae3b112b11b4d5ca4d24b41b8e7fbbcb99b2ad /engines | |
parent | 6343b2eee059ff43c6f7849fb45ef72b33b4bf9d (diff) | |
download | scummvm-rg350-df81ef750c819a483514f423599366c155057b90.tar.gz scummvm-rg350-df81ef750c819a483514f423599366c155057b90.tar.bz2 scummvm-rg350-df81ef750c819a483514f423599366c155057b90.zip |
tinsel: added Discworld PSX palette converting function
svn-id: r40109
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( |