[Scummvm-cvs-logs] SF.net SVN: scummvm:[41846] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Thu Jun 25 03:29:41 CEST 2009


Revision: 41846
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41846&view=rev
Author:   lordhoto
Date:     2009-06-25 01:29:41 +0000 (Thu, 25 Jun 2009)

Log Message:
-----------
Implement palette fading for 16 color version of Kyrandia 1.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/screen.h
    scummvm/trunk/engines/kyra/screen_lok.cpp
    scummvm/trunk/engines/kyra/screen_lok.h

Modified: scummvm/trunk/engines/kyra/screen.h
===================================================================
--- scummvm/trunk/engines/kyra/screen.h	2009-06-25 01:29:27 UTC (rev 41845)
+++ scummvm/trunk/engines/kyra/screen.h	2009-06-25 01:29:41 UTC (rev 41846)
@@ -228,9 +228,9 @@
 	void fadeFromBlack(int delay=0x54, const UpdateFunctor *upFunc = 0);
 	void fadeToBlack(int delay=0x54, const UpdateFunctor *upFunc = 0);
 
-	void fadePalette(const Palette &pal, int delay, const UpdateFunctor *upFunc = 0);
+	virtual void fadePalette(const Palette &pal, int delay, const UpdateFunctor *upFunc = 0);
 	virtual void getFadeParams(const Palette &pal, int delay, int &delayInc, int &diff);
-	int fadePalStep(const Palette &pal, int diff);
+	virtual int fadePalStep(const Palette &pal, int diff);
 
 	void setPaletteIndex(uint8 index, uint8 red, uint8 green, uint8 blue);
 	virtual void setScreenPalette(const Palette &pal);

Modified: scummvm/trunk/engines/kyra/screen_lok.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen_lok.cpp	2009-06-25 01:29:27 UTC (rev 41845)
+++ scummvm/trunk/engines/kyra/screen_lok.cpp	2009-06-25 01:29:41 UTC (rev 41846)
@@ -251,17 +251,78 @@
 	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
 // we added conversion to 16 colors, when usehiResOverlay is enabled and that the
 // key color is 255 instead of 0. We might consider merging this again with
@@ -403,4 +464,16 @@
 	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

Modified: scummvm/trunk/engines/kyra/screen_lok.h
===================================================================
--- scummvm/trunk/engines/kyra/screen_lok.h	2009-06-25 01:29:27 UTC (rev 41845)
+++ scummvm/trunk/engines/kyra/screen_lok.h	2009-06-25 01:29:41 UTC (rev 41846)
@@ -83,6 +83,10 @@
 
 	void setScreenPalette(const Palette &pal);
 
+	void fadePalette(const Palette &pal, int delay, const UpdateFunctor *upFunc = 0);
+	void getFadeParams(const Palette &pal, int delay, int &delayInc, int &diff);
+	int fadePalStep(const Palette &pal, int diff);
+
 	void setMouseCursor(int x, int y, const byte *shape);
 private:
 	void updateDirtyRectsOvl();
@@ -90,6 +94,8 @@
 	void convertTo16Colors(uint8 *page, int w, int h, int pitch, int keyColor = -1);
 	void mergeOverlay(int x, int y, int w, int h);
 
+	void set16ColorPalette(const uint8 *pal);
+
 	void paletteMap(uint8 idx, int r, int g, int b);
 	uint8 _paletteMap[1024];
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list