aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra/screen_lok.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2009-06-25 01:29:41 +0000
committerJohannes Schickel2009-06-25 01:29:41 +0000
commit0ec0b1d4981e227fddd03bf7d5be7077a445baae (patch)
tree838a97933c32751506c8cd2cdcd105b908471902 /engines/kyra/screen_lok.cpp
parent857ee03c7d28dc10969193a0e42283621350289e (diff)
downloadscummvm-rg350-0ec0b1d4981e227fddd03bf7d5be7077a445baae.tar.gz
scummvm-rg350-0ec0b1d4981e227fddd03bf7d5be7077a445baae.tar.bz2
scummvm-rg350-0ec0b1d4981e227fddd03bf7d5be7077a445baae.zip
Implement palette fading for 16 color version of Kyrandia 1.
svn-id: r41846
Diffstat (limited to 'engines/kyra/screen_lok.cpp')
-rw-r--r--engines/kyra/screen_lok.cpp87
1 files changed, 80 insertions, 7 deletions
diff --git a/engines/kyra/screen_lok.cpp b/engines/kyra/screen_lok.cpp
index fe3e713e15..e96ca9b2ed 100644
--- a/engines/kyra/screen_lok.cpp
+++ b/engines/kyra/screen_lok.cpp
@@ -251,15 +251,76 @@ void Screen_LoK_16::setScreenPalette(const Palette &pal) {
for (int i = 0; i < 256; ++i)
paletteMap(i, pal[i * 3 + 0] << 2, pal[i * 3 + 1] << 2, pal[i * 3 + 2] << 2);
- uint8 palette[16 * 4];
- for (int i = 0; i < 16; ++i) {
- palette[i * 4 + 0] = (_palette16[i * 3 + 0] * 0xFF) / 0x0F;
- palette[i * 4 + 1] = (_palette16[i * 3 + 1] * 0xFF) / 0x0F;
- palette[i * 4 + 2] = (_palette16[i * 3 + 2] * 0xFF) / 0x0F;
- palette[i * 4 + 3] = 0;
+ set16ColorPalette(_palette16);
+}
+
+void Screen_LoK_16::fadePalette(const Palette &pal, int delay, const UpdateFunctor *upFunc) {
+ uint8 notBlackFlag = 0;
+ for (int i = 0; i < 768; ++i) {
+ if ((*_screenPalette)[i])
+ notBlackFlag |= 1;
+ if (pal[i])
+ notBlackFlag |= 2;
}
- _system->setPalette(palette, 0, 16);
+ if (notBlackFlag == 1 || notBlackFlag == 2) {
+ bool upFade = false;
+
+ for (int i = 0; i < 768; ++i) {
+ if ((*_screenPalette)[i] < pal[i]) {
+ upFade = true;
+ break;
+ }
+ }
+
+ if (upFade) {
+ for (int i = 0; i < 256; ++i)
+ paletteMap(i, pal[i * 3 + 0] << 2, pal[i * 3 + 1] << 2, pal[i * 3 + 2] << 2);
+ _forceFullUpdate = true;
+ }
+
+ uint8 color16Palette[16 * 3];
+
+ if (upFade)
+ memset(color16Palette, 0, sizeof(color16Palette));
+ else
+ memcpy(color16Palette, _palette16, sizeof(color16Palette));
+
+ set16ColorPalette(color16Palette);
+ updateScreen();
+
+ for (int i = 0; i < 16; ++i) {
+ set16ColorPalette(color16Palette);
+
+ for (int k = 0; k < 48; ++k) {
+ if (upFade) {
+ if (color16Palette[k] < _palette16[k])
+ ++color16Palette[k];
+ } else {
+ if (color16Palette[k] > 0)
+ --color16Palette[k];
+ }
+ }
+
+ if (upFunc && upFunc->isValid())
+ (*upFunc)();
+ else
+ _system->updateScreen();
+
+ _vm->delay((delay >> 5) * _vm->tickLength());
+ }
+ }
+
+ setScreenPalette(pal);
+}
+
+void Screen_LoK_16::getFadeParams(const Palette &pal, int delay, int &delayInc, int &diff) {
+ error("Screen_LoK_16::getFadeParams called");
+}
+
+int Screen_LoK_16::fadePalStep(const Palette &pal, int diff) {
+ error("Screen_LoK_16::fadePalStep called");
+ return 0;
}
// TODO: This is currently nearly the same as Screen::setMouseCursor, only that
@@ -403,4 +464,16 @@ void Screen_LoK_16::mergeOverlay(int x, int y, int w, int h) {
convertTo16Colors(_sjisOverlayPtrs[0] + y * 640 + x, w, h, 640);
}
+void Screen_LoK_16::set16ColorPalette(const uint8 *pal) {
+ uint8 palette[16 * 4];
+ for (int i = 0; i < 16; ++i) {
+ palette[i * 4 + 0] = (pal[i * 3 + 0] * 0xFF) / 0x0F;
+ palette[i * 4 + 1] = (pal[i * 3 + 1] * 0xFF) / 0x0F;
+ palette[i * 4 + 2] = (pal[i * 3 + 2] * 0xFF) / 0x0F;
+ palette[i * 4 + 3] = 0;
+ }
+
+ _system->setPalette(palette, 0, 16);
+}
+
} // end of namespace Kyra