[Scummvm-cvs-logs] scummvm master -> 44ad7d45baa628e59105ecf3a1977b369b40c395

clone2727 clone2727 at gmail.com
Fri May 6 04:42:57 CEST 2011


This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
4a3d94a60e GRAPHICS: Add a new MacCursor class for handling CURS/crsr cursors
0f0ae4576e SCI: Use new MacCursor code instead of convertCrsrCursor()
1f39e0b6c6 MOHAWK: Use new MacCursor code instead of convertCrsrCursor()
04dd4cabdf SCUMM: Use new MacCursor code instead of convertCrsrCursor()
44ad7d45ba COMMON: Remove convertCrsrCursor()


Commit: 4a3d94a60e74b9f1c2d48d3d739928cf9feef2c7
    https://github.com/scummvm/scummvm/commit/4a3d94a60e74b9f1c2d48d3d739928cf9feef2c7
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-05-05T16:26:44-07:00

Commit Message:
GRAPHICS: Add a new MacCursor class for handling CURS/crsr cursors

Changed paths:
  A graphics/maccursor.cpp
  A graphics/maccursor.h
    graphics/module.mk



diff --git a/graphics/maccursor.cpp b/graphics/maccursor.cpp
new file mode 100644
index 0000000..e086e22
--- /dev/null
+++ b/graphics/maccursor.cpp
@@ -0,0 +1,185 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/textconsole.h"
+
+#include "graphics/maccursor.h"
+
+namespace Graphics {
+
+MacCursor::MacCursor() {
+	_surface = 0;
+	memset(_palette, 0, 256 * 3);
+
+	_hotspotX = 0;
+	_hotspotY = 0;
+}
+
+MacCursor::~MacCursor() {
+	clear();
+}
+
+void MacCursor::clear() {
+	delete[] _surface; _surface = 0;
+	memset(_palette, 0, 256 * 3);
+}
+
+bool MacCursor::readFromStream(Common::SeekableReadStream &stream, bool forceMonochrome) {
+	clear();
+
+	// Older Mac CURS monochrome cursors had a set size
+	// All crsr cursors are larger than this
+	if (stream.size() == 32 * 2 + 4)
+		return readFromCURS(stream);
+
+	return readFromCRSR(stream, forceMonochrome);
+}
+
+bool MacCursor::readFromCURS(Common::SeekableReadStream &stream) {
+	// Grab B/W icon data
+	_surface = new byte[16 * 16];
+	for (int i = 0; i < 32; i++) {
+		byte imageByte = stream.readByte();
+		for (int b = 0; b < 8; b++)
+			_surface[i * 8 + b] = (byte)((imageByte & (0x80 >> b)) > 0 ? 0 : 1);
+	}
+
+	// Apply mask data
+	for (int i = 0; i < 32; i++) {
+		byte imageByte = stream.readByte();
+		for (int b = 0; b < 8; b++)
+			if ((imageByte & (0x80 >> b)) == 0)
+				_surface[i * 8 + b] = 0xff;
+	}
+
+	_hotspotY = stream.readUint16BE();
+	_hotspotX = stream.readUint16BE();
+
+	// Setup a basic palette
+	_palette[1 * 3 + 0] = 0xff;
+	_palette[1 * 3 + 1] = 0xff;
+	_palette[1 * 3 + 2] = 0xff;
+
+	return !stream.eos();
+}
+
+bool MacCursor::readFromCRSR(Common::SeekableReadStream &stream, bool forceMonochrome) {
+	stream.readUint16BE(); // type
+	stream.readUint32BE(); // offset to pixel map
+	stream.readUint32BE(); // offset to pixel data
+	stream.readUint32BE(); // expanded cursor data
+	stream.readUint16BE(); // expanded data depth
+	stream.readUint32BE(); // reserved
+
+	// Read the B/W data first
+	if (!readFromCURS(stream))
+		return false;
+
+	// Use b/w cursor on backends which don't support cursor palettes
+	if (forceMonochrome)
+		return true;
+
+	stream.readUint32BE(); // reserved
+	stream.readUint32BE(); // cursorID
+
+	// Color version of cursor
+	stream.readUint32BE(); // baseAddr
+
+	// Keep only lowbyte for now
+	stream.readByte();
+	int iconRowBytes = stream.readByte();
+
+	if (!iconRowBytes)
+		return false;
+
+	int iconBounds[4];
+	iconBounds[0] = stream.readUint16BE();
+	iconBounds[1] = stream.readUint16BE();
+	iconBounds[2] = stream.readUint16BE();
+	iconBounds[3] = stream.readUint16BE();
+
+	stream.readUint16BE(); // pmVersion
+	stream.readUint16BE(); // packType
+	stream.readUint32BE(); // packSize
+
+	stream.readUint32BE(); // hRes
+	stream.readUint32BE(); // vRes
+
+	stream.readUint16BE(); // pixelType
+	stream.readUint16BE(); // pixelSize
+	stream.readUint16BE(); // cmpCount
+	stream.readUint16BE(); // cmpSize
+
+	stream.readUint32BE(); // planeByte
+	stream.readUint32BE(); // pmTable
+	stream.readUint32BE(); // reserved
+
+	// Pixel data for cursor
+	int iconDataSize =  iconRowBytes * (iconBounds[3] - iconBounds[1]);
+	byte *iconData = new byte[iconDataSize];
+
+	if (!iconData)
+		error("Cannot allocate Mac color cursor iconData");
+
+	stream.read(iconData, iconDataSize);
+
+	// Color table
+	stream.readUint32BE(); // ctSeed
+	stream.readUint16BE(); // ctFlag
+	uint16 ctSize = stream.readUint16BE() + 1;
+
+	// Read just high byte of 16-bit color
+	for (int c = 0; c < ctSize; c++) {
+		stream.readUint16BE();
+		_palette[c * 3 + 0] = stream.readUint16BE() >> 8;
+		_palette[c * 3 + 1] = stream.readUint16BE() >> 8;
+		_palette[c * 3 + 2] = stream.readUint16BE() >> 8;
+	}
+
+	int pixelsPerByte = (iconBounds[2] - iconBounds[0]) / iconRowBytes;
+	int bpp           = 8 / pixelsPerByte;
+
+	// build a mask to make sure the pixels are properly shifted out
+	int bitmask = 0;
+	for (int m = 0; m < bpp; m++) {
+		bitmask <<= 1;
+		bitmask  |= 1;
+	}
+
+	// Extract pixels from bytes
+	for (int j = 0; j < iconDataSize; j++) {
+		for (int b = 0; b < pixelsPerByte; b++) {
+			int idx = j * pixelsPerByte + (pixelsPerByte - 1 - b);
+
+			if (_surface[idx] != 0xff) // if mask is not there
+				_surface[idx] = (byte)((iconData[j] >> (b * bpp)) & bitmask);
+		}
+	}
+
+	delete[] iconData;
+	return stream.pos() == stream.size();
+}
+
+} // End of namespace Common
diff --git a/graphics/maccursor.h b/graphics/maccursor.h
new file mode 100644
index 0000000..fac78d9
--- /dev/null
+++ b/graphics/maccursor.h
@@ -0,0 +1,83 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+/**
+ * @file
+ * Macintosh cursor decoding used in engines:
+ * - mohawk
+ * - sci
+ * - scumm
+ */
+
+#include "common/stream.h"
+
+#ifndef GRAPHICS_MACCURSOR_H
+#define GRAPHICS_MACCURSOR_H
+
+namespace Graphics {
+
+/**
+ * A Mac crsr or CURS cursor
+ * TODO: Think about making a base class with WinCursor
+ */
+class MacCursor {
+public:
+	MacCursor();
+	~MacCursor();
+
+	/** Return the cursor's width. */
+	uint16 getWidth() const { return 16; }
+	/** Return the cursor's height. */
+	uint16 getHeight() const { return 16; }
+	/** Return the cursor's hotspot's x coordinate. */
+	uint16 getHotspotX() const { return _hotspotX; }
+	/** Return the cursor's hotspot's y coordinate. */
+	uint16 getHotspotY() const { return _hotspotY; }
+	/** Return the cursor's transparent key. */
+	byte getKeyColor() const { return 0xFF; }
+
+	const byte *getSurface() const { return _surface; }
+	const byte *getPalette() const { return _palette; }
+
+	/** Read the cursor's data out of a stream. */
+	bool readFromStream(Common::SeekableReadStream &stream, bool forceMonochrome = false);
+
+private:
+	bool readFromCURS(Common::SeekableReadStream &stream);
+	bool readFromCRSR(Common::SeekableReadStream &stream, bool forceMonochrome);
+
+	byte *_surface;
+	byte _palette[256 * 3];
+
+	uint16 _hotspotX; ///< The cursor's hotspot's x coordinate.
+	uint16 _hotspotY; ///< The cursor's hotspot's y coordinate.
+
+	/** Clear the cursor. */
+	void clear();
+};
+
+} // End of namespace Graphics
+
+#endif
diff --git a/graphics/module.mk b/graphics/module.mk
index cb3a07e..59621dc 100644
--- a/graphics/module.mk
+++ b/graphics/module.mk
@@ -14,6 +14,7 @@ MODULE_OBJS := \
 	iff.o \
 	imagedec.o \
 	jpeg.o \
