From 6dcf366b7d5d6700c416d0f6b0c2d8d6bf40bb00 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Fri, 8 Oct 2010 12:41:03 +0000 Subject: SCI: fixing mag cursor as far as possible added TODO for real proper implementation at least the alignment and content shown is now correct svn-id: r53071 --- engines/sci/graphics/cursor.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'engines/sci/graphics/cursor.cpp') diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp index 94d122c432..2f881e1a76 100644 --- a/engines/sci/graphics/cursor.cpp +++ b/engines/sci/graphics/cursor.cpp @@ -373,18 +373,38 @@ void GfxCursor::refreshPosition() { // Pic const CelInfo *picCelInfo = _zoomPicView->getCelInfo(0, 0); const byte *rawPicBitmap = _zoomPicView->getBitmap(0, 0); - // Compute hotspot from xoffset/yoffset + + // Compute hotspot of cursor Common::Point cursorHotspot = Common::Point((cursorCelInfo->width >> 1) - cursorCelInfo->displaceX, cursorCelInfo->height - cursorCelInfo->displaceY - 1); - uint16 targetX = CLIP((mousePoint.x - _zoomZone.left) * _zoomMultiplier, 0, picCelInfo->width - cursorCelInfo->width); - uint16 targetY = CLIP((mousePoint.y - _zoomZone.top) * _zoomMultiplier, 0, picCelInfo->height - cursorCelInfo->height); + int16 targetX = ((mousePoint.x - _moveZone.left) * _zoomMultiplier); + int16 targetY = ((mousePoint.y - _moveZone.top) * _zoomMultiplier); + if (targetX < 0) + targetX = 0; + if (targetY < 0) + targetY = 0; + + targetX -= cursorHotspot.x; + targetY -= cursorHotspot.y; + + // Sierra SCI actually drew only within zoom area, thus removing the need to fill any other pixels with upmost/left + // color of the picture cel. This also made the cursor not appear on top of everything. They actually drew the + // cursor manually within kAnimate processing and used a hidden cursor for moving. + // TODO: we should also do this // Replace the special magnifier color with the associated magnified pixels for (int x = 0; x < cursorCelInfo->width; x++) { for (int y = 0; y < cursorCelInfo->height; y++) { int curPos = cursorCelInfo->width * y + x; if (cursorBitmap[curPos] == _zoomColor) { - _cursorSurface[curPos] = rawPicBitmap[picCelInfo->width * (targetY + y) + (targetX + x)]; + int16 rawY = targetY + y; + int16 rawX = targetX + x; + if ((rawY >= 0) && (rawY < picCelInfo->height) && (rawX >= 0) && (rawX < picCelInfo->width)) { + int rawPos = picCelInfo->width * rawY + rawX; + _cursorSurface[curPos] = rawPicBitmap[rawPos]; + } else { + _cursorSurface[curPos] = rawPicBitmap[0]; // use left and upmost pixel color + } } } } -- cgit v1.2.3