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

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Mon Jun 29 20:00:18 CEST 2009


Revision: 41959
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41959&view=rev
Author:   lordhoto
Date:     2009-06-29 18:00:18 +0000 (Mon, 29 Jun 2009)

Log Message:
-----------
- Get rid of code duplication for mouse cursor setup
- Fix mouse cursor colors in LoL PC98
(This commit might introduce regressions, since it changes the key color the mouse cursor uses)

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

Modified: scummvm/trunk/engines/kyra/screen.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen.cpp	2009-06-29 17:26:56 UTC (rev 41958)
+++ scummvm/trunk/engines/kyra/screen.cpp	2009-06-29 18:00:18 UTC (rev 41959)
@@ -2622,12 +2622,12 @@
 		y <<= 1;
 		mouseWidth <<= 1;
 		mouseHeight <<= 1;
-		fillRect(mouseWidth, 0, mouseWidth, mouseHeight, 0, 8);
+		fillRect(mouseWidth, 0, mouseWidth, mouseHeight, 255, 8);
 	}
 
 
 	uint8 *cursor = new uint8[mouseHeight * mouseWidth];
-	fillRect(0, 0, mouseWidth, mouseHeight, 0, 8);
+	fillRect(0, 0, mouseWidth, mouseHeight, 255, 8);
 	drawShape(8, shape, 0, 0, 0, 0);
 
 	int xOffset = 0;
@@ -2635,11 +2635,14 @@
 	if (_vm->gameFlags().useHiResOverlay) {
 		xOffset = mouseWidth;
 		scale2x(getPagePtr(8) + mouseWidth, SCREEN_W, getPagePtr(8), SCREEN_W, mouseWidth, mouseHeight);
+		postProcessCursor(getPagePtr(8) + mouseWidth, mouseWidth, mouseHeight, SCREEN_W);
+	} else {
+		postProcessCursor(getPagePtr(8), mouseWidth, mouseHeight, SCREEN_W);
 	}
 
 	CursorMan.showMouse(false);
 	copyRegionToBuffer(8, xOffset, 0, mouseWidth, mouseHeight, cursor);
-	CursorMan.replaceCursor(cursor, mouseWidth, mouseHeight, x, y, 0);
+	CursorMan.replaceCursor(cursor, mouseWidth, mouseHeight, x, y, 255);
 	if (isMouseVisible())
 		CursorMan.showMouse(true);
 	delete[] cursor;

Modified: scummvm/trunk/engines/kyra/screen.h
===================================================================
--- scummvm/trunk/engines/kyra/screen.h	2009-06-29 17:26:56 UTC (rev 41958)
+++ scummvm/trunk/engines/kyra/screen.h	2009-06-29 18:00:18 UTC (rev 41959)
@@ -298,7 +298,7 @@
 	void hideMouse();
 	void showMouse();
 	bool isMouseVisible() const;
-	virtual void setMouseCursor(int x, int y, const byte *shape);
+	void setMouseCursor(int x, int y, const byte *shape);
 
 	// rect handling
 	virtual int getRectSize(int w, int h) = 0;
@@ -396,8 +396,11 @@
 	uint8 *_animBlockPtr;
 	int _animBlockSize;
 
+	// mouse handling
 	int _mouseLockCount;
 
+	virtual void postProcessCursor(uint8 *data, int w, int h, int pitch) {};
+
 	enum {
 		kMaxDirtyRects = 50
 	};

Modified: scummvm/trunk/engines/kyra/screen_lok.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen_lok.cpp	2009-06-29 17:26:56 UTC (rev 41958)
+++ scummvm/trunk/engines/kyra/screen_lok.cpp	2009-06-29 18:00:18 UTC (rev 41959)
@@ -324,62 +324,6 @@
 	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
