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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Wed Sep 9 10:19:17 CEST 2009


Revision: 44017
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44017&view=rev
Author:   thebluegr
Date:     2009-09-09 08:19:16 +0000 (Wed, 09 Sep 2009)

Log Message:
-----------
Removed/replaced the gfx_pixmap_color struct

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kgraphics.cpp
    scummvm/trunk/engines/sci/gfx/gfx_res_options.h
    scummvm/trunk/engines/sci/gfx/gfx_resource.h
    scummvm/trunk/engines/sci/gfx/gfx_system.h
    scummvm/trunk/engines/sci/gfx/operations.cpp
    scummvm/trunk/engines/sci/gfx/palette.cpp
    scummvm/trunk/engines/sci/gfx/palette.h
    scummvm/trunk/engines/sci/gfx/res_cursor.cpp
    scummvm/trunk/engines/sci/gfx/res_pic.cpp

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-09-08 22:03:28 UTC (rev 44016)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-09-09 08:19:16 UTC (rev 44017)
@@ -3327,16 +3327,17 @@
 			
 			if (player->dirtyPalette()) {
 				byte *rawPalette = player->getPalette();
-				gfx_pixmap_color_t *colors = new gfx_pixmap_color_t[256];
+				Palette *colors = new Palette(256);
 
+				byte r, g, b;
+
 				for (uint16 i = 0; i < 256; i++) {
-					colors[i].r = rawPalette[i * 4];
-					colors[i].g = rawPalette[i * 4 + 1];
-					colors[i].b = rawPalette[i * 4 + 2];
-					colors[i].global_index = i;
+					r = rawPalette[i * 4];
+					g = rawPalette[i * 4 + 1];
+					b = rawPalette[i * 4 + 2];
+					colors->setColor(i, r, g, b);
 				}
 
-				palette = new Palette(colors, 256);
 				palette->forceInto(s->gfx_state->driver->getMode()->palette);
 			}
 				

Modified: scummvm/trunk/engines/sci/gfx/gfx_res_options.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_res_options.h	2009-09-08 22:03:28 UTC (rev 44016)
+++ scummvm/trunk/engines/sci/gfx/gfx_res_options.h	2009-09-09 08:19:16 UTC (rev 44017)
@@ -47,7 +47,7 @@
 	union {
 		struct {
 			int colors_nr;
-			gfx_pixmap_color_t *colors;
+			PaletteEntry *colors;
 		} palette;
 	} assign;
 };

Modified: scummvm/trunk/engines/sci/gfx/gfx_resource.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_resource.h	2009-09-08 22:03:28 UTC (rev 44016)
+++ scummvm/trunk/engines/sci/gfx/gfx_resource.h	2009-09-09 08:19:16 UTC (rev 44017)
@@ -67,7 +67,7 @@
 
 /** The 16 EGA base colors */
 extern Palette* gfx_sci0_image_pal[];
-extern gfx_pixmap_color_t gfx_sci0_image_colors[][16];
+extern PaletteEntry gfx_sci0_image_colors[][16];
 
 /**
  * The 256 interpolated colors (initialized when gfxr_init_pic() is called

Modified: scummvm/trunk/engines/sci/gfx/gfx_system.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_system.h	2009-09-08 22:03:28 UTC (rev 44016)
+++ scummvm/trunk/engines/sci/gfx/gfx_system.h	2009-09-09 08:19:16 UTC (rev 44017)
@@ -39,8 +39,6 @@
 /*** Data structures ***/
 /***********************/
 
