aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMatthew Hoops2011-03-04 19:47:21 -0500
committerMatthew Hoops2011-03-04 19:48:14 -0500
commitdbaad1a89633fe51eabb64a910568fe3995734ec (patch)
treeee095ed3a2aa4563e6968527769290f8489c5d32 /engines
parenta2b75466da399e34fa0d4ee1d4287dd60f1d1fc3 (diff)
downloadscummvm-rg350-dbaad1a89633fe51eabb64a910568fe3995734ec.tar.gz
scummvm-rg350-dbaad1a89633fe51eabb64a910568fe3995734ec.tar.bz2
scummvm-rg350-dbaad1a89633fe51eabb64a910568fe3995734ec.zip
SCI: Fix Mac icon bar palette match order
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/graphics/palette.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp
index 1b3e259ae5..48a069b88c 100644
--- a/engines/sci/graphics/palette.cpp
+++ b/engines/sci/graphics/palette.cpp
@@ -858,19 +858,28 @@ void GfxPalette::palVaryProcess(int signal, bool setPalette) {
}
}
+static inline uint getMacColorDiff(byte r1, byte g1, byte b1, byte r2, byte g2, byte b2) {
+ // Use the difference of the top 4 bits and add together the differences
+ return ABS((r2 & 0xf0) - (r1 & 0xf0)) + ABS((g2 & 0xf0) - (g1 & 0xf0)) + ABS((b2 & 0xf0) - (b1 & 0xf0));
+}
+
byte GfxPalette::findMacIconBarColor(byte r, byte g, byte b) {
// Find the best color for use with the Mac icon bar
+ // Check white, then the palette colors, and then black
- byte found = 0xFF;
- uint diff = 0xFFFFFFFF;
+ // Try white first
+ byte found = 0xff;
+ uint diff = getMacColorDiff(r, g, b, 0xff, 0xff, 0xff);
- for (uint16 i = 0; i < 256; i++) {
- // Use the difference of the top 4 bits
- int dr = (_macClut[i * 3 ] & 0xf0) - (r & 0xf0);
- int dg = (_macClut[i * 3 + 1] & 0xf0) - (g & 0xf0);
- int db = (_macClut[i * 3 + 2] & 0xf0) - (b & 0xf0);
+ if (diff == 0)
+ return found;
- uint cdiff = ABS(dr) + ABS(dg) + ABS(db);
+ // Go through the main colors of the CLUT
+ for (uint16 i = 1; i < 255; i++) {
+ if (!colorIsFromMacClut(i))
+ continue;
+
+ uint cdiff = getMacColorDiff(r, g, b, _macClut[i * 3], _macClut[i * 3 + 1], _macClut[i * 3 + 2]);
if (cdiff == 0)
return i;
@@ -880,6 +889,10 @@ byte GfxPalette::findMacIconBarColor(byte r, byte g, byte b) {
}
}
+ // Also check black here
+ if (getMacColorDiff(r, g, b, 0, 0, 0) < diff)
+ return 0;
+
return found;
}