Skip to content

Commit

Permalink
SCUMM: Make the default cursor for all v80+ games be the Windows cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Hoops committed Aug 16, 2011
1 parent 310bd54 commit 111d70a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 46 deletions.
85 changes: 41 additions & 44 deletions engines/scumm/cursor.cpp
Expand Up @@ -180,12 +180,8 @@ void ScummEngine_v70he::setDefaultCursor() {
0xff, 0xff, 0xff,
0, 0, 0, };

if (_bytesPerPixel == 2) {
for (i = 0; i < 1024; i++)
WRITE_UINT16(_grabbedCursor + i * 2, 5);
} else {
memset(_grabbedCursor, 5, sizeof(_grabbedCursor));
}

memset(_grabbedCursor, 5, sizeof(_grabbedCursor));

_cursor.hotspotX = _cursor.hotspotY = 2;
src = default_he_cursor;
Expand All @@ -198,16 +194,10 @@ void ScummEngine_v70he::setDefaultCursor() {
for (j = 0; j < 32; j++) {
switch ((p & (0x3 << 14)) >> 14) {
case 1:
if (_bytesPerPixel == 2)
WRITE_UINT16(_grabbedCursor + 64 * i + j * 2, get16BitColor(palette[4], palette[5], palette[6]));
else
_grabbedCursor[32 * i + j] = 0xfe;
_grabbedCursor[32 * i + j] = 0xfe;
break;
case 2:
if (_bytesPerPixel == 2)
WRITE_UINT16(_grabbedCursor + 64 * i + j * 2, get16BitColor(palette[0], palette[1], palette[2]));
else
_grabbedCursor[32 * i + j] = 0xfd;
_grabbedCursor[32 * i + j] = 0xfd;
break;
default:
break;
Expand All @@ -219,52 +209,59 @@ void ScummEngine_v70he::setDefaultCursor() {
}
}

if (_bytesPerPixel == 1) {
// Since white color position is not guaranteed
// we setup our own palette if supported by backend
CursorMan.disableCursorPalette(false);
CursorMan.replaceCursorPalette(palette, 0xfd, 3);
}
// Since white color position is not guaranteed
// we setup our own palette if supported by backend
CursorMan.disableCursorPalette(false);
CursorMan.replaceCursorPalette(palette, 0xfd, 3);

updateCursor();
}

#ifdef ENABLE_HE
void ScummEngine_v100he::setDefaultCursor() {
if (_game.id == GID_MOONBASE) {
// Moonbase uses the default Windows cursor instead of the usual
// default HE cursor.
Graphics::Cursor *cursor = Graphics::makeDefaultWinCursor();
void ScummEngine_v80he::setDefaultCursor() {
// v80+ games use the default Windows cursor instead of the usual
// default HE cursor.
Graphics::Cursor *cursor = Graphics::makeDefaultWinCursor();

// Clear the cursor
// Clear the cursor
if (_bytesPerPixel == 2) {
for (int i = 0; i < 1024; i++)
WRITE_UINT16(_grabbedCursor + i * 2, 5);
} else {
memset(_grabbedCursor, 5, sizeof(_grabbedCursor));
}

_cursor.width = cursor->getWidth();
_cursor.height = cursor->getHeight();
_cursor.hotspotX = cursor->getHotspotX();
_cursor.hotspotY = cursor->getHotspotY();
_cursor.width = cursor->getWidth();
_cursor.height = cursor->getHeight();
_cursor.hotspotX = cursor->getHotspotX();
_cursor.hotspotY = cursor->getHotspotY();

const byte *surface = cursor->getSurface();
const byte *palette = cursor->getPalette();
const byte *surface = cursor->getSurface();
const byte *palette = cursor->getPalette();

for (uint16 y = 0; y < _cursor.height; y++) {
for (uint16 x = 0; x < _cursor.width; x++) {
byte pixel = *surface++;
if (pixel != cursor->getKeyColor()) {
pixel -= cursor->getPaletteStartIndex();
WRITE_UINT16(_grabbedCursor + (y * _cursor.width + x) * 2, get16BitColor(palette[pixel * 3], palette[pixel * 3 + 1], palette[pixel * 3 + 2]));
}
for (uint16 y = 0; y < _cursor.height; y++) {
for (uint16 x = 0; x < _cursor.width; x++) {
byte pixel = *surface++;

if (pixel != cursor->getKeyColor()) {
pixel -= cursor->getPaletteStartIndex();

if (_bytesPerPixel == 2)
WRITE_UINT16(_grabbedCursor + (y * _cursor.width + x) * 2, get16BitColor(palette[pixel * 3], palette[pixel * 3 + 1], palette[pixel * 3 + 2]));
else
_grabbedCursor[y * _cursor.width + x] = (pixel == 0) ? 0xfd : 0xfe;
}
}
}

delete cursor;
delete cursor;

updateCursor();
} else {
ScummEngine_v70he::setDefaultCursor();
}
// Since white color position is not guaranteed
// we setup our own palette if supported by backend
CursorMan.disableCursorPalette(false);
CursorMan.replaceCursorPalette(palette, 0xfd, cursor->getPaletteCount() * 3);

updateCursor();
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions engines/scumm/he/intern_he.h
Expand Up @@ -383,6 +383,8 @@ class ScummEngine_v80he : public ScummEngine_v72he {
void drawLine(int x1, int y1, int x, int unk1, int unk2, int type, int id);
void drawPixel(int x, int y, int flags);

virtual void setDefaultCursor();

/* HE version 80 script opcodes */
void o80_createSound();
void o80_getFileSize();
Expand Down Expand Up @@ -570,8 +572,6 @@ class ScummEngine_v100he : public ScummEngine_v99he {

virtual void decodeParseString(int a, int b);

virtual void setDefaultCursor();

/* HE version 100 script opcodes */
void o100_actorOps();
void o100_arrayOps();
Expand Down

0 comments on commit 111d70a

Please sign in to comment.