-// Screen::setMouseCursor.
-void Screen_LoK_16::setMouseCursor(int x, int y, const byte *shape) {
-	if (!shape)
-		return;
-	// if mouseDisabled
-	//	return _mouseShape
-
-	if (_vm->gameFlags().useAltShapeHeader)
-		shape += 2;
-
-	int mouseHeight = *(shape + 2);
-	int mouseWidth = (READ_LE_UINT16(shape + 3)) + 2;
-
-	if (_vm->gameFlags().useAltShapeHeader)
-		shape -= 2;
-
-	if (_vm->gameFlags().useHiResOverlay) {
-		x <<= 1;
-		y <<= 1;
-		mouseWidth <<= 1;
-		mouseHeight <<= 1;
-		fillRect(mouseWidth, 0, mouseWidth, mouseHeight, 0, 8);
-	}
-
-
-	uint8 *cursor = new uint8[mouseHeight * mouseWidth];
-	// Since color id '0' is used for black in some tiems, we must switch to 255 as color key.
-	fillRect(0, 0, mouseWidth, mouseHeight, 255, 8);
-	drawShape(8, shape, 0, 0, 0, 0);
-
-	int xOffset = 0;
-
-	if (_vm->gameFlags().useHiResOverlay) {
-		xOffset = mouseWidth;
-		scale2x(getPagePtr(8) + mouseWidth, SCREEN_W, getPagePtr(8), SCREEN_W, mouseWidth, mouseHeight);
-		// We need to pass the color key number to our conversion function, else it'll convert the color too.
-		convertTo16Colors(getPagePtr(8) + mouseWidth, mouseWidth * 2, mouseHeight * 2, 320, 255);
-	}
-
-	CursorMan.showMouse(false);
-	copyRegionToBuffer(8, xOffset, 0, mouseWidth, mouseHeight, cursor);
-	CursorMan.replaceCursor(cursor, mouseWidth, mouseHeight, x, y, 255);
-	if (isMouseVisible())
-		CursorMan.showMouse(true);
-	delete[] cursor;
-
-	// makes sure that the cursor is drawn
-	// we do not use Screen::updateScreen here
-	// so we can be sure that changes to page 0
-	// are NOT updated on the real screen here
-	_system->updateScreen();
-}
-
 void Screen_LoK_16::paletteMap(uint8 idx, int r, int g, int b) {
 	const int red = r;
 	const int green = g;

Modified: scummvm/trunk/engines/kyra/screen_lok.h
===================================================================
--- scummvm/trunk/engines/kyra/screen_lok.h	2009-06-29 17:26:56 UTC (rev 41958)
+++ scummvm/trunk/engines/kyra/screen_lok.h	2009-06-29 18:00:18 UTC (rev 41959)
@@ -86,12 +86,13 @@
 	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();
 
 	void convertTo16Colors(uint8 *page, int w, int h, int pitch, int keyColor = -1);
+	void postProcessCursor(uint8 *data, int width, int height, int pitch) {
+		convertTo16Colors(data, width, height, pitch, 255);
+	}
 	void mergeOverlay(int x, int y, int w, int h);
 
 	void set16ColorPalette(const uint8 *pal);

Modified: scummvm/trunk/engines/kyra/screen_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen_lol.cpp	2009-06-29 17:26:56 UTC (rev 41958)
+++ scummvm/trunk/engines/kyra/screen_lol.cpp	2009-06-29 18:00:18 UTC (rev 41959)
@@ -994,6 +994,18 @@
 	}
 }
 
+void Screen_LoL::postProcessCursor(uint8 *data, int w, int h, int pitch) {
+	while (h--) {
+		for (int i = 0; i < w; ++i) {
+			if (*data != 255)
+				*data = _paletteConvTable[*data];
+			++data;
+		}
+
+		data += pitch - w;
+	}
+}
+
 } // end of namespace Kyra
 
 #endif // ENABLE_LOL

Modified: scummvm/trunk/engines/kyra/screen_lol.h
===================================================================
--- scummvm/trunk/engines/kyra/screen_lol.h	2009-06-29 17:26:56 UTC (rev 41958)
+++ scummvm/trunk/engines/kyra/screen_lol.h	2009-06-29 18:00:18 UTC (rev 41959)
@@ -111,6 +111,7 @@
 
 	static const uint8 _paletteConvTable[256];
 	void mergeOverlay(int x, int y, int w, int h);
+	void postProcessCursor(uint8 *data, int width, int height, int pitch);
 
 	// magic atlas
 	void calcBoundariesIntern(int dstX, int dstY, int c, int d);


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