From 111d70af7d06743d61188443b2bf474f5ba64499 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Tue, 16 Aug 2011 02:44:29 -0400 Subject: [PATCH] SCUMM: Make the default cursor for all v80+ games be the Windows cursor --- engines/scumm/cursor.cpp | 85 +++++++++++++++++------------------- engines/scumm/he/intern_he.h | 4 +- 2 files changed, 43 insertions(+), 46 deletions(-) diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 6708d393f3b6..29b5eaedcba8 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -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; @@ -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; @@ -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 diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h index 145172b901bc..f4df6571fa33 100644 --- a/engines/scumm/he/intern_he.h +++ b/engines/scumm/he/intern_he.h @@ -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(); @@ -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();