aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJody Northup2009-06-11 05:56:00 +0000
committerJody Northup2009-06-11 05:56:00 +0000
commit6adbd0c41e79b5a21f0430e060347d4978e9ce78 (patch)
treee8d99c06d597b74a64b7d1590885c13db2f03010
parentb4c44a018b636a9805c725f9a286e58be554afc2 (diff)
downloadscummvm-rg350-6adbd0c41e79b5a21f0430e060347d4978e9ce78.tar.gz
scummvm-rg350-6adbd0c41e79b5a21f0430e060347d4978e9ce78.tar.bz2
scummvm-rg350-6adbd0c41e79b5a21f0430e060347d4978e9ce78.zip
Renamed Graphics::ColorFormat to Graphics::ColorMode, streamlined enum by removing order section and temporarily removing kFormatARGB1555
Converted cursor code to make use of _screenFormat, instead of a parameter passed directly to it by the engine. Adjusted scumm engine to account for these changes. This should probably have been two separate commits, but the changes concern the same files... svn-id: r41443
-rw-r--r--backends/platform/sdl/graphics.cpp126
-rw-r--r--backends/platform/sdl/sdl.cpp2
-rw-r--r--backends/platform/sdl/sdl.h10
-rw-r--r--base/main.cpp2
-rw-r--r--common/system.h10
-rw-r--r--engines/engine.cpp17
-rw-r--r--engines/engine.h2
-rw-r--r--engines/scumm/cursor.cpp19
-rw-r--r--engines/scumm/scumm.cpp10
-rw-r--r--graphics/cursorman.cpp56
-rw-r--r--graphics/cursorman.h45
-rw-r--r--graphics/pixelformat.h52
12 files changed, 118 insertions, 233 deletions
diff --git a/backends/platform/sdl/graphics.cpp b/backends/platform/sdl/graphics.cpp
index 4035bdb661..51f63a364a 100644
--- a/backends/platform/sdl/graphics.cpp
+++ b/backends/platform/sdl/graphics.cpp
@@ -123,6 +123,13 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) {
_videoMode.mode = _oldVideoMode.mode;
_videoMode.scaleFactor = _oldVideoMode.scaleFactor;
+#ifdef ENABLE_16BIT
+ } else if (_videoMode.format != _oldVideoMode.format) {
+ errors |= kTransactionPixelFormatNotSupported;
+
+ _videoMode.format = _oldVideoMode.format;
+ _screenFormat = getPixelFormat(_videoMode.format);
+#endif
} else if (_videoMode.screenWidth != _oldVideoMode.screenWidth || _videoMode.screenHeight != _oldVideoMode.screenHeight) {
errors |= kTransactionSizeChangeFailed;
@@ -130,12 +137,6 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) {
_videoMode.screenHeight = _oldVideoMode.screenHeight;
_videoMode.overlayWidth = _oldVideoMode.overlayWidth;
_videoMode.overlayHeight = _oldVideoMode.overlayHeight;
-#ifdef ENABLE_16BIT
- } else if (_videoMode.format != _oldVideoMode.format) {
- errors |= kTransactionPixelFormatNotSupported;
-
- _videoMode.format = _oldVideoMode.format;
-#endif
}
if (_videoMode.fullscreen == _oldVideoMode.fullscreen &&
@@ -153,32 +154,8 @@ OSystem::TransactionError OSystem_SDL::endGFXTransaction(void) {
}
#ifdef ENABLE_16BIT
- if (_transactionDetails.formatChanged) {
- _screenFormat = getPixelFormat(_videoMode.format);
- if (!_transactionDetails.sizeChanged) {
- unloadGFXMode();
- if (!loadGFXMode()) {
- if (_oldVideoMode.setup) {
- _transactionMode = kTransactionRollback;
- errors |= endGFXTransaction();
- }
- } else {
- setGraphicsModeIntern();
- clearOverlay();
-
- _videoMode.setup = true;
- _modeChanged = true;
- // OSystem_SDL::pollEvent used to update the screen change count,
- // but actually it gives problems when a video mode was changed
- // but OSystem_SDL::pollEvent was not called. This for example
- // caused a crash under certain circumstances when doing an RTL.
- // To fix this issue we update the screen change count right here.
- _screenChangeCount++;
- }
- }
- }
+ if (_transactionDetails.sizeChanged || _transactionDetails.formatChanged) {
#endif
- if (_transactionDetails.sizeChanged) {
unloadGFXMode();
if (!loadGFXMode()) {
if (_oldVideoMode.setup) {
@@ -375,11 +352,11 @@ int OSystem_SDL::getGraphicsMode() const {
return _videoMode.mode;
}
#ifdef ENABLE_16BIT
-Graphics::ColorFormat OSystem_SDL::findCompatibleFormat(Common::List<Graphics::ColorFormat> formatList) {
+Graphics::ColorMode OSystem_SDL::findCompatibleFormat(Common::List<Graphics::ColorMode> formatList) {
bool typeAccepted = false;
- Graphics::ColorFormat format;
+ Graphics::ColorMode format;
- while (!formatList.empty() && !typeAccepted) {
+ while (!formatList.empty()) {
typeAccepted = false;
format = formatList.front();
@@ -389,33 +366,21 @@ Graphics::ColorFormat OSystem_SDL::findCompatibleFormat(Common::List<Graphics::C
return format;
formatList.pop_front();
- switch (format & Graphics::kFormatTypeMask) {
- case Graphics::kFormat8Bit:
- if (format == Graphics::kFormat8Bit)
+ switch (format) {
+ case Graphics::kFormatCLUT8:
+ if (format == Graphics::kFormatCLUT8)
return format;
break;
case Graphics::kFormatRGB555:
- case Graphics::kFormatARGB1555:
case Graphics::kFormatRGB565:
- typeAccepted = true;
- break;
- }
-
- if (!typeAccepted)
- continue;
-
- switch (format & Graphics::kFormatOrderMask) {
- case Graphics::kFormatRGB:
- case Graphics::kFormatRGBA:
return format;
- default:
break;
}
}
- return Graphics::kFormat8Bit;
+ return Graphics::kFormatCLUT8;
}
-void OSystem_SDL::initFormat(Graphics::ColorFormat format) {
+void OSystem_SDL::initFormat(Graphics::ColorMode format) {
assert(_transactionMode == kTransactionActive);
//avoid redundant format changes
@@ -424,17 +389,13 @@ void OSystem_SDL::initFormat(Graphics::ColorFormat format) {
_videoMode.format = format;
_transactionDetails.formatChanged = true;
-
+ _screenFormat = getPixelFormat(format);
}
//This should only ever be called with a format that is known supported.
-Graphics::PixelFormat OSystem_SDL::getPixelFormat(Graphics::ColorFormat format) {
+Graphics::PixelFormat OSystem_SDL::getPixelFormat(Graphics::ColorMode format) {
Graphics::PixelFormat result;
- switch (format & Graphics::kFormatTypeMask) {
- case Graphics::kFormatARGB1555:
- result.aLoss = 7;
- result.bytesPerPixel = 2;
- result.rLoss = result.gLoss = result.bLoss = 3;
+ switch (format) {
case Graphics::kFormatRGB555:
result.aLoss = 8;
result.bytesPerPixel = 2;
@@ -446,24 +407,17 @@ Graphics::PixelFormat OSystem_SDL::getPixelFormat(Graphics::ColorFormat format)
result.gLoss = 2;
result.rLoss = result.bLoss = 3;
break;
- case Graphics::kFormat8Bit:
+ case Graphics::kFormatCLUT8:
default:
result.bytesPerPixel = 1;
result.rShift = result.gShift = result.bShift = result.aShift = 0;
result.rLoss = result.gLoss = result.bLoss = result.aLoss = 8;
return result;
}
- switch (format & Graphics::kFormatOrderMask) {
- default:
- case Graphics::kFormatRGBA:
- result.aShift = 0;
- // fall through
- case Graphics::kFormatRGB:
- result.bShift = result.aBits();
- result.gShift = result.bShift + result.bBits();
- result.rShift = result.gShift + result.gBits();
- break;
- }
+ result.aShift = 0;
+ result.bShift = result.aBits();
+ result.gShift = result.bShift + result.bBits();
+ result.rShift = result.gShift + result.gBits();
return result;
}
#endif
@@ -1473,15 +1427,8 @@ void OSystem_SDL::warpMouse(int x, int y) {
}
#ifdef ENABLE_16BIT
-void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, uint8 bitDepth) {
- uint32 colmask = 0xFF;
- uint8 byteDepth = bitDepth >> 3;
- for (int i = byteDepth; i > 1; i--) {
- colmask <<= 8;
- colmask |= 0xFF;
- }
- keycolor &= colmask;
- _cursorBitDepth = bitDepth;
+void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale) {
+ keycolor &= (1 << (_screenFormat.bytesPerPixel << 3)) - 1;
#else
void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, byte keycolor, int cursorTargetScale) {
#endif
@@ -1520,8 +1467,8 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x,
free(_mouseData);
#ifdef ENABLE_16BIT
- _mouseData = (byte *)malloc(w * h * byteDepth);
- memcpy(_mouseData, buf, w * h * byteDepth);
+ _mouseData = (byte *)malloc(w * h * _screenFormat.bytesPerPixel);
+ memcpy(_mouseData, buf, w * h * _screenFormat.bytesPerPixel);
#else
_mouseData = (byte *)malloc(w * h);
memcpy(_mouseData, buf, w * h);
@@ -1533,7 +1480,12 @@ void OSystem_SDL::setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x,
void OSystem_SDL::blitCursor() {
byte *dstPtr;
const byte *srcPtr = _mouseData;
+#ifdef ENABLE_16BIT
+ uint32 color;
+ uint32 colormask = (1 << (_screenFormat.bytesPerPixel << 3)) - 1;
+#else
byte color;
+#endif
int w, h, i, j;
if (!_mouseOrigSurface || !_mouseData)
@@ -1567,20 +1519,20 @@ void OSystem_SDL::blitCursor() {
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
- color = *srcPtr;
#ifdef ENABLE_16BIT
- if (_cursorBitDepth == 16) {
+ if (_screenFormat.bytesPerPixel > 1) {
+ color = (*(uint32 *) srcPtr) & colormask;
if (color != _mouseKeyColor) { // transparent, don't draw
- int8 r = ((*(uint16 *)srcPtr >> 10) & 0x1F) << 3;
- int8 g = ((*(uint16 *)srcPtr >> 5) & 0x1F) << 3;
- int8 b = (*(uint16 *)srcPtr & 0x1F) << 3;
+ uint8 r,g,b;
+ _screenFormat.colorToRGB(color,r,g,b);
*(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format,
r, g, b);
}
dstPtr += 2;
- srcPtr += 2;
+ srcPtr += _screenFormat.bytesPerPixel;
} else {
#endif
+ color = *srcPtr;
if (color != _mouseKeyColor) { // transparent, don't draw
*(uint16 *)dstPtr = SDL_MapRGB(_mouseOrigSurface->format,
palette[color].r, palette[color].g, palette[color].b);
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 3ec4da1196..5bcd91d566 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -197,7 +197,7 @@ OSystem_SDL::OSystem_SDL()
#endif
_hwscreen(0), _screen(0), _tmpscreen(0),
#ifdef ENABLE_16BIT
- _screenFormat(getPixelFormat(Graphics::kFormat8Bit)),
+ _screenFormat(getPixelFormat(Graphics::kFormatCLUT8)),
_cursorBitDepth(8),
#endif
_overlayVisible(false),
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 513ad73934..4d5ea3f548 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -84,17 +84,17 @@ public:
#ifdef ENABLE_16BIT
// Find a compatible format from the list of formats supported by the engine
// Fallback to CLUT8 if none found
- virtual Graphics::ColorFormat findCompatibleFormat(Common::List<Graphics::ColorFormat> formatList);
+ virtual Graphics::ColorMode findCompatibleFormat(Common::List<Graphics::ColorMode> formatList);
// Set the depth and format of the video bitmap
// Typically, CLUT8
- virtual void initFormat(Graphics::ColorFormat format);
+ virtual void initFormat(Graphics::ColorMode format);
// Game screen
virtual Graphics::PixelFormat getScreenFormat() const { return _screenFormat; }
//Create a Graphics::PixelFormat to describe the requested color mode
- virtual Graphics::PixelFormat getPixelFormat(Graphics::ColorFormat format);
+ virtual Graphics::PixelFormat getPixelFormat(Graphics::ColorMode format);
#endif
// Set the size of the video bitmap.
@@ -129,7 +129,7 @@ public:
// Set the bitmap that's used when drawing the cursor.
#ifdef ENABLE_16BIT
- virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale, uint8 bitDepth = 8); // overloaded by CE backend (FIXME)
+ virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, int cursorTargetScale); // overloaded by CE backend (FIXME)
#else
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)
#endif
@@ -302,7 +302,7 @@ protected:
int screenWidth, screenHeight;
int overlayWidth, overlayHeight;
#ifdef ENABLE_16BIT
- Graphics::ColorFormat format;
+ Graphics::ColorMode format;
#endif
};
VideoState _videoMode, _oldVideoMode;
diff --git a/base/main.cpp b/base/main.cpp
index d76d8828a1..5c1ca7dc20 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -227,7 +227,7 @@ static void setupGraphics(OSystem &system) {
system.setGraphicsMode(ConfMan.get("gfx_mode").c_str());
#ifdef ENABLE_16BIT
- system.initFormat(Graphics::kFormat8Bit);
+ system.initFormat(Graphics::kFormatCLUT8);
#endif
system.initSize(320, 200);
diff --git a/common/system.h b/common/system.h
index 59da28c990..82a89f4ad3 100644
--- a/common/system.h
+++ b/common/system.h
@@ -357,9 +357,9 @@ public:
*
* @param formatList A list of requested pixel formats, ordered by priority
*
- * @return a supported ColorFormat from the list, or kFormat8Bit if no supported format was found
+ * @return a supported ColorMode from the list, or kFormatCLUT8 if no supported format was found
*/
- virtual Graphics::ColorFormat findCompatibleFormat(Common::List<Graphics::ColorFormat> formatList) = 0;
+ virtual Graphics::ColorMode findCompatibleFormat(Common::List<Graphics::ColorMode> formatList) = 0;
/**
* Set the color format of the virtual screen. Typical formats include:
@@ -374,7 +374,7 @@ public:
*
* @param format A pixel format that the backend screen will use
*/
- virtual void initFormat(Graphics::ColorFormat format) = 0;
+ virtual void initFormat(Graphics::ColorMode format) = 0;
/**
* Returns the pixel format description of the screen.
@@ -386,7 +386,7 @@ public:
* Returns the pixel format description of the requested color mode
* @see Graphics::PixelFormat
*/
- virtual Graphics::PixelFormat getPixelFormat(Graphics::ColorFormat format) = 0;
+ virtual Graphics::PixelFormat getPixelFormat(Graphics::ColorMode format) = 0;
#endif
@@ -738,7 +738,7 @@ public:
* @param cursorTargetScale scale factor which cursor is designed for
*/
#ifdef ENABLE_16BIT
- virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int cursorTargetScale = 1, uint8 bitDepth = 8) = 0;
+ virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int cursorTargetScale = 1) = 0;
#else
virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int cursorTargetScale = 1) = 0;
#endif
diff --git a/engines/engine.cpp b/engines/engine.cpp
index 4be4fe90be..31ead2df1a 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -126,18 +126,18 @@ void initCommonGFX(bool defaultTo1XScaler) {
}
void initGraphics(int width, int height, bool defaultTo1xScaler) {
#ifdef ENABLE_16BIT
- Common::List<Graphics::ColorFormat> formatList;
- formatList.push_back(Graphics::kFormat8Bit);
+ Common::List<Graphics::ColorMode> formatList;
+ formatList.push_back(Graphics::kFormatCLUT8);
initGraphics(width,height,defaultTo1xScaler, formatList);
}
-void initGraphics(int width, int height, bool defaultTo1xScaler, Common::List<Graphics::ColorFormat> formatList) {
+void initGraphics(int width, int height, bool defaultTo1xScaler, Common::List<Graphics::ColorMode> formatList) {
#endif
g_system->beginGFXTransaction();
initCommonGFX(defaultTo1xScaler);
#ifdef ENABLE_16BIT
- Graphics::ColorFormat format = g_system->findCompatibleFormat(formatList);
+ Graphics::ColorMode format = g_system->findCompatibleFormat(formatList);
debug("%X",format); //TODO: set up the pixelFormat here
g_system->initFormat(format);
#endif
@@ -161,6 +161,15 @@ void initGraphics(int width, int height, bool defaultTo1xScaler, Common::List<Gr
error("%s", message.c_str());
}
+#ifdef ENABLE_16BIT
+ if (gfxError & OSystem::kTransactionPixelFormatNotSupported) {
+ Common::String message = "Could not initialize color format.";
+
+ GUIErrorMessage(message);
+ error("%s", message.c_str());
+ }
+#endif
+
// Just show warnings then these occur:
if (gfxError & OSystem::kTransactionModeSwitchFailed) {
Common::String message = "Could not switch to video mode: '";
diff --git a/engines/engine.h b/engines/engine.h
index 8538cc779f..87ee70b1b9 100644
--- a/engines/engine.h
+++ b/engines/engine.h
@@ -63,7 +63,7 @@ void initCommonGFX(bool defaultTo1XScaler);
* mode.
*/
#ifdef ENABLE_16BIT
-void initGraphics(int width, int height, bool defaultTo1xScaler, Common::List<Graphics::ColorFormat> formatList);
+void initGraphics(int width, int height, bool defaultTo1xScaler, Common::List<Graphics::ColorMode> formatList);
#endif
void initGraphics(int width, int height, bool defaultTo1xScaler);
diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp
index bc4a2e0d33..fcde07cbdf 100644
--- a/engines/scumm/cursor.cpp
+++ b/engines/scumm/cursor.cpp
@@ -112,21 +112,10 @@ void ScummEngine_v6::setCursorTransparency(int a) {
void ScummEngine::updateCursor() {
int transColor = (_game.heversion >= 80) ? 5 : 255;
- if (_game.features & GF_16BIT_COLOR) {
- //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.replaceCursorReal(_grabbedCursor, _cursor.width, _cursor.height,
- _cursor.hotspotX, _cursor.hotspotY,
- (_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor),
- (_game.heversion == 70 ? 2 : 1),
- 16);
- } else {
- CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height,
- _cursor.hotspotX, _cursor.hotspotY,
- (_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor),
- (_game.heversion == 70 ? 2 : 1));
- }
+ 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/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 3d0a2d0bc2..0ebf832a37 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -1083,12 +1083,14 @@ Common::Error ScummEngine::init() {
// CJK FT and DIG use usual NUT fonts, not FM-TOWNS ROM, so
// there is no text surface for them. This takes that into account
(_screenWidth * _textSurfaceMultiplier > 320));
+#ifdef ENABLE_16BIT
} else if (_game.features & GF_16BIT_COLOR) {
- int format = Graphics::kFormatRGB555 | Graphics::kFormatRGB;
- Common::List<Graphics::ColorFormat> formatList;
- formatList.push_back((Graphics::ColorFormat) format);
- formatList.push_back(Graphics::kFormat8Bit);
+ int format = Graphics::kFormatRGB555;
+ Common::List<Graphics::ColorMode> formatList;
+ formatList.push_back((Graphics::ColorMode) format);
+ formatList.push_back(Graphics::kFormatCLUT8);
initGraphics(_screenWidth, _screenHeight, _screenWidth > 320, formatList);
+#endif
} else {
initGraphics(_screenWidth, _screenHeight, _screenWidth > 320);
}
diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp
index 00932e55b0..850b0044dc 100644
--- a/graphics/cursorman.cpp
+++ b/graphics/cursorman.cpp
@@ -57,33 +57,18 @@ bool CursorManager::showMouse(bool visible) {
return g_system->showMouse(visible);
}
-void CursorManager::pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetScale) {
#ifdef ENABLE_16BIT
- pushCursorReal(buf,w,h,hotspotX,hotspotY,keycolor,targetScale,8);
-}
-void CursorManager::pushCursorReal(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale, uint8 bitDepth) {
- uint32 colmask = 0xFF;
- uint8 byteDepth = bitDepth >> 3;
- for (int i = byteDepth; i > 1; i--) {
- colmask <<= 8;
- colmask |= 0xFF;
- }
- keycolor &= colmask;
-
- Cursor *cur = new Cursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale, bitDepth);
+void CursorManager::pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale) {
#else
- Cursor *cur = new Cursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale);
+void CursorManager::pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetScale) {
#endif
+ Cursor *cur = new Cursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale);
cur->_visible = isVisible();
_cursorStack.push(cur);
if (buf) {
-#ifdef ENABLE_16BIT
- g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, bitDepth);
-#else
g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale);
-#endif
}
}
@@ -96,11 +81,7 @@ void CursorManager::popCursor() {
if (!_cursorStack.empty()) {
cur = _cursorStack.top();
-#ifdef ENABLE_16BIT
- g_system->setMouseCursor(cur->_data, cur->_width, cur->_height, cur->_hotspotX, cur->_hotspotY, cur->_keycolor, cur->_targetScale, cur->_bitDepth);
-#else
g_system->setMouseCursor(cur->_data, cur->_width, cur->_height, cur->_hotspotX, cur->_hotspotY, cur->_keycolor, cur->_targetScale);
-#endif
}
g_system->showMouse(isVisible());
@@ -123,34 +104,25 @@ void CursorManager::popAllCursors() {
g_system->showMouse(isVisible());
}
-void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetScale) {
#ifdef ENABLE_16BIT
- replaceCursorReal(buf,w,h,hotspotX,hotspotY,keycolor,targetScale);
-}
-
-void CursorManager::replaceCursorReal(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale, uint8 bitDepth) {
- uint32 colmask = 0xFF;
- uint8 byteDepth = bitDepth >> 3;
- for (int i = byteDepth; i > 1; i--) {
- colmask <<= 8;
- colmask |= 0xFF;
- }
- keycolor &= colmask;
-
+void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int targetScale) {
+#else
+void CursorManager::replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetScale) {
#endif
+
if (_cursorStack.empty()) {
-#ifdef ENABLE_16BIT
- pushCursorReal(buf, w, h, hotspotX, hotspotY, keycolor, targetScale, bitDepth);
-#else
pushCursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale);
-#endif
return;
}
Cursor *cur = _cursorStack.top();
#ifdef ENABLE_16BIT
- uint size = w * h * (bitDepth >> 3);
+ uint size;
+ { //limit the lifespan of the format variable to minimize memory impact
+ Graphics::PixelFormat f = g_system->getScreenFormat();
+ size = w * h * (f.bytesPerPixel);
+ }
#else
uint size = w * h;
#endif
@@ -171,11 +143,7 @@ void CursorManager::replaceCursorReal(const byte *buf, uint w, uint h, int hotsp
cur->_keycolor = keycolor;
cur->_targetScale = targetScale;
-#ifdef ENABLE_16BIT
- g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale, bitDepth);
-#else
g_system->setMouseCursor(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale);
-#endif
}
void CursorManager::disableCursorPalette(bool disable) {
diff --git a/graphics/cursorman.h b/graphics/cursorman.h
index 481567bb09..0c02292818 100644
--- a/graphics/cursorman.h
+++ b/graphics/cursorman.h
@@ -28,6 +28,10 @@
#include "common/scummsys.h"
#include "common/stack.h"
#include "common/singleton.h"
+#ifdef ENABLE_16BIT
+#include "graphics/pixelformat.h"
+#include "common/system.h"
+#endif
namespace Graphics {
@@ -56,10 +60,11 @@ public:
* useful to push a "dummy" cursor and modify it later. The
* cursor will be added to the stack, but not to the backend.
*/
- void pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int targetScale = 1);
-#ifdef ENABLE_16BIT
- void pushCursorReal(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1, uint8 bitDepth = 8);
-#endif
+//#ifdef ENABLE_16BIT
+ void pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1);
+//#else
+// void pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int targetScale = 1);
+//#endif
/**
* Pop a cursor from the stack, and restore the previous one to the
@@ -80,11 +85,11 @@ public:
* @param keycolor the index for the transparent color
* @param targetScale the scale for which the cursor is designed
*/
- void replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int targetScale = 1);
-#ifdef ENABLE_16BIT
- //HACK made a separate method to avoid massive linker errors on every engine.
- void replaceCursorReal(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1, uint8 bitDepth = 8);
-#endif
+//#ifdef ENABLE_16BIT
+ void replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1);
+//#else
+// void replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int targetScale = 1);
+//#endif
/**
* Pop all of the cursors and cursor palettes from their respective stacks.
@@ -148,28 +153,22 @@ private:
uint _height;
int _hotspotX;
int _hotspotY;
-#ifdef ENABLE_16BIT
+//#ifdef ENABLE_16BIT
uint32 _keycolor;
- uint8 _bitDepth;
-#else
- byte _keycolor;
-#endif
+//#else
+// byte _keycolor;
+//#endif
byte _targetScale;
uint _size;
#ifdef ENABLE_16BIT
Cursor(const byte *data, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 0xFFFFFFFF, int targetScale = 1, uint8 bitDepth = 8) {
- uint32 colmask = 0xFF;
- uint8 byteDepth = bitDepth >> 3;
- _size = w * h * byteDepth;
- _bitDepth = bitDepth;
- for (int i = byteDepth; i > 1; i--) {
- colmask <<= 8;
- colmask |= 0xFF;
+ { //limit the lifespan of the format value to minimize impact on memory usage
+ Graphics::PixelFormat f = g_system->getScreenFormat();
+ _size = w * h * f.bytesPerPixel;
+ _keycolor = keycolor & ((1 << (f.bytesPerPixel << 3)) - 1);
}
- _keycolor = keycolor & colmask;
-
#else
Cursor(const byte *data, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int targetScale = 1) {
_size = w * h;
diff --git a/graphics/pixelformat.h b/graphics/pixelformat.h
index 2e8c065414..d37a7794f4 100644
--- a/graphics/pixelformat.h
+++ b/graphics/pixelformat.h
@@ -43,50 +43,16 @@ namespace Graphics {
* Use (format & kFormatTypeMask) to get the type, and (format & kFormatOrderMask)
* to get the applicable color order.
*/
-enum ColorFormat {
- kFormat8Bit = 0,
+enum ColorMode {
+ kFormatCLUT8 = 0,
kFormatRGB555 = 1,
- kFormatARGB1555 = 2, // Rare, but I know a guy who knows a guy who's heard of it being used
- kFormatRGB556 = 3, // 6 bits for blue, in case this ever happens
- kFormatRGB565 = 4,
- kFormatRGB655 = 5, // 6 bits for red, in case this ever happens
- kFormatARGB4444 = 6,
- kFormatRGB888 = 7,
- kFormatARGB6666 = 8, // I've never heard of this, but it's theoretically possible
- kFormatARGB8888 = 9,
- kFormatTypeMask = 0xFF, // & by this to get the overall bit format
- kFormatPalette = 0 << 8,
- kFormatRGB = 1 << 8,
- kFormatRBG = 2 << 8,
- kFormatGRB = 3 << 8,
- kFormatGBR = 4 << 8,
- kFormatBRG = 5 << 8,
- kFormatBGR = 6 << 8,
- kFormatARGB = 7 << 8,
- kFormatARBG = 8 << 8,
- kFormatAGRB = 9 << 8,
- kFormatAGBR = 10 << 8,
- kFormatABRG = 11 << 8,
- kFormatABGR = 12 << 8,
- kFormatRAGB = 13 << 8,
- kFormatRABG = 14 << 8,
- kFormatGARB = 15 << 8,
- kFormatGABR = 16 << 8,
- kFormatBARG = 17 << 8,
- kFormatBAGR = 18 << 8,
- kFormatRGAB = 19 << 8,
- kFormatRBAG = 20 << 8,
- kFormatGRAB = 21 << 8,
- kFormatGBAR = 22 << 8,
- kFormatBRAG = 23 << 8,
- kFormatBGAR = 24 << 8,
- kFormatRGBA = 25 << 8,
- kFormatRBGA = 26 << 8,
- kFormatGRBA = 27 << 8,
- kFormatGBRA = 28 << 8,
- kFormatBRGA = 29 << 8,
- kFormatBGRA = 30 << 8,
- kFormatOrderMask = 0xFF << 8 // & by this to get the order
+ kFormatRGB556 = 2, // 6 bits for blue, in case this ever happens
+ kFormatRGB565 = 3,
+ kFormatRGB655 = 4, // 6 bits for red, in case this ever happens
+ kFormatRGBA4444 = 5,
+ kFormatRGB888 = 6,
+ kFormatRGBA6666 = 7, // I've never heard of this, but it's theoretically possible
+ kFormatRGBA8888 = 8
};
#endif