aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2009-09-30 22:43:29 +0000
committerFilippos Karapetis2009-09-30 22:43:29 +0000
commitbbb2274a7d7d57edfbf0c11271a7203c036cba7d (patch)
treee06ec57d8cde25cdef4a08e0900c73b0fa410439 /engines
parent598056ead0bfff5bf6b08de50cc19e159f91d35a (diff)
downloadscummvm-rg350-bbb2274a7d7d57edfbf0c11271a7203c036cba7d.tar.gz
scummvm-rg350-bbb2274a7d7d57edfbf0c11271a7203c036cba7d.tar.bz2
scummvm-rg350-bbb2274a7d7d57edfbf0c11271a7203c036cba7d.zip
- Removed some leftover 16/32bpp color code, as we're always using palette mode now
- Simplified the mouse cursor manipulation code svn-id: r44502
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/gfx/gfx_driver.cpp14
-rw-r--r--engines/sci/gfx/gfx_driver.h2
-rw-r--r--engines/sci/gfx/gfx_tools.cpp2
-rw-r--r--engines/sci/gfx/gfx_tools.h4
-rw-r--r--engines/sci/gfx/operations.cpp96
-rw-r--r--engines/sci/gfx/operations.h2
-rw-r--r--engines/sci/gfx/res_pic.cpp6
-rw-r--r--engines/sci/sci.cpp8
8 files changed, 28 insertions, 106 deletions
diff --git a/engines/sci/gfx/gfx_driver.cpp b/engines/sci/gfx/gfx_driver.cpp
index dd98843e0f..15704b636c 100644
--- a/engines/sci/gfx/gfx_driver.cpp
+++ b/engines/sci/gfx/gfx_driver.cpp
@@ -36,10 +36,10 @@
namespace Sci {
-GfxDriver::GfxDriver(int xfact, int yfact, Graphics::PixelFormat format) {
+GfxDriver::GfxDriver(int xfact, int yfact) {
int i;
- _mode = gfx_new_mode(xfact, yfact, format, format.bytesPerPixel == 1 ? new Palette(256) : 0, 0);
+ _mode = gfx_new_mode(xfact, yfact, new Palette(256));
_mode->xsize = xfact * 320;
_mode->ysize = yfact * 200;
@@ -217,6 +217,8 @@ void GfxDriver::setPointer(gfx_pixmap_t *pointer, Common::Point *hotspot) {
return;
}
+ pointer->palette->mergeInto(_mode->palette);
+
// Scale cursor and map its colors to the global palette
byte *cursorData = new byte[pointer->width * pointer->height];
@@ -225,9 +227,7 @@ void GfxDriver::setPointer(gfx_pixmap_t *pointer, Common::Point *hotspot) {
for (int xc = 0; xc < pointer->index_width; xc++) {
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())
+ if (color < pointer->palette->size())
color = pointer->palette->getColor(color).getParentIndex();
memset(&linebase[xc], color, _mode->scaleFactor);
}
@@ -237,10 +237,8 @@ void GfxDriver::setPointer(gfx_pixmap_t *pointer, Common::Point *hotspot) {
memcpy(&linebase[pointer->width * scalectr], linebase, pointer->width);
}
- // 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()))
+ if ((pointer->color_key != GFX_PIXMAP_COLOR_KEY_NONE) && ((uint)pointer->color_key < pointer->palette->size()))
color_key = pointer->palette->getColor(pointer->color_key).getParentIndex();
CursorMan.replaceCursor(cursorData, pointer->width, pointer->height, hotspot->x, hotspot->y, color_key);
diff --git a/engines/sci/gfx/gfx_driver.h b/engines/sci/gfx/gfx_driver.h
index b7af895237..ede48a6b34 100644
--- a/engines/sci/gfx/gfx_driver.h
+++ b/engines/sci/gfx/gfx_driver.h
@@ -85,7 +85,7 @@ public:
* not be set, or GFX_FATAL if the graphics target
* is unuseable.
*/
- GfxDriver(int xfact, int yfact, Graphics::PixelFormat mode);
+ GfxDriver(int xfact, int yfact);
/**
* Uninitializes the current graphics mode.
diff --git a/engines/sci/gfx/gfx_tools.cpp b/engines/sci/gfx/gfx_tools.cpp
index 34632260b3..5df8f4a97c 100644
--- a/engines/sci/gfx/gfx_tools.cpp
+++ b/engines/sci/gfx/gfx_tools.cpp
@@ -43,7 +43,7 @@ void gfx_clip_box_basic(rect_t *box, int maxx, int maxy) {
box->height = maxy - box->y + 1;
}
-gfx_mode_t *gfx_new_mode(int xfact, int yfact, const Graphics::PixelFormat &format, Palette *palette, int flags) {
+gfx_mode_t *gfx_new_mode(int xfact, int yfact, Palette *palette) {
gfx_mode_t *mode = (gfx_mode_t *)malloc(sizeof(gfx_mode_t));
mode->scaleFactor = xfact;
diff --git a/engines/sci/gfx/gfx_tools.h b/engines/sci/gfx/gfx_tools.h
index a17760f16d..0abf5e26e7 100644
--- a/engines/sci/gfx/gfx_tools.h
+++ b/engines/sci/gfx/gfx_tools.h
@@ -41,12 +41,10 @@ namespace Sci {
*
* @param[in] xfact Horizontal scaling factors
* @param[in] yfact Vertical scaling factors
- * @param[in] format Pixel format description
* @param[in] palette Number of palette colors, 0 if we're not in palette mode
- * @param[in] flags GFX_MODE_FLAG_* values ORred together, or just 0
* @return A newly allocated gfx_mode_t structure
*/
-gfx_mode_t *gfx_new_mode(int xfact, int yfact, const Graphics::PixelFormat &format, Palette *palette, int flags);
+gfx_mode_t *gfx_new_mode(int xfact, int yfact, Palette *palette);
/**
* Clips a rect_t
diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp
index 1787643ae7..6c0d333849 100644
--- a/engines/sci/gfx/operations.cpp
+++ b/engines/sci/gfx/operations.cpp
@@ -63,7 +63,7 @@ PaletteEntry default_colors[DEFAULT_COLORS_NR] = {
#define POINTER_VISIBLE_BUT_CLIPPED 2
// How to determine whether colors have to be allocated
-#define PALETTE_MODE state->driver->getMode()->palette
+#define SCREEN_PALETTE state->driver->getMode()->palette
//#define GFXOP_DEBUG_DIRTY
@@ -386,10 +386,7 @@ static void init_aux_pixmap(gfx_pixmap_t **pixmap) {
void gfxop_init(GfxState *state,
gfx_options_t *options, ResourceManager *resMan,
- Graphics::PixelFormat mode, int xfact, int yfact) {
- //int color_depth = bpp ? bpp : 1;
- //int initialized = 0;
-
+ int xfact, int yfact) {
state->options = options;
state->visible_map = GFX_MASK_VISUAL;
state->fullscreen_override = NULL; // No magical override
@@ -402,7 +399,7 @@ void gfxop_init(GfxState *state,
state->pic_port_bounds = gfx_rect(0, 10, 320, 190);
state->_dirtyRects.clear();
- state->driver = new GfxDriver(xfact, yfact, mode);
+ state->driver = new GfxDriver(xfact, yfact);
state->gfxResMan = new GfxResManager(state->options, state->driver, resMan);
@@ -521,7 +518,7 @@ void gfxop_set_color(GfxState *state, gfx_color_t *color, int r, int g, int b, i
int mask = ((r >= 0 && g >= 0 && b >= 0) ? GFX_MASK_VISUAL : 0) | ((priority >= 0) ? GFX_MASK_PRIORITY : 0)
| ((control >= 0) ? GFX_MASK_CONTROL : 0);
- if (PALETTE_MODE && a >= GFXOP_ALPHA_THRESHOLD)
+ if (a >= GFXOP_ALPHA_THRESHOLD)
mask &= ~GFX_MASK_VISUAL;
color->mask = mask;
@@ -534,10 +531,7 @@ void gfxop_set_color(GfxState *state, gfx_color_t *color, int r, int g, int b, i
color->visual.g = g;
color->visual.b = b;
color->alpha = a;
-
- if (PALETTE_MODE) {
- color->visual._parentIndex = PALETTE_MODE->findNearbyColor(r,g,b,true);
- }
+ color->visual._parentIndex = SCREEN_PALETTE->findNearbyColor(r,g,b,true);
}
}
@@ -553,14 +547,11 @@ void gfxop_set_color(GfxState *state, gfx_color_t *colorOut, gfx_color_t &colorI
}
void gfxop_set_system_color(GfxState *state, unsigned int index, gfx_color_t *color) {
- if (!PALETTE_MODE)
- return;
-
- if (index >= PALETTE_MODE->size()) {
+ if (index >= SCREEN_PALETTE->size()) {
error("Attempt to set invalid color index %02x as system color", color->visual.getParentIndex());
}
- PALETTE_MODE->makeSystemColor(index, color->visual);
+ SCREEN_PALETTE->makeSystemColor(index, color->visual);
}
void gfxop_free_color(GfxState *state, gfx_color_t *color) {
@@ -822,8 +813,6 @@ void gfxop_draw_rectangle(GfxState *state, rect_t rect, gfx_color_t color, gfx_l
}
-#define COLOR_MIX(type, dist) ((color1.type * dist) + (color2.type * (1.0 - dist)))
-
void gfxop_draw_box(GfxState *state, rect_t box, gfx_color_t color1, gfx_color_t color2, gfx_box_shade_t shade_type) {
GfxDriver *drv = state->driver;
int reverse = 0; // switch color1 and color2
@@ -898,40 +887,8 @@ void gfxop_draw_box(GfxState *state, rect_t box, gfx_color_t color1, gfx_color_t
gfxop_set_color(state, &color1, color1);
drv->drawFilledRect(new_box, color1, color1, GFX_SHADE_FLAT);
return;
- } else {
- if (PALETTE_MODE) {
- warning("[GFX] Attempting to draw shaded box in palette mode");
- return; // not critical
- }
-
- gfx_color_t draw_color1; // CHECKME
- gfx_color_t draw_color2;
- gfxop_set_color(state, &draw_color1, 0, 0, 0, 0, 0, 0);
- gfxop_set_color(state, &draw_color2, 0, 0, 0, 0, 0, 0);
-
- draw_color1.mask = draw_color2.mask = color1.mask;
- draw_color1.priority = draw_color2.priority = color1.priority;
-
- if (draw_color1.mask & GFX_MASK_VISUAL) {
- draw_color1.visual.r = (byte) COLOR_MIX(visual.r, mod_offset);
- draw_color1.visual.g = (byte) COLOR_MIX(visual.g, mod_offset);
- draw_color1.visual.b = (byte) COLOR_MIX(visual.b, mod_offset);
- draw_color1.alpha = (byte) COLOR_MIX(alpha, mod_offset);
-
- mod_offset += mod_breadth;
-
- draw_color2.visual.r = (byte) COLOR_MIX(visual.r, mod_offset);
- draw_color2.visual.g = (byte) COLOR_MIX(visual.g, mod_offset);
- draw_color2.visual.b = (byte) COLOR_MIX(visual.b, mod_offset);
- draw_color2.alpha = (byte) COLOR_MIX(alpha, mod_offset);
- }
- if (reverse)
- return drv->drawFilledRect(new_box, draw_color2, draw_color1, driver_shade_type);
- else
- return drv->drawFilledRect(new_box, draw_color1, draw_color2, driver_shade_type);
}
}
-#undef COLOR_MIX
void gfxop_fill_box(GfxState *state, rect_t box, gfx_color_t color) {
gfxop_draw_box(state, box, color, color, GFX_BOX_SHADE_FLAT);
@@ -1047,21 +1004,9 @@ void gfxop_sleep(GfxState *state, uint32 msecs) {
}
}
-static void _gfxop_set_pointer(GfxState *state, gfx_pixmap_t *pxm, Common::Point *hotspot) {
- // FIXME: We may have to store this pxm somewhere, as the global palette
- // may change when a new PIC is loaded. The cursor has to be regenerated
- // from this pxm at that point. (An alternative might be to ensure the
- // cursor only uses colours in the static part of the palette?)
- if (pxm && PALETTE_MODE) {
- assert(pxm->palette);
- pxm->palette->mergeInto(PALETTE_MODE);
- }
- state->driver->setPointer(pxm, hotspot);
-}
-
void gfxop_set_pointer_cursor(GfxState *state, int nr) {
if (nr == GFXOP_NO_POINTER) {
- _gfxop_set_pointer(state, NULL, NULL);
+ state->driver->setPointer(NULL, NULL);
return;
}
@@ -1073,36 +1018,25 @@ void gfxop_set_pointer_cursor(GfxState *state, int nr) {
}
Common::Point p = Common::Point(new_pointer->xoffset, new_pointer->yoffset);
- _gfxop_set_pointer(state, new_pointer, &p);
+ state->driver->setPointer(new_pointer, &p);
}
void gfxop_set_pointer_view(GfxState *state, int nr, int loop, int cel, Common::Point *hotspot) {
- int real_loop = loop;
- int real_cel = cel;
// FIXME: For now, don't palettize pointers
- gfx_pixmap_t *new_pointer = _gfxr_get_cel(state, nr, &real_loop, &real_cel, 0);
-
- if (!new_pointer) {
- warning("[GFX] Attempt to set invalid pointer #%d", nr);
- return;
- }
-
- if (real_loop != loop || real_cel != cel) {
- debugC(2, kDebugLevelGraphics, "Changed loop/cel from %d/%d to %d/%d in view %d\n", loop, cel, real_loop, real_cel, nr);
- }
+ gfx_pixmap_t *new_pointer = state->gfxResMan->getView(nr, &loop, &cel, 0)->loops[loop].cels[cel];
// Eco Quest 1 uses a 1x1 transparent cursor to hide the cursor from the user. Some scalers don't seem to support this.
if (new_pointer->width < 2 || new_pointer->height < 2) {
- _gfxop_set_pointer(state, NULL, NULL);
+ state->driver->setPointer(NULL, NULL);
return;
}
if (hotspot)
- _gfxop_set_pointer(state, new_pointer, hotspot);
+ state->driver->setPointer(new_pointer, hotspot);
else {
// Compute hotspot from xoffset/yoffset
Common::Point p = Common::Point(new_pointer->xoffset + (new_pointer->width >> 1), new_pointer->yoffset + new_pointer->height - 1);
- _gfxop_set_pointer(state, new_pointer, &p);
+ state->driver->setPointer(new_pointer, &p);
}
}
@@ -1625,8 +1559,8 @@ static void _gfxop_set_pic(GfxState *state) {
// FIXME: The _gfxop_install_pixmap call below updates the OSystem palette.
// This is too soon, since it causes brief palette corruption until the
// screen is updated too. (Possibly related: EngineState::pic_not_valid .)
- if (state->pic->visual_map->palette && PALETTE_MODE) {
- state->pic->visual_map->palette->forceInto(PALETTE_MODE);
+ if (state->pic->visual_map->palette) {
+ state->pic->visual_map->palette->forceInto(SCREEN_PALETTE);
_gfxop_install_pixmap(state->driver, state->pic->visual_map);
}
diff --git a/engines/sci/gfx/operations.h b/engines/sci/gfx/operations.h
index 03ab882452..47713d6db1 100644
--- a/engines/sci/gfx/operations.h
+++ b/engines/sci/gfx/operations.h
@@ -144,7 +144,7 @@ struct GfxState {
*/
void gfxop_init(GfxState *state,
gfx_options_t *options, ResourceManager *resMan,
- Graphics::PixelFormat mode, int xfact = 1, int yfact = 1);
+ int xfact = 1, int yfact = 1);
/**
* Deinitializes a currently active driver.
diff --git a/engines/sci/gfx/res_pic.cpp b/engines/sci/gfx/res_pic.cpp
index 1bf094fb48..cb628b94ef 100644
--- a/engines/sci/gfx/res_pic.cpp
+++ b/engines/sci/gfx/res_pic.cpp
@@ -1485,9 +1485,8 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
view->index_height = CLIP<int>(view->index_height, 0, portBounds.height());
// Set up mode structure for resizing the view
- Graphics::PixelFormat format(1, 0, 0, 0, 0, 0, 0, 0, 0); // 1byte/p, which handles masks and the rest for us
gfx_mode_t *mode = gfx_new_mode(pic->visual_map->index_width / 320,
- pic->visual_map->index_height / 200, format, view->palette, 0);
+ pic->visual_map->index_height / 200, view->palette);
gfx_xlate_pixmap(view, mode);
gfx_free_mode(mode);
@@ -1591,8 +1590,7 @@ void gfxr_draw_pic11(gfxr_pic_t *pic, int flags, int default_palette, int size,
view->palette = pic->visual_map->palette->getref();
// Set up mode structure for resizing the view
- Graphics::PixelFormat format(1, 0, 0, 0, 0, 0, 0, 0, 0); // 1 byte/p, which handles masks and the rest for us
- gfx_mode_t *mode = gfx_new_mode(pic->visual_map->index_width / 320, pic->visual_map->index_height / 200, format, view->palette, 0);
+ gfx_mode_t *mode = gfx_new_mode(pic->visual_map->index_width / 320, pic->visual_map->index_height / 200, view->palette);
gfx_xlate_pixmap(view, mode);
gfx_free_mode(mode);
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index a65351eeb4..a8f130f674 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -98,13 +98,7 @@ SciEngine::~SciEngine() {
}
Common::Error SciEngine::run() {
- Graphics::PixelFormat gfxmode;
-#if 0 && defined(USE_RGB_COLOR)
- initGraphics(320, 200, false, NULL);
-#else
initGraphics(320, 200, false);
-#endif
- gfxmode = _system->getScreenFormat();
// Create debugger console. It requires GFX to be initialized
_console = new Console(this);
@@ -177,7 +171,7 @@ Common::Error SciEngine::run() {
// Default config ends
#endif
- gfxop_init(&gfx_state, &gfx_options, _resMan, gfxmode, 1, 1);
+ gfxop_init(&gfx_state, &gfx_options, _resMan, 1, 1);
if (game_init_graphics(_gamestate)) { // Init interpreter graphics
warning("Game initialization failed: Error in GFX subsystem. Aborting...");