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

gregfrieger at users.sourceforge.net gregfrieger at users.sourceforge.net
Sun Mar 1 05:07:04 CET 2009


Revision: 39000
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39000&view=rev
Author:   gregfrieger
Date:     2009-03-01 04:07:04 +0000 (Sun, 01 Mar 2009)

Log Message:
-----------
Fixed windows and text drawing problem in SCI1

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

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-03-01 03:45:42 UTC (rev 38999)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-03-01 04:07:04 UTC (rev 39000)
@@ -1287,7 +1287,6 @@
 				bestindex = i;
 			}
 		}
-
 		// Don't warn about inexact mappings -- it's actually the
 		// rule rather than the exception
 		return make_reg(0, bestindex);

Modified: scummvm/trunk/engines/sci/gfx/operations.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.cpp	2009-03-01 03:45:42 UTC (rev 38999)
+++ scummvm/trunk/engines/sci/gfx/operations.cpp	2009-03-01 04:07:04 UTC (rev 39000)
@@ -1002,6 +1002,24 @@
 
 #define COLOR_MIX(type, dist) ((color1.type * dist) + (color2.type * (1.0 - dist)))
 
+int _gfxop_matchColor(gfx_state_t *state, byte r, byte g, byte b) {
+	int i, delta, bestindex = -1, bestdelta = 200000;
+
+	for (i = 0; i < state->static_palette_entries; i++) {
+		int dr = abs(state->static_palette[i].r - r);
+		int dg = abs(state->static_palette[i].g - g);
+		int db = abs(state->static_palette[i].b - b);
+
+		delta = dr * dr + dg * dg + db * db;
+
+		if (delta < bestdelta) {
+			bestdelta = delta;
+			bestindex = i;
+		}
+	}
+	return bestindex;
+}
+
 int gfxop_draw_box(gfx_state_t *state, rect_t box, gfx_color_t color1, gfx_color_t color2, gfx_box_shade_t shade_type) {
 	gfx_driver_t *drv = state->driver;
 	int reverse = 0; // switch color1 and color2
@@ -1072,9 +1090,12 @@
 		mod_offset = (float)(1.0 - (mod_offset + mod_breadth));
 	// Reverse offset if we have to interpret colors inversely
 
-	if (shade_type == GFX_BOX_SHADE_FLAT)
+	if (shade_type == GFX_BOX_SHADE_FLAT) {
+		if (color1.visual.global_index == -1)
+			color1.visual.global_index = _gfxop_matchColor(state, color1.visual.r, color1.visual.g,
+				color1.visual.b);
 		return drv->draw_filled_rect(drv, new_box, color1, color1, GFX_SHADE_FLAT);
-	else {
+	} else {
 		if (PALETTE_MODE) {
 			GFXWARN("Attempting to draw shaded box in palette mode!\n");
 			return GFX_ERROR;
@@ -1920,6 +1941,13 @@
 		gfx_pixmap_t *pxm = handle->text_pixmaps[i];
 
 		if (!pxm->data) {
+			// Matching pixmap's colors to current system palette if needed
+			for (int i = 0; i < pxm->colors_nr; i++) {
+				if (pxm->colors[i].global_index == -1)
+					pxm->colors[i].global_index = _gfxop_matchColor(state, pxm->colors[i].r, pxm->colors[i].g,
+					pxm->colors[i].b);
+			}
+
 			gfx_xlate_pixmap(pxm, state->driver->mode, state->options->text_xlate_filter);
 			gfxr_endianness_adjust(pxm, state->driver->mode); // FIXME: resmgr layer!
 		}
@@ -1952,7 +1980,6 @@
 		pos.yl = pxm->yl;
 
 		_gfxop_add_dirty(state, pos);
-
 		_gfxop_draw_pixmap(state->driver, pxm, handle->priority, handle->control,
 		                   gfx_rect(0, 0, pxm->xl, pxm->yl), pos, state->clip_zone, 0, state->control_map, state->priority_map);
 


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