aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2014-05-25 18:32:54 -0400
committerPaul Gilbert2014-05-25 18:32:54 -0400
commit49866d442fdd816a89a5c1bd4ddb1e68013c8d9e (patch)
tree593a787790b7d2d7db4e5febf17d68ed1562743b /engines
parenta01d502d2015b916b61a99ac0dcc0fcf1a289b78 (diff)
downloadscummvm-rg350-49866d442fdd816a89a5c1bd4ddb1e68013c8d9e.tar.gz
scummvm-rg350-49866d442fdd816a89a5c1bd4ddb1e68013c8d9e.tar.bz2
scummvm-rg350-49866d442fdd816a89a5c1bd4ddb1e68013c8d9e.zip
MADS: Properly implement cursor hotspot handling
Diffstat (limited to 'engines')
-rw-r--r--engines/mads/events.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 5d6a16ff1f..870a902866 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -90,9 +90,38 @@ void EventsManager::waitCursor() {
void EventsManager::changeCursor() {
if (_cursorSprites) {
MSprite *cursor = _cursorSprites->getFrame(_cursorId - 1);
- CursorMan.replaceCursor(cursor->getData(), cursor->w, cursor->h, 0, 0,
- cursor->getTransparencyIndex());
+ assert(cursor->w == cursor->h);
+ byte transIndex = cursor->getTransparencyIndex();
+
+ // Check for hotspot indication pixels along the right-hand and bottom
+ // row. Put together, these give the cursor's hotspot x,y
+ int hotspotX = 0, hotspotY = 0;
+ byte *cursorData = cursor->getData();
+ for (int idx = 0; idx < cursor->w; ++idx) {
+ if (cursorData[(cursor->h - 1) * cursor->w + idx] != transIndex)
+ hotspotX = idx;
+
+ if (cursorData[(cursor->h + 1) * cursor->w - 1] != transIndex)
+ hotspotY = idx;
+ }
+
+ // Reduce the cursor data to remove the last column from each row, since
+ // the cursor routines don't have a pitch option
+ byte *destCursor = new byte[(cursor->w - 1) * (cursor->h - 1)];
+ byte *srcP = cursorData;
+ byte *destP = destCursor;
+
+ for (int idx = 0; idx < (cursor->h - 1); ++idx) {
+ Common::copy(srcP, srcP + cursor->w - 1, destP);
+ srcP += cursor->w;
+ destP += cursor->w - 1;
+ }
+
+ // Set the raw cursor data to use
+ CursorMan.replaceCursor(destCursor, cursor->w - 1, cursor->h - 1,
+ hotspotX, hotspotY, transIndex);
showCursor();
+ delete[] destCursor;
}
}