diff options
Diffstat (limited to 'engines/sci/graphics')
-rw-r--r-- | engines/sci/graphics/cursor.cpp | 24 | ||||
-rw-r--r-- | engines/sci/graphics/screen.cpp | 8 |
2 files changed, 21 insertions, 11 deletions
diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp index a939b042a7..daab532d0e 100644 --- a/engines/sci/graphics/cursor.cpp +++ b/engines/sci/graphics/cursor.cpp @@ -125,12 +125,17 @@ void GfxCursor::kernelSetShape(GuiResourceId resourceId) { error("cursor resource %d has invalid size", resourceId); resourceData = resource->data; - // hotspot is specified for SCI1 cursors - hotspot.x = READ_LE_UINT16(resourceData); - hotspot.y = READ_LE_UINT16(resourceData + 2); - // bit 0 of resourceData[3] is set on <SCI1 games, which means center hotspot - if ((hotspot.x == 0) && (hotspot.y == 256)) - hotspot.x = hotspot.y = SCI_CURSOR_SCI0_HEIGHTWIDTH / 2; + + if (getSciVersion() <= SCI_VERSION_0_LATE) { + // SCI0 cursors contain hotspot flags, not actual hotspot coordinates. + // If bit 0 of resourceData[3] is set, the hotspot should be centered, + // otherwise it's in the top left of the mouse cursor. + hotspot.x = hotspot.y = resourceData[3] ? SCI_CURSOR_SCI0_HEIGHTWIDTH / 2 : 0; + } else { + // Cursors in newer SCI versions contain actual hotspot coordinates. + hotspot.x = READ_LE_UINT16(resourceData); + hotspot.y = READ_LE_UINT16(resourceData + 2); + } // Now find out what colors we are supposed to use colorMapping[0] = 0; // Black is hardcoded @@ -140,7 +145,7 @@ void GfxCursor::kernelSetShape(GuiResourceId resourceId) { // Special case for the magnifier cursor in LB1 (bug #3487092). // No other SCI0 game has a cursor resource of 1, so this is handled // specifically for LB1. - if (resourceId == 1) + if (g_sci->getGameId() == GID_LAURABOW && resourceId == 1) colorMapping[3] = _screen->getColorWhite(); // Seek to actual data @@ -170,6 +175,11 @@ void GfxCursor::kernelSetShape(GuiResourceId resourceId) { rawBitmap = upscaledBitmap; } + if (hotspot.x >= heightWidth || hotspot.y >= heightWidth) { + error("cursor %d's hotspot (%d, %d) is out of range of the cursor's dimensions (%dx%d)", + resourceId, hotspot.x, hotspot.y, heightWidth, heightWidth); + } + CursorMan.replaceCursor(rawBitmap, heightWidth, heightWidth, hotspot.x, hotspot.y, SCI_CURSOR_SCI0_TRANSPARENCYCOLOR); kernelShow(); diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp index 6469bc0cb3..4020518b72 100644 --- a/engines/sci/graphics/screen.cpp +++ b/engines/sci/graphics/screen.cpp @@ -438,7 +438,7 @@ void GfxScreen::bitsSaveScreen(Common::Rect rect, byte *screen, uint16 screenWid screen += (rect.top * screenWidth) + rect.left; for (y = rect.top; y < rect.bottom; y++) { - memcpy(memoryPtr, (void*)screen, width); memoryPtr += width; + memcpy(memoryPtr, (void *)screen, width); memoryPtr += width; screen += screenWidth; } } @@ -458,7 +458,7 @@ void GfxScreen::bitsSaveDisplayScreen(Common::Rect rect, byte *&memoryPtr) { } for (y = rect.top; y < rect.bottom; y++) { - memcpy(memoryPtr, (void*)screen, width); memoryPtr += width; + memcpy(memoryPtr, (void *)screen, width); memoryPtr += width; screen += _displayWidth; } } @@ -503,7 +503,7 @@ void GfxScreen::bitsRestoreScreen(Common::Rect rect, byte *&memoryPtr, byte *scr screen += (rect.top * screenWidth) + rect.left; for (y = rect.top; y < rect.bottom; y++) { - memcpy((void*) screen, memoryPtr, width); memoryPtr += width; + memcpy((void *) screen, memoryPtr, width); memoryPtr += width; screen += screenWidth; } } @@ -523,7 +523,7 @@ void GfxScreen::bitsRestoreDisplayScreen(Common::Rect rect, byte *&memoryPtr) { } for (y = rect.top; y < rect.bottom; y++) { - memcpy((void*) screen, memoryPtr, width); memoryPtr += width; + memcpy((void *) screen, memoryPtr, width); memoryPtr += width; screen += _displayWidth; } } |