aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2009-09-22 08:57:45 +0000
committerFilippos Karapetis2009-09-22 08:57:45 +0000
commitaf7b2fc0187a21b9762a22a07597e745b2fbfb80 (patch)
treea6ae7a32050bf6a1d7e42cb88e601d254734bc14 /engines
parent444615777b2c09353802311c6812e5fd7d912081 (diff)
downloadscummvm-rg350-af7b2fc0187a21b9762a22a07597e745b2fbfb80.tar.gz
scummvm-rg350-af7b2fc0187a21b9762a22a07597e745b2fbfb80.tar.bz2
scummvm-rg350-af7b2fc0187a21b9762a22a07597e745b2fbfb80.zip
Simplified the code which creates the mouse cursor
svn-id: r44248
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/gfx/gfx_driver.cpp62
-rw-r--r--engines/sci/gfx/gfx_driver.h2
2 files changed, 24 insertions, 40 deletions
diff --git a/engines/sci/gfx/gfx_driver.cpp b/engines/sci/gfx/gfx_driver.cpp
index 91c5fadc23..e4d8f8b8cb 100644
--- a/engines/sci/gfx/gfx_driver.cpp
+++ b/engines/sci/gfx/gfx_driver.cpp
@@ -211,57 +211,43 @@ void GfxDriver::setStaticBuffer(gfx_pixmap_t *pic, gfx_pixmap_t *priority) {
// Mouse pointer operations
-// Scale cursor and map its colors to the global palette
-byte *GfxDriver::createCursor(gfx_pixmap_t *pointer) {
- int linewidth = pointer->width;
- int lines = pointer->height;
- byte *data = new byte[linewidth*lines];
- byte *linebase = data, *pos;
- byte *src = pointer->index_data;
+void GfxDriver::setPointer(gfx_pixmap_t *pointer, Common::Point *hotspot) {
+ if (!pointer || !hotspot) {
+ CursorMan.showMouse(false);
+ return;
+ }
+
+ // Scale cursor and map its colors to the global palette
+ byte *cursorData = new byte[pointer->width * pointer->height];
for (int yc = 0; yc < pointer->index_height; yc++) {
- pos = linebase;
+ byte *linebase = &cursorData[yc * (pointer->width * _mode->scaleFactor)];
for (int xc = 0; xc < pointer->index_width; xc++) {
- byte color = *src;
+ byte color = pointer->index_data[yc * pointer->index_width + xc];
// FIXME: The palette size check is a workaround for cursors using non-palette colour GFX_CURSOR_TRANSPARENT
// Note that some cursors don't have a palette in SQ5
if (pointer->palette && color < pointer->palette->size())
color = pointer->palette->getColor(color).parent_index;
- for (int scalectr = 0; scalectr < _mode->scaleFactor; scalectr++) {
- *pos++ = color;
- }
- src++;
+ memset(&linebase[xc], color, _mode->scaleFactor);
}
+
+ // Scale vertically
for (int scalectr = 1; scalectr < _mode->scaleFactor; scalectr++)
- memcpy(linebase + linewidth * scalectr, linebase, linewidth);
- linebase += linewidth * _mode->scaleFactor;
+ memcpy(&linebase[pointer->width * scalectr], linebase, pointer->width);
}
- return data;
-}
+ // FIXME: The palette size check is a workaround for cursors using non-palette color GFX_CURSOR_TRANSPARENT
+ // Note that some cursors don't have a palette (e.g. in SQ5 and QFG3)
+ byte color_key = pointer->color_key;
+ if ((pointer->color_key != GFX_PIXMAP_COLOR_KEY_NONE) && (pointer->palette && (uint)pointer->color_key < pointer->palette->size()))
+ color_key = pointer->palette->getColor(pointer->color_key).parent_index;
-void GfxDriver::setPointer(gfx_pixmap_t *pointer, Common::Point *hotspot) {
- if ((pointer == NULL) || (hotspot == NULL)) {
- CursorMan.showMouse(false);
- } else {
- byte *cursorData = createCursor(pointer);
-
- // FIXME: The palette size check is a workaround for cursors using non-palette color GFX_CURSOR_TRANSPARENT
- // Note that some cursors don't have a palette (e.g. in SQ5 and QFG3)
- byte color_key = GFX_CURSOR_TRANSPARENT;
- if ((pointer->color_key != GFX_PIXMAP_COLOR_KEY_NONE) && (pointer->palette && (unsigned int)pointer->color_key < pointer->palette->size()))
- color_key = pointer->palette->getColor(pointer->color_key).parent_index;
- // Some cursors don't have a palette, so we set the color key directly
- if (!pointer->palette)
- color_key = pointer->color_key;
-
- CursorMan.replaceCursor(cursorData, pointer->width, pointer->height, hotspot->x, hotspot->y, color_key);
- CursorMan.showMouse(true);
-
- delete[] cursorData;
- cursorData = 0;
- }
+ CursorMan.replaceCursor(cursorData, pointer->width, pointer->height, hotspot->x, hotspot->y, color_key);
+ CursorMan.showMouse(true);
+
+ delete[] cursorData;
+ cursorData = 0;
}
} // End of namespace Sci
diff --git a/engines/sci/gfx/gfx_driver.h b/engines/sci/gfx/gfx_driver.h
index e277e3b7df..b7af895237 100644
--- a/engines/sci/gfx/gfx_driver.h
+++ b/engines/sci/gfx/gfx_driver.h
@@ -229,8 +229,6 @@ public:
byte *getVisual0() { return _visual[0]; }
private:
- byte *createCursor(gfx_pixmap_t *pointer);
-
gfx_pixmap_t *_priority[2];
byte *_visual[2];
gfx_mode_t *_mode; /**< Currently active mode, NULL if no mode is active */