aboutsummaryrefslogtreecommitdiff
path: root/sword2/driver/_mouse.cpp
diff options
context:
space:
mode:
authorOliver Kiehl2003-08-20 21:46:00 +0000
committerOliver Kiehl2003-08-20 21:46:00 +0000
commitbfefcc3567748e8dadd0eb8d879572f1996a4567 (patch)
tree18e0d9ac3e11577944881b23351146d0271303fe /sword2/driver/_mouse.cpp
parent8b9158817d7b3f08f752402d0d3ff1c943c42732 (diff)
downloadscummvm-rg350-bfefcc3567748e8dadd0eb8d879572f1996a4567.tar.gz
scummvm-rg350-bfefcc3567748e8dadd0eb8d879572f1996a4567.tar.bz2
scummvm-rg350-bfefcc3567748e8dadd0eb8d879572f1996a4567.zip
Draw combined cursor properly. Thanks to joost for finding out that the
maximum cursor size in SDL is 80x80. This *might* cause problems in some cases svn-id: r9805
Diffstat (limited to 'sword2/driver/_mouse.cpp')
-rw-r--r--sword2/driver/_mouse.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/sword2/driver/_mouse.cpp b/sword2/driver/_mouse.cpp
index a6e3139251..97dbd1ca7e 100644
--- a/sword2/driver/_mouse.cpp
+++ b/sword2/driver/_mouse.cpp
@@ -215,7 +215,7 @@ void LogMouseEvent(uint16 buttons)
// 0xFF. That means that parts of the mouse cursor that weren't meant to be
// transparent may be now.
-int32 DecompressMouse(uint8 *decomp, uint8 *comp, int width, int height, int pitch) {
+int32 DecompressMouse(uint8 *decomp, uint8 *comp, int width, int height, int pitch, int xOff = 0, int yOff = 0) {
int32 size = width * height;
int32 i = 0;
int x = 0;
@@ -223,7 +223,7 @@ int32 DecompressMouse(uint8 *decomp, uint8 *comp, int width, int height, int pit
while (i < size) {
if (*comp > 183) {
- decomp[y * pitch + x] = *comp++;
+ decomp[(y + yOff) * pitch + x + xOff] = *comp++;
if (++x >= width) {
x = 0;
y++;
@@ -257,6 +257,8 @@ void DrawMouse(void) {
uint16 mouse_height = 0;
uint16 hotspot_x = 0;
uint16 hotspot_y = 0;
+ int deltaX = 0;
+ int deltaY = 0;
if (mouseAnim) {
hotspot_x = mouseAnim->xHotSpot;
@@ -265,10 +267,6 @@ void DrawMouse(void) {
mouse_height = mouseAnim->mouseh;
}
- // FIXME: The luggage's hotspot and the standard cursor's hotspot may
- // not be the same. The luggage image should be offset to compensate
- // for that.
-
if (luggageAnim) {
if (!mouseAnim) {
hotspot_x = luggageAnim->xHotSpot;
@@ -280,6 +278,23 @@ void DrawMouse(void) {
mouse_height = luggageAnim->mouseh;
}
+ if (mouseAnim && luggageAnim) {
+ deltaX = mouseAnim->xHotSpot - luggageAnim->xHotSpot;
+ deltaY = mouseAnim->yHotSpot - luggageAnim->yHotSpot;
+ }
+
+ assert(deltaX >= 0);
+ assert(deltaY >= 0);
+
+ // HACK for maximum cursor size
+ if (mouse_width + deltaX > 80)
+ deltaX = 80 - mouse_width;
+ if (mouse_height + deltaY > 80)
+ deltaY = 80 - mouse_height;
+
+ mouse_width += deltaX;
+ mouse_height += deltaY;
+
if (mouse_width * mouse_height > sizeof(_mouseData)) {
warning("Mouse cursor too large");
return;
@@ -288,7 +303,8 @@ void DrawMouse(void) {
memset(_mouseData, 0xFF, mouse_width * mouse_height);
if (luggageAnim)
- DecompressMouse(_mouseData, (uint8 *) luggageAnim + *luggageOffset, luggageAnim->mousew, luggageAnim->mouseh, mouse_width);
+ DecompressMouse(_mouseData, (uint8 *) luggageAnim + *luggageOffset, luggageAnim->mousew,
+ luggageAnim->mouseh, mouse_width, deltaX, deltaY);
if (mouseAnim)
DecompressMouse(_mouseData, mouseSprite, mouseAnim->mousew, mouseAnim->mouseh, mouse_width);