aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/palette.cpp
diff options
context:
space:
mode:
authorTravis Howell2009-01-04 03:49:23 +0000
committerTravis Howell2009-01-04 03:49:23 +0000
commitd0fc28bbd1bd5a3399c629e5d25ae3a64fef977c (patch)
tree68d39802db270642507b027fdeb25cfc059315de /engines/scumm/palette.cpp
parent4670e37a78409bfe9279c5d73c8d581f0d66143e (diff)
downloadscummvm-rg350-d0fc28bbd1bd5a3399c629e5d25ae3a64fef977c.tar.gz
scummvm-rg350-d0fc28bbd1bd5a3399c629e5d25ae3a64fef977c.tar.bz2
scummvm-rg350-d0fc28bbd1bd5a3399c629e5d25ae3a64fef977c.zip
Use cache when converting 16bit colors, for faster conversions.
svn-id: r35714
Diffstat (limited to 'engines/scumm/palette.cpp')
-rw-r--r--engines/scumm/palette.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp
index 4214ab2330..a4ba9b25c4 100644
--- a/engines/scumm/palette.cpp
+++ b/engines/scumm/palette.cpp
@@ -310,6 +310,9 @@ void ScummEngine::setDirtyColors(int min, int max) {
_palDirtyMin = min;
if (_palDirtyMax < max)
_palDirtyMax = max;
+
+ if (_hePaletteCache)
+ memset(_hePaletteCache, -1, 65536);
}
void ScummEngine::initCycl(const byte *ptr) {
@@ -810,6 +813,16 @@ void ScummEngine_v8::desaturatePalette(int hueScale, int satScale, int lightScal
#endif
+int ScummEngine::convert16BitColor(uint16 color, uint8 r, uint8 g, uint8 b) {
+ // HACK: Find the closest matching color, and store in
+ // cache for faster access.
+ if (_hePaletteCache[color] == -1) {
+ _hePaletteCache[color] = remapPaletteColor(r, g, b, -1);
+ }
+
+ return _hePaletteCache[color];
+}
+
int ScummEngine::remapPaletteColor(int r, int g, int b, int threshold) {
byte *pal;
int ar, ag, ab, i;