+	maccursor.o \
 	pict.o \
 	png.o \
 	primitives.o \


Commit: 0f0ae4576e40ae7a2a7c6f23f12c2d56b52a9b75
    https://github.com/scummvm/scummvm/commit/0f0ae4576e40ae7a2a7c6f23f12c2d56b52a9b75
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-05-05T16:27:28-07:00

Commit Message:
SCI: Use new MacCursor code instead of convertCrsrCursor()

Changed paths:
    engines/sci/graphics/cursor.cpp



diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp
index 3b95a5c..d4d7dcf 100644
--- a/engines/sci/graphics/cursor.cpp
+++ b/engines/sci/graphics/cursor.cpp
@@ -25,11 +25,11 @@
 
 #include "common/config-manager.h"
 #include "common/events.h"
-#include "common/macresman.h"
 #include "common/memstream.h"
 #include "common/system.h"
 #include "common/util.h"
 #include "graphics/cursorman.h"
+#include "graphics/maccursor.h"
 
 #include "sci/sci.h"
 #include "sci/event.h"
@@ -473,49 +473,19 @@ void GfxCursor::kernelSetMacCursor(GuiResourceId viewNum, int loopNum, int celNu
 
 	assert(resource);
 
-	if (resource->size == 32 * 2 + 4) {
-		// Mac CURS cursor
-		// See http://developer.apple.com/legacy/mac/library/documentation/mac/QuickDraw/QuickDraw-402.html
-		// for more information.
-		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 ? 1 : 2);
-		}
-
-		// 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] = 0; // Doesn't matter, just is transparent
-		}
-
-		uint16 hotspotY = READ_BE_UINT16(data);
-		uint16 hotspotX = READ_BE_UINT16(data + 2);
-
-		static const byte cursorPalette[] = { 0x00, 0x00, 0x00, 0xff, 0xff, 0xff };
-
-		CursorMan.replaceCursor(cursorBitmap, 16, 16, hotspotX, hotspotY, 0);
-		CursorMan.replaceCursorPalette(cursorPalette, 1, 2);
+	Common::MemoryReadStream resStream(resource->data, resource->size);
+	Graphics::MacCursor *macCursor = new Graphics::MacCursor();
 
