[Scummvm-cvs-logs] SF.net SVN: scummvm: [31208] scummvm/trunk/engines/kyra
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Fri Mar 21 13:51:04 CET 2008
Revision: 31208
http://scummvm.svn.sourceforge.net/scummvm/?rev=31208&view=rev
Author: lordhoto
Date: 2008-03-21 05:51:03 -0700 (Fri, 21 Mar 2008)
Log Message:
-----------
Proper fix for bug #1920869 "HoF: palette artifacts in inventory".
Modified Paths:
--------------
scummvm/trunk/engines/kyra/screen_v2.cpp
scummvm/trunk/engines/kyra/screen_v2.h
Modified: scummvm/trunk/engines/kyra/screen_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen_v2.cpp 2008-03-20 20:36:36 UTC (rev 31207)
+++ scummvm/trunk/engines/kyra/screen_v2.cpp 2008-03-21 12:51:03 UTC (rev 31208)
@@ -84,68 +84,39 @@
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 + 1;
+ uint8 *dst = buffer;
+ *dst++ = 0;
+
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;
+ processedPalette[2] = 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;
- }
- }
- }
-
- *dst++ = colorNumber;
+ *dst++ = findLeastDifferentColor(processedPalette, palette+3, 255)+1;
}
return buffer;
Modified: scummvm/trunk/engines/kyra/screen_v2.h
===================================================================
--- scummvm/trunk/engines/kyra/screen_v2.h 2008-03-20 20:36:36 UTC (rev 31207)
+++ scummvm/trunk/engines/kyra/screen_v2.h 2008-03-21 12:51:03 UTC (rev 31208)
@@ -54,7 +54,7 @@
void copyWsaRect(int x, int y, int w, int h, int dimState, int plotFunc, const uint8 *src,
int unk1, const uint8 *unkPtr1, const uint8 *unkPtr2);
- uint8 *generateOverlay(const uint8 *palette, uint8 *buffer, int color, int factor);
+ uint8 *generateOverlay(const uint8 *palette, uint8 *buffer, int color, uint16 factor);
void applyOverlay(int x, int y, int w, int h, int pageNum, const uint8 *overlay);
// shape handling
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list