aboutsummaryrefslogtreecommitdiff
path: root/engines/mads/palette.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2015-02-14 15:34:11 -0500
committerPaul Gilbert2015-02-14 15:34:11 -0500
commit1aa9181466d1916824abb7301ea3e67781d08183 (patch)
tree8dc129d17f08b29ab3ac745e1ccc60e18567987e /engines/mads/palette.cpp
parent52adf5135b7b075c1cfc63ce8094538edf279039 (diff)
downloadscummvm-rg350-1aa9181466d1916824abb7301ea3e67781d08183.tar.gz
scummvm-rg350-1aa9181466d1916824abb7301ea3e67781d08183.tar.bz2
scummvm-rg350-1aa9181466d1916824abb7301ea3e67781d08183.zip
MADS: Cleanup and bugfixes for panning transition support methods
Diffstat (limited to 'engines/mads/palette.cpp')
-rw-r--r--engines/mads/palette.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index b41eaedfcc..b5ea136abd 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -428,6 +428,14 @@ void Fader::grabPalette(byte *colors, uint start, uint num) {
g_system->getPaletteManager()->grabPalette(colors, start, num);
}
+void Fader::getFullPalette(byte palette[PALETTE_SIZE]) {
+ grabPalette(&palette[0], 0, PALETTE_COUNT);
+}
+
+void Fader::setFullPalette(byte palette[PALETTE_SIZE]) {
+ setPalette(&palette[0], 0, PALETTE_COUNT);
+}
+
void Fader::fadeOut(byte palette[PALETTE_SIZE], byte *paletteMap,
int baseColor, int numColors, int baseGrey, int numGreys,
int tickDelay, int steps) {
@@ -886,25 +894,25 @@ void Palette::refreshSceneColors() {
}
int Palette::closestColor(const byte *matchColor, const byte *refPalette,
- int listWrap, int count) {
+ int paletteInc, int count) {
int bestColor = 0;
int bestDistance = 0x7fff;
for (int idx = 0; idx < count; ++idx) {
- // Figure out hash for color
+ // Figure out figure for 'distance' between two colors
int distance = 0;
- for (int rgbIdx = 0; rgbIdx < 3; ++rgbIdx, ++refPalette) {
- byte diff = *refPalette - matchColor[rgbIdx];
- distance += (int)diff * (int)diff;
+ for (int rgbIdx = 0; rgbIdx < RGB_SIZE; ++rgbIdx) {
+ int diff = refPalette[rgbIdx] - matchColor[rgbIdx];
+ distance += diff * diff;
}
// If the given color is a closer match to our color, store the index
- if (distance < bestDistance) {
+ if (distance <= bestDistance) {
bestDistance = distance;
bestColor = idx;
}
- refPalette += listWrap - 3;
+ refPalette += paletteInc;
}
return bestColor;