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

gregfrieger at users.sourceforge.net gregfrieger at users.sourceforge.net
Tue Mar 3 15:27:49 CET 2009


Revision: 39089
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39089&view=rev
Author:   gregfrieger
Date:     2009-03-03 14:27:49 +0000 (Tue, 03 Mar 2009)

Log Message:
-----------
SCI1: Improved color mapping when drawing line/box/text. Text with transparent background now displays correctly. 

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/game.cpp
    scummvm/trunk/engines/sci/engine/kgraphics.cpp
    scummvm/trunk/engines/sci/gfx/gfx_widgets.cpp
    scummvm/trunk/engines/sci/gfx/operations.cpp

Modified: scummvm/trunk/engines/sci/engine/game.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/game.cpp	2009-03-03 11:08:03 UTC (rev 39088)
+++ scummvm/trunk/engines/sci/engine/game.cpp	2009-03-03 14:27:49 UTC (rev 39089)
@@ -121,7 +121,7 @@
 int _reset_graphics_input(EngineState *s) {
 	Resource *resource;
 	int font_nr;
-	gfx_color_t transparent;
+	gfx_color_t transparent = { { -1, 0, 0, 0 }, 0, -1, -1, 0 };
 	sciprintf("Initializing graphics\n");
 
 	if (s->resmgr->_sciVersion <= SCI_VERSION_01) {
@@ -157,7 +157,6 @@
 			}
 		}
 	}
-	transparent.mask = 0;
 
 	gfxop_fill_box(s->gfx_state, gfx_rect(0, 0, 320, 200), s->ega_colors[0]); // Fill screen black
 	gfxop_update(s->gfx_state);

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-03-03 11:08:03 UTC (rev 39088)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-03-03 14:27:49 UTC (rev 39089)
@@ -3081,11 +3081,11 @@
 	reg_t textp = argv[0];
 	int index = UKPV_OR_ALT(1, 0);
 	int temp;
-	int save_under = 0;
-	gfx_color_t transparent = { { 0, 0, 0, 0 }, 0, 0, 0, 0 };
+	bool save_under = false;
+	gfx_color_t transparent = { { -1, 0, 0, 0 }, 0, -1, -1, 0 };
 	char *text;
 	gfxw_port_t *port = (s->port) ? s->port : s->picture_port;
-	int update_immediately = 1;
+	bool update_immediately = true;
 
 	gfx_color_t color0, *color1, bg_color;
 	gfx_alignment_t halign = ALIGN_LEFT;
@@ -3096,6 +3096,11 @@
 
 	color0 = port->color;
 	bg_color = port->bgcolor;
