Skip to content

Commit

Permalink
GRAPHICS: Display Mac monochrome cursor inverted pixels
Browse files Browse the repository at this point in the history
Bug #7050
  • Loading branch information
sluicebox authored and bluegr committed Aug 21, 2019
1 parent 83a4794 commit 60fcf99
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
5 changes: 4 additions & 1 deletion engines/sci/graphics/cursor.cpp
Expand Up @@ -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;
Expand Down
24 changes: 15 additions & 9 deletions graphics/maccursor.cpp
Expand Up @@ -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++) {
Expand All @@ -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();
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions graphics/maccursor.h
Expand Up @@ -63,11 +63,11 @@ class MacCursor : public Cursor {
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];
Expand Down

0 comments on commit 60fcf99

Please sign in to comment.