aboutsummaryrefslogtreecommitdiff
path: root/engines/mads/palette.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2015-02-08 22:07:42 -0500
committerPaul Gilbert2015-02-08 22:07:42 -0500
commit5e00b39caec66e1c5626a89f207c26c577fd30d8 (patch)
treed8d81eb6a19754c031fd603b4f6af5810fd38878 /engines/mads/palette.cpp
parentcbbd1a92192ad118897f645f1aa6e968bff01466 (diff)
downloadscummvm-rg350-5e00b39caec66e1c5626a89f207c26c577fd30d8.tar.gz
scummvm-rg350-5e00b39caec66e1c5626a89f207c26c577fd30d8.tar.bz2
scummvm-rg350-5e00b39caec66e1c5626a89f207c26c577fd30d8.zip
MADS: Implementing code for panning screen transitions
Diffstat (limited to 'engines/mads/palette.cpp')
-rw-r--r--engines/mads/palette.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 250eb75955..250c98b074 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -885,4 +885,30 @@ void Palette::refreshSceneColors() {
setPalette(_mainPalette + (val * 3), val, 256 - val);
}
+int Palette::closestColor(const byte *matchColor, const byte *refPalette,
+ int listWrap, int count) {
+ int bestColor = 0;
+ int bestDifference = 0x7fff;
+
+ for (int idx = 0; idx < count; ++idx) {
+ // Figure out hash for color
+ int hash = 0;
+ for (int rgbIdx = 0; rgbIdx < 3; ++rgbIdx, ++refPalette) {
+ byte diff = *refPalette - matchColor[rgbIdx];
+ hash += (int)diff * (int)diff;
+ }
+
+ // If the given color is a closer match to our color, store the index
+ if (hash < bestDifference) {
+ bestDifference = hash;
+ bestColor = idx;
+ }
+
+ refPalette += listWrap - 3;
+ }
+
+ return bestColor;
+}
+
+
} // End of namespace MADS