diff options
author | Martin Kiewitz | 2010-01-26 21:12:13 +0000 |
---|---|---|
committer | Martin Kiewitz | 2010-01-26 21:12:13 +0000 |
commit | f8a83cd61d4609be9b392e0ee7d7d71a489ebebd (patch) | |
tree | dd35e1591a25dd592b1f7ddd39d1d323b705a367 /engines/sci | |
parent | 545e221d417346644f52cae35d412b40c4967f2b (diff) | |
download | scummvm-rg350-f8a83cd61d4609be9b392e0ee7d7d71a489ebebd.tar.gz scummvm-rg350-f8a83cd61d4609be9b392e0ee7d7d71a489ebebd.tar.bz2 scummvm-rg350-f8a83cd61d4609be9b392e0ee7d7d71a489ebebd.zip |
SCI: dont do real merging of palettes for sci1.1+, fixes sq5 wilco face, wilco blue thingie in the background of intro, island of dr. brain, sq4 white pixels in background and more
svn-id: r47574
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/graphics/palette.cpp | 90 |
1 files changed, 52 insertions, 38 deletions
diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp index 0e2e7ddd9d..f3a6803660 100644 --- a/engines/sci/graphics/palette.cpp +++ b/engines/sci/graphics/palette.cpp @@ -210,46 +210,60 @@ void SciPalette::set(Palette *sciPal, uint16 flag) { void SciPalette::merge(Palette *pFrom, Palette *pTo, uint16 flag) { uint16 res; int i,j; - // colors 0 (black) and 255 (white) are not affected by merging - for (i = 1 ; i < 255; i++) { - if (!pFrom->colors[i].used)// color is not used - so skip it - continue; - // forced palette merging or dest color is not used yet or bit 1 of new color is set - if (flag == 2 || (!pTo->colors[i].used) || (pFrom->colors[i].used & 2)) { - pTo->colors[i].used = pFrom->colors[i].used; - pTo->colors[i].r = pFrom->colors[i].r; - pTo->colors[i].g = pFrom->colors[i].g; - pTo->colors[i].b = pFrom->colors[i].b; - pFrom->mapping[i] = i; - continue; - } - // is the same color already at the same position? -> match it directly w/o lookup - // this fixes games like lsl1demo/sq5 where the same rgb color exists multiple times and where we would - // otherwise match the wrong one (which would result into the pixels affected (or not) by palette changes) - if ((pTo->colors[i].r == pFrom->colors[i].r) && (pTo->colors[i].g == pFrom->colors[i].g) && (pTo->colors[i].b == pFrom->colors[i].b)) { - pFrom->mapping[i] = i; - continue; - } - // check if exact color could be matched - res = matchColor(pTo, pFrom->colors[i].r, pFrom->colors[i].g, pFrom->colors[i].b); - if (res & 0x8000) { // exact match was found - pFrom->mapping[i] = res & 0xFF; - continue; + + if (getSciVersion() >= SCI_VERSION_1_1) { + // SCI1.1+ doesnt do real merging anymore, but simply copying over the used colors from other palettes + for (i = 1; i < 255; i++) { + if (pFrom->colors[i].used) { + pTo->colors[i].used = pFrom->colors[i].used; + pTo->colors[i].r = pFrom->colors[i].r; + pTo->colors[i].g = pFrom->colors[i].g; + pTo->colors[i].b = pFrom->colors[i].b; + pFrom->mapping[i] = i; + } } - // no exact match - see if there is an unused color - for (j = 1; j < 256; j++) - if (!pTo->colors[j].used) { - pTo->colors[j].used = pFrom->colors[i].used; - pTo->colors[j].r = pFrom->colors[i].r; - pTo->colors[j].g = pFrom->colors[i].g; - pTo->colors[j].b = pFrom->colors[i].b; - pFrom->mapping[i] = j; - break; + } else { + // colors 0 (black) and 255 (white) are not affected by merging + for (i = 1 ; i < 255; i++) { + if (!pFrom->colors[i].used)// color is not used - so skip it + continue; + // forced palette merging or dest color is not used yet or bit 1 of new color is set + if (flag == 2 || (!pTo->colors[i].used) || (pFrom->colors[i].used & 2)) { + pTo->colors[i].used = pFrom->colors[i].used; + pTo->colors[i].r = pFrom->colors[i].r; + pTo->colors[i].g = pFrom->colors[i].g; + pTo->colors[i].b = pFrom->colors[i].b; + pFrom->mapping[i] = i; + continue; + } + // is the same color already at the same position? -> match it directly w/o lookup + // this fixes games like lsl1demo/sq5 where the same rgb color exists multiple times and where we would + // otherwise match the wrong one (which would result into the pixels affected (or not) by palette changes) + if ((pTo->colors[i].r == pFrom->colors[i].r) && (pTo->colors[i].g == pFrom->colors[i].g) && (pTo->colors[i].b == pFrom->colors[i].b)) { + pFrom->mapping[i] = i; + continue; + } + // check if exact color could be matched + res = matchColor(pTo, pFrom->colors[i].r, pFrom->colors[i].g, pFrom->colors[i].b); + if (res & 0x8000) { // exact match was found + pFrom->mapping[i] = res & 0xFF; + continue; + } + // no exact match - see if there is an unused color + for (j = 1; j < 256; j++) + if (!pTo->colors[j].used) { + pTo->colors[j].used = pFrom->colors[i].used; + pTo->colors[j].r = pFrom->colors[i].r; + pTo->colors[j].g = pFrom->colors[i].g; + pTo->colors[j].b = pFrom->colors[i].b; + pFrom->mapping[i] = j; + break; + } + // if still no luck - set an approximate color + if (j == 256) { + pFrom->mapping[i] = res & 0xFF; + pTo->colors[res & 0xFF].used |= 0x10; } - // if still no luck - set an approximate color - if (j == 256) { - pFrom->mapping[i] = res & 0xFF; - pTo->colors[res & 0xFF].used |= 0x10; } } pTo->timestamp = g_system->getMillis() * 60 / 1000; |