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

upthorn at users.sourceforge.net upthorn at users.sourceforge.net
Fri Jun 5 08:41:04 CEST 2009


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

Log Message:
-----------
Converted cursor code to use 16-bit.

Modified Paths:
--------------
    scummvm/branches/gsoc2009-16bit/backends/platform/sdl/graphics.cpp
    scummvm/branches/gsoc2009-16bit/engines/scumm/costume.cpp
    scummvm/branches/gsoc2009-16bit/engines/scumm/cursor.cpp
    scummvm/branches/gsoc2009-16bit/engines/scumm/he/wiz_he.cpp
    scummvm/branches/gsoc2009-16bit/engines/scumm/scumm.h
    scummvm/branches/gsoc2009-16bit/graphics/cursorman.cpp

Modified: scummvm/branches/gsoc2009-16bit/backends/platform/sdl/graphics.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/backends/platform/sdl/graphics.cpp	2009-06-05 04:28:07 UTC (rev 41190)
+++ scummvm/branches/gsoc2009-16bit/backends/platform/sdl/graphics.cpp	2009-06-05 06:41:04 UTC (rev 41191)
@@ -1438,8 +1438,13 @@
 
 	free(_mouseData);
 
+#ifdef ENABLE_16BIT
+	_mouseData = (byte *)malloc(w * h * 2);
+	memcpy(_mouseData, buf, w * h * 2);
+#else
 	_mouseData = (byte *)malloc(w * h);
 	memcpy(_mouseData, buf, w * h);
+#endif
 	blitCursor();
 }
 
@@ -1481,12 +1486,24 @@
 	for (i = 0; i < h; i++) {
 		for (j = 0; j < w; j++) {
 			color = *srcPtr;
+#ifdef ENABLE_16BIT
 			if (color != _mouseKeyColor) {	// transparent, don't draw
+				int8 r = ((*(uint16 *)srcPtr >> 10) & 0x1F) << 3;
+				int8 g = ((*(uint16 *)srcPtr >> 5) & 0x1F) << 3;
+				int8 b = (*(uint16 *)srcPtr & 0x1F) << 3;
 				*(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format,
+					r, g, b);
+			}
+			dstPtr += 2;
+			srcPtr += 2;
+#else
+			if (color != _mouseKeyColor) {	// transparent, don't draw
+				*(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format,
 					palette[color].r, palette[color].g, palette[color].b);
 			}
 			dstPtr += 2;
 			srcPtr++;
+#endif
 		}
 		dstPtr += _mouseOrigSurface->pitch - w * 2;
 	}

Modified: scummvm/branches/gsoc2009-16bit/engines/scumm/costume.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/engines/scumm/costume.cpp	2009-06-05 04:28:07 UTC (rev 41190)
+++ scummvm/branches/gsoc2009-16bit/engines/scumm/costume.cpp	2009-06-05 06:41:04 UTC (rev 41191)
@@ -876,7 +876,7 @@
 
 void ClassicCostumeRenderer::setPalette(uint16 *palette) {
 	int i;
-	byte color;
+	byte color = 0;
 
 	if (_loaded._format == 0x57) {
 		for (i = 0; i < 13; i++)

Modified: scummvm/branches/gsoc2009-16bit/engines/scumm/cursor.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/engines/scumm/cursor.cpp	2009-06-05 04:28:07 UTC (rev 41190)
+++ scummvm/branches/gsoc2009-16bit/engines/scumm/cursor.cpp	2009-06-05 06:41:04 UTC (rev 41191)
@@ -111,7 +111,13 @@
 }
 
 void ScummEngine::updateCursor() {
-	const int transColor = (_game.heversion >= 80) ? 5 : 255;
+	//HACK Put the 16-bit mapped color, and
+	//hope no other palette entry shares it
+	int transColor = (_game.heversion >= 80) ? 5 : 255;
+	if (_game.features & GF_16BIT_COLOR && _hePalettes) 
+		transColor = READ_LE_UINT16(_hePalettes + 2048 + transColor * 2);
+	else
+		transColor = 0;
 	CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height,
 							_cursor.hotspotX, _cursor.hotspotY,
 							(_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor),
@@ -138,7 +144,7 @@
 	uint size;
 	byte *dst;
 
-	size = width * height;
+	size = width * height * _bitDepth;
 	if (size > sizeof(_grabbedCursor))
 		error("grabCursor: grabbed cursor too big");
 
@@ -148,8 +154,8 @@
 
 	dst = _grabbedCursor;
 	for (; height; height--) {
-		memcpy(dst, ptr, width);
-		dst += width;
+		memcpy(dst, ptr, width * _bitDepth);
+		dst += width * _bitDepth;
 		ptr += pitch;
 	}
 

Modified: scummvm/branches/gsoc2009-16bit/engines/scumm/he/wiz_he.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/engines/scumm/he/wiz_he.cpp	2009-06-05 04:28:07 UTC (rev 41190)
+++ scummvm/branches/gsoc2009-16bit/engines/scumm/he/wiz_he.cpp	2009-06-05 06:41:04 UTC (rev 41191)
@@ -1800,14 +1800,12 @@
 	}
 
 	const Common::Rect *r = NULL;
-	_vm->_bitDepth = 1;
 	uint8 *cursor = drawWizImage(resId, 0, 0, 0, 0, 0, 0, r, kWIFBlitToMemBuffer, 0, _vm->getHEPaletteSlot(palette));
-	_vm->_bitDepth = (_vm->_game.features & GF_16BIT_COLOR) ? 2 : 1;
 
 	int32 cw, ch;
 	getWizImageDim(resId, 0, cw, ch);
 	_vm->setCursorHotspot(x, y);
-	_vm->setCursorFromBuffer(cursor, cw, ch, cw);
+	_vm->setCursorFromBuffer(cursor, cw, ch, cw * _vm->_bitDepth);
 
 	// Since we set up cursor palette for default cursor, disable it now
 	CursorMan.disableCursorPalette(true);

Modified: scummvm/branches/gsoc2009-16bit/engines/scumm/scumm.h
===================================================================
--- scummvm/branches/gsoc2009-16bit/engines/scumm/scumm.h	2009-06-05 04:28:07 UTC (rev 41190)
+++ scummvm/branches/gsoc2009-16bit/engines/scumm/scumm.h	2009-06-05 06:41:04 UTC (rev 41191)
@@ -974,7 +974,10 @@
 		byte animate, animateIndex;
 		int8 state;
 	} _cursor;
-	byte _grabbedCursor[8192];
+
+	// HACK Double the array size to handle 16-bit images.
+	// this should be dynamically allocated based on game depth instead.
+	byte _grabbedCursor[16384]; 
 	byte _currentCursor;
 
 	byte _newEffect, _switchRoomEffect2, _switchRoomEffect;

Modified: scummvm/branches/gsoc2009-16bit/graphics/cursorman.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/graphics/cursorman.cpp	2009-06-05 04:28:07 UTC (rev 41190)
+++ scummvm/branches/gsoc2009-16bit/graphics/cursorman.cpp	2009-06-05 06:41:04 UTC (rev 41191)
@@ -108,7 +108,11 @@
 	}
 
 	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;


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