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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Fri Apr 3 09:52:17 CEST 2009


Revision: 39806
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39806&view=rev
Author:   thebluegr
Date:     2009-04-03 07:52:17 +0000 (Fri, 03 Apr 2009)

Log Message:
-----------
Merged the SCI1 and SCI11 cel drawing functions

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gfx/gfx_resource.h
    scummvm/trunk/engines/sci/gfx/res_pic.cpp
    scummvm/trunk/engines/sci/gfx/res_view1.cpp

Modified: scummvm/trunk/engines/sci/gfx/gfx_resource.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_resource.h	2009-04-02 23:37:21 UTC (rev 39805)
+++ scummvm/trunk/engines/sci/gfx/gfx_resource.h	2009-04-03 07:52:17 UTC (rev 39806)
@@ -290,7 +290,7 @@
 ** Returns   : (gfxr_view_t *) The resulting view
 */
 
-gfx_pixmap_t *gfxr_draw_cel11(int id, int loop, int cel, int mirrored, byte *resource_base, byte *cel_base, int size, gfxr_view_t *view);
+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, bool isAmiga, bool isSci11);
 
 
 gfx_pixmap_t *gfxr_endianness_adjust(gfx_pixmap_t *pixmap, gfx_mode_t *mode);

Modified: scummvm/trunk/engines/sci/gfx/res_pic.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/res_pic.cpp	2009-04-02 23:37:21 UTC (rev 39805)
+++ scummvm/trunk/engines/sci/gfx/res_pic.cpp	2009-04-03 07:52:17 UTC (rev 39806)
@@ -1280,7 +1280,6 @@
 }
 
 extern gfx_pixmap_t *gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size, gfxr_view_t *view, int mirrored);
-extern gfx_pixmap_t *gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, int size, gfxr_view_t *view, int amiga_game);
 extern void _gfx_crossblit_simple(byte *dest, byte *src, int dest_line_width, int src_line_width, int xl, int yl, int bpp);
 
 void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, byte *resource,
@@ -1661,7 +1660,7 @@
 				if (!sci1 && !nodraw)
 					view = gfxr_draw_cel0(-1, -1, -1, resource + pos, bytesize, NULL, 0);
 				else
-					view = gfxr_draw_cel1(-1, -1, -1, 0, resource + pos, bytesize, NULL, (static_pal && static_pal->size() == GFX_SCI1_AMIGA_COLORS_NR));
+					view = gfxr_draw_cel1(-1, -1, -1, 0, resource + pos, resource + pos, bytesize, NULL, (static_pal && static_pal->size() == GFX_SCI1_AMIGA_COLORS_NR), false);
 				pos += bytesize;
 				if (nodraw)
 					continue;
@@ -1792,7 +1791,7 @@
 	pic->visual_map->palette = gfxr_read_pal11(-1, resource + palette_data_ptr, 1284);
 
 	if (has_bitmap)
-		view = gfxr_draw_cel11(-1, 0, 0, 0, resource, resource + bitmap_data_ptr, size - bitmap_data_ptr, NULL);
+		view = gfxr_draw_cel1(-1, 0, 0, 0, resource, resource + bitmap_data_ptr, size - bitmap_data_ptr, NULL, 0, true);
 
 	if (view) {
 		view->palette = pic->visual_map->palette->getref();

Modified: scummvm/trunk/engines/sci/gfx/res_view1.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/res_view1.cpp	2009-04-02 23:37:21 UTC (rev 39805)
+++ scummvm/trunk/engines/sci/gfx/res_view1.cpp	2009-04-03 07:52:17 UTC (rev 39806)
@@ -42,6 +42,17 @@
 #define V1_RLE 0x80 // run-length encode?
 #define V1_RLE_BG 0x40 // background fill
 
+#define V2_HEADER_SIZE 0
+#define V2_LOOPS_NUM 2
+#define V2_PALETTE_OFFSET 8
+#define V2_BYTES_PER_LOOP 12
+#define V2_BYTES_PER_CEL 13
+
+#define V2_IS_MIRROR 1
+#define V2_COPY_OF_LOOP 2
+#define V2_CELS_NUM 4
+#define V2_LOOP_OFFSET 14
+
 #define NEXT_RUNLENGTH_BYTE(n) \
 	if (literal_pos == runlength_pos) \
 		literal_pos += n; \
@@ -229,38 +240,35 @@
 	return 0;
 }
 