+	// TODO: in SCI1VGA the default colors for text and background are #0 (black)
+	// SCI0 case should be checked 
+	if (s->resmgr->_sciVersion >= SCI_VERSION_01_VGA) {
+		color0.visual = bg_color.visual = *get_pic_color(s, 0);
+	}
 
 	if (textp.segment) {
 		argpt = 1;
@@ -3184,7 +3189,7 @@
 
 		case K_DISPLAY_SAVE_UNDER:
 
-			save_under = 1;
+			save_under = true;
 			SCIkdebug(SCIkGRAPHICS, "Display: set_save_under()\n");
 			break;
 
@@ -3192,13 +3197,13 @@
 
 			SCIkdebug(SCIkGRAPHICS, "Display: restore_under(%04x)\n", UKPV(argpt));
 			graph_restore_box(s, argv[argpt++]);
-			update_immediately = 1;
+			update_immediately = true;
 			argpt++;
 			return s->r_acc;
 
 		case K_DONT_UPDATE_IMMEDIATELY:
 
-			update_immediately = 0;
+			update_immediately = false;
 			SCIkdebug(SCIkGRAPHICS, "Display: set_dont_update()\n");
 			argpt++;
 			break;

Modified: scummvm/trunk/engines/sci/gfx/gfx_widgets.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_widgets.cpp	2009-03-03 11:08:03 UTC (rev 39088)
+++ scummvm/trunk/engines/sci/gfx/gfx_widgets.cpp	2009-03-03 14:27:49 UTC (rev 39089)
@@ -2041,7 +2041,7 @@
 
 gfxw_port_t *gfxw_get_chrono_port(gfxw_visual_t *visual, gfxw_list_t **temp_widgets_list, int flags) {
 	gfxw_port_t *result = NULL;
-	gfx_color_t transparent = {{0, 0, 0, 0}, 0, 0, 0, 0};
+	gfx_color_t transparent = {{-1, 0, 0, 01}, 0, -1, -1, 0};
 	int id = 0;
 
 	if (!(flags & GFXW_CHRONO_NON_TOPMOST)) {

Modified: scummvm/trunk/engines/sci/gfx/operations.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.cpp	2009-03-03 11:08:03 UTC (rev 39088)
+++ scummvm/trunk/engines/sci/gfx/operations.cpp	2009-03-03 14:27:49 UTC (rev 39089)
@@ -662,6 +662,16 @@
 	return GFX_OK;
 }
 
+// Wrapper for gfxop_set_color
+int gfxop_set_color(gfx_state_t *state, gfx_color_t *colorOut, gfx_color_t &colorIn) {
+	if (colorIn.mask & GFX_MASK_VISUAL)
+		return gfxop_set_color(state, colorOut, colorIn.visual.r, colorIn.visual.g, colorIn.visual.b, 
+			colorIn.alpha, colorIn.priority, colorIn.control);
+	else
+		return gfxop_set_color(state, colorOut, -1, -1, -1, colorIn.alpha, 
+			colorIn.priority, colorIn.control);
+}
+
 int gfxop_set_system_color(gfx_state_t *state, gfx_color_t *color) {
 	gfx_palette_color_t *palette_colors;
 	BASIC_CHECKS(GFX_FATAL);
@@ -937,7 +947,9 @@
 		end.x += xfact >> 1;
 		end.y += yfact >> 1;
 	}
-
+	
+	if (color.visual.global_index == GFX_COLOR_INDEX_UNMAPPED)
+		gfxop_set_color(state, &color, color);
 	return _gfxop_draw_line_clipped(state, start, end, color, line_mode, line_style);
 }
 
@@ -1073,7 +1085,8 @@
 	// Reverse offset if we have to interpret colors inversely
 
 	if (shade_type == GFX_BOX_SHADE_FLAT) {
-		gfxop_set_color(state, &color1, color1.visual.r, color1.visual.g, color1.visual.b, 0, 0, 0);
+		if (color1.visual.global_index == GFX_COLOR_INDEX_UNMAPPED)
+			gfxop_set_color(state, &color1, color1);
 		return drv->draw_filled_rect(drv, new_box, color1, color1, GFX_SHADE_FLAT);
 	} else {
 		if (PALETTE_MODE) {
@@ -1766,33 +1779,22 @@
 	return GFX_OK;
 }
 
-#define COL_XLATE(des,src) \
-	des = src.visual; /* The new gfx_color_t structure makes things a lot easier :-) */ /* \
-	if (gfxop_set_color(state, &src, \
-		src.visual.r, \
-		src.visual.g, \
-		src.visual.b, \
-		src.alpha, \
-		src.priority, \
-		src.control)) \
-	{ \
-	GFXERROR("Unable to set up colors"); \
-	return NULL; \
-	}
-*/
-
 gfx_text_handle_t *gfxop_new_text(gfx_state_t *state, int font_nr, char *text, int maxwidth, gfx_alignment_t halign,
 								  gfx_alignment_t valign, gfx_color_t color1, gfx_color_t color2, gfx_color_t bg_color, int flags) {
 	gfx_text_handle_t *handle;
 	gfx_bitmap_font_t *font;
-	int i;
-	gfx_pixmap_color_t pxm_col1, pxm_col2, pxm_colbg;
+	int i, error = 0;
 	BASIC_CHECKS(NULL);
 
-	COL_XLATE(pxm_col1, color1);
-	COL_XLATE(pxm_col2, color2);
-	COL_XLATE(pxm_colbg, bg_color);
-
+	// mapping text colors to palette
+	error |= gfxop_set_color(state, &color1, color1);
+	error |= gfxop_set_color(state, &color2, color2);
+	error |= gfxop_set_color(state, &bg_color, bg_color);
+	if (error) {
+		GFXERROR("Unable to set up colors");
+		return NULL; 
+	}
+		
 	font = gfxr_get_font(state->resstate, font_nr, 0);
 
 	if (!font) {
@@ -1830,9 +1832,9 @@
 		int chars_nr = handle->lines[i].length;
 
 		handle->text_pixmaps[i] = gfxr_draw_font(font, handle->lines[i].offset, chars_nr,
-		                          (color1.mask & GFX_MASK_VISUAL) ? &pxm_col1 : NULL,
-		                          (color2.mask & GFX_MASK_VISUAL) ? &pxm_col2 : NULL,
-		                          (bg_color.mask & GFX_MASK_VISUAL) ? &pxm_colbg : NULL);
+		                          (color1.mask & GFX_MASK_VISUAL) ? &color1.visual : NULL,
+		                          (color2.mask & GFX_MASK_VISUAL) ? &color2.visual : NULL,
+		                          (bg_color.mask & GFX_MASK_VISUAL) ? &bg_color.visual : NULL);
 
 		if (!handle->text_pixmaps[i]) {
 			int j;
@@ -1921,14 +1923,6 @@
 		gfx_pixmap_t *pxm = handle->text_pixmaps[i];
 
 		if (!pxm->data) {
-			// Matching pixmap's colors to current system palette if needed
-			gfx_color_t matched;
-			for (int j = 0; j < pxm->colors_nr; j++) {
-				gfxop_set_color(state, &matched, pxm->colors[j].r, pxm->colors[j].g, pxm->colors[j].b,
-					0, 0, 0);
-				pxm->colors[j].global_index = matched.visual.global_index;
-			}
-
 			gfx_xlate_pixmap(pxm, state->driver->mode, state->options->text_xlate_filter);
 			gfxr_endianness_adjust(pxm, state->driver->mode); // FIXME: resmgr layer!
 		}


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