[Scummvm-cvs-logs] SF.net SVN: scummvm:[44502] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Thu Oct 1 00:43:30 CEST 2009


Revision: 44502
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44502&view=rev
Author:   thebluegr
Date:     2009-09-30 22:43:29 +0000 (Wed, 30 Sep 2009)

Log Message:
-----------
- Removed some leftover 16/32bpp color code, as we're always using palette mode now
- Simplified the mouse cursor manipulation code

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gfx/gfx_driver.cpp
    scummvm/trunk/engines/sci/gfx/gfx_driver.h
    scummvm/trunk/engines/sci/gfx/gfx_tools.cpp
    scummvm/trunk/engines/sci/gfx/gfx_tools.h
    scummvm/trunk/engines/sci/gfx/operations.cpp
    scummvm/trunk/engines/sci/gfx/operations.h
    scummvm/trunk/engines/sci/gfx/res_pic.cpp
    scummvm/trunk/engines/sci/sci.cpp

Modified: scummvm/trunk/engines/sci/gfx/gfx_driver.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_driver.cpp	2009-09-30 21:46:00 UTC (rev 44501)
+++ scummvm/trunk/engines/sci/gfx/gfx_driver.cpp	2009-09-30 22:43:29 UTC (rev 44502)
@@ -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 @@
 		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 @@
 
 		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 @@
 			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);

Modified: scummvm/trunk/engines/sci/gfx/gfx_driver.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_driver.h	2009-09-30 21:46:00 UTC (rev 44501)
+++ scummvm/trunk/engines/sci/gfx/gfx_driver.h	2009-09-30 22:43:29 UTC (rev 44502)
@@ -85,7 +85,7 @@
 	 * 						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.

Modified: scummvm/trunk/engines/sci/gfx/gfx_tools.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_tools.cpp	2009-09-30 21:46:00 UTC (rev 44501)
+++ scummvm/trunk/engines/sci/gfx/gfx_tools.cpp	2009-09-30 22:43:29 UTC (rev 44502)
@@ -43,7 +43,7 @@
 		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;

Modified: scummvm/trunk/engines/sci/gfx/gfx_tools.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_tools.h	2009-09-30 21:46:00 UTC (rev 44501)
+++ scummvm/trunk/engines/sci/gfx/gfx_tools.h	2009-09-30 22:43:29 UTC (rev 44502)
@@ -41,12 +41,10 @@
  *
  * @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

Modified: scummvm/trunk/engines/sci/gfx/operations.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.cpp	2009-09-30 21:46:00 UTC (rev 44501)
+++ scummvm/trunk/engines/sci/gfx/operations.cpp	2009-09-30 22:43:29 UTC (rev 44502)
@@ -63,7 +63,7 @@
 #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 @@
 
 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 @@
 	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 @@
 	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 @@
 		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_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 @@
 }
 
 
-#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 @@
 			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 @@
 	}
 }
 
-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 @@
 	}
 
 	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);
+	gfx_pixmap_t *new_pointer = state->gfxResMan->getView(nr, &loop, &cel, 0)->loops[loop].cels[cel];
 
-	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);
-	}
-
 	// 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 @@
 	// 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);
 	}
 

Modified: scummvm/trunk/engines/sci/gfx/operations.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.h	2009-09-30 21:46:00 UTC (rev 44501)
+++ scummvm/trunk/engines/sci/gfx/operations.h	2009-09-30 22:43:29 UTC (rev 44502)
@@ -144,7 +144,7 @@
  */
 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.

Modified: scummvm/trunk/engines/sci/gfx/res_pic.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/res_pic.cpp	2009-09-30 21:46:00 UTC (rev 44501)
+++ scummvm/trunk/engines/sci/gfx/res_pic.cpp	2009-09-30 22:43:29 UTC (rev 44502)
@@ -1485,9 +1485,8 @@
 				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 @@
 		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);

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2009-09-30 21:46:00 UTC (rev 44501)
+++ scummvm/trunk/engines/sci/sci.cpp	2009-09-30 22:43:29 UTC (rev 44502)
@@ -98,13 +98,7 @@
 }
 
 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 @@
 	// 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...");


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list