aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFabio Battaglia2009-04-26 10:25:41 +0000
committerFabio Battaglia2009-04-26 10:25:41 +0000
commitb45f2e21fa87fcaade9f2ac083effe150294ef79 (patch)
tree5cf98095edd1e6c8ff6c70e58f7731a5d8fd7040 /engines
parent5eb4bdce66357b01414faba7a5cfccc9c9a3fd7e (diff)
downloadscummvm-rg350-b45f2e21fa87fcaade9f2ac083effe150294ef79.tar.gz
scummvm-rg350-b45f2e21fa87fcaade9f2ac083effe150294ef79.tar.bz2
scummvm-rg350-b45f2e21fa87fcaade9f2ac083effe150294ef79.zip
tinsel: changed PSX CLUT converter to report effective number of colours used in the palette
svn-id: r40151
Diffstat (limited to 'engines')
-rw-r--r--engines/tinsel/palette.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/engines/tinsel/palette.cpp b/engines/tinsel/palette.cpp
index 22c913a8a1..9fb40f8d09 100644
--- a/engines/tinsel/palette.cpp
+++ b/engines/tinsel/palette.cpp
@@ -94,9 +94,10 @@ static int maxDACQ = 0;
/**
* 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 @@ COLORREF* psxClutToRGBPal(uint8 *srcClut) {
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 @@ COLORREF* psxClutToRGBPal(uint8 *srcClut) {
dstPal[idx] = TINSEL_RGB(red, green, blue);
}
+ *colours = coloursInPalette;
return dstPal;
}