diff options
author | Jody Northup | 2009-06-05 08:09:37 +0000 |
---|---|---|
committer | Jody Northup | 2009-06-05 08:09:37 +0000 |
commit | 9789ba7f28d2c0a093adda01435306f28e91fede (patch) | |
tree | ced66d59e1c0b16a59ca36196159378b871d4333 /graphics | |
parent | 662a305752214564a9db0ac2d61594367067efa1 (diff) | |
download | scummvm-rg350-9789ba7f28d2c0a093adda01435306f28e91fede.tar.gz scummvm-rg350-9789ba7f28d2c0a093adda01435306f28e91fede.tar.bz2 scummvm-rg350-9789ba7f28d2c0a093adda01435306f28e91fede.zip |
Corrected backend to be able to accept a 16-bit mouseKeyColor without overflow
svn-id: r41194
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/cursorman.cpp | 36 | ||||
-rw-r--r-- | graphics/cursorman.h | 4 |
2 files changed, 36 insertions, 4 deletions
diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp index f303749572..84578a3911 100644 --- a/graphics/cursorman.cpp +++ b/graphics/cursorman.cpp @@ -100,6 +100,37 @@ void CursorManager::popAllCursors() { g_system->showMouse(isVisible()); } +#ifdef ENABLE_16BIT +//HACK Made a separate method to avoid massive linker errors on every engine +void CursorManager::replaceCursor16(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint16 keycolor, int targetScale) { + if (_cursorStack.empty()) { + pushCursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale); + return; + } + + Cursor *cur = _cursorStack.top(); + + uint size = w * h * 2; + + if (cur->_size < size) { + delete[] cur->_data; + cur->_data = new byte[size]; + cur->_size = size; + } + + if (buf && cur->_data) + memcpy(cur->_data, buf, size); + + cur->_width = w; + cur->_height = h; + cur->_hotspotX = hotspotX; + cur->_hotspotY = hotspotY; + cur->_keycolor = keycolor; + cur->_targetScale = targetScale; + + g_system->setMouseCursor16(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale); +} +#endif void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetScale) { if (_cursorStack.empty()) { @@ -108,11 +139,8 @@ void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, } Cursor *cur = _cursorStack.top(); -#ifdef ENABLE_16BIT - uint size = w * h * 2; -#else + uint size = w * h; -#endif if (cur->_size < size) { delete[] cur->_data; diff --git a/graphics/cursorman.h b/graphics/cursorman.h index bc38466eda..8ad42fe0d4 100644 --- a/graphics/cursorman.h +++ b/graphics/cursorman.h @@ -77,6 +77,10 @@ public: * @param keycolor the index for the transparent color * @param targetScale the scale for which the cursor is designed */ +#ifdef ENABLE_16BIT + //HACK made a separate method to avoid massive linker errors on every engine. + void replaceCursor16(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint16 keycolor = 65535, int targetScale = 1); +#endif void replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int targetScale = 1); /** |