[Scummvm-cvs-logs] SF.net SVN: scummvm: [22914] scummvm/trunk/backends/gp32/gp32_osys.cpp

wonst719 at users.sourceforge.net wonst719 at users.sourceforge.net
Sun Jun 4 15:13:48 CEST 2006


Revision: 22914
Author:   wonst719
Date:     2006-06-04 06:13:40 -0700 (Sun, 04 Jun 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22914&view=rev

Log Message:
-----------
Fix infinite loop in updateScren() when mouse cursor is not initialized by setMouseCursor().

Modified Paths:
--------------
    scummvm/trunk/backends/gp32/gp32_osys.cpp
Modified: scummvm/trunk/backends/gp32/gp32_osys.cpp
===================================================================
--- scummvm/trunk/backends/gp32/gp32_osys.cpp	2006-06-04 12:38:27 UTC (rev 22913)
+++ scummvm/trunk/backends/gp32/gp32_osys.cpp	2006-06-04 13:13:40 UTC (rev 22914)
@@ -42,7 +42,9 @@
 OSystem_GP32::OSystem_GP32() :
 		_screenWidth(0), _screenHeight(0), _gameScreen(NULL), _hwScreen(NULL),
 		_overlayVisible(false), _forceFull(false), _adjustAspectRatio(false),
-		/*_paletteDirtyStart(0), _paletteDirtyEnd(0),*/ _mouseBuf(NULL) {
+		/*_paletteDirtyStart(0), _paletteDirtyEnd(0),*/
+		_mouseBuf(NULL), _mouseHeight(0), _mouseWidth(0), _mouseKeyColor(0),
+		_mouseHotspotX(0), _mouseHotspotY(0) {
 	NP("OSys::OSystem_GP32()");
 	// allocate palette storage
 	memset(_currentPalette, 0, 256 * sizeof(uint16));
@@ -209,7 +211,6 @@
 void OSystem_GP32::updateScreen() {
 	uint16 *buffer;
 	//TODO: adjust shakePos
-	NP("updateScreen");
 
 	// draw gamescreen
 	buffer = &_tmpScreen[240 - _screenHeight];
@@ -291,21 +292,58 @@
 	_forceFull = true;
 }
 
-void OSystem_GP32::grabOverlay(OverlayColor *buf, int pitch)
-{
+void OSystem_GP32::grabOverlay(OverlayColor *buf, int pitch) {
 	NP("OSys::grabOverlay()");
-}
+	int h = _overlayHeight;
+	OverlayColor *src = _overlayBuffer;
 
-void OSystem_GP32::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {
-	NP("OSys::copyRectToOverlay()");
-	OverlayColor *dst = (OverlayColor *)_overlayBuffer + y * _overlayWidth + x;
 	do {
-		memcpy(dst, buf, w * sizeof(uint16));
-		dst += _overlayWidth;
+		memcpy(buf, src, _overlayWidth * sizeof(OverlayColor));
+		src += _overlayWidth;
 		buf += pitch;
 	} while (--h);
 }
 
+void OSystem_GP32::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {
+	NP("OSys::copyRectToOverlay()");
+
+	//Clip the coordinates
+	if (x < 0) {
+		w += x;
+		buf -= x;
+		x = 0;
+	}
+
+	if (y < 0) {
+		h += y;
+		buf -= y * pitch;
+		y = 0;
+	}
+
+	if (w > _overlayWidth - x) {
+		w = _overlayWidth - x;
+	}
+
+	if (h > _overlayHeight - y) {
+		h = _overlayHeight - y;
+	}
+
+	if (w <= 0 || h <= 0)
+		return;
+
+	
+	OverlayColor *dst = _overlayBuffer + y * _overlayWidth + x;
+	if (_overlayWidth == pitch && pitch == w) {
+		memcpy(dst, buf, h * w * sizeof(OverlayColor));
+	} else {
+		do {
+			memcpy(dst, buf, w * sizeof(OverlayColor));
+			buf += pitch;
+			dst += _overlayWidth;
+		} while (--h);
+	}
+}
+
 int16 OSystem_GP32::getOverlayHeight() {
 	//NP("OSys::getOverlayHeight()");
 	return getHeight();


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