aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra/screen_v2.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2008-03-21 12:51:03 +0000
committerJohannes Schickel2008-03-21 12:51:03 +0000
commit88069c943a6bd94da8d183f943200076d5638148 (patch)
tree2b1b3c66a9860279bdd4e3708c9468216f4f57da /engines/kyra/screen_v2.cpp
parent2f7b59d3e289be6c9968aa5bad671b6987555108 (diff)
downloadscummvm-rg350-88069c943a6bd94da8d183f943200076d5638148.tar.gz
scummvm-rg350-88069c943a6bd94da8d183f943200076d5638148.tar.bz2
scummvm-rg350-88069c943a6bd94da8d183f943200076d5638148.zip
Proper fix for bug #1920869 "HoF: palette artifacts in inventory".
svn-id: r31208
Diffstat (limited to 'engines/kyra/screen_v2.cpp')
-rw-r--r--engines/kyra/screen_v2.cpp59
1 files changed, 15 insertions, 44 deletions
diff --git a/engines/kyra/screen_v2.cpp b/engines/kyra/screen_v2.cpp
index ba17fbca39..5199543632 100644
--- a/engines/kyra/screen_v2.cpp
+++ b/engines/kyra/screen_v2.cpp
@@ -84,68 +84,39 @@ void Screen_v2::generateGrayOverlay(const uint8 *srcPal, uint8 *grayOverlay, int
grayOverlay[i] = findLeastDifferentColor(tmpPal + 3 * i, srcPal, lastColor);
}
-uint8 *Screen_v2::generateOverlay(const uint8 *palette, uint8 *buffer, int startColor, int fac) {
+uint8 *Screen_v2::generateOverlay(const uint8 *palette, uint8 *buffer, int startColor, uint16 factor) {
if (!palette || !buffer)
return buffer;
- fac = MIN(0xFF, fac);
+ factor = MIN<uint16>(255, factor);
+ factor >>= 1;
+ factor &= 0xFF;
- byte col1, col2, col3;
- col1 = palette[startColor * 3 + 0];
- col2 = palette[startColor * 3 + 1];
- col3 = palette[startColor * 3 + 2];
- *buffer = 0;
+ const byte col1 = palette[startColor * 3 + 0];
+ const byte col2 = palette[startColor * 3 + 1];
+ const byte col3 = palette[startColor * 3 + 2];
+
+ uint8 *dst = buffer;
+ *dst++ = 0;
- uint8 *dst = buffer + 1;
for (int i = 1; i != 255; ++i) {
- byte procCol1, procCol2, procCol3;
+ uint8 processedPalette[3];
const uint8 *src = palette + i*3;
- const int factor = (fac >> 1) & 0xFF;
byte col;
col = *src++;
col -= ((((col - col1) * factor) << 1) >> 8) & 0xFF;
- procCol1 = col;
+ processedPalette[0] = col;
col = *src++;
col -= ((((col - col2) * factor) << 1) >> 8) & 0xFF;
- procCol2 = col;
+ processedPalette[1] = col;
col = *src++;
col -= ((((col - col3) * factor) << 1) >> 8) & 0xFF;
- procCol3 = col;
-
- uint16 minValue = 0xFFFF;
- uint8 colorNumber = startColor;
- const uint8 *pal = palette + 3;
- for (int count = 0xFF, cur = 1; count > 0; --count, ++cur) {
- pal += 3;
- if (cur != i) {
- uint16 value = 0;
- pal -= 3;
- col = *pal++ - procCol1;
- col *= col;
- value += col;
-
- col = *pal++ - procCol2;
- col *= col;
- value += col;
-
- col = *pal++ - procCol3;
- col *= col;
- value += col;
-
- if (value == 0) {
- colorNumber = i;
- break;
- } else if (value < minValue) {
- minValue = value;
- colorNumber = cur;
- }
- }
- }
+ processedPalette[2] = col;
- *dst++ = colorNumber;
+ *dst++ = findLeastDifferentColor(processedPalette, palette+3, 255)+1;
}
return buffer;