diff options
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/maccursor.cpp | 24 | ||||
-rw-r--r-- | graphics/maccursor.h | 6 |
2 files changed, 18 insertions, 12 deletions
diff --git a/graphics/maccursor.cpp b/graphics/maccursor.cpp index a66a9104f3..75669e8ebf 100644 --- a/graphics/maccursor.cpp +++ b/graphics/maccursor.cpp @@ -43,18 +43,18 @@ void MacCursor::clear() { memset(_palette, 0, 256 * 3); } -bool MacCursor::readFromStream(Common::SeekableReadStream &stream, bool forceMonochrome) { +bool MacCursor::readFromStream(Common::SeekableReadStream &stream, bool forceMonochrome, byte monochromeInvertedPixelColor) { 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 readFromCURS(stream, monochromeInvertedPixelColor); - return readFromCRSR(stream, forceMonochrome); + return readFromCRSR(stream, forceMonochrome, monochromeInvertedPixelColor); } -bool MacCursor::readFromCURS(Common::SeekableReadStream &stream) { +bool MacCursor::readFromCURS(Common::SeekableReadStream &stream, byte monochromeInvertedPixelColor) { // Grab B/W icon data _surface = new byte[16 * 16]; for (int i = 0; i < 32; i++) { @@ -66,9 +66,15 @@ bool MacCursor::readFromCURS(Common::SeekableReadStream &stream) { // 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; + for (int b = 0; b < 8; b++) { + if ((imageByte & (0x80 >> b)) == 0) { + // if an image bit is set outside the mask then the destination pixel + // would have been inverted on macintosh, otherwise it's transparent. + // we don't currently implement this inversion effect so instead we + // use the optional color provided by the caller for these pixels. + _surface[i * 8 + b] = _surface[i * 8 + b] ? 0xff : monochromeInvertedPixelColor; + } + } } _hotspotY = stream.readUint16BE(); @@ -82,7 +88,7 @@ bool MacCursor::readFromCURS(Common::SeekableReadStream &stream) { return !stream.eos(); } -bool MacCursor::readFromCRSR(Common::SeekableReadStream &stream, bool forceMonochrome) { +bool MacCursor::readFromCRSR(Common::SeekableReadStream &stream, bool forceMonochrome, byte monochromeInvertedPixelColor) { stream.readUint16BE(); // type stream.readUint32BE(); // offset to pixel map stream.readUint32BE(); // offset to pixel data @@ -91,7 +97,7 @@ bool MacCursor::readFromCRSR(Common::SeekableReadStream &stream, bool forceMonoc stream.readUint32BE(); // reserved // Read the B/W data first - if (!readFromCURS(stream)) + if (!readFromCURS(stream, monochromeInvertedPixelColor)) return false; // Use b/w cursor on backends which don't support cursor palettes diff --git a/graphics/maccursor.h b/graphics/maccursor.h index 1ae38f8aa9..a4da7cb46f 100644 --- a/graphics/maccursor.h +++ b/graphics/maccursor.h @@ -63,11 +63,11 @@ public: uint16 getPaletteCount() const { return 256; } /** Read the cursor's data out of a stream. */ - bool readFromStream(Common::SeekableReadStream &stream, bool forceMonochrome = false); + bool readFromStream(Common::SeekableReadStream &stream, bool forceMonochrome = false, byte monochromeInvertedPixelColor = 0xff); private: - bool readFromCURS(Common::SeekableReadStream &stream); - bool readFromCRSR(Common::SeekableReadStream &stream, bool forceMonochrome); + bool readFromCURS(Common::SeekableReadStream &stream, byte monochromeInvertedPixelColor); + bool readFromCRSR(Common::SeekableReadStream &stream, bool forceMonochrome, byte monochromeInvertedPixelColor); byte *_surface; byte _palette[256 * 3]; |