-		delete[] cursorBitmap;
-	} else {
-		// Mac crsr cursor
-		byte *cursorBitmap, *palette;
-		int width, height, hotspotX, hotspotY, palSize, keycolor;
-		Common::MemoryReadStream resStream(resource->data, resource->size);
-		Common::MacResManager::convertCrsrCursor(&resStream, &cursorBitmap, width, height, hotspotX, hotspotY, keycolor, true, &palette, palSize);
-		CursorMan.replaceCursor(cursorBitmap, width, height, hotspotX, hotspotY, keycolor);
-		CursorMan.replaceCursorPalette(palette, 0, palSize);
-		delete[] cursorBitmap;
-		delete[] palette;
+	if (!macCursor->readFromStream(resStream)) {
+		warning("Failed to load Mac cursor %d", viewNum);
+		return;
 	}
 
+	CursorMan.replaceCursor(macCursor->getSurface(), macCursor->getWidth(), macCursor->getHeight(),
+			macCursor->getHotspotX(), macCursor->getHotspotY(), macCursor->getKeyColor());
+	CursorMan.replaceCursorPalette(macCursor->getPalette(), 0, 256);
+
+	delete macCursor;
 	kernelShow();
 }
 


Commit: 1f39e0b6c676be72a4171964be770faf0411f9ba
    https://github.com/scummvm/scummvm/commit/1f39e0b6c676be72a4171964be770faf0411f9ba
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-05-05T16:35:31-07:00

