From b29935e93c9ffddf8c510c0f192e9aafd522ea2d Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Tue, 31 Jul 2007 19:25:07 +0000 Subject: Generalized fadePalette to support custom target palette. svn-id: r28367 --- engines/parallaction/graphics.cpp | 14 +++++++++++--- engines/parallaction/graphics.h | 2 +- engines/parallaction/location.cpp | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 948f2a7b34..27e2de939d 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -226,11 +226,19 @@ void Gfx::makeGrayscalePalette(Palette pal) { return; } -void Gfx::fadePalette(Palette pal) { +void Gfx::fadePalette(Palette pal, Palette target, uint step) { + + if (step == 0) + return; for (uint16 i = 0; i < BASE_PALETTE_COLORS * 3; i++) { - if (pal[i] == _palette[i]) continue; - pal[i] += (pal[i] < _palette[i] ? 4 : -4); + if (pal[i] == target[i]) continue; + + if (pal[i] < target[i]) + pal[i] = CLIP(pal[i] + step, (uint)0, (uint)target[i]); + else + pal[i] = CLIP(pal[i] - step, (uint)target[i], (uint)255); + } return; diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index 11589b22cd..b7013d125e 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -210,7 +210,7 @@ public: void setBlackPalette(); void animatePalette(); void fadeInPalette(Palette palette); // fades palette (from black) to system palette - void fadePalette(Palette palette); // fades palette to system palette + void fadePalette(Palette palette, Palette target, uint step); // fades palette to target palette, with specified step void makeGrayscalePalette(Palette palette); // transform palette into black and white // amiga specific diff --git a/engines/parallaction/location.cpp b/engines/parallaction/location.cpp index e689a8e82d..024938074b 100644 --- a/engines/parallaction/location.cpp +++ b/engines/parallaction/location.cpp @@ -452,7 +452,7 @@ void Parallaction::doLocationEnterTransition() { // fades maximum intensity palette towards approximation of main palette for (uint16 _si = 0; _si<6; _si++) { - _gfx->fadePalette(pal); + _gfx->fadePalette(pal, _gfx->_palette, 4); _gfx->setPalette(pal); waitTime( 1 ); _gfx->updateScreen(); -- cgit v1.2.3