diff options
author | sluicebox | 2019-08-20 18:54:24 -0700 |
---|---|---|
committer | Filippos Karapetis | 2019-08-21 14:13:26 +0300 |
commit | 60fcf993e7c19cf3c3c5e74c2dd447e2e2b2c4ac (patch) | |
tree | 1e7347bfa807b79f2eff2169a0ee273cb56d17f7 | |
parent | 83a479470ff467ced73ee97e2d5ed7203071050a (diff) | |
download | scummvm-rg350-60fcf993e7c19cf3c3c5e74c2dd447e2e2b2c4ac.tar.gz scummvm-rg350-60fcf993e7c19cf3c3c5e74c2dd447e2e2b2c4ac.tar.bz2 scummvm-rg350-60fcf993e7c19cf3c3c5e74c2dd447e2e2b2c4ac.zip |
GRAPHICS: Display Mac monochrome cursor inverted pixels
Bug #7050
-rw-r--r-- | engines/sci/graphics/cursor.cpp | 5 | ||||
-rw-r--r-- | graphics/maccursor.cpp | 24 | ||||
-rw-r--r-- | graphics/maccursor.h | 6 |
3 files changed, 22 insertions, 13 deletions
diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp index bcddd16083..c2d737b32b 100644 --- a/engines/sci/graphics/cursor.cpp +++ b/engines/sci/graphics/cursor.cpp @@ -508,7 +508,10 @@ void GfxCursor::kernelSetMacCursor(GuiResourceId viewNum, int loopNum, int celNu Common::MemoryReadStream resStream(resource->toStream()); Graphics::MacCursor *macCursor = new Graphics::MacCursor(); - if (!macCursor->readFromStream(resStream)) { + // use black for mac monochrome inverted pixels so that cursor + // features in FPFP and KQ6 Mac are displayed, bug #7050 + byte macMonochromeInvertedPixelColor = 0; + if (!macCursor->readFromStream(resStream, false, macMonochromeInvertedPixelColor)) { warning("Failed to load Mac cursor %d", viewNum); delete macCursor; return; 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]; |