diff options
author | Eugene Sandulenko | 2004-05-05 02:32:46 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2004-05-05 02:32:46 +0000 |
commit | b7e62e4b61c7552fa91c9dbdd9273b620d7f876b (patch) | |
tree | 61cc2d13b77e8c8514954241f050b8245155283b | |
parent | 5d0f0ea0c6afd7defaba3df69b39879a63256776 (diff) | |
download | scummvm-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
-rw-r--r-- | backends/PalmOS/Src/palm.cpp | 12 | ||||
-rw-r--r-- | backends/PalmOS/Src/palm.h | 5 | ||||
-rw-r--r-- | backends/dc/dc.h | 3 | ||||
-rw-r--r-- | backends/dc/display.cpp | 12 | ||||
-rw-r--r-- | backends/gp32/gp32.cpp | 13 | ||||
-rw-r--r-- | backends/gp32/gp32.h | 3 | ||||
-rw-r--r-- | backends/morphos/morphos.cpp | 13 | ||||
-rw-r--r-- | backends/morphos/morphos.h | 3 | ||||
-rw-r--r-- | backends/null/null.cpp | 2 | ||||
-rw-r--r-- | backends/sdl/graphics.cpp | 14 | ||||
-rw-r--r-- | backends/sdl/sdl-common.h | 5 | ||||
-rw-r--r-- | backends/x11/x11.cpp | 17 | ||||
-rw-r--r-- | common/system.h | 3 |
13 files changed, 76 insertions, 29 deletions
diff --git a/backends/PalmOS/Src/palm.cpp b/backends/PalmOS/Src/palm.cpp index 278cc68211..0b7eceb8e6 100644 --- a/backends/PalmOS/Src/palm.cpp +++ b/backends/PalmOS/Src/palm.cpp @@ -62,6 +62,7 @@ void OSystem_PALMOS::init_intern(UInt16 gfx_mode) { _vibrate = gVars->vibrator; _fullscreen = (ConfMan.getBool("fullscreen") && OPTIONS_TST(kOptModeWide)); _adjustAspectRatio = ConfMan.getBool("aspect_ratio"); + _mouseDataP = NULL; } void OSystem_PALMOS::setPalette(const byte *colors, uint start, uint num) { @@ -701,14 +702,19 @@ void OSystem_PALMOS::set_mouse_pos(int x, int y) { } } -void OSystem_PALMOS::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y) { +void OSystem_PALMOS::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor) { _mouseCurState.w = w; _mouseCurState.h = h; _mouseHotspotX = hotspot_x; _mouseHotspotY = hotspot_y; - _mouseDataP = (byte*)buf; + _mouseKeycolor = keycolor; + + if (_mouseDataP) + free(_mouseDataP); + _mouseDataP = malloc(w * h); + memcpy(_mouseDataP, buf, w * h); undraw_mouse(); } @@ -1316,7 +1322,7 @@ void OSystem_PALMOS::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/PalmOS/Src/palm.h b/backends/PalmOS/Src/palm.h index 8cf579641e..5c203ddfcf 100644 --- a/backends/PalmOS/Src/palm.h +++ b/backends/PalmOS/Src/palm.h @@ -76,7 +76,7 @@ public: // 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); @@ -215,6 +215,7 @@ private: MousePos _mouseOldState; int16 _mouseHotspotX; int16 _mouseHotspotY; + byte _mouseKeycolor; int _current_shake_pos; int _new_shake_pos; @@ -284,4 +285,4 @@ private: void init_intern(UInt16 gfx_mode); }; -#endif
\ No newline at end of file +#endif diff --git a/backends/dc/dc.h b/backends/dc/dc.h index 04b9fc5bb6..286cb99bb3 100644 --- a/backends/dc/dc.h +++ b/backends/dc/dc.h @@ -85,7 +85,7 @@ class OSystem_Dreamcast : public OSystem { 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); @@ -163,6 +163,7 @@ class OSystem_Dreamcast : public OSystem { int _current_shake_pos, _screen_w, _screen_h; int _overlay_x, _overlay_y; unsigned char *_ms_buf; + unsigned char _ms_keycolor; SoundProc _sound_proc; void *_sound_proc_param; bool _overlay_visible, _overlay_dirty, _screen_dirty; diff --git a/backends/dc/display.cpp b/backends/dc/display.cpp index 50abc5e522..53aa2f9a8a 100644 --- a/backends/dc/display.cpp +++ b/backends/dc/display.cpp @@ -259,15 +259,21 @@ void OSystem_Dreamcast::warpMouse(int x, int y) } void OSystem_Dreamcast::setMouseCursor(const byte *buf, uint w, uint h, - int hotspot_x, int hotspot_y) + int hotspot_x, int hotspot_y, byte keycolor) { _ms_cur_w = w; _ms_cur_h = h; _ms_hotspot_x = hotspot_x; _ms_hotspot_y = hotspot_y; + + _ms_keycolor = keycolor; - _ms_buf = (byte*)buf; + if (_ms_buf) + free(_ms_buf); + + _ms_buf = (byte *)malloc(w * h); + memcpy(_ms_buf, buf, w * h); } void OSystem_Dreamcast::set_shake_pos(int shake_pos) @@ -456,7 +462,7 @@ void OSystem_Dreamcast::drawMouse(int xdraw, int ydraw, int w, int h, for(int y=0; y<h; y++) { int x; for(x=0; x<w; x++) - if(*buf == 0xff) { + if(*buf == _ms_keycolor) { *dst++ = 0; buf++; } else diff --git a/backends/gp32/gp32.cpp b/backends/gp32/gp32.cpp index 6d3f7dbf02..5a636a38da 100644 --- a/backends/gp32/gp32.cpp +++ b/backends/gp32/gp32.cpp @@ -67,6 +67,7 @@ void OSystem_GP32::initSize(uint w, uint h) { if (_dirty_checksums) free(_dirty_checksums); _dirty_checksums = (uint32*)calloc(CKSUM_NUM*2, sizeof(uint32)); + _mouseData = NULL; unload_gfx_mode(); load_gfx_mode(); @@ -538,7 +539,7 @@ void OSystem_GP32::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--; @@ -830,14 +831,20 @@ void OSystem_GP32::warpMouse(int x, int y) { } // Set the bitmap that's used when drawing the cursor. -void OSystem_GP32::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y) { +void OSystem_GP32::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor) { _mouse_cur_state.w = w; _mouse_cur_state.h = h; _mouseHotspotX = hotspot_x; _mouseHotspotY = hotspot_y; - _mouseData = (byte*)buf; + _mouseKeycolor = keycolor; + + if (_mouseData) + free(_mouseData); + + _mouseData = (byte *)malloc(w * h); + memcpy(_mouseData, buf, w * h); undraw_mouse(); } diff --git a/backends/gp32/gp32.h b/backends/gp32/gp32.h index 37c08ce080..af5834e0f0 100644 --- a/backends/gp32/gp32.h +++ b/backends/gp32/gp32.h @@ -62,7 +62,7 @@ public: void set_mouse_pos(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, int keycolor = 255); // Shaking is used in SCUMM. Set current shake position. void set_shake_pos(int shake_pos); @@ -188,6 +188,7 @@ private: MousePos _mouse_old_state; int16 _mouseHotspotX; int16 _mouseHotspotY; + byte _mouseKeycolor; // Shake mode int _currentShakePos; diff --git a/backends/morphos/morphos.cpp b/backends/morphos/morphos.cpp index ed62106f32..d7f3f9e345 100644 --- a/backends/morphos/morphos.cpp +++ b/backends/morphos/morphos.cpp @@ -130,6 +130,7 @@ OSystem_MorphOS::OSystem_MorphOS(SCALERTYPE gfx_mode, bool full_screen) ScummNoCursor = NULL; UpdateRegion = NULL; NewUpdateRegion = NULL; + MouseImage = NULL; } bool OSystem_MorphOS::Initialise() @@ -1360,7 +1361,7 @@ void OSystem_MorphOS::DrawMouse() if (xdraw+x < ScummBufferWidth) { bak[x] = dst[x]; - if ((color=buf[x])!=0xFF) + if ((color=buf[x])!=MouseKeycolor) dst[x] = color; } } @@ -1423,7 +1424,7 @@ void OSystem_MorphOS::set_mouse_pos(int x, int y) } } -void OSystem_MorphOS::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y) +void OSystem_MorphOS::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor = 255) { MouseWidth = w; MouseHeight = h; @@ -1431,7 +1432,13 @@ void OSystem_MorphOS::setMouseCursor(const byte *buf, uint w, uint h, int hotspo MouseHotspotX = hotspot_x; MouseHotspotY = hotspot_y; - MouseImage = (byte*)buf; + MouseKeycolor = keycolor; + + if (MouseImage) + free(MouseImage); + + MouseImage = (byte *)malloc(w * h); + memcpy(mouseImage, buf, w * h); UndrawMouse(); } diff --git a/backends/morphos/morphos.h b/backends/morphos/morphos.h index 3d23e28476..5b14f5bfa8 100644 --- a/backends/morphos/morphos.h +++ b/backends/morphos/morphos.h @@ -64,7 +64,7 @@ class OSystem_MorphOS : public OSystem virtual void set_mouse_pos(int x, int y); // Set the bitmap that's used when drawing the cursor. - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y); + virtual 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. virtual void set_shake_pos(int shake_pos); @@ -201,6 +201,7 @@ class OSystem_MorphOS : public OSystem int MouseOldWidth, MouseOldHeight; int MouseHotspotX, MouseHotspotY; byte *MouseImage, MouseBackup[MAX_MOUSE_W*MAX_MOUSE_H]; + byte MouseKeycolor; MsgPort* InputMsgPort; IOStdReq*InputIORequest; diff --git a/backends/null/null.cpp b/backends/null/null.cpp index 71685882f7..6fed878e9c 100644 --- a/backends/null/null.cpp +++ b/backends/null/null.cpp @@ -36,7 +36,7 @@ public: void updateScreen() {} bool showMouse(bool visible) { return false; } void set_mouse_pos(int x, int y) {} - 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) {} void set_shake_pos(int shake_pos) {} uint32 get_msecs(); void delay_msecs(uint msecs); 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; diff --git a/backends/x11/x11.cpp b/backends/x11/x11.cpp index 482c52bbc6..af8695d685 100644 --- a/backends/x11/x11.cpp +++ b/backends/x11/x11.cpp @@ -107,7 +107,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); @@ -222,9 +222,10 @@ private: int hot_x, hot_y; } mouse_state; mouse_state old_state, cur_state; - const byte *_ms_buf; + byte *_ms_buf; bool _mouse_visible; bool _mouse_state_changed; + byte _mouseKeycolor; uint32 _timer_duration, _timer_next_expiry; bool _timer_active; @@ -363,6 +364,7 @@ OSystem_X11::OSystem_X11() { _overlay_visible = false; _mouse_state_changed = true; _mouse_visible = true; + _ms_buf = NULL; cur_state.x = 0; cur_state.y = 0; cur_state.hot_x = 0; @@ -780,7 +782,7 @@ void OSystem_X11::draw_mouse(dirty_square *dout) { int width = real_w; while (width > 0) { byte color = *buf; - if (color != 0xFF) { + if (color != _mouseKeycolor) { *dst = palette[color]; } buf++; @@ -808,16 +810,21 @@ void OSystem_X11::warpMouse(int x, int y) { set_mouse_pos(x, y); } -void OSystem_X11::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y) { +void OSystem_X11::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor) { cur_state.w = w; cur_state.h = h; cur_state.hot_x = hotspot_x; cur_state.hot_y = hotspot_y; - _ms_buf = buf; + + if (_ms_buf) + free(_ms_buf); + _ms_buf = malloc(w * h); + memcpy(_ms_buf, buf, w * h); if (_mouse_state_changed == false) { undraw_mouse(); } + _mouseKeycolor = keycolor; _mouse_state_changed = true; } diff --git a/common/system.h b/common/system.h index 2039085fdb..ec057dde63 100644 --- a/common/system.h +++ b/common/system.h @@ -357,8 +357,9 @@ public: * @param h height of the mouse cursor * @param hotspotX horizontal offset from the left side to the hotspot * @param hotspotY vertical offset from the top side to the hotspot + * @param keycolor transparency color index */ - virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY) = 0; + virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255) = 0; //@} |