[Scummvm-cvs-logs] SF.net SVN: scummvm:[41194] scummvm/branches/gsoc2009-16bit

upthorn at users.sourceforge.net upthorn at users.sourceforge.net
Fri Jun 5 10:09:38 CEST 2009


Revision: 41194
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41194&view=rev
Author:   upthorn
Date:     2009-06-05 08:09:37 +0000 (Fri, 05 Jun 2009)

Log Message:
-----------
Corrected backend to be able to accept a 16-bit mouseKeyColor without overflow

Modified Paths:
--------------
    scummvm/branches/gsoc2009-16bit/backends/platform/sdl/graphics.cpp
    scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.h
    scummvm/branches/gsoc2009-16bit/common/system.h
    scummvm/branches/gsoc2009-16bit/dists/msvc8/scumm.vcproj
    scummvm/branches/gsoc2009-16bit/engines/scumm/cursor.cpp
    scummvm/branches/gsoc2009-16bit/graphics/cursorman.cpp
    scummvm/branches/gsoc2009-16bit/graphics/cursorman.h

Modified: scummvm/branches/gsoc2009-16bit/backends/platform/sdl/graphics.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/backends/platform/sdl/graphics.cpp	2009-06-05 07:07:56 UTC (rev 41193)
+++ scummvm/branches/gsoc2009-16bit/backends/platform/sdl/graphics.cpp	2009-06-05 08:09:37 UTC (rev 41194)
@@ -1403,7 +1403,8 @@
 	}
 }
 
-void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale) {
+#ifdef ENABLE_16BIT
+void OSystem_SDL::setMouseCursor16(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint16 keycolor, int cursorTargetScale) {
 	if (w == 0 || h == 0)
 		return;
 
@@ -1438,13 +1439,51 @@
 
 	free(_mouseData);
 
-#ifdef ENABLE_16BIT
 	_mouseData = (byte *)malloc(w * h * 2);
 	memcpy(_mouseData, buf, w * h * 2);
-#else
+
+	blitCursor();
+}
+#endif
+
+void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale) {
+	if (w == 0 || h == 0)
+		return;
+
+	_mouseCurState.hotX = hotspot_x;
+	_mouseCurState.hotY = hotspot_y;
+
+	_mouseKeyColor = keycolor;
+
+	_cursorTargetScale = cursorTargetScale;
+
+	if (_mouseCurState.w != (int)w || _mouseCurState.h != (int)h) {
+		_mouseCurState.w = w;
+		_mouseCurState.h = h;
+
+		if (_mouseOrigSurface)
+			SDL_FreeSurface(_mouseOrigSurface);
+
+		// Allocate bigger surface because AdvMame2x adds black pixel at [0,0]
+		_mouseOrigSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA,
+						_mouseCurState.w + 2,
+						_mouseCurState.h + 2,
+						16,
+						_hwscreen->format->Rmask,
+						_hwscreen->format->Gmask,
+						_hwscreen->format->Bmask,
+						_hwscreen->format->Amask);
+
+		if (_mouseOrigSurface == NULL)
+			error("allocating _mouseOrigSurface failed");
+		SDL_SetColorKey(_mouseOrigSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, kMouseColorKey);
+	}
+
+	free(_mouseData);
+
 	_mouseData = (byte *)malloc(w * h);
 	memcpy(_mouseData, buf, w * h);
-#endif
+
 	blitCursor();
 }
 

Modified: scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.h
===================================================================
--- scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.h	2009-06-05 07:07:56 UTC (rev 41193)
+++ scummvm/branches/gsoc2009-16bit/backends/platform/sdl/sdl.h	2009-06-05 08:09:37 UTC (rev 41194)
@@ -112,6 +112,10 @@
 	virtual void warpMouse(int x, int y); // overloaded by CE backend (FIXME)
 
 	// Set the bitmap that's used when drawing the cursor.
+#ifdef ENABLE_16BIT
+	//HACK Made a second method as a quick and dirty workaround to avoid linker errors with engine libs
+	virtual void setMouseCursor16(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint16 keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME)
+#endif
 	virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME)
 
 	// Set colors of cursor palette

Modified: scummvm/branches/gsoc2009-16bit/common/system.h
===================================================================
--- scummvm/branches/gsoc2009-16bit/common/system.h	2009-06-05 07:07:56 UTC (rev 41193)
+++ scummvm/branches/gsoc2009-16bit/common/system.h	2009-06-05 08:09:37 UTC (rev 41194)
@@ -687,8 +687,13 @@
 	 * @param keycolor			transparency color index
 	 * @param cursorTargetScale	scale factor which cursor is designed for
 	 */
+#ifdef ENABLE_16BIT
+	//HACK made a second method as a quick and dirty workaround to avoid linker errors with engine libs
+	virtual void setMouseCursor16(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint16 keycolor = 65535, int cursorTargetScale = 1) = 0;
+#endif
 	virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int cursorTargetScale = 1) = 0;
 