-#define GFX_COLOR_SYSTEM -1
-
 #define GFX_MODE_IS_UNSCALED(mode) (((mode)->scaleFactor == 1) && ((mode)->scaleFactor == 1))
 
 /** Graphics mode description
@@ -69,14 +67,6 @@
 
 
 
-#define GFX_COLOR_INDEX_UNMAPPED -1
-
-/** Pixmap-specific color entries */
-struct  gfx_pixmap_color_t{
-	int global_index; /**< Global index color or GFX_COLOR_INDEX_UNMAPPED. */
-	uint8 r, g, b; /**< Real color */
-};
-
 /** Full color */
 struct gfx_color_t {
 	PaletteEntry visual;

Modified: scummvm/trunk/engines/sci/gfx/operations.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.cpp	2009-09-08 22:03:28 UTC (rev 44016)
+++ scummvm/trunk/engines/sci/gfx/operations.cpp	2009-09-09 08:19:16 UTC (rev 44017)
@@ -49,14 +49,15 @@
 // Default color maps
 #define DEFAULT_COLORS_NR 16
 
-gfx_pixmap_color_t default_colors[DEFAULT_COLORS_NR] = {{GFX_COLOR_SYSTEM, 0x00, 0x00, 0x00}, {GFX_COLOR_SYSTEM, 0x00, 0x00, 0xaa},
-	{GFX_COLOR_SYSTEM, 0x00, 0xaa, 0x00}, {GFX_COLOR_SYSTEM, 0x00, 0xaa, 0xaa},
-	{GFX_COLOR_SYSTEM, 0xaa, 0x00, 0x00}, {GFX_COLOR_SYSTEM, 0xaa, 0x00, 0xaa},
-	{GFX_COLOR_SYSTEM, 0xaa, 0x55, 0x00}, {GFX_COLOR_SYSTEM, 0xaa, 0xaa, 0xaa},
-	{GFX_COLOR_SYSTEM, 0x55, 0x55, 0x55}, {GFX_COLOR_SYSTEM, 0x55, 0x55, 0xff},
-	{GFX_COLOR_SYSTEM, 0x55, 0xff, 0x55}, {GFX_COLOR_SYSTEM, 0x55, 0xff, 0xff},
-	{GFX_COLOR_SYSTEM, 0xff, 0x55, 0x55}, {GFX_COLOR_SYSTEM, 0xff, 0x55, 0xff},
-	{GFX_COLOR_SYSTEM, 0xff, 0xff, 0x55}, {GFX_COLOR_SYSTEM, 0xff, 0xff, 0xff}
+PaletteEntry default_colors[DEFAULT_COLORS_NR] = {
+	PaletteEntry(0x00, 0x00, 0x00), PaletteEntry(0x00, 0x00, 0xaa),
+	PaletteEntry(0x00, 0xaa, 0x00), PaletteEntry(0x00, 0xaa, 0xaa),
+	PaletteEntry(0xaa, 0x00, 0x00), PaletteEntry(0xaa, 0x00, 0xaa),
+	PaletteEntry(0xaa, 0x55, 0x00), PaletteEntry(0xaa, 0xaa, 0xaa),
+	PaletteEntry(0x55, 0x55, 0x55), PaletteEntry(0x55, 0x55, 0xff),
+	PaletteEntry(0x55, 0xff, 0x55), PaletteEntry(0x55, 0xff, 0xff),
+	PaletteEntry(0xff, 0x55, 0x55), PaletteEntry(0xff, 0x55, 0xff),
+	PaletteEntry(0xff, 0xff, 0x55), PaletteEntry(0xff, 0xff, 0xff)
 }; // "Normal" EGA
 
 #define POINTER_VISIBLE_BUT_CLIPPED 2
@@ -775,7 +776,7 @@
 		end.y += yfact >> 1;
 	}
 
-	if (color.visual.parent_index == GFX_COLOR_INDEX_UNMAPPED)
+	if (color.visual.parent_index == -1)
 		gfxop_set_color(state, &color, color);
 	_gfxop_draw_line_clipped(state, start, end, color, line_mode, line_style);
 }
@@ -893,7 +894,7 @@
 	if (shade_type == GFX_BOX_SHADE_FLAT) {
 		color1.priority = 0;
 		color1.control = 0;
-		if (color1.visual.parent_index == GFX_COLOR_INDEX_UNMAPPED)
+		if (color1.visual.parent_index == -1)
 			gfxop_set_color(state, &color1, color1);
 		drv->drawFilledRect(new_box, color1, color1, GFX_SHADE_FLAT);
 		return;

Modified: scummvm/trunk/engines/sci/gfx/palette.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/palette.cpp	2009-09-08 22:03:28 UTC (rev 44016)
+++ scummvm/trunk/engines/sci/gfx/palette.cpp	2009-09-09 08:19:16 UTC (rev 44017)
@@ -39,7 +39,7 @@
 	_revision = 0;
 }
 
-Palette::Palette(const gfx_pixmap_color_t *colors, uint s) {
+Palette::Palette(const PaletteEntry *colors, uint s) {
 	_size = s;
 	_colors = new PaletteEntry[s];
 	_parent = 0;
@@ -131,7 +131,7 @@
 	_parent = 0;
 }
 
-void Palette::setColor(uint index, byte r, byte g, byte b) {
+void Palette::setColor(uint index, byte r, byte g, byte b, int parentIndex) {
 	assert(index < _size);
 	assert(!_parent);
 
@@ -146,7 +146,7 @@
 	entry.r = r;
 	entry.g = g;
 	entry.b = b;
-	entry.parent_index = -1;
+	entry.parent_index = parentIndex;
 
 	_dirty = true;
 }

Modified: scummvm/trunk/engines/sci/gfx/palette.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/palette.h	2009-09-08 22:03:28 UTC (rev 44016)
+++ scummvm/trunk/engines/sci/gfx/palette.h	2009-09-09 08:19:16 UTC (rev 44017)
@@ -57,12 +57,10 @@
 	int refcount;
 };
 
-struct gfx_pixmap_color_t;
-
 class Palette {
 public:
 	explicit Palette(uint size);
-	Palette(const gfx_pixmap_color_t *colors, uint size);
+	Palette(const PaletteEntry *colors, uint size);
 	~Palette();
 
 	Palette *getref();
@@ -70,7 +68,7 @@
 	Palette *copy();
 
 	void resize(uint size);
-	void setColor(uint index, byte r, byte g, byte b);
+	void setColor(uint index, byte r, byte g, byte b, int parentIndex = -1);
 	void makeSystemColor(uint index, const PaletteEntry &color);
 	const PaletteEntry &getColor(uint index) const {
 		assert(index < _size);

Modified: scummvm/trunk/engines/sci/gfx/res_cursor.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/res_cursor.cpp	2009-09-08 22:03:28 UTC (rev 44016)
+++ scummvm/trunk/engines/sci/gfx/res_cursor.cpp	2009-09-09 08:19:16 UTC (rev 44017)
@@ -37,10 +37,10 @@
 #define GFX_SCI01_CURSOR_COLORS_NR 3
 #define GFX_SCI0_CURSOR_COLORS_NR 2
 
-gfx_pixmap_color_t gfx_sci01_cursor_colors[GFX_SCI01_CURSOR_COLORS_NR] = {
-	{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0x00},
-	{GFX_COLOR_INDEX_UNMAPPED, 0xff, 0xff, 0xff},
-	{GFX_COLOR_INDEX_UNMAPPED, 0xaa, 0xaa, 0xaa}
+PaletteEntry gfx_sci01_cursor_colors[GFX_SCI01_CURSOR_COLORS_NR] = {
+	PaletteEntry(0x00, 0x00, 0x00),
+	PaletteEntry(0xff, 0xff, 0xff),
+	PaletteEntry(0xaa, 0xaa, 0xaa)
 };
 
 gfx_pixmap_t *gfxr_draw_cursor(int id, byte *resource, int size, bool isSci01) {

Modified: scummvm/trunk/engines/sci/gfx/res_pic.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/res_pic.cpp	2009-09-08 22:03:28 UTC (rev 44016)
+++ scummvm/trunk/engines/sci/gfx/res_pic.cpp	2009-09-09 08:19:16 UTC (rev 44017)
@@ -45,25 +45,25 @@
 	((first) + (((nr)-1) * (last - first)) / 14)))
 
 // Default color maps
-gfx_pixmap_color_t gfx_sci0_image_colors[SCI0_MAX_PALETTE+1][GFX_SCI0_IMAGE_COLORS_NR] = {
-	{{GFX_COLOR_SYSTEM, 0x00, 0x00, 0x00}, {GFX_COLOR_SYSTEM, 0x00, 0x00, 0xaa},
-		{GFX_COLOR_SYSTEM, 0x00, 0xaa, 0x00}, {GFX_COLOR_SYSTEM, 0x00, 0xaa, 0xaa},
-		{GFX_COLOR_SYSTEM, 0xaa, 0x00, 0x00}, {GFX_COLOR_SYSTEM, 0xaa, 0x00, 0xaa},
-		{GFX_COLOR_SYSTEM, 0xaa, 0x55, 0x00}, {GFX_COLOR_SYSTEM, 0xaa, 0xaa, 0xaa},
-		{GFX_COLOR_SYSTEM, 0x55, 0x55, 0x55}, {GFX_COLOR_SYSTEM, 0x55, 0x55, 0xff},
-		{GFX_COLOR_SYSTEM, 0x55, 0xff, 0x55}, {GFX_COLOR_SYSTEM, 0x55, 0xff, 0xff},
-		{GFX_COLOR_SYSTEM, 0xff, 0x55, 0x55}, {GFX_COLOR_SYSTEM, 0xff, 0x55, 0xff},
-		{GFX_COLOR_SYSTEM, 0xff, 0xff, 0x55}, {GFX_COLOR_SYSTEM, 0xff, 0xff, 0xff}}, // "Normal" EGA
+PaletteEntry gfx_sci0_image_colors[SCI0_MAX_PALETTE+1][GFX_SCI0_IMAGE_COLORS_NR] = {
+	{PaletteEntry(0x00, 0x00, 0x00), PaletteEntry(0x00, 0x00, 0xaa),
+		PaletteEntry(0x00, 0xaa, 0x00), PaletteEntry(0x00, 0xaa, 0xaa),
+		PaletteEntry(0xaa, 0x00, 0x00), PaletteEntry(0xaa, 0x00, 0xaa),
+		PaletteEntry(0xaa, 0x55, 0x00), PaletteEntry(0xaa, 0xaa, 0xaa),
+		PaletteEntry(0x55, 0x55, 0x55), PaletteEntry(0x55, 0x55, 0xff),
+		PaletteEntry(0x55, 0xff, 0x55), PaletteEntry(0x55, 0xff, 0xff),
+		PaletteEntry(0xff, 0x55, 0x55), PaletteEntry(0xff, 0x55, 0xff),
+		PaletteEntry(0xff, 0xff, 0x55), PaletteEntry(0xff, 0xff, 0xff)}, // "Normal" EGA
 
 
-	{{GFX_COLOR_SYSTEM, 0x00, 0x00, 0x00}, {GFX_COLOR_SYSTEM, 0x00, 0x00, 0xff},
-		{GFX_COLOR_SYSTEM, 0x00, 0xaa, 0x00}, {GFX_COLOR_SYSTEM, 0x00, 0xaa, 0xaa},
-		{GFX_COLOR_SYSTEM, 0xce, 0x00, 0x00}, {GFX_COLOR_SYSTEM, 0xbe, 0x71, 0xde},
-		{GFX_COLOR_SYSTEM, 0x8d, 0x50, 0x00}, {GFX_COLOR_SYSTEM, 0xbe, 0xbe, 0xbe},
-		{GFX_COLOR_SYSTEM, 0x55, 0x55, 0x55}, {GFX_COLOR_SYSTEM, 0x00, 0xbe, 0xff},
-		{GFX_COLOR_SYSTEM, 0x00, 0xce, 0x55}, {GFX_COLOR_SYSTEM, 0x55, 0xff, 0xff},
-		{GFX_COLOR_SYSTEM, 0xff, 0x9d, 0x8d}, {GFX_COLOR_SYSTEM, 0xff, 0x55, 0xff},
-		{GFX_COLOR_SYSTEM, 0xff, 0xff, 0x00}, {GFX_COLOR_SYSTEM, 0xff, 0xff, 0xff}}, // AGI Amiga-ish
+	{PaletteEntry(0x00, 0x00, 0x00), PaletteEntry(0x00, 0x00, 0xff),
+		PaletteEntry(0x00, 0xaa, 0x00), PaletteEntry(0x00, 0xaa, 0xaa),
+		PaletteEntry(0xce, 0x00, 0x00), PaletteEntry(0xbe, 0x71, 0xde),
+		PaletteEntry(0x8d, 0x50, 0x00), PaletteEntry(0xbe, 0xbe, 0xbe),
+		PaletteEntry(0x55, 0x55, 0x55), PaletteEntry(0x00, 0xbe, 0xff),
+		PaletteEntry(0x00, 0xce, 0x55), PaletteEntry(0x55, 0xff, 0xff),
+		PaletteEntry(0xff, 0x9d, 0x8d), PaletteEntry(0xff, 0x55, 0xff),
+		PaletteEntry(0xff, 0xff, 0x00), PaletteEntry(0xff, 0xff, 0xff)}, // AGI Amiga-ish
 
 // RGB and I intensities (former taken from the GIMP)
 #define GR 30
@@ -75,14 +75,14 @@
 
 #define CC(x) (((x)*255)/FULL),(((x)*255)/FULL),(((x)*255)/FULL)         // Combines color intensities
 
-	{{GFX_COLOR_SYSTEM, CC(0)           }, {GFX_COLOR_SYSTEM, CC(GB)          },
-		{GFX_COLOR_SYSTEM, CC(GG)          }, {GFX_COLOR_SYSTEM, CC(GB + GG)       },
-		{GFX_COLOR_SYSTEM, CC(GR)          }, {GFX_COLOR_SYSTEM, CC(GB + GR)       },
-		{GFX_COLOR_SYSTEM, CC(GG + GR)       }, {GFX_COLOR_SYSTEM, CC(GB + GG + GR)    },
-		{GFX_COLOR_SYSTEM, CC(GI)          }, {GFX_COLOR_SYSTEM, CC(GB + GI)       },
-		{GFX_COLOR_SYSTEM, CC(GG + GI)       }, {GFX_COLOR_SYSTEM, CC(GB + GG + GI)    },
-		{GFX_COLOR_SYSTEM, CC(GR + GI)       }, {GFX_COLOR_SYSTEM, CC(GB + GR + GI)    },
-		{GFX_COLOR_SYSTEM, CC(GG + GR + GI)    }, {GFX_COLOR_SYSTEM, CC(GB + GG + GR + GI) }}
+	{PaletteEntry(CC(0)           ), PaletteEntry(CC(GB)          ),
+		PaletteEntry(CC(GG)          ), PaletteEntry(CC(GB + GG)       ),
+		PaletteEntry(CC(GR)          ), PaletteEntry(CC(GB + GR)       ),
+		PaletteEntry(CC(GG + GR)       ), PaletteEntry(CC(GB + GG + GR)    ),
+		PaletteEntry(CC(GI)          ), PaletteEntry(CC(GB + GI)       ),
+		PaletteEntry(CC(GG + GI)       ), PaletteEntry(CC(GB + GG + GI)    ),
+		PaletteEntry(CC(GR + GI)       ), PaletteEntry(CC(GB + GR + GI)    ),
+		PaletteEntry(CC(GG + GR + GI)    ), PaletteEntry(CC(GB + GG + GR + GI) )}
 }; // Grayscale
 
 #undef GR
@@ -102,25 +102,19 @@
 
 #define SCI1_PALETTE_SIZE 1284
 
-// Color mapping used while scaling embedded views.
-static const gfx_pixmap_color_t embedded_view_colors[16] = {
-	{0x00, 0, 0, 0}, {0x11, 0, 0, 0}, {0x22, 0, 0, 0}, {0x33, 0, 0, 0},
-	{0x44, 0, 0, 0}, {0x55, 0, 0, 0}, {0x66, 0, 0, 0}, {0x77, 0, 0, 0},
-	{0x88, 0, 0, 0}, {0x99, 0, 0, 0}, {0xaa, 0, 0, 0}, {0xbb, 0, 0, 0},
-	{0xcc, 0, 0, 0}, {0xdd, 0, 0, 0}, {0xee, 0, 0, 0}, {0xff, 0, 0, 0}
-};
-
 void gfxr_init_static_palette() {
+	int i;
+
 	if (!gfx_sci0_pic_colors) {
 		gfx_sci0_pic_colors = new Palette(256);
 		gfx_sci0_pic_colors->name = "gfx_sci0_pic_colors";
 		// TODO: Discover the exact purpose of gfx_sci0_pic_colors
 		// For now, we set the first 16 colours to the standard EGA palette,
 		// and fill the remaining entries with slight variations
-		for (int i = 0; i < 16; i++) {
-			gfx_sci0_pic_colors->setColor(i,gfx_sci0_image_colors[0][i].r, gfx_sci0_image_colors[0][i].g, gfx_sci0_image_colors[0][i].b);
+		for (i = 0; i < 16; i++) {
+			gfx_sci0_pic_colors->setColor(i, gfx_sci0_image_colors[0][i].r, gfx_sci0_image_colors[0][i].g, gfx_sci0_image_colors[0][i].b);
 		}
-		for (int i = 16; i < 256; i++) {
+		for (i = 16; i < 256; i++) {
 			byte r = INTERCOL(gfx_sci0_image_colors[sci0_palette][i & 0xf].r,
 			                  gfx_sci0_image_colors[sci0_palette][i >> 4].r);
 			byte g = INTERCOL(gfx_sci0_image_colors[sci0_palette][i & 0xf].g,
@@ -132,12 +126,14 @@
 		//warning("Uncomment me after fixing sci0_palette changes to reset me");
 		//_gfxr_pic0_colors_initialized = 1;
 
-		for (int i = 0; i <= SCI0_MAX_PALETTE; ++i) {
+		for (i = 0; i <= SCI0_MAX_PALETTE; ++i) {
 			gfx_sci0_image_pal[i] = new Palette(gfx_sci0_image_colors[i], GFX_SCI0_IMAGE_COLORS_NR);
 			gfx_sci0_image_pal[i]->name = "gfx_sci0_image_pal[i]";
 		}
 
-		embedded_view_pal = new Palette(embedded_view_colors, 16);
+		embedded_view_pal = new Palette(16);
+		for (i = 0; i < 16; i++)
+			embedded_view_pal->setColor(i, 0, 0, i * 0x11);
 		embedded_view_pal->name = "embedded_view_pal";
 	}
 }


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