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

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Sat Aug 14 06:21:09 CEST 2010


Revision: 52076
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52076&view=rev
Author:   mthreepwood
Date:     2010-08-14 04:21:09 +0000 (Sat, 14 Aug 2010)

Log Message:
-----------
SCI: Add support for Mac 'crsr' cursors used in SCI2+ games

Modified Paths:
--------------
    scummvm/trunk/engines/sci/graphics/cursor.cpp
    scummvm/trunk/engines/sci/resource.cpp

Modified: scummvm/trunk/engines/sci/graphics/cursor.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/cursor.cpp	2010-08-14 04:03:36 UTC (rev 52075)
+++ scummvm/trunk/engines/sci/graphics/cursor.cpp	2010-08-14 04:21:09 UTC (rev 52076)
@@ -23,10 +23,11 @@
  *
  */
 
-#include "graphics/cursorman.h"
-#include "common/util.h"
 #include "common/events.h"
+#include "common/macresman.h"
 #include "common/system.h"
+#include "common/util.h"
+#include "graphics/cursorman.h"
 
 #include "sci/sci.h"
 #include "sci/event.h"
@@ -206,7 +207,7 @@
 	// See http://developer.apple.com/legacy/mac/library/documentation/mac/QuickDraw/QuickDraw-402.html
 	// for more information.
 
-	// View 998 seems to be a fake resource used to call for the Mac CURS resources.
+	// View 998 seems to be a fake resource used to call for Mac cursor resources.
 	// For other resources, they're still in the views, so use them.
 	if (viewNum != 998) {
 		kernelSetView(viewNum, loopNum, celNum, hotspot);
@@ -214,43 +215,53 @@
 	}
 
 	// TODO: What about the 2000 resources? Inventory items? How to handle?
-	// TODO: What games does this work for? At least it does for KQ6.
-	// TODO: Stop asking rhetorical questions.
-	// TODO: It was fred all along!
+	// TODO: 1000 + celNum won't work for GK1
 
 	Resource *resource = _resMan->findResource(ResourceId(kResourceTypeCursor, 1000 + celNum), false);
 
 	if (!resource) {
-		warning("CURS %d not found", 1000 + celNum);
+		warning("Mac cursor %d not found", 1000 + celNum);
 		return;
 	}
 
 	assert(resource);
 
-	byte *cursorBitmap = new byte[16 * 16];
-	byte *data = resource->data;
+	if (resource->size == 32 * 2 + 4) {
+		// Mac CURS cursor
+		byte *cursorBitmap = new byte[16 * 16];
+		byte *data = resource->data;
 
-	// Get B&W data
-	for (byte i = 0; i < 32; i++) {
-		byte imageByte = *data++;
-		for (byte b = 0; b < 8; b++)
-			cursorBitmap[i * 8 + b] = (byte)((imageByte & (0x80 >> b)) > 0 ? 0x00 : 0xFF);
-	}
+		// Get B&W data
+		for (byte i = 0; i < 32; i++) {
+			byte imageByte = *data++;
+			for (byte b = 0; b < 8; b++)
+				cursorBitmap[i * 8 + b] = (byte)((imageByte & (0x80 >> b)) > 0 ? 0x00 : 0xFF);
+		}
 
-	// Apply mask data
-	for (byte i = 0; i < 32; i++) {
-		byte imageByte = *data++;
-		for (byte b = 0; b < 8; b++)
-			if ((imageByte & (0x80 >> b)) == 0)
-				cursorBitmap[i * 8 + b] = SCI_CURSOR_SCI0_TRANSPARENCYCOLOR; // Doesn't matter, just is transparent
-	}
+		// Apply mask data
+		for (byte i = 0; i < 32; i++) {
+			byte imageByte = *data++;
+			for (byte b = 0; b < 8; b++)
+				if ((imageByte & (0x80 >> b)) == 0)
+					cursorBitmap[i * 8 + b] = SCI_CURSOR_SCI0_TRANSPARENCYCOLOR; // Doesn't matter, just is transparent
+		}
 
-	uint16 hotspotX = READ_BE_UINT16(data);
-	uint16 hotspotY = READ_BE_UINT16(data + 2);
+		uint16 hotspotX = READ_BE_UINT16(data);
+		uint16 hotspotY = READ_BE_UINT16(data + 2);
 
-	CursorMan.replaceCursor(cursorBitmap, 16, 16, hotspotX, hotspotY, SCI_CURSOR_SCI0_TRANSPARENCYCOLOR);
+		CursorMan.replaceCursor(cursorBitmap, 16, 16, hotspotX, hotspotY, SCI_CURSOR_SCI0_TRANSPARENCYCOLOR);
 
-	delete[] cursorBitmap;
+		delete[] cursorBitmap;
+	} else {
+		// Mac crsr cursor
+		byte *cursorBitmap, *palette;
+		int width, height, hotspotX, hotspotY, palSize, keycolor;
+		Common::MacResManager::convertCrsrCursor(resource->data, resource->size, &cursorBitmap, &width, &height, &hotspotX, &hotspotY, &keycolor, true, &palette, &palSize);
+		CursorMan.replaceCursor(cursorBitmap, width, height, hotspotX, hotspotY, keycolor);
+		CursorMan.replaceCursorPalette(palette, 0, palSize);
+		free(cursorBitmap);
+		free(palette);
+	}
 
 	kernelShow();
 }

Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp	2010-08-14 04:03:36 UTC (rev 52075)
+++ scummvm/trunk/engines/sci/resource.cpp	2010-08-14 04:21:09 UTC (rev 52076)
@@ -365,8 +365,6 @@
 	return NULL;
 }
 
-static uint32 resTypeToMacTag(ResourceType type);
-
 void ResourceManager::loadResource(Resource *res) {
 	res->_source->loadResource(this, res);
 }
@@ -382,9 +380,15 @@
 	}
 }
 
+static Common::Array<uint32> resTypeToMacTags(ResourceType type);
+
 void MacResourceForkResourceSource::loadResource(ResourceManager *resMan, Resource *res) {
-	Common::SeekableReadStream *stream = _macResMan->getResource(resTypeToMacTag(res->getType()), res->getNumber());
+	Common::SeekableReadStream *stream = 0;
+	Common::Array<uint32> tagArray = resTypeToMacTags(res->getType());
 
+	for (uint32 i = 0; i < tagArray.size() && !stream; i++)
+		stream = _macResMan->getResource(tagArray[i], res->getNumber());
+
 	if (!stream)
 		error("Could not get Mac resource fork resource: %s %d", getResourceTypeName(res->getType()), res->getNumber());
 
@@ -1588,12 +1592,14 @@
 	{ MKID_BE('SYN '), kResourceTypeSync }
 };
 
-static uint32 resTypeToMacTag(ResourceType type) {
+static Common::Array<uint32> resTypeToMacTags(ResourceType type) {
+	Common::Array<uint32> tags;
+
 	for (uint32 i = 0; i < ARRAYSIZE(macResTagMap); i++)
 		if (macResTagMap[i].type == type)
-			return macResTagMap[i].tag;
+			tags.push_back(macResTagMap[i].tag);
 
-	return 0;
+	return tags;
 }
 
 void MacResourceForkResourceSource::scanSource(ResourceManager *resMan) {


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