+
 	/**
 	 * Replace the specified range of cursor the palette with new colors.
 	 * The palette entries from 'start' till (start+num-1) will be replaced - so

Modified: scummvm/branches/gsoc2009-16bit/dists/msvc8/scumm.vcproj
===================================================================
--- scummvm/branches/gsoc2009-16bit/dists/msvc8/scumm.vcproj	2009-06-05 07:07:56 UTC (rev 41193)
+++ scummvm/branches/gsoc2009-16bit/dists/msvc8/scumm.vcproj	2009-06-05 08:09:37 UTC (rev 41194)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="8,00"
+	Version="8.00"
 	Name="scumm"
 	ProjectGUID="{B6AFD548-63D2-40CD-A652-E87095AFCBAF}"
 	RootNamespace="scumm"
@@ -43,7 +43,7 @@
 				Optimization="0"
 				InlineFunctionExpansion="0"
 				AdditionalIncludeDirectories="../../;../../engines"
-				PreprocessorDefinitions="WIN32;_DEBUG;ENABLE_SCUMM_7_8;ENABLE_HE;USE_ZLIB;USE_MAD;USE_VORBIS"
+				PreprocessorDefinitions="WIN32;_DEBUG;ENABLE_SCUMM_7_8;ENABLE_HE;USE_ZLIB;USE_MAD;USE_VORBIS; ENABLE_16BIT"
 				MinimalRebuild="true"
 				ExceptionHandling="1"
 				BasicRuntimeChecks="3"

Modified: scummvm/branches/gsoc2009-16bit/engines/scumm/cursor.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/engines/scumm/cursor.cpp	2009-06-05 07:07:56 UTC (rev 41193)
+++ scummvm/branches/gsoc2009-16bit/engines/scumm/cursor.cpp	2009-06-05 08:09:37 UTC (rev 41194)
@@ -112,10 +112,20 @@
 
 void ScummEngine::updateCursor() {
 	int transColor = (_game.heversion >= 80) ? 5 : 255;
-	CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height,
-							_cursor.hotspotX, _cursor.hotspotY,
-							(_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor),
-							(_game.heversion == 70 ? 2 : 1));
+	if (_game.features & GF_16BIT_COLOR && _hePalettes) {
+		//HACK Had to make a second method to avoid many, many linker errors from other engines
+		//this requires ENABLE_16BIT to be defined in the Scumm project, again, because I #ifdef'ed
+		//the method's definition and declaration in cursorman.h 
+		CursorMan.replaceCursor16(_grabbedCursor, _cursor.width, _cursor.height,
+								_cursor.hotspotX, _cursor.hotspotY,
+								(_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor),
+								(_game.heversion == 70 ? 2 : 1));
+	} else {
+		CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height,
+								_cursor.hotspotX, _cursor.hotspotY,
+								(_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor),
+								(_game.heversion == 70 ? 2 : 1));
+	}
 }
 
 void ScummEngine_v6::grabCursor(int x, int y, int w, int h) {

Modified: scummvm/branches/gsoc2009-16bit/graphics/cursorman.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/graphics/cursorman.cpp	2009-06-05 07:07:56 UTC (rev 41193)
+++ scummvm/branches/gsoc2009-16bit/graphics/cursorman.cpp	2009-06-05 08:09:37 UTC (rev 41194)
@@ -100,7 +100,38 @@
 	g_system->showMouse(isVisible());
 }
 
+#ifdef ENABLE_16BIT
+//HACK Made a separate method to avoid massive linker errors on every engine
+void CursorManager::replaceCursor16(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint16 keycolor, int targetScale) {
+	if (_cursorStack.empty()) {
+		pushCursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale);
+		return;
+	}
 
+	Cursor *cur = _cursorStack.top();
+
+	uint size = w * h * 2;
+
+	if (cur->_size < size) {
+		delete[] cur->_data;
+		cur->_data = new byte[size];
+		cur->_size = size;
+	}
+
+	if (buf && cur->_data)
+		memcpy(cur->_data, buf, size);
+
+	cur->_width = w;
+	cur->_height = h;
+	cur->_hotspotX = hotspotX;
+	cur->_hotspotY = hotspotY;
+	cur->_keycolor = keycolor;
+	cur->_targetScale = targetScale;
+
+	g_system->setMouseCursor16(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale);
+}
+#endif
+
 void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetScale) {
 	if (_cursorStack.empty()) {
 		pushCursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale);
@@ -108,11 +139,8 @@
 	}
 
 	Cursor *cur = _cursorStack.top();
-#ifdef ENABLE_16BIT
-	uint size = w * h * 2;
-#else
+
 	uint size = w * h;
-#endif
 
 	if (cur->_size < size) {
 		delete[] cur->_data;

Modified: scummvm/branches/gsoc2009-16bit/graphics/cursorman.h
===================================================================
--- scummvm/branches/gsoc2009-16bit/graphics/cursorman.h	2009-06-05 07:07:56 UTC (rev 41193)
+++ scummvm/branches/gsoc2009-16bit/graphics/cursorman.h	2009-06-05 08:09:37 UTC (rev 41194)
@@ -77,6 +77,10 @@
 	 * @param keycolor	the index for the transparent color
 	 * @param targetScale	the scale for which the cursor is designed
 	 */
+#ifdef ENABLE_16BIT
+	//HACK made a separate method to avoid massive linker errors on every engine.
+	void replaceCursor16(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint16 keycolor = 65535, int targetScale = 1);
+#endif
 	void replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int targetScale = 1);
 
 	/**


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