aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJody Northup2009-06-05 08:09:37 +0000
committerJody Northup2009-06-05 08:09:37 +0000
commit9789ba7f28d2c0a093adda01435306f28e91fede (patch)
treeced66d59e1c0b16a59ca36196159378b871d4333
parent662a305752214564a9db0ac2d61594367067efa1 (diff)
downloadscummvm-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
-rw-r--r--backends/platform/sdl/graphics.cpp47
-rw-r--r--backends/platform/sdl/sdl.h4
-rw-r--r--common/system.h5
-rw-r--r--dists/msvc8/scumm.vcproj4
-rw-r--r--engines/scumm/cursor.cpp18
-rw-r--r--graphics/cursorman.cpp36
-rw-r--r--graphics/cursorman.h4
7 files changed, 104 insertions, 14 deletions
diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp
index 1a80b9be19..fadd7a376c 100644
--- a/backends/platform/sdl/graphics.cpp
+++ b/backends/platform/sdl/graphics.cpp
@@ -1403,7 +1403,8 @@ 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, byte keycolor, int cursorTargetScale) {
+#ifdef ENABLE_16BIT
+void OSystem_SDL::setMouseCursor16(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint16 keycolor, int cursorTargetScale) {
if (w == 0 || h == 0)
return;
@@ -1438,13 +1439,51 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x,
free(_mouseData);
-#ifdef ENABLE_16BIT
_mouseData = (byte *)malloc(w * h * 2);
memcpy(_mouseData, buf, w * h * 2);
-#else
+
+ blitCursor();
+}
+#endif
+
+void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale) {
+ if (w == 0 || h == 0)
+ return;
+
+ _mouseCurState.hotX = hotspot_x;
+ _mouseCurState.hotY = hotspot_y;
+
+ _mouseKeyColor = keycolor;
+
+ _cursorTargetScale = cursorTargetScale;
+
+ if (_mouseCurState.w != (int)w || _mouseCurState.h != (int)h) {
+ _mouseCurState.w = w;
+ _mouseCurState.h = h;
+
+ if (_mouseOrigSurface)
+ SDL_FreeSurface(_mouseOrigSurface);
+
+ // Allocate bigger surface because AdvMame2x adds black pixel at [0,0]
+ _mouseOrigSurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA,
+ _mouseCurState.w + 2,
+ _mouseCurState.h + 2,
+ 16,
+ _hwscreen->format->Rmask,
+ _hwscreen->format->Gmask,
+ _hwscreen->format->Bmask,
+ _hwscreen->format->Amask);
+
+ if (_mouseOrigSurface == NULL)
+ error("allocating _mouseOrigSurface failed");
+ SDL_SetColorKey(_mouseOrigSurface, SDL_RLEACCEL | SDL_SRCCOLORKEY | SDL_SRCALPHA, kMouseColorKey);
+ }
+
+ free(_mouseData);
+
_mouseData = (byte *)malloc(w * h);
memcpy(_mouseData, buf, w * h);
-#endif
+
blitCursor();
}
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index f843066749..3e0bf19f8f 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -112,6 +112,10 @@ public:
virtual void warpMouse(int x, int y); // overloaded by CE backend (FIXME)
// Set the bitmap that's used when drawing the cursor.
+#ifdef ENABLE_16BIT
+ //HACK Made a second method as a quick and dirty workaround to avoid linker errors with engine libs
+ virtual void setMouseCursor16(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint16 keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME)
+#endif
virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME)
// Set colors of cursor palette
diff --git a/common/system.h b/common/system.h
index 5b72dab7c1..eb01093049 100644
--- a/common/system.h
+++ b/common/system.h
@@ -687,8 +687,13 @@ public:
* @param keycolor transparency color index
* @param cursorTargetScale scale factor which cursor is designed for
*/
+#ifdef ENABLE_16BIT
+ //HACK made a second method as a quick and dirty workaround to avoid linker errors with engine libs
+ virtual void setMouseCursor16(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint16 keycolor = 65535, int cursorTargetScale = 1) = 0;
+#endif
virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int cursorTargetScale = 1) = 0;
+
/**
* Replace the specified range of cursor the palette with new colors.
* The palette entries from 'start' till (start+num-1) will be replaced - so
diff --git a/dists/msvc8/scumm.vcproj b/dists/msvc8/scumm.vcproj
index 7b7588b0fd..03e1f9cc39 100644
--- a/dists/msvc8/scumm.vcproj
+++ b/dists/msvc8/scumm.vcproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="8,00"
+ Version="8.00"
Name="scumm"
ProjectGUID="{B6AFD548-63D2-40CD-A652-E87095AFCBAF}"
RootNamespace="scumm"
@@ -43,7 +43,7 @@
Optimization="0"
InlineFunctionExpansion="0"
AdditionalIncludeDirectories="../../;../../engines"
- PreprocessorDefinitions="WIN32;_DEBUG;ENABLE_SCUMM_7_8;ENABLE_HE;USE_ZLIB;USE_MAD;USE_VORBIS"
+ PreprocessorDefinitions="WIN32;_DEBUG;ENABLE_SCUMM_7_8;ENABLE_HE;USE_ZLIB;USE_MAD;USE_VORBIS; ENABLE_16BIT"
MinimalRebuild="true"
ExceptionHandling="1"
BasicRuntimeChecks="3"
diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp
index 957370b8fe..3710956b74 100644
--- a/engines/scumm/cursor.cpp
+++ b/engines/scumm/cursor.cpp
@@ -112,10 +112,20 @@ void ScummEngine_v6::setCursorTransparency(int a) {
void ScummEngine::updateCursor() {
int transColor = (_game.heversion >= 80) ? 5 : 255;
- CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height,
- _cursor.hotspotX, _cursor.hotspotY,
- (_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor),
- (_game.heversion == 70 ? 2 : 1));
+ if (_game.features & GF_16BIT_COLOR && _hePalettes) {
+ //HACK Had to make a second method to avoid many, many linker errors from other engines
+ //this requires ENABLE_16BIT to be defined in the Scumm project, again, because I #ifdef'ed
+ //the method's definition and declaration in cursorman.h
+ CursorMan.replaceCursor16(_grabbedCursor, _cursor.width, _cursor.height,
+ _cursor.hotspotX, _cursor.hotspotY,
+ (_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor),
+ (_game.heversion == 70 ? 2 : 1));
+ } else {
+ CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height,
+ _cursor.hotspotX, _cursor.hotspotY,
+ (_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor),
+ (_game.heversion == 70 ? 2 : 1));
+ }
}
void ScummEngine_v6::grabCursor(int x, int y, int w, int h) {
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);
/**