Commit Message:
MOHAWK: Use new MacCursor code instead of convertCrsrCursor()

Changed paths:
    engines/mohawk/cursors.cpp
    engines/mohawk/cursors.h



diff --git a/engines/mohawk/cursors.cpp b/engines/mohawk/cursors.cpp
index 66669e3..3327860 100644
--- a/engines/mohawk/cursors.cpp
+++ b/engines/mohawk/cursors.cpp
@@ -29,9 +29,11 @@
 
 #include "common/macresman.h"
 #include "common/system.h"
+#include "common/textconsole.h"
 #include "common/winexe_ne.h"
 #include "common/winexe_pe.h"
 #include "graphics/cursorman.h"
+#include "graphics/maccursor.h"
 #include "graphics/wincursor.h"
 
 #ifdef ENABLE_MYST
@@ -41,11 +43,6 @@
 
 namespace Mohawk {
 
-static const byte s_bwPalette[] = {
-	0x00, 0x00, 0x00,	// Black
-	0xFF, 0xFF, 0xFF	// White
-};
-
 void CursorManager::showCursor() {
 	CursorMan.showMouse(true);
 }
@@ -78,8 +75,13 @@ void CursorManager::setDefaultCursor() {
 		0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0
 	};
 
+	static const byte bwPalette[] = {
+		0x00, 0x00, 0x00,	// Black
+		0xFF, 0xFF, 0xFF	// White
+	};
+
 	CursorMan.replaceCursor(defaultCursor, 12, 20, 0, 0, 0);
-	CursorMan.replaceCursorPalette(s_bwPalette, 1, 2);
+	CursorMan.replaceCursorPalette(bwPalette, 1, 2);
 }
 
 void CursorManager::setCursor(uint16 id) {
@@ -87,35 +89,24 @@ void CursorManager::setCursor(uint16 id) {
 	setDefaultCursor();
 }
 
-void CursorManager::setMacXorCursor(Common::SeekableReadStream *stream) {
+void CursorManager::setMacCursor(Common::SeekableReadStream *stream) {
 	assert(stream);
 
-	byte cursorBitmap[16 * 16];
+	Graphics::MacCursor *macCursor = new Graphics::MacCursor();
 
-	// Get black and white data
-	for (int i = 0; i < 32; i++) {
-		byte imageByte = stream->readByte();
-		for (int b = 0; b < 8; b++)
-			cursorBitmap[i * 8 + b] = (imageByte & (0x80 >> b)) ? 1 : 2;
-	}
+	if (!macCursor->readFromStream(*stream))
+		error("Could not parse Mac cursor");
 
-	// Apply mask data
-	for (int i = 0; i < 32; i++) {
-		byte imageByte = stream->readByte();
-		for (int b = 0; b < 8; b++)
-			if ((imageByte & (0x80 >> b)) == 0)
-				cursorBitmap[i * 8 + b] = 0;
-	}
-
-	uint16 hotspotY = stream->readUint16BE();
-	uint16 hotspotX = stream->readUint16BE();
+	CursorMan.replaceCursor(macCursor->getSurface(), macCursor->getWidth(), macCursor->getHeight(),
+			macCursor->getHotspotX(), macCursor->getHotspotY(), macCursor->getKeyColor());
+	CursorMan.replaceCursorPalette(macCursor->getPalette(), 0, 256);
 
-	CursorMan.replaceCursor(cursorBitmap, 16, 16, hotspotX, hotspotY, 0);
-	CursorMan.replaceCursorPalette(s_bwPalette, 1, 2);
+	delete macCursor;
+	delete stream;
 }
 
 void DefaultCursorManager::setCursor(uint16 id) {
-	setMacXorCursor(_vm->getResource(_tag, id));
+	setMacCursor(_vm->getResource(_tag, id));
 }
 
 #ifdef ENABLE_MYST
@@ -223,26 +214,12 @@ void MacCursorManager::setCursor(uint16 id) {
 	// Try a color cursor first
 	Common::SeekableReadStream *stream = _resFork->getResource(MKTAG('c','r','s','r'), id);
 
-	if (stream) {
-		byte *cursor, *palette;
-		int width, height, hotspotX, hotspotY, keyColor, palSize;
-
-		_resFork->convertCrsrCursor(stream, &cursor, width, height, hotspotX, hotspotY, keyColor, true, &palette, palSize);
-
-		CursorMan.replaceCursor(cursor, width, height, hotspotX, hotspotY, keyColor);
-		CursorMan.replaceCursorPalette(palette, 0, palSize);
-
-		delete[] cursor;
-		delete[] palette;
-		delete stream;
-		return;
-	}
-
-	// Fall back to b&w cursors
-	stream = _resFork->getResource(MKTAG('C','U','R','S'), id);
+	// Fall back to monochrome cursors
+	if (!stream)
+		stream = _resFork->getResource(MKTAG('C','U','R','S'), id);
 
 	if (stream) {
-		setMacXorCursor(stream);
+		setMacCursor(stream);
 		delete stream;
 	} else {
 		setDefaultCursor();
@@ -265,7 +242,7 @@ LivingBooksCursorManager_v2::~LivingBooksCursorManager_v2() {
 
 void LivingBooksCursorManager_v2::setCursor(uint16 id) {
 	if (_sysArchive && _sysArchive->hasResource(ID_TCUR, id)) {
-		setMacXorCursor(_sysArchive->getResource(ID_TCUR, id));
+		setMacCursor(_sysArchive->getResource(ID_TCUR, id));
 	} else {
 		// TODO: Handle generated cursors
 	}
diff --git a/engines/mohawk/cursors.h b/engines/mohawk/cursors.h
index 1fb8b35..ba9700c 100644
--- a/engines/mohawk/cursors.h
+++ b/engines/mohawk/cursors.h
@@ -63,8 +63,8 @@ public:
 	virtual bool hasSource() const { return false; }
 
 protected:
-	// Set a Mac XOR/AND map cursor to the screen
-	void setMacXorCursor(Common::SeekableReadStream *stream);
+	// Set a Mac CURS/crsr cursor to the screen
+	void setMacCursor(Common::SeekableReadStream *stream);
 };
 
 // The default Mohawk cursor manager


Commit: 04dd4cabdf9ff9749023bde18f4871302f8f6b05
    https://github.com/scummvm/scummvm/commit/04dd4cabdf9ff9749023bde18f4871302f8f6b05
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-05-05T16:46:33-07:00

Commit Message:
SCUMM: Use new MacCursor code instead of convertCrsrCursor()

Changed paths:
    engines/scumm/he/resource_he.cpp



diff --git a/engines/scumm/he/resource_he.cpp b/engines/scumm/he/resource_he.cpp
index ecb094f..552c420 100644
--- a/engines/scumm/he/resource_he.cpp
+++ b/engines/scumm/he/resource_he.cpp
@@ -32,6 +32,7 @@
 
 #include "audio/decoders/wave.h"
 #include "graphics/cursorman.h"
+#include "graphics/maccursor.h"
 #include "graphics/wincursor.h"
 
 #include "common/archive.h"
@@ -172,11 +173,49 @@ bool MacResExtractor::extractResource(int id, CachedCursor *cc) {
 	if (!dataStream)
 		return false;
 
-	int keyColor; // HACK: key color is ignored
-	_resMgr->convertCrsrCursor(dataStream, &cc->bitmap, cc->width, cc->height, cc->hotspotX, cc->hotspotY,
-						keyColor, _vm->_system->hasFeature(OSystem::kFeatureCursorHasPalette),
-						&cc->palette, cc->palSize);
+	// If we don't have a cursor palette, force monochrome cursors
+	bool forceMonochrome = !_vm->_system->hasFeature(OSystem::kFeatureCursorHasPalette);
 
+	Graphics::MacCursor *macCursor = new Graphics::MacCursor();
+
+	if (!macCursor->readFromStream(*dataStream, forceMonochrome)) {
+		delete dataStream;
+		delete macCursor;
+		return false;
+	}
+
+	cc->bitmap = new byte[macCursor->getWidth() * macCursor->getHeight()];
+	cc->width = macCursor->getWidth();
+	cc->height = macCursor->getHeight();
+	cc->hotspotX = macCursor->getHotspotX();
+	cc->hotspotY = macCursor->getHotspotY();
+
+	if (forceMonochrome) {
+		// Convert to the SCUMM palette
+		const byte *srcBitmap = macCursor->getSurface();
+
+		for (int i = 0; i < macCursor->getWidth() * macCursor->getHeight(); i++) {
+			if (srcBitmap[i] == macCursor->getKeyColor()) // Transparent
+				cc->bitmap[i] = 255;
+			else if (srcBitmap[i] == 0)                // Black
+				cc->bitmap[i] = 253;
+			else                                       // White
+				cc->bitmap[i] = 254;
+		}
+	} else {
+		// Copy data and palette
+
+		// Sanity check. This code assumes that the key color is the same
+		assert(macCursor->getKeyColor() == 255);
+
+		memcpy(cc->bitmap, macCursor->getSurface(), macCursor->getWidth() * macCursor->getHeight());
+
+		cc->palette = new byte[256 * 3];
+		cc->palSize = 256;
+		memcpy(cc->palette, macCursor->getPalette(), 256 * 3);
+	}
+
+	delete macCursor;
 	delete dataStream;
 	return true;
 }


Commit: 44ad7d45baa628e59105ecf3a1977b369b40c395
    https://github.com/scummvm/scummvm/commit/44ad7d45baa628e59105ecf3a1977b369b40c395
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-05-05T16:48:57-07:00

Commit Message:
COMMON: Remove convertCrsrCursor()

Graphics::MacCursor is its replacement

Changed paths:
    common/macresman.cpp
    common/macresman.h



diff --git a/common/macresman.cpp b/common/macresman.cpp
index 489f8f9..0ecb430 100644
--- a/common/macresman.cpp
+++ b/common/macresman.cpp
@@ -550,132 +550,4 @@ void MacResManager::readMap() {
 	}
 }
 
-void MacResManager::convertCrsrCursor(SeekableReadStream *data, byte **cursor, int &w, int &h, int &hotspotX,
-			int &hotspotY, int &keycolor, bool colored, byte **palette, int &palSize) {
-
-	data->readUint16BE(); // type
-	data->readUint32BE(); // offset to pixel map
-	data->readUint32BE(); // offset to pixel data
-	data->readUint32BE(); // expanded cursor data
-	data->readUint16BE(); // expanded data depth
-	data->readUint32BE(); // reserved
-
-	// Grab B/W icon data
-	*cursor = new byte[16 * 16];
-	for (int i = 0; i < 32; i++) {
-		byte imageByte = data->readByte();
-		for (int b = 0; b < 8; b++)
-			cursor[0][i * 8 + b] = (byte)((imageByte & (0x80 >> b)) > 0 ? 0x0F : 0x00);
-	}
-
-	// Apply mask data
-	for (int i = 0; i < 32; i++) {
-		byte imageByte = data->readByte();
-		for (int b = 0; b < 8; b++)
-			if ((imageByte & (0x80 >> b)) == 0)
-				cursor[0][i * 8 + b] = 0xff;
-	}
-
-	hotspotY = data->readUint16BE();
-	hotspotX = data->readUint16BE();
-	w = h = 16;
-	keycolor = 0xff;
-
-	// Use b/w cursor on backends which don't support cursor palettes
-	if (!colored)
-		return;
-
-	data->readUint32BE(); // reserved
-	data->readUint32BE(); // cursorID
-
-	// Color version of cursor
-	data->readUint32BE(); // baseAddr
-
-	// Keep only lowbyte for now
-	data->readByte();
-	int iconRowBytes = data->readByte();
-
-	if (!iconRowBytes)
-		return;
-
-	int iconBounds[4];
-	iconBounds[0] = data->readUint16BE();
-	iconBounds[1] = data->readUint16BE();
-	iconBounds[2] = data->readUint16BE();
-	iconBounds[3] = data->readUint16BE();
-
-	data->readUint16BE(); // pmVersion
-	data->readUint16BE(); // packType
-	data->readUint32BE(); // packSize
-
-	data->readUint32BE(); // hRes
-	data->readUint32BE(); // vRes
-
-	data->readUint16BE(); // pixelType
-	data->readUint16BE(); // pixelSize
-	data->readUint16BE(); // cmpCount
-	data->readUint16BE(); // cmpSize
-
-	data->readUint32BE(); // planeByte
-	data->readUint32BE(); // pmTable
-	data->readUint32BE(); // reserved
-
-	// Pixel data for cursor
-	int iconDataSize =  iconRowBytes * (iconBounds[3] - iconBounds[1]);
-	byte *iconData = new byte[iconDataSize];
-
-	if (!iconData) {
-		error("Cannot allocate iconData in macresman.cpp");
-	}
-
-	data->read(iconData, iconDataSize);
-
-	// Color table
-	data->readUint32BE(); // ctSeed
-	data->readUint16BE(); // ctFlag
-	uint16 ctSize = data->readUint16BE() + 1;
-
-	*palette = new byte[ctSize * 3];
-
-	// Read just high byte of 16-bit color
-	for (int c = 0; c < ctSize; c++) {
-		// We just use indices 0..ctSize, so ignore color ID
-		data->readUint16BE(); // colorID[c]
-
-		palette[0][c * 3 + 0] = data->readByte();
-		data->readByte();
-
-		palette[0][c * 3 + 1] = data->readByte();
-		data->readByte();
-
-		palette[0][c * 3 + 2] = data->readByte();
-		data->readByte();
-	}
-
-	palSize = ctSize;
-
-	int pixelsPerByte = (iconBounds[2] - iconBounds[0]) / iconRowBytes;
-	int bpp           = 8 / pixelsPerByte;
-
-	// build a mask to make sure the pixels are properly shifted out
-	int bitmask = 0;
-	for (int m = 0; m < bpp; m++) {
-		bitmask <<= 1;
-		bitmask  |= 1;
-	}
-
-	// Extract pixels from bytes
-	for (int j = 0; j < iconDataSize; j++)
-		for (int b = 0; b < pixelsPerByte; b++) {
-			int idx = j * pixelsPerByte + (pixelsPerByte - 1 - b);
-
-			if (cursor[0][idx] != 0xff) // if mask is not there
-				cursor[0][idx] = (byte)((iconData[j] >> (b * bpp)) & bitmask);
-		}
-
-	delete[] iconData;
-
-	assert(data->size() - data->pos() == 0);
-}
-
 } // End of namespace Common
diff --git a/common/macresman.h b/common/macresman.h
index fdb3ce4..f588d8f 100644
--- a/common/macresman.h
+++ b/common/macresman.h
@@ -152,25 +152,6 @@ public:
 	String getBaseFileName() const { return _baseFileName; }
 
 	/**
-	 * Convert cursor from crsr format to format suitable for feeding to CursorMan
-	 * @param data Pointer to the cursor datax
-	 * @param cursor Pointer to memory where result cursor will be stored. The memory
-	 *               block will be malloc()'ed
-	 * @param w Pointer to int where the cursor width will be stored
-	 * @param h Pointer to int where the cursor height will be stored
-	 * @param hotspotX Storage for cursor hotspot X coordinate
-	 * @param hotspotY Storage for cursor hotspot Y coordinate
-	 * @param keycolor Pointer to int where the transpared color value will be stored
-	 * @param colored If set to true then colored cursor will be returned (if any).
-	 *                b/w version will be used otherwise
-	 * @param palette Pointer to memory where the cursor palette will be stored.
-	 *                The memory will be malloc()'ed
-	 * @param palSize Pointer to integer where the palette size will be stored.
-	 */
-	static void convertCrsrCursor(SeekableReadStream *data, byte **cursor, int &w, int &h, int &hotspotX,
-			int &hotspotY, int &keycolor, bool colored, byte **palette, int &palSize);
-
-	/**
 	 * Return list of resource IDs with specified type ID
 	 */
 	MacResIDArray getResIDArray(uint32 typeID);






More information about the Scummvm-git-logs mailing list