[Scummvm-cvs-logs] SF.net SVN: scummvm:[45565] scummvm/trunk/engines/sci/gui

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sat Oct 31 16:44:59 CET 2009


Revision: 45565
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45565&view=rev
Author:   thebluegr
Date:     2009-10-31 15:44:59 +0000 (Sat, 31 Oct 2009)

Log Message:
-----------
Upscale the mouse cursor when the screen is upscaled. Also, reapplied some code which was accidentally reverted in commit #45562

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gui/gui_cursor.cpp
    scummvm/trunk/engines/sci/gui/gui_screen.cpp
    scummvm/trunk/engines/sci/gui/gui_screen.h

Modified: scummvm/trunk/engines/sci/gui/gui_cursor.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_cursor.cpp	2009-10-31 15:25:47 UTC (rev 45564)
+++ scummvm/trunk/engines/sci/gui/gui_cursor.cpp	2009-10-31 15:44:59 UTC (rev 45565)
@@ -40,8 +40,9 @@
 	: _resMan(resMan), _palette(palette), _screen(screen) {
 
 	_upscaledHires = _screen->getUpscaledHires();
-	setPosition(Common::Point(160, 150));		// TODO: how is that different in 640x400 games?
-	setMoveZone(Common::Rect(0, 0, 320, 200));	// TODO: hires games
+	// center mouse cursor
+	setPosition(Common::Point(_screen->_displayWidth / 2, _screen->_displayHeight / 2));
+	setMoveZone(Common::Rect(0, 0, _screen->_displayWidth, _screen->_displayHeight));
 }
 
 SciGuiCursor::~SciGuiCursor() {
@@ -149,9 +150,23 @@
 		return;
 	}
 
-	cursorView->getBitmap(loopNum, celNum);
+	byte *cursorBitmap = cursorView->getBitmap(loopNum, celNum);
 
-	CursorMan.replaceCursor(celInfo->rawBitmap, width, height, cursorHotspot->x, cursorHotspot->y, clearKey);
+	if (_upscaledHires) {
+		// Scale cursor by 2x
+		width *= 2;
+		height *= 2;
+		cursorHotspot->x *= 2;
+		cursorHotspot->y *= 2;
+		cursorBitmap = new byte[width * height];
+		_screen->scale2x(celInfo->rawBitmap, cursorBitmap, celInfo->width, celInfo->height);
+	}
+
+	CursorMan.replaceCursor(cursorBitmap, width, height, cursorHotspot->x, cursorHotspot->y, clearKey);
+
+	if (_upscaledHires)
+		delete cursorBitmap;
+
 	show();
 
 	delete cursorHotspot;
@@ -166,13 +181,14 @@
 }
 
 Common::Point SciGuiCursor::getPosition() {
-	if (!_upscaledHires) {
-		return g_system->getEventManager()->getMousePos();
-	} else {
-		Common::Point mousePos = g_system->getEventManager()->getMousePos();
-		mousePos.x /= 2; mousePos.y /= 2;
-		return mousePos;
+	Common::Point mousePos = g_system->getEventManager()->getMousePos();
+	
+	if (_upscaledHires) {
+		mousePos.x /= 2;
+		mousePos.y /= 2;
 	}
+
+	return mousePos;
 }
 
 void SciGuiCursor::refreshPosition() {
@@ -197,7 +213,7 @@
 
 	// FIXME: Do this only when mouse is grabbed?
 	if (clipped)
-		g_system->warpMouse(mousePoint.x, mousePoint.y);
+		setPosition(mousePoint);
 }
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/gui/gui_screen.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_screen.cpp	2009-10-31 15:25:47 UTC (rev 45564)
+++ scummvm/trunk/engines/sci/gui/gui_screen.cpp	2009-10-31 15:44:59 UTC (rev 45565)
@@ -119,14 +119,13 @@
 
 void SciGuiScreen::putPixel(int x, int y, byte drawMask, byte color, byte priority, byte control) {
 	int offset = y * _width + x;
-	int displayOffset;
 
 	if (drawMask & SCI_SCREEN_MASK_VISUAL) {
 		_visualScreen[offset] = color;
 		if (!_upscaledHires) {
 			_displayScreen[offset] = color;
 		} else {
-			displayOffset = y * 2 * _displayWidth + x * 2;
+			int displayOffset = y * 2 * _displayWidth + x * 2;
 			_displayScreen[displayOffset] = color;
 			_displayScreen[displayOffset + 1] = color;
 			_displayScreen[displayOffset + _displayWidth] = color;
@@ -494,4 +493,19 @@
 	copyToScreen();
 }
 
+void SciGuiScreen::scale2x(byte *src, byte *dst, int16 srcWidth, int16 srcHeight) {
+	int newWidth = srcWidth * 2;
+
+	for (int y = 0; y < srcHeight; y++) {
+		for (int x = 0; x < srcWidth; x++) {
+			int destOffset = y * 2 * newWidth + x * 2;
+			int color = src[y * srcWidth + x];
+			dst[destOffset] = color;
+			dst[destOffset + 1] = color;
+			dst[destOffset + newWidth] = color;
+			dst[destOffset + newWidth + 1] = color;
+		}
+	}
+}
+
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/gui/gui_screen.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_screen.h	2009-10-31 15:25:47 UTC (rev 45564)
+++ scummvm/trunk/engines/sci/gui/gui_screen.h	2009-10-31 15:44:59 UTC (rev 45565)
@@ -75,6 +75,8 @@
 
 	void setVerticalShakePos(uint16 shakePos);
 
+	void scale2x(byte *src, byte *dst, int16 srcWidth, int16 srcHeight);
+
 	void dither(bool addToFlag);
 	void unditherSetState(bool flag);
 	int16 *unditherGetMemorial();


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