-gfx_pixmap_t *gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, int size, gfxr_view_t *view, int amiga_game) {
-	int xl = READ_LE_UINT16(resource);
-	int yl = READ_LE_UINT16(resource + 2);
-	int xhot = (int8) resource[4];
-	int yhot = (uint8) resource[5];
-	int pos = 8;
+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, bool isAmiga, bool isSci11) {
+	int xl = READ_LE_UINT16(cel_base);
+	int yl = READ_LE_UINT16(cel_base + 2);
 	int pixmap_size = xl * yl;
+	int xdisplace = isSci11 ? READ_LE_UINT16(cel_base + 4) : (int8) cel_base[4];
+	int ydisplace = isSci11 ? READ_LE_UINT16(cel_base + 6) : (uint8) cel_base[5];
+	int runlength_offset = isSci11 ? READ_LE_UINT16(cel_base + 24) : 8;
+	int literal_offset = isSci11 ? READ_LE_UINT16(cel_base + 28) : 8;
 	gfx_pixmap_t *retval = gfx_pixmap_alloc_index_data(gfx_new_pixmap(xl, yl, id, loop, cel));
 	byte *dest = retval->index_data;
 	int decompress_failed;
 
-	retval->color_key = resource[6];
-	retval->xoffset = (mirrored) ? xhot : -xhot;
-	retval->yoffset = -yhot;
+	retval->color_key = cel_base[isSci11 ? 8 : 6];
+	retval->xoffset = (mirrored) ? xdisplace : -xdisplace;
+	retval->yoffset = -ydisplace;
+	retval->palette = view ? view->palette->getref() : NULL;
 
-	if (view)
-		retval->palette = view->palette->getref();
-	else
-		retval->palette = NULL;
-
 	if (xl <= 0 || yl <= 0) {
 		gfx_free_pixmap(retval);
 		GFXERROR("View %02x:(%d/%d) has invalid xl=%d or yl=%d\n", id, loop, cel, xl, yl);
 		return NULL;
 	}
 
-	if (amiga_game)
-		decompress_failed = decompress_sci_view_amiga(id, loop, cel, resource, dest, mirrored, pixmap_size, size, pos,
-		                    xl, yl, retval->color_key);
+	if (!isAmiga)
+		decompress_failed = decompress_sci_view(id, loop, cel, resource, dest, mirrored, pixmap_size, size, runlength_offset,
+		                                        literal_offset, xl, yl, retval->color_key);
 	else
-		decompress_failed = decompress_sci_view(id, loop, cel, resource, dest, mirrored, pixmap_size, size, pos,
-		                                        pos, xl, yl, retval->color_key);
+		decompress_failed = decompress_sci_view_amiga(id, loop, cel, resource, dest, mirrored, pixmap_size, size, runlength_offset,
+		                    xl, yl, retval->color_key);
 
 	if (decompress_failed) {
 		gfx_free_pixmap(retval);
@@ -295,7 +303,7 @@
 			GFXERROR("View %02x:(%d/%d) supposed to be at illegal offset 0x%04x\n", id, loop, i, cel_offset);
 			cel = NULL;
 		} else
-			cel = gfxr_draw_cel1(id, loop, i, mirrored, resource + cel_offset, size - cel_offset, view, amiga_game);
+			cel = gfxr_draw_cel1(id, loop, i, mirrored, resource + cel_offset, resource + cel_offset, size - cel_offset, view, amiga_game, false);
 
 		if (!cel) {
 			dest->cels_nr = i;
@@ -310,10 +318,6 @@
 	return 0;
 }
 
-#define V1_FIRST_MAGIC 1
-#define V1_MAGICS_NR 5
-//static byte view_magics[V1_MAGICS_NR] = {0x80, 0x00, 0x00, 0x00, 0x00};
-
 gfxr_view_t *gfxr_draw_view1(int id, byte *resource, int size, Palette *static_pal) {
 	int i;
 	int palette_offset;
@@ -340,15 +344,6 @@
 		return NULL;
 	}
 
-	/*	fprintf(stderr, "View flags are 0x%02x\n", resource[3]);*/
-
-	/*
-		for (i = 0; i < V1_MAGICS_NR; i++)
-			if (resource[V1_FIRST_MAGIC + i] != view_magics[i]) {
-				GFXWARN("View %04x: View magic #%d should be %02x but is %02x\n", id, i, view_magics[i], resource[V1_FIRST_MAGIC + i]);
-			}
-	*/
-
 	if (palette_offset > 0) {
 		if (palette_offset > size) {
 			GFXERROR("Palette is outside of view %04x\n", id);
@@ -391,62 +386,6 @@
 	return view;
 }
 
-#define V2_HEADER_SIZE 0
-#define V2_LOOPS_NUM 2
-#define V2_PALETTE_OFFSET 8
-#define V2_BYTES_PER_LOOP 12
-#define V2_BYTES_PER_CEL 13
-
-#define V2_IS_MIRROR 1
-#define V2_COPY_OF_LOOP 2
-#define V2_CELS_NUM 4
-#define V2_LOOP_OFFSET 14
-
-#define V2_CEL_WIDTH 0
-#define V2_CEL_HEIGHT 2
-#define V2_X_DISPLACEMENT 4
-#define V2_Y_DISPLACEMENT 6
-#define V2_COLOR_KEY 8
-#define V2_RUNLENGTH_OFFSET 24
-#define V2_LITERAL_OFFSET 28
-
-gfx_pixmap_t *gfxr_draw_cel11(int id, int loop, int cel, int mirrored, byte *resource_base, byte *cel_base, int size, gfxr_view_t *view) {
-	int xl = READ_LE_UINT16(cel_base + V2_CEL_WIDTH);
-	int yl = READ_LE_UINT16(cel_base + V2_CEL_HEIGHT);
-	int xdisplace = READ_LE_UINT16(cel_base + V2_X_DISPLACEMENT);
-	int ydisplace = READ_LE_UINT16(cel_base + V2_Y_DISPLACEMENT);
-	int runlength_offset = READ_LE_UINT16(cel_base + V2_RUNLENGTH_OFFSET);
-	int literal_offset = READ_LE_UINT16(cel_base + V2_LITERAL_OFFSET);
-	int pixmap_size = xl * yl;
-
-	gfx_pixmap_t *retval = gfx_pixmap_alloc_index_data(gfx_new_pixmap(xl, yl, id, loop, cel));
-	byte *dest = retval->index_data;
-	int decompress_failed;
-
-	retval->color_key = cel_base[V2_COLOR_KEY];
-	retval->xoffset = (mirrored) ? xdisplace : -xdisplace;
-	retval->yoffset = -ydisplace;
-
-	if (view)
-		retval->palette = view->palette->getref();
-
-	if (xl <= 0 || yl <= 0) {
-		gfx_free_pixmap(retval);
-		GFXERROR("View %02x:(%d/%d) has invalid xl=%d or yl=%d\n", id, loop, cel, xl, yl);
-		return NULL;
-	}
-
-	decompress_failed = decompress_sci_view(id, loop, cel, resource_base, dest, mirrored, pixmap_size, size,
-	                                        runlength_offset, literal_offset, xl, yl, retval->color_key);
-
-	if (decompress_failed) {
-		gfx_free_pixmap(retval);
-		return NULL;
-	}
-
-	return retval;
-}
-
 gfxr_loop_t *gfxr_draw_loop11(int id, int loop, int mirrored, byte *resource_base, byte *loop_base, int size, int cels_nr,
 	gfxr_loop_t *result, gfxr_view_t *view, int bytes_per_cel) {
 	byte *seeker = loop_base;
@@ -456,7 +395,7 @@
 	result->cels = (gfx_pixmap_t **)sci_malloc(sizeof(gfx_pixmap_t *) * cels_nr);
 
 	for (i = 0; i < cels_nr; i++) {
-		result->cels[i] = gfxr_draw_cel11(id, loop, i, mirrored, resource_base, seeker, size, view);
+		result->cels[i] = gfxr_draw_cel1(id, loop, i, mirrored, resource_base, seeker, size, view, 0, true);
 		seeker += bytes_per_cel;
 	}
 


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