Skip to content

Commit

Permalink
SCI: Use new MacCursor code instead of convertCrsrCursor()
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Hoops committed May 5, 2011
1 parent 4a3d94a commit 0f0ae45
Showing 1 changed file with 11 additions and 41 deletions.
52 changes: 11 additions & 41 deletions engines/sci/graphics/cursor.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit 0f0ae45

Please sign in to comment.