aboutsummaryrefslogtreecommitdiff
path: root/backends/sdl
diff options
context:
space:
mode:
authorEugene Sandulenko2004-05-05 02:32:46 +0000
committerEugene Sandulenko2004-05-05 02:32:46 +0000
commitb7e62e4b61c7552fa91c9dbdd9273b620d7f876b (patch)
tree61cc2d13b77e8c8514954241f050b8245155283b /backends/sdl
parent5d0f0ea0c6afd7defaba3df69b39879a63256776 (diff)
downloadscummvm-rg350-b7e62e4b61c7552fa91c9dbdd9273b620d7f876b.tar.gz
scummvm-rg350-b7e62e4b61c7552fa91c9dbdd9273b620d7f876b.tar.bz2
scummvm-rg350-b7e62e4b61c7552fa91c9dbdd9273b620d7f876b.zip
Extend setMouseCursor with additional keycolor parameter. Lets saga use 255
as white color. Made this function more safe by copying cursor data to newly created buffer. svn-id: r13777
Diffstat (limited to 'backends/sdl')
-rw-r--r--backends/sdl/graphics.cpp14
-rw-r--r--backends/sdl/sdl-common.h5
2 files changed, 14 insertions, 5 deletions
diff --git a/backends/sdl/graphics.cpp b/backends/sdl/graphics.cpp
index e89151e03e..b28eb97ed5 100644
--- a/backends/sdl/graphics.cpp
+++ b/backends/sdl/graphics.cpp
@@ -175,6 +175,8 @@ void OSystem_SDL::initSize(uint w, uint h) {
free(_dirty_checksums);
_dirty_checksums = (uint32 *)calloc(CKSUM_NUM * 2, sizeof(uint32));
+ _mouseData = NULL;
+
unload_gfx_mode();
load_gfx_mode();
}
@@ -992,7 +994,7 @@ void OSystem_SDL::warpMouse(int x, int y) {
}
}
-void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y) {
+void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor) {
undraw_mouse();
@@ -1004,7 +1006,13 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x,
_mouseHotspotX = hotspot_x;
_mouseHotspotY = hotspot_y;
- _mouseData = buf;
+ _mouseKeycolor = keycolor;
+
+ if (_mouseData)
+ free(_mouseData);
+
+ _mouseData = (byte *)malloc(w * h);
+ memcpy(_mouseData, buf, w * h);
}
void OSystem_SDL::toggleMouseGrab() {
@@ -1063,7 +1071,7 @@ void OSystem_SDL::draw_mouse() {
while (width > 0) {
*bak++ = *dst;
color = *src++;
- if (color != 0xFF) // 0xFF = transparent, don't draw
+ if (color != _mouseKeycolor) // transparent, don't draw
*dst = color;
dst++;
width--;
diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h
index 127267f878..276f021b9b 100644
--- a/backends/sdl/sdl-common.h
+++ b/backends/sdl/sdl-common.h
@@ -64,7 +64,7 @@ public:
void warpMouse(int x, int y);
// Set the bitmap that's used when drawing the cursor.
- void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y);
+ void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor = 255);
// Shaking is used in SCUMM. Set current shake position.
void set_shake_pos(int shake_pos);
@@ -217,11 +217,12 @@ protected:
// mouse
bool _mouseVisible;
bool _mouseDrawn;
- const byte *_mouseData;
+ byte *_mouseData;
byte *_mouseBackup;
MousePos _mouseCurState;
int16 _mouseHotspotX;
int16 _mouseHotspotY;
+ byte _mouseKeycolor;
// joystick
SDL_Joystick *_joystick;