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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Wed Oct 7 18:26:16 CEST 2009


Revision: 44737
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44737&view=rev
Author:   thebluegr
Date:     2009-10-07 16:26:16 +0000 (Wed, 07 Oct 2009)

Log Message:
-----------
Replaced the view loading code with the new view loading functions. EGA view color translation has been disabled, as it caused palette problems in Codename:Iceman

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp
    scummvm/trunk/engines/sci/gfx/gfx_resource.h
    scummvm/trunk/engines/sci/gfx/gfx_system.h
    scummvm/trunk/engines/sci/gfx/res_view.cpp
    scummvm/trunk/engines/sci/gui/gui_view.cpp
    scummvm/trunk/engines/sci/gui/gui_view.h

Modified: scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp	2009-10-07 16:16:34 UTC (rev 44736)
+++ scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp	2009-10-07 16:26:16 UTC (rev 44737)
@@ -507,8 +507,7 @@
 	gfx_pixmap_t *cel_data = NULL;
 
 	if (!res || res->mode != hash) {
-		// Wrapper code for the new view decoder - still WIP
-#if 0
+		// Wrapper code for the new view decoder
 		view = (gfxr_view_t *)malloc(sizeof(gfxr_view_t));
 
 		view->ID = nr;
@@ -526,14 +525,17 @@
 				for (int c = 0; c < 256; c++)
 					view->palette->setColor(c, viewPalette->colors[c].r, viewPalette->colors[c].g, viewPalette->colors[c].b);
 			}
+
+			// Assign missing colors from the view's palette to the global palette ones
+			for (unsigned i = 0; i < MIN(view->palette->size(), _staticPalette->size()); i++) {
+				const PaletteEntry& vc = view->palette->getColor(i);
+				if (vc.r == 0 && vc.g == 0 && vc.b == 0) {
+					const PaletteEntry& sc = _staticPalette->getColor(i);
+					view->palette->setColor(i, sc.r, sc.g, sc.b);
+				}
+			}
 		} else {
 			view->palette = _staticPalette->getref();
-
-			const byte *paldata = guiView->getEgaMapping();
-			for (int p = 0; p < GFX_SCI0_IMAGE_COLORS_NR; p++)
-				view->translation[p] = *(paldata++);
-
-			view->flags |= GFX_PIXMAP_FLAG_PALETTIZED;
 		}
 
 		view->loops_nr = guiView->getLoopCount();
@@ -557,44 +559,12 @@
 				curCel->palette_revision = -1;
 				curCel->xoffset = -celInfo->displaceX;
 				curCel->yoffset = -celInfo->displaceY;
+				curCel->palette = view->palette->getref();
 				curCel->alpha_map = 0;	// will be allocated by gfx_xlate_pixmap()
 				curCel->data = 0;		// will be allocated by gfx_xlate_pixmap()
-				curCel->palette = NULL;	// will be assigned to the view palette below
 			}
 		}
 
-		if (viewType == kViewVga || viewType == kViewVga11) {
-#else
-
-		// Existing code
-
-		Resource *viewRes = _resMan->findResource(ResourceId(kResourceTypeView, nr), 0);
-		if (!viewRes || !viewRes->data)
-			return NULL;
-
-		int resid = GFXR_RES_ID(GFX_RESOURCE_TYPE_VIEW, nr);
-
-		if (viewType == kViewEga) {
-			int pal = (getSciVersion() <= SCI_VERSION_01) ? -1 : palette;
-			view = getEGAView(resid, viewRes->data, viewRes->size, pal);
-		} else {
-			view = getVGAView(resid, viewRes->data, viewRes->size, viewType);
-#endif
-
-			if (view->palette) {
-				// Palettize view
-				for (unsigned i = 0; i < MIN(view->palette->size(), _staticPalette->size()); i++) {
-					const PaletteEntry& vc = view->palette->getColor(i);
-					if (vc.r == 0 && vc.g == 0 && vc.b == 0) {
-						const PaletteEntry& sc = _staticPalette->getColor(i);
-						view->palette->setColor(i, sc.r, sc.g, sc.b);
-					}
-				}
-			} else {
-				view->palette = _staticPalette->getref();
-			}
-		}
-
 		if (!res) {
 			res = (gfx_resource_t *)malloc(sizeof(gfx_resource_t));
 			res->scaled_data.view = NULL;
@@ -620,8 +590,6 @@
 	cel_data = loop_data->cels[*cel];
 
 	if (!cel_data->data) {
-		if (!cel_data->palette)
-			cel_data->palette = view->palette->getref();
 		gfx_get_res_config(_options->res_conf, cel_data);
 		gfx_xlate_pixmap(cel_data, _driver->getMode());
 	}

Modified: scummvm/trunk/engines/sci/gfx/gfx_resource.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_resource.h	2009-10-07 16:16:34 UTC (rev 44736)
+++ scummvm/trunk/engines/sci/gfx/gfx_resource.h	2009-10-07 16:26:16 UTC (rev 44737)
@@ -130,8 +130,6 @@
 
 	int loops_nr;
 	gfxr_loop_t *loops;
-
-	int translation[GFX_SCI0_IMAGE_COLORS_NR];
 };
 
 /**
@@ -252,17 +250,6 @@
 void gfxr_dither_pic0(gfxr_pic_t *pic, DitherMode mode);
 
 /**
- * Calculates an EGA view.
- *
- * @param[in] id		Resource ID of the view
- * @param[in] resource	Pointer to the resource to read
- * @param[in] size		Size of the resource
- * @param[in] palette	The palette to use
- * @return				The resulting view
- */
-gfxr_view_t *getEGAView(int id, byte *resource, int size, int palette);
-
-/**
  * Calculates a SCI cursor.
  *
  * @param[in] id		The cursor's resource ID
@@ -309,18 +296,6 @@
  */
 Palette *gfxr_read_pal11(int id, byte *resource, int size);
 
-/**
- * Calculates a VGA view.
- *
- * @param[in] id			Resource ID of the view
- * @param[in] resource		Pointer to the resource to read
- * @param[in] size			Size of the resource
- * @param[in] static_pal	The static palette
- * @param[in] isSci11		true if SCI1.1, false otherwise
- * @return					The resulting view
- */
-gfxr_view_t *getVGAView(int id, byte *resource, int size, ViewType viewType);
-
 gfx_pixmap_t *gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, byte *cel_base, int size, gfxr_view_t *view, ViewType viewType);
 /** @} */
 

Modified: scummvm/trunk/engines/sci/gfx/gfx_system.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_system.h	2009-10-07 16:16:34 UTC (rev 44736)
+++ scummvm/trunk/engines/sci/gfx/gfx_system.h	2009-10-07 16:26:16 UTC (rev 44737)
@@ -133,7 +133,6 @@
 
 #define GFX_PIXMAP_FLAG_SCALED_INDEX	(1<<0) /* Index data is scaled already */
 #define GFX_PIXMAP_FLAG_INSTALLED		(1<<2) /* Pixmap has been registered */
-#define GFX_PIXMAP_FLAG_PALETTIZED		(1<<6) /* Indicates a palettized view */
 
 #define GFX_PIXMAP_COLOR_KEY_NONE -1 /* No transpacency colour key */
 #define GFX_CURSOR_TRANSPARENT 255 // Cursor colour key

Modified: scummvm/trunk/engines/sci/gfx/res_view.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/res_view.cpp	2009-10-07 16:16:34 UTC (rev 44736)
+++ scummvm/trunk/engines/sci/gfx/res_view.cpp	2009-10-07 16:26:16 UTC (rev 44737)
@@ -86,9 +86,6 @@
 			int count = op >> 4;
 			int color = op & 0xf;
 
-			if (view->flags & GFX_PIXMAP_FLAG_PALETTIZED)
-				color = view->translation[color];
-
 			if (color == color_key)
 				color = retval->color_key;
 
@@ -116,9 +113,6 @@
 			int count = op >> 4;
 			int color = op & 0xf;
 
-			if (view && (view->flags & GFX_PIXMAP_FLAG_PALETTIZED))
-				color = view->translation[color];
-
 			if (color == color_key)
 				color = retval->color_key;
 
@@ -135,65 +129,6 @@
 	return retval;
 }
 
-gfxr_view_t *getEGAView(int id, byte *resource, int size, int palette) {
-	int i;
-	gfxr_view_t *view;
-	int mirror_bitpos = 1;
-	int mirror_bytepos = V0_MIRROR_LIST_OFFSET;
-	int palette_ofs = READ_LE_UINT16(resource + 6);
-
-	if (size < V0_FIRST_LOOP_OFFSET + 8) {
-		error("Attempt to draw empty view %04x", id);
-		return NULL;
-	}
-
-	view = (gfxr_view_t *)malloc(sizeof(gfxr_view_t));
-	view->ID = id;
-
-	view->loops_nr = resource[V0_LOOPS_NR_OFFSET];
-
-	// Set palette
-	view->flags = 0;
-	view->palette = gfx_sci0_image_pal[sci0_palette]->getref();
-
-	if ((palette_ofs) && (palette >= 0)) {
-		byte *paldata = resource + palette_ofs + (palette * GFX_SCI0_IMAGE_COLORS_NR);
-
-		for (i = 0; i < GFX_SCI0_IMAGE_COLORS_NR; i++)
-			view->translation[i] = *(paldata++);
-
-		view->flags |= GFX_PIXMAP_FLAG_PALETTIZED;
-	}
-
-	if (view->loops_nr * 2 + V0_FIRST_LOOP_OFFSET > size) {
-		error("View %04x: Not enough space in resource to accomodate for the claimed %d loops", id, view->loops_nr);
-		free(view);
-		return NULL;
-	}
-
-	view->loops = (gfxr_loop_t*)malloc(sizeof(gfxr_loop_t) * ((view->loops_nr) ? view->loops_nr : 1)); /* Alloc 1 if no loop */
-
-	for (i = 0; i < view->loops_nr; i++) {
-		int loop_offset = READ_LE_UINT16(resource + V0_FIRST_LOOP_OFFSET + (i << 1));
-		int mirrored = resource[mirror_bytepos] & mirror_bitpos;
-
-		if ((mirror_bitpos <<= 1) == 0x100) {
-			mirror_bytepos++;
-			mirror_bitpos = 1;
-		}
-
-		view->loops[i].cels_nr = READ_LE_UINT16(resource + loop_offset);
-		view->loops[i].cels = (gfx_pixmap_t**)calloc(view->loops[i].cels_nr, sizeof(gfx_pixmap_t *));
-
-		for (int j = 0; j < view->loops[i].cels_nr; j++) {
-			int cel_offset = READ_LE_UINT16(resource + loop_offset + 4 + (j << 1));
-			view->loops[i].cels[j] = gfxr_draw_cel0(id, i, j, resource + cel_offset, size - cel_offset, view, mirrored);
-		}
-	}
-
-	return view;
-}
-
 #define NEXT_LITERAL_BYTE(n) \
 	if (literal_pos == runlength_pos) \
 		runlength_pos += n; \
@@ -365,68 +300,4 @@
 	return retval;
 }
 
-// SCI1:
-// [LoopCount:WORD] [MirrorMask:WORD] [??:WORD] [PaletteOffset:WORD] [LoopOffset0:WORD] [LoopOffset1:WORD]...
-// Loop-data:
-// [CelCount:WORD] [Unknown:WORD] [CelOffset0:WORD] [CelOffset1:WORD]...
-// SCI11:
-// [HeaderSize:WORD] [LoopCount:BYTE] [Unknown:BYTE] [??:WORD] [??:WORD] [PaletteOffset:WORD]
-gfxr_view_t *getVGAView(int id, byte *resource, int size, ViewType viewType) {
-	uint16 palOffset = READ_LE_UINT16(resource + V1_PALETTE_OFFSET + ((viewType == kViewVga11) ? 2 : 0));
-	uint16 headerSize = (viewType == kViewVga11) ? READ_LE_UINT16(resource + V2_HEADER_SIZE) : 0;
-	byte* seeker = resource + headerSize;
-	uint16 loopOffset = 0;
-	gfxr_view_t *view = (gfxr_view_t *)malloc(sizeof(gfxr_view_t));
-
-	view->ID = id;
-	view->flags = 0;
-	view->loops_nr = READ_LE_UINT16(resource + V1_LOOPS_NR_OFFSET + ((viewType == kViewVga11) ? 2 : 0)) & 0xFF;
-
-	if (palOffset > 0) {
-		if (viewType == kViewVga11)
-			view->palette = gfxr_read_pal11(id, resource + palOffset, size - palOffset);
-		else
-			view->palette = gfxr_read_pal1(id, resource + palOffset, size - palOffset);
-	} else {
-		view->palette = NULL;
-	}
-
-	view->loops = (gfxr_loop_t *)calloc(view->loops_nr, sizeof(gfxr_loop_t));
-
-	for (int i = 0; i < view->loops_nr; i++) {
-		if (viewType != kViewVga11) {
-			bool mirrored = READ_LE_UINT16(resource + V1_MIRROR_MASK) & (1 << i);
-			loopOffset = READ_LE_UINT16(resource + V1_FIRST_LOOP_OFFSET + (i << 1));
-			view->loops[i].cels_nr = READ_LE_UINT16(resource + loopOffset);
-			view->loops[i].cels = (gfx_pixmap_t**)calloc(view->loops[i].cels_nr, sizeof(gfx_pixmap_t *));
-
-			for (int j = 0; j < view->loops[i].cels_nr; j++) {
-				int cel_offset = READ_LE_UINT16(resource + loopOffset + 4 + (j << 1));
-				view->loops[i].cels[j] = gfxr_draw_cel1(id, i, j, mirrored, 
-														resource + cel_offset, 
-														resource + cel_offset, 
-														size - cel_offset, 
-														view, viewType);
-			}
-		} else {
-			byte copy_entry = seeker[V2_COPY_OF_LOOP];
-			bool mirrored = (copy_entry != 255);
-			byte *buf = !mirrored ? seeker : resource + headerSize + copy_entry * resource[V2_BYTES_PER_LOOP];
-			loopOffset = READ_LE_UINT16(buf + V2_LOOP_OFFSET);
-			view->loops[i].cels_nr = buf[V2_CELS_NUM];
-			view->loops[i].cels = (gfx_pixmap_t**)calloc(view->loops[i].cels_nr, sizeof(gfx_pixmap_t *));
-
-			byte* celSeeker = resource + loopOffset;
-			for (int j = 0; j < view->loops[i].cels_nr; j++) {
-				view->loops[i].cels[j] = gfxr_draw_cel1(id, i, j, mirrored, resource, celSeeker, size, view, viewType);
-				celSeeker += resource[V2_BYTES_PER_CEL];
-			}
-
-			seeker += resource[V2_BYTES_PER_LOOP];
-		}
-	}
-
-	return view;
-}
-
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/gui/gui_view.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_view.cpp	2009-10-07 16:16:34 UTC (rev 44736)
+++ scummvm/trunk/engines/sci/gui/gui_view.cpp	2009-10-07 16:26:16 UTC (rev 44737)
@@ -81,7 +81,8 @@
 
 		if (palOffset && palOffset != 0x100) {
 			if (IsEGA) { // simple mapping for 16 colors
-				_EGAMapping = _resourceData + palOffset;
+				// FIXME: this messes up the colors in Codename: Iceman
+				//_EGAMapping = _resourceData + palOffset;
 			} else {
 				_palette->createFromData(&_resourceData[palOffset], &_viewPalette);
 				_embeddedPal = true;
@@ -374,4 +375,8 @@
 	}
 }
 
+GuiPalette *SciGuiView::getPalette() {
+	return _embeddedPal ? &_viewPalette : &_palette->_sysPalette;
+}
+
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/gui/gui_view.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_view.h	2009-10-07 16:16:34 UTC (rev 44736)
+++ scummvm/trunk/engines/sci/gui/gui_view.h	2009-10-07 16:26:16 UTC (rev 44737)
@@ -59,7 +59,7 @@
 	byte *getBitmap(GuiViewLoopNo loopNo, GuiViewCelNo celNo);
 	void draw(Common::Rect rect, Common::Rect clipRect, Common::Rect clipRectTranslated, GuiViewLoopNo loopNo, GuiViewCelNo celNo, byte priority, uint16 paletteNo);
 	uint16 getLoopCount() const { return _loopCount; }
-	GuiPalette *getPalette() { return &_viewPalette; }
+	GuiPalette *getPalette();
 	const byte *getEgaMapping() const { return _EGAMapping; }
 
 private:


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