From 5ef58bdfbe443c19d2f185d924b5058f25cab962 Mon Sep 17 00:00:00 2001 From: Fabio Battaglia Date: Mon, 25 May 2009 07:57:38 +0000 Subject: tinsel: avoid unnecessary iterations in Discworld PSX palette remapper svn-id: r40879 --- engines/tinsel/graphics.cpp | 1 - engines/tinsel/palette.cpp | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/engines/tinsel/graphics.cpp b/engines/tinsel/graphics.cpp index f66c57590b..42e117aa8f 100644 --- a/engines/tinsel/graphics.cpp +++ b/engines/tinsel/graphics.cpp @@ -769,7 +769,6 @@ void DrawObject(DRAWOBJECT *pObj) { } break; case 0x44: // PSX 4-bit CLUT - memset(psxMapperTable, 0, 16); psxPaletteMapper(pObj->pPal, srcPtr + sizeof(uint16), psxMapperTable); psxFourBitClut = true; diff --git a/engines/tinsel/palette.cpp b/engines/tinsel/palette.cpp index 6f7b5e5f6b..d090cfa690 100644 --- a/engines/tinsel/palette.cpp +++ b/engines/tinsel/palette.cpp @@ -99,6 +99,8 @@ void psxPaletteMapper(PALQ *originalPal, uint8 *psxClut, byte *mapperTable) { bool colorFound = false; uint16 clutEntry = 0; + memset(mapperTable, 0, 16); + for (int j = 0; j < 16; j++) { clutEntry = READ_LE_UINT16(psxClut + (sizeof(uint16) * j)); if(clutEntry) { @@ -117,7 +119,9 @@ void psxPaletteMapper(PALQ *originalPal, uint8 *psxClut, byte *mapperTable) { // black, i still have to find the correct fix for this. if(clutEntry == 0x7EC0 && !colorFound) mapperTable[j] = 197; colorFound = false; - } else { + } else if (!clutEntry && j) { // The rest of the colours are zeroes + return; + } else { // Skip first entry mapperTable[j] = 0; } } -- cgit v1.2.3