diff options
Diffstat (limited to 'engines')
| -rw-r--r-- | engines/sci/gfx/font.cpp | 82 | ||||
| -rw-r--r-- | engines/sci/gfx/gfx_driver.cpp | 103 | ||||
| -rw-r--r-- | engines/sci/gfx/gfx_line.cpp | 52 | ||||
| -rw-r--r-- | engines/sci/gfx/gfx_pixmap_scale.cpp | 112 | ||||
| -rw-r--r-- | engines/sci/gfx/gfx_res_options.cpp | 63 | ||||
| -rw-r--r-- | engines/sci/gfx/gfx_resource.cpp | 86 | ||||
| -rw-r--r-- | engines/sci/gfx/gfx_support.cpp | 77 | ||||
| -rw-r--r-- | engines/sci/gfx/gfx_tools.cpp | 110 | 
8 files changed, 243 insertions, 442 deletions
diff --git a/engines/sci/gfx/font.cpp b/engines/sci/gfx/font.cpp index 0b25ba2edf..55e9b02cbb 100644 --- a/engines/sci/gfx/font.cpp +++ b/engines/sci/gfx/font.cpp @@ -30,8 +30,7 @@  int font_counter = 0; -void -gfxr_free_font(gfx_bitmap_font_t *font) { +void gfxr_free_font(gfx_bitmap_font_t *font) {  	if (font->widths)  		free(font->widths); @@ -43,10 +42,7 @@ gfxr_free_font(gfx_bitmap_font_t *font) {  	free(font);  } - - -void -scale_char(byte *dest, byte *src, int width, int height, int newwidth, int xfact, int yfact) { +void scale_char(byte *dest, byte *src, int width, int height, int newwidth, int xfact, int yfact) {  	int x, y;  	for (y = 0; y < height; y++) { @@ -85,9 +81,8 @@ scale_char(byte *dest, byte *src, int width, int height, int newwidth, int xfact  	}  } -gfx_bitmap_font_t * -gfxr_scale_font_unfiltered(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode) { -	gfx_bitmap_font_t *font = (gfx_bitmap_font_t*)sci_malloc(sizeof(gfx_bitmap_font_t)); +gfx_bitmap_font_t *gfxr_scale_font_unfiltered(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode) { +	gfx_bitmap_font_t *font = (gfx_bitmap_font_t *)sci_malloc(sizeof(gfx_bitmap_font_t));  	int height = orig_font->height * mode->yfact;  	int width = 0;  	int byte_width; @@ -115,18 +110,14 @@ gfxr_scale_font_unfiltered(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode) {  	for (i = 0; i < font->chars_nr; i++) {  		font->widths[i] = orig_font->widths[i] * mode->xfact; -		scale_char(font->data + font->char_size * i, -		           orig_font->data + orig_font->char_size * i, -		           orig_font->row_size, orig_font->height, -		           font->row_size, -		           mode->xfact, mode->yfact); +		scale_char(font->data + font->char_size * i, orig_font->data + orig_font->char_size * i, +		           orig_font->row_size, orig_font->height, font->row_size, mode->xfact, mode->yfact);  	} +  	return font;  } - -gfx_bitmap_font_t * -gfxr_scale_font(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode, gfxr_font_scale_filter_t filter) { +gfx_bitmap_font_t *gfxr_scale_font(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode, gfxr_font_scale_filter_t filter) {  	GFXWARN("This function hasn't been tested yet");  	switch (filter) { @@ -140,16 +131,10 @@ gfxr_scale_font(gfx_bitmap_font_t *orig_font, gfx_mode_t *mode, gfxr_font_scale_  	}  } - - - -text_fragment_t * -gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *text, -                         int *width, int *height, -                         int *lines, int *line_height_p, int *last_offset_p, -                         int flags) { +text_fragment_t *gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *text, int *width, int *height,  +                         int *lines, int *line_height_p, int *last_offset_p, int flags) {  	int est_char_width = font->widths[(font->chars_nr > 'M')? 'M' : font->chars_nr - 1]; -	/* 'M' is typically among the widest chars */ +	// 'M' is typically among the widest chars  	int fragments_nr;  	text_fragment_t *fragments;  	int lineheight = font->line_height; @@ -168,13 +153,11 @@ gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *tex  	if (max_width > 1) fragments_nr = 3 + (strlen(text) * est_char_width) * 3 / (max_width << 1);  	else fragments_nr = 1; -	fragments = (text_fragment_t*)sci_calloc(sizeof(text_fragment_t), fragments_nr); - +	fragments = (text_fragment_t *)sci_calloc(sizeof(text_fragment_t), fragments_nr);  	fragments[0].offset = text;  	while ((foo = *text++)) { -  		if (foo >= font->chars_nr) {  			GFXWARN("Invalid char 0x%02x (max. 0x%02x) encountered in text string '%s', font %04x\n",  			        foo, font->chars_nr, text, font->ID); @@ -186,16 +169,14 @@ gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *tex  			}  		} -		if (((foo == '\n') || (foo == 0x0d)) -		        && !(flags & GFXR_FONT_FLAG_NO_NEWLINES)) { - +		if (((foo == '\n') || (foo == 0x0d)) && !(flags & GFXR_FONT_FLAG_NO_NEWLINES)) {  			fragments[current_fragment-1].length = text - 1 - fragments[current_fragment-1].offset;  			if (*text)  				maxheight += lineheight;  			if (foo == 0x0d && *text == '\n') -				text++; /* Interpret DOS-style CR LF as single NL */ +				text++; // Interpret DOS-style CR LF as single NL  			fragments[current_fragment++].offset = text; @@ -207,27 +188,26 @@ gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *tex  			localmaxwidth = 0; -		} else { /* foo != '\n' */ +		} else { // foo != '\n'  			localmaxwidth += font->widths[foo];  			if (localmaxwidth > max_allowed_width) { -				int blank_break = 1; /* break is at a blank char, i.e. not within a word */ +				int blank_break = 1; // break is at a blank char, i.e. not within a word  				maxheight += lineheight; -				if (last_breakpoint == 0) { /* Text block too long and without whitespace? */ +				if (last_breakpoint == 0) { // Text block too long and without whitespace?  					last_breakpoint = localmaxwidth - font->widths[foo];  					last_break_width = 0;  					--text; -					blank_break = 0; /* non-blank break */ +					blank_break = 0; // non-blank break  				} else {  					text = breakpoint_ptr + 1;  					assert(breakpoint_ptr);  				}  				if (last_breakpoint == 0) { -					GFXWARN("Warning: maxsize %d too small for '%s'\n", -					        max_allowed_width, text); +					GFXWARN("Warning: maxsize %d too small for '%s'\n", max_allowed_width, text);  				}  				if (last_breakpoint > maxwidth) @@ -271,9 +251,7 @@ gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width, const char *tex  	return fragments;  } - -static inline void -render_char(byte *dest, byte *src, int width, int line_width, int lines, int bytes_per_src_line, int fg0, int fg1, int bg) { +static inline void render_char(byte *dest, byte *src, int width, int line_width, int lines, int bytes_per_src_line, int fg0, int fg1, int bg) {  	int x, y;  	for (y = 0; y < lines; y++) { @@ -301,10 +279,9 @@ render_char(byte *dest, byte *src, int width, int line_width, int lines, int byt  	}  } -gfx_pixmap_t * -gfxr_draw_font(gfx_bitmap_font_t *font, const char *stext, int characters, +gfx_pixmap_t *gfxr_draw_font(gfx_bitmap_font_t *font, const char *stext, int characters,                 gfx_pixmap_color_t *fg0, gfx_pixmap_color_t *fg1, gfx_pixmap_color_t *bg) { -	unsigned char *text = (unsigned char *) stext; +	unsigned char *text = (unsigned char *)stext;  	int height = font->height;  	int width = 0;  	gfx_pixmap_t *pxm; @@ -334,7 +311,7 @@ gfxr_draw_font(gfx_bitmap_font_t *font, const char *stext, int characters,  		hack = 1;  		fg0 = fg1 = bg = &dummy;  	} -	pxm->colors = (gfx_pixmap_color_t*)sci_malloc(sizeof(gfx_pixmap_color_t) * pxm->colors_nr); +	pxm->colors = (gfx_pixmap_color_t *)sci_malloc(sizeof(gfx_pixmap_color_t) * pxm->colors_nr);  #ifdef SATISFY_PURIFY  	memset(pxm->colors, 0, sizeof(gfx_pixmap_color_t) * pxm->colors_nr);  #endif @@ -345,17 +322,20 @@ gfxr_draw_font(gfx_bitmap_font_t *font, const char *stext, int characters,  	if (fg0 || hack) {  		memcpy(pxm->colors + i, fg0, sizeof(gfx_pixmap_color_t));  		fore_0 = i++; -	} else fore_0 = pxm->color_key; +	} else +		fore_0 = pxm->color_key;  	if (fg1 || hack) {  		memcpy(pxm->colors + i, fg1, sizeof(gfx_pixmap_color_t));  		fore_1 = i++; -	} else fore_1 = pxm->color_key; +	} else +		fore_1 = pxm->color_key;  	if (bg || hack) {  		memcpy(pxm->colors + i, bg, sizeof(gfx_pixmap_color_t));  		back = i++; -	} else back = pxm->color_key; +	} else +		back = pxm->color_key;  	offset = pxm->index_data; @@ -365,12 +345,10 @@ gfxr_draw_font(gfx_bitmap_font_t *font, const char *stext, int characters,  		width = font->widths[ch];  		render_char(offset, font->data + (ch * font->char_size), width, -		            pxm->index_xl, pxm->index_yl, font->row_size, -		            fore_0, fore_1, back); +		            pxm->index_xl, pxm->index_yl, font->row_size, fore_0, fore_1, back);  		offset += width;  	}  	return pxm;  } - diff --git a/engines/sci/gfx/gfx_driver.cpp b/engines/sci/gfx/gfx_driver.cpp index 841ab04b8b..97c48eccae 100644 --- a/engines/sci/gfx/gfx_driver.cpp +++ b/engines/sci/gfx/gfx_driver.cpp @@ -61,8 +61,7 @@ scummvm_init_specific(struct _gfx_driver *drv, int xfact, int yfact, int bytespp  	for (i = 0; i < 2; i++) {  		S->priority[i] = gfx_pixmap_alloc_index_data(gfx_new_pixmap(S->xsize, S->ysize, GFX_RESID_NONE, -i, -777));  		if (!S->priority[i]) { -			printf("Out of memory: Could not allocate priority maps! (%dx%d)\n", -			       S->xsize, S->ysize); +			printf("Out of memory: Could not allocate priority maps! (%dx%d)\n", S->xsize, S->ysize);  			return GFX_FATAL;  		}  	} @@ -71,27 +70,22 @@ scummvm_init_specific(struct _gfx_driver *drv, int xfact, int yfact, int bytespp  		S->visual[i] = NULL;  		S->visual[i] = new byte[S->xsize * S->ysize];  		if (!S->visual[i]) { -			printf("Out of memory: Could not allocate visual buffers! (%dx%d)\n", -			       S->xsize, S->ysize); +			printf("Out of memory: Could not allocate visual buffers! (%dx%d)\n", S->xsize, S->ysize);  			return GFX_FATAL;  		}  		memset(S->visual[i], 0, S->xsize * S->ysize);  	} -	drv->mode = gfx_new_mode(xfact, yfact, bytespp, -	                         0, 0, 0, 0, -	                         0, 0, 0, 0, 256, 0); +	drv->mode = gfx_new_mode(xfact, yfact, bytespp, 0, 0, 0, 0, 0, 0, 0, 0, 256, 0);  	return GFX_OK;  } -static int -scummvm_init(struct _gfx_driver *drv) { +static int scummvm_init(struct _gfx_driver *drv) {  	return scummvm_init_specific(drv, 1, 1, GFX_COLOR_MODE_INDEX);  } -static void -scummvm_exit(struct _gfx_driver *drv) { +static void scummvm_exit(struct _gfx_driver *drv) {  	int i;  	if (S) {  		for (i = 0; i < 2; i++) { @@ -117,9 +111,8 @@ scummvm_exit(struct _gfx_driver *drv) {  // Drawing operations -/* This code shamelessly lifted from the SDL_gfxPrimitives package */ -static void -lineColor2(byte *dst, int16 x1, int16 y1, int16 x2, int16 y2, uint32 color) { +// This code shamelessly lifted from the SDL_gfxPrimitives package +static void lineColor2(byte *dst, int16 x1, int16 y1, int16 x2, int16 y2, uint32 color) {  	int pixx, pixy;  	int x, y;  	int dx, dy; @@ -148,7 +141,7 @@ lineColor2(byte *dst, int16 x1, int16 y1, int16 x2, int16 y2, uint32 color) {  		pixy = swaptmp;  	} -	/* Draw */ +	// Draw  	x = 0;  	y = 0;  	for (; x < dx; x++, pixel += pixx) { @@ -161,10 +154,8 @@ lineColor2(byte *dst, int16 x1, int16 y1, int16 x2, int16 y2, uint32 color) {  	}  } -static int -scummvm_draw_line(struct _gfx_driver *drv, Common::Point start, Common::Point end, -                  gfx_color_t color, -                  gfx_line_mode_t line_mode, gfx_line_style_t line_style) { +static int scummvm_draw_line(struct _gfx_driver *drv, Common::Point start, Common::Point end, +                  gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style) {  	uint32 scolor = color.visual.global_index;  	int xsize = S->xsize;  	int ysize = S->ysize; @@ -177,21 +168,17 @@ scummvm_draw_line(struct _gfx_driver *drv, Common::Point start, Common::Point en  		nend.x = CLIP<int16>(end.x, 0, xsize - 1);  		nend.y = CLIP<int16>(end.y, 0, ysize - 1); -		lineColor2(S->visual[1], (int16)nstart.x, (int16)nstart.y, -		           (int16)nend.x, (int16)nend.y, scolor); +		lineColor2(S->visual[1], (int16)nstart.x, (int16)nstart.y, (int16)nend.x, (int16)nend.y, scolor);  		if (color.mask & GFX_MASK_PRIORITY) { -			gfx_draw_line_pixmap_i(S->priority[0], nstart, nend, -			                       color.priority); +			gfx_draw_line_pixmap_i(S->priority[0], nstart, nend, color.priority);  		}  	}  	return GFX_OK;  } -static int -scummvm_draw_filled_rect(struct _gfx_driver *drv, rect_t rect, -                         gfx_color_t color1, gfx_color_t color2, +static int scummvm_draw_filled_rect(struct _gfx_driver *drv, rect_t rect, gfx_color_t color1, gfx_color_t color2,                           gfx_rectangle_fill_t shade_mode) {  	if (color1.mask & GFX_MASK_VISUAL) {  		for (int i = rect.y; i < rect.y + rect.yl; i++) { @@ -205,32 +192,25 @@ scummvm_draw_filled_rect(struct _gfx_driver *drv, rect_t rect,  	return GFX_OK;  } -  // Pixmap operations -static int -scummvm_draw_pixmap(struct _gfx_driver *drv, gfx_pixmap_t *pxm, int priority, -                    rect_t src, rect_t dest, gfx_buffer_t buffer) { +static int scummvm_draw_pixmap(struct _gfx_driver *drv, gfx_pixmap_t *pxm, int priority,  +							   rect_t src, rect_t dest, gfx_buffer_t buffer) {  	int bufnr = (buffer == GFX_BUFFER_STATIC) ? 2 : 1;  	int pribufnr = bufnr - 1;  	if (dest.xl != src.xl || dest.yl != src.yl) { -		printf("Attempt to scale pixmap (%dx%d)->(%dx%d): Not supported\n", -		       src.xl, src.yl, dest.xl, dest.yl); +		printf("Attempt to scale pixmap (%dx%d)->(%dx%d): Not supported\n", src.xl, src.yl, dest.xl, dest.yl);  		return GFX_ERROR;  	} -	gfx_crossblit_pixmap(drv->mode, pxm, priority, src, dest, -	                     S->visual[bufnr], S->xsize, -	                     S->priority[pribufnr]->index_data, -	                     S->priority[pribufnr]->index_xl, 1, 0); +	gfx_crossblit_pixmap(drv->mode, pxm, priority, src, dest, S->visual[bufnr], S->xsize, +	                     S->priority[pribufnr]->index_data, S->priority[pribufnr]->index_xl, 1, 0);  	return GFX_OK;  } -static int -scummvm_grab_pixmap(struct _gfx_driver *drv, rect_t src, gfx_pixmap_t *pxm, -                    gfx_map_mask_t map) { +static int scummvm_grab_pixmap(struct _gfx_driver *drv, rect_t src, gfx_pixmap_t *pxm, gfx_map_mask_t map) {  	if (src.x < 0 || src.y < 0) {  		printf("Attempt to grab pixmap from invalid coordinates (%d,%d)\n", src.x, src.y);  		return GFX_ERROR; @@ -263,19 +243,16 @@ scummvm_grab_pixmap(struct _gfx_driver *drv, rect_t src, gfx_pixmap_t *pxm,  	return GFX_OK;  } -  // Buffer operations -static int -scummvm_update(struct _gfx_driver *drv, rect_t src, Common::Point dest, gfx_buffer_t buffer) { +static int scummvm_update(struct _gfx_driver *drv, rect_t src, Common::Point dest, gfx_buffer_t buffer) {  	//TODO  	int data_source = (buffer == GFX_BUFFER_BACK) ? 2 : 1;  	int data_dest = data_source - 1;  	/*  	if (src.x != dest.x || src.y != dest.y) { -		printf("Updating %d (%d,%d)(%dx%d) to (%d,%d) on %d\n", buffer, src.x, src.y, -			src.xl, src.yl, dest.x, dest.y, data_dest); +		printf("Updating %d (%d,%d)(%dx%d) to (%d,%d) on %d\n", buffer, src.x, src.y, src.xl, src.yl, dest.x, dest.y, data_dest);  	} else {  		printf("Updating %d (%d,%d)(%dx%d) to %d\n", buffer, src.x, src.y, src.xl, src.yl, data_dest);  	} @@ -294,14 +271,11 @@ scummvm_update(struct _gfx_driver *drv, rect_t src, Common::Point dest, gfx_buff  			gfx_copy_pixmap_box_i(S->priority[0], S->priority[1], src);  		break;  	case GFX_BUFFER_FRONT: -		memcpy(S->visual[data_dest], S->visual[data_source], -		       S->xsize * S->ysize); +		memcpy(S->visual[data_dest], S->visual[data_source], S->xsize * S->ysize); -		g_system->copyRectToScreen(S->visual[data_dest] + src.x + src.y * S->xsize, -		                           S->xsize, dest.x, dest.y, src.xl, src.yl); +		g_system->copyRectToScreen(S->visual[data_dest] + src.x + src.y * S->xsize, S->xsize, dest.x, dest.y, src.xl, src.yl);  		/* -		g_system->copyRectToScreen(S->visual[data_dest], -			S->xsize, 0, 0, S->xsize, S->ysize); +		g_system->copyRectToScreen(S->visual[data_dest], S->xsize, 0, 0, S->xsize, S->ysize);  		*/  		S->update_screen = true;  		break; @@ -310,28 +284,22 @@ scummvm_update(struct _gfx_driver *drv, rect_t src, Common::Point dest, gfx_buff  		return GFX_ERROR;  	} -  	return GFX_OK;  } -static int -scummvm_set_static_buffer(struct _gfx_driver *drv, gfx_pixmap_t *pic, gfx_pixmap_t *priority) { +static int scummvm_set_static_buffer(struct _gfx_driver *drv, gfx_pixmap_t *pic, gfx_pixmap_t *priority) {  	memcpy(S->visual[2], pic->data, S->xsize * S->ysize); -	/*gfx_crossblit_pixmap(drv->mode, pic, 0, rect, rect, -			S->visual[2], S->xsize, -			S->priority[1]->index_data, -			S->priority[1]->index_xl, 1, 0);*/ +	/*gfx_crossblit_pixmap(drv->mode, pic, 0, rect, rect, S->visual[2], S->xsize, S->priority[1]->index_data, +							S->priority[1]->index_xl, 1, 0);*/  	gfx_copy_pixmap_box_i(S->priority[1], priority, gfx_rect(0, 0, S->xsize, S->ysize));  	return GFX_OK;  } -  // Mouse pointer operations -static int -scummvm_set_pointer(struct _gfx_driver *drv, gfx_pixmap_t *pointer) { +static int scummvm_set_pointer(struct _gfx_driver *drv, gfx_pixmap_t *pointer) {  	if (pointer == NULL) {  		g_system->showMouse(false);  	} else { @@ -344,11 +312,9 @@ scummvm_set_pointer(struct _gfx_driver *drv, gfx_pixmap_t *pointer) {  	return GFX_OK;  } -  // Palette operations -static int -scummvm_set_palette(struct _gfx_driver *drv, int index, byte red, byte green, byte blue) { +static int scummvm_set_palette(struct _gfx_driver *drv, int index, byte red, byte green, byte blue) {  	if (index < 0 || index > 255) {  		GFXERROR("Attempt to set invalid palette entry %d\n", index);  		return GFX_ERROR; @@ -356,14 +322,13 @@ scummvm_set_palette(struct _gfx_driver *drv, int index, byte red, byte green, by  	byte color[] = {red, green, blue, 255};  	g_system->setPalette(color, index, 1); +  	return GFX_OK;  } -  // Event management -static sci_event_t -scummvm_get_event(struct _gfx_driver *drv) { +static sci_event_t scummvm_get_event(struct _gfx_driver *drv) {  	sci_event_t input = { SCI_EVT_NONE, 0, 0, 0 };  	Common::EventManager *em = g_system->getEventManager(); @@ -513,14 +478,12 @@ scummvm_get_event(struct _gfx_driver *drv) {  	return input;  } -static int -scummvm_usec_sleep(struct _gfx_driver *drv, long usecs) { +static int scummvm_usec_sleep(struct _gfx_driver *drv, long usecs) {  	g_system->delayMillis(usecs / 1000);  	return GFX_OK;  } -gfx_driver_t -gfx_driver_scummvm = { +gfx_driver_t gfx_driver_scummvm = {  	NULL,  	0, 0,  	0,		// flags here diff --git a/engines/sci/gfx/gfx_line.cpp b/engines/sci/gfx/gfx_line.cpp index e38e7696e5..3bc52098b8 100644 --- a/engines/sci/gfx/gfx_line.cpp +++ b/engines/sci/gfx/gfx_line.cpp @@ -25,25 +25,24 @@  #define LINEMACRO(startx, starty, deltalinear, deltanonlinear, linearvar, nonlinearvar, \                    linearend, nonlinearstart, linearmod, nonlinearmod) \ -   x = (startx); y = (starty); \ -   incrNE = ((deltalinear) > 0)? (deltalinear) : -(deltalinear); \ -   incrNE <<= 1; \ -   deltanonlinear <<= 1; \ -   incrE = ((deltanonlinear) > 0) ? -(deltanonlinear) : (deltanonlinear);  \ -   d = nonlinearstart-1;  \ -   while (linearvar != (linearend)) { \ -     memcpy(buffer + linewidth * y + x, &color, PIXELWIDTH); \ -     linearvar += linearmod; \ -     if ((d+=incrE) < 0) { \ -       d += incrNE; \ -       nonlinearvar += nonlinearmod; \ -     }; \ -   }; \ -   memcpy(buffer + linewidth * y + x, &color, PIXELWIDTH); +	x = (startx); y = (starty); \ +	incrNE = ((deltalinear) > 0) ? (deltalinear) : -(deltalinear); \ +	incrNE <<= 1; \ +	deltanonlinear <<= 1; \ +	incrE = ((deltanonlinear) > 0) ? -(deltanonlinear) : (deltanonlinear);  \ +	d = nonlinearstart - 1;  \ +	while (linearvar != (linearend)) { \ +		memcpy(buffer + linewidth * y + x, &color, PIXELWIDTH); \ +		linearvar += linearmod; \ +		if ((d += incrE) < 0) { \ +			d += incrNE; \ +			nonlinearvar += nonlinearmod; \ +		}; \ +	}; \ +	memcpy(buffer + linewidth * y + x, &color, PIXELWIDTH); -static inline -void DRAWLINE_FUNC(byte *buffer, int linewidth, Common::Point start, Common::Point end, unsigned int color) { +static inline void DRAWLINE_FUNC(byte *buffer, int linewidth, Common::Point start, Common::Point end, unsigned int color) {  	int dx, dy, incrE, incrNE, d, finalx, finaly;  	int x = start.x;  	int y = start.y; @@ -59,29 +58,29 @@ void DRAWLINE_FUNC(byte *buffer, int linewidth, Common::Point start, Common::Poi  	if (dx > dy) {  		if (finalx < x) { -			if (finaly < y) { /* llu == left-left-up */ +			if (finaly < y) { // llu == left-left-up  				LINEMACRO(x, y, dx, dy, x, y, finalx, dx, -PIXELWIDTH, -1);  			} else {         /* lld */  				LINEMACRO(x, y, dx, dy, x, y, finalx, dx, -PIXELWIDTH, 1);  			} -		} else { /* x1 >= x */ -			if (finaly < y) { /* rru */ +		} else { // x1 >= x +			if (finaly < y) { // rru  				LINEMACRO(x, y, dx, dy, x, y, finalx, dx, PIXELWIDTH, -1); -			} else {         /* rrd */ +			} else {         // rrd  				LINEMACRO(x, y, dx, dy, x, y, finalx, dx, PIXELWIDTH, 1);  			}  		} -	} else { /* dx <= dy */ +	} else { // dx <= dy  		if (finaly < y) { -			if (finalx < x) { /* luu */ +			if (finalx < x) { // luu  				LINEMACRO(x, y, dy, dx, y, x, finaly, dy, -1, -PIXELWIDTH);  			} else {         /* ruu */  				LINEMACRO(x, y, dy, dx, y, x, finaly, dy, -1, PIXELWIDTH);  			} -		} else { /* y1 >= y */ -			if (finalx < x) { /* ldd */ +		} else { // y1 >= y +			if (finalx < x) { // ldd  				LINEMACRO(x, y, dy, dx, y, x, finaly, dy, 1, -PIXELWIDTH); -			} else {         /* rdd */ +			} else {         // rdd  				LINEMACRO(x, y, dy, dx, y, x, finaly, dy, 1, PIXELWIDTH);  			}  		} @@ -89,5 +88,4 @@ void DRAWLINE_FUNC(byte *buffer, int linewidth, Common::Point start, Common::Poi  } -  #undef LINEMACRO diff --git a/engines/sci/gfx/gfx_pixmap_scale.cpp b/engines/sci/gfx/gfx_pixmap_scale.cpp index 773f9c88a5..b1a26d2a5d 100644 --- a/engines/sci/gfx/gfx_pixmap_scale.cpp +++ b/engines/sci/gfx/gfx_pixmap_scale.cpp @@ -29,33 +29,18 @@  ** EXTRA_BYTE_OFFSET: Extra source byte offset for copying (used on big-endian machines in 24 bit mode)  */ -/* set optimisations for Win32: */ -/* g on: enable global optimizations */ -/* t on: use fast code */ -/* y on: suppress creation of frame pointers on stack */ -/* s off: disable minimize size code */ -#ifdef WIN32 -#	include <memory.h> -#	ifndef SATISFY_PURIFY -#		pragma optimize( "s", off ) -#		pragma optimize( "gty", on ) -#		pragma intrinsic( memcpy, memset ) -#	endif -#endif -  #include "sci/include/sci_memory.h"  #define EXTEND_COLOR(x) (unsigned) ((((unsigned) x) << 24) | (((unsigned) x) << 16) | (((unsigned) x) << 8) | ((unsigned) x))  #define PALETTE_MODE mode->palette -void -FUNCNAME(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) { +void FUNCNAME(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  	SIZETYPE result_colors[GFX_PIC_COLORS];  	SIZETYPE alpha_color = 0xffffffff & mode->alpha_mask;  	SIZETYPE alpha_ormask = 0;  	int xfact = (scale) ? mode->xfact : 1;  	int yfact = (scale) ? mode->yfact : 1; -	int widthc, heightc; /* Width duplication counter */ +	int widthc, heightc; // Width duplication counter  	int line_width = xfact * pxm->index_xl;  	int bytespp = mode->bytespp;  	int x, y; @@ -76,9 +61,9 @@ FUNCNAME(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  	assert(bytespp == COPY_BYTES);  	if (separate_alpha_map && !alpha_dest) -		alpha_dest = pxm->alpha_map = (byte*)sci_malloc(pxm->index_xl * xfact * pxm->index_yl * yfact); +		alpha_dest = pxm->alpha_map = (byte *)sci_malloc(pxm->index_xl * xfact * pxm->index_yl * yfact); -	/* Calculate all colors */ +	// Calculate all colors  	for (i = 0; i < pxm->colors_nr; i++) {  		int col; @@ -96,7 +81,7 @@ FUNCNAME(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  	if (!separate_alpha_map && pxm->color_key != GFX_PIXMAP_COLOR_KEY_NONE)  		result_colors[pxm->color_key] = alpha_color; -	src = pxm->index_data; /* Workaround for gcc 4.2.3 bug on EMT64 */ +	src = pxm->index_data; // Workaround for gcc 4.2.3 bug on EMT64  	for (y = 0; y < pxm->index_yl; y++) {  		byte *prev_dest = dest;  		byte *prev_alpha_dest = alpha_dest; @@ -106,23 +91,22 @@ FUNCNAME(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  			SIZETYPE col = result_colors[isalpha = *src++] << (EXTRA_BYTE_OFFSET * 8);  			isalpha = (isalpha == pxm->color_key) && using_alpha; -			/* O(n) loops. There is an O(ln(n)) algorithm for this, but its slower for small n (which we're optimizing for here). -			** And, anyway, most of the time is spent in memcpy() anyway. */ +			// O(n) loops. There is an O(ln(n)) algorithm for this, but its slower for small n (which we're optimizing for here). +			// And, anyway, most of the time is spent in memcpy() anyway.  			for (widthc = 0; widthc < xfact; widthc++) {  				memcpy(dest, &col, COPY_BYTES);  				dest += COPY_BYTES;  			} -			if (separate_alpha_map) { /* Set separate alpha map */ +			if (separate_alpha_map) { // Set separate alpha map  				memset(alpha_dest, (isalpha) ? byte_transparent : byte_opaque, xfact);  				alpha_dest += xfact;  			}  		} -		/* Copies each line. O(n) iterations; again, this could be optimized to O(ln(n)) for very high resolutions, -		** but that wouldn't really help that much, as the same amount of data still would have to be transferred. -		*/ +		// Copies each line. O(n) iterations; again, this could be optimized to O(ln(n)) for very high resolutions, +		// but that wouldn't really help that much, as the same amount of data still would have to be transferred.  		for (heightc = 1; heightc < yfact; heightc++) {  			memcpy(dest, prev_dest, line_width * bytespp);  			dest += line_width * bytespp; @@ -135,15 +119,13 @@ FUNCNAME(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  } +// linear filter: Macros (in reverse order) - -/* linear filter: Macros (in reverse order) */ - -#define X_CALC_INTENSITY_NORMAL (ctexel[i] << 16) + ((linecolor[i])*(256-column_valuator)) + ((othercolumn[i]*column_valuator))*(256-line_valuator) -#define X_CALC_INTENSITY_CENTER (ctexel[i] << 16) + ((linecolor[i])*(256-column_valuator)) +#define X_CALC_INTENSITY_NORMAL (ctexel[i] << 16) + ((linecolor[i]) * (256-column_valuator)) + ((othercolumn[i] * column_valuator)) * (256-line_valuator) +#define X_CALC_INTENSITY_CENTER (ctexel[i] << 16) + ((linecolor[i]) * (256-column_valuator))  #define WRITE_XPART(X_CALC_INTENSITY, DO_X_STEP) \ -				for (subx = 0; subx < ((DO_X_STEP)? (xfact >> 1) : 1); subx++) { \ +				for (subx = 0; subx < ((DO_X_STEP) ? (xfact >> 1) : 1); subx++) { \                                          unsigned int intensity; \  					wrcolor = 0; \  					for (i = 0; i < 3; i++) { \ @@ -165,11 +147,11 @@ FUNCNAME(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  				} \                                  if (DO_X_STEP) \  				        column_step = -column_step -/* End of macro definition */ +// End of macro definition  #define Y_CALC_INTENSITY_CENTER 0 -#define Y_CALC_INTENSITY_NORMAL otherline[i]*line_valuator +#define Y_CALC_INTENSITY_NORMAL otherline[i] * line_valuator  #define WRITE_YPART(DO_Y_STEP, LINE_COLOR) \  			for (suby = 0; suby < ((DO_Y_STEP)? yfact >> 1 : 1); suby++) { \ @@ -191,7 +173,7 @@ FUNCNAME(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  					WRITE_XPART(X_CALC_INTENSITY_CENTER, 0); \  				} \  				/*-- right half --*/ \ -				MAKE_PIXEL((x+1 == pxm->index_xl), othercolumn, ctexel, src[+1]); \ +				MAKE_PIXEL((x + 1 == pxm->index_xl), othercolumn, ctexel, src[+1]); \  				WRITE_XPART(X_CALC_INTENSITY_NORMAL, 1); \  				if (DO_Y_STEP) \                                          line_valuator -= line_step; \ @@ -200,13 +182,10 @@ FUNCNAME(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  			} \  			if (DO_Y_STEP) \  			        line_step = -line_step -/* End of macro definition */ - +// End of macro definition - -void -FUNCNAME_LINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) { +void FUNCNAME_LINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  	int xfact = mode->xfact;  	int yfact = mode->yfact;  	int line_step = (yfact < 2) ? 0 : 256 / (yfact & ~1); @@ -242,15 +221,15 @@ FUNCNAME_LINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  	shifts[3] = mode->alpha_shift;  	if (separate_alpha_map && !alpha_dest) -		alpha_dest = pxm->alpha_map = (byte*)sci_malloc(pxm->index_xl * xfact * pxm->index_yl * yfact); +		alpha_dest = pxm->alpha_map = (byte *)sci_malloc(pxm->index_xl * xfact * pxm->index_yl * yfact);  	for (y = 0; y < pxm->index_yl; y++) {  		byte *linepos = dest;  		byte *alpha_linepos = alpha_dest;  		for (x = 0; x < pxm->index_xl; x++) { -			int otherline[4]; /* the above line or the line below */ -			int ctexel[4]; /* Current texel */ +			int otherline[4]; // the above line or the line below +			int ctexel[4]; // Current texel  			int subx, suby;  			int line_valuator = line_step ? 128 - (line_step >> 1) : 256;  			byte *wrpos, *alpha_wrpos; @@ -274,7 +253,7 @@ FUNCNAME_LINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  			MAKE_PIXEL(0, ctexel, zero, *src); -			/*-- Upper half --*/ +			//-- Upper half --  			MAKE_PIXEL((y == 0), otherline, ctexel, src[-pxm->index_xl]);  			WRITE_YPART(1, Y_CALC_INTENSITY_NORMAL); @@ -282,7 +261,7 @@ FUNCNAME_LINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  				WRITE_YPART(0, Y_CALC_INTENSITY_CENTER);  			} -			/*-- Lower half --*/ +			//-- Lower half --  			line_valuator -= line_step;  			MAKE_PIXEL((y + 1 == pxm->index_yl), otherline, ctexel, src[pxm->index_xl]);  			WRITE_YPART(1, Y_CALC_INTENSITY_NORMAL); @@ -298,33 +277,31 @@ FUNCNAME_LINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  } - -/*----------------------*/ -/*** Trilinear filter ***/ -/*----------------------*/ +//---------------------- +//** Trilinear filter ** +//----------------------  #ifndef GFX_GET_PIXEL_DELTA  #define GFX_GET_PIXEL_DELTA -static inline void -gfx_get_pixel_delta(unsigned int *color, int *delta, unsigned int *pixel0, unsigned int *pixel1) { +static inline void gfx_get_pixel_delta(unsigned int *color, int *delta, unsigned int *pixel0, unsigned int *pixel1) {  	int j;  	int transp0 = pixel0[3] == 0xffffff;  	int transp1 = pixel1[3] == 0xffffff; -	if (transp0 && !transp1) { /* Transparent -> Opaque */ +	if (transp0 && !transp1) { // Transparent -> Opaque  		memset(delta, 0, sizeof(int) * 3);  		delta[3] = ((pixel1[3] >> 8) - (pixel0[3] >> 8));  		memcpy(color, pixel1, sizeof(int) * 3);  		color[3] = 0xffffff; -	} else if (!transp0 && transp1) { /* Opaque -> Transparent */ +	} else if (!transp0 && transp1) { // Opaque -> Transparent  		memset(delta, 0, sizeof(int) * 3);  		delta[3] = ((pixel1[3] >> 8) - (pixel0[3] >> 8));  		memcpy(color, pixel0, sizeof(int) * 4); -	} else if (transp0 && transp1) { /* Transparent */ +	} else if (transp0 && transp1) { // Transparent  		delta[3] = 0;  		color[3] = 0xffffff; -	} else { /* Opaque */ +	} else { // Opaque  		memcpy(color, pixel0, sizeof(int) * 4);  		for (j = 0; j < 4; j++)  			delta[j] = ((pixel1[j] >> 8) - (pixel0[j] >> 8)); @@ -332,9 +309,9 @@ gfx_get_pixel_delta(unsigned int *color, int *delta, unsigned int *pixel0, unsig  } -static inline void -gfx_apply_delta(unsigned int *color, int *delta, int factor) { +static inline void gfx_apply_delta(unsigned int *color, int *delta, int factor) {  	int i; +  	for (i = 0; i < 4; i++)  		color[i] += delta[i] * factor;  } @@ -353,10 +330,9 @@ gfx_apply_delta(unsigned int *color, int *delta, int factor) {  				rec[3] = 0; \  			} -#define REVERSE_ALPHA(foo) ((inverse_alpha)? ~(foo) : (foo)) +#define REVERSE_ALPHA(foo) ((inverse_alpha) ? ~(foo) : (foo)) -void -FUNCNAME_TRILINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) { +void FUNCNAME_TRILINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  	int xfact = mode->xfact;  	int yfact = mode->yfact;  	int line_step = (yfact < 2) ? 0 : 256 / yfact; @@ -369,8 +345,8 @@ FUNCNAME_TRILINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  	int separate_alpha_map = (!mode->alpha_mask) && using_alpha;  	unsigned int masks[4], shifts[4];  	unsigned int pixels[4][4]; -	/* 0 1 -	** 2 3 */ +	// 0 1 +	// 2 3  	int x, y;  	byte inverse_alpha = mode->flags & GFX_MODE_FLAG_REVERSE_ALPHA; @@ -392,7 +368,7 @@ FUNCNAME_TRILINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  	shifts[3] = mode->alpha_shift;  	if (!(pxm->index_xl && pxm->index_yl)) -		return; /* Duh. */ +		return;  	if (separate_alpha_map && !alpha_dest)  		alpha_dest = pxm->alpha_map = (byte*)sci_malloc(pxm->index_xl * xfact * pxm->index_yl * yfact); @@ -438,10 +414,9 @@ FUNCNAME_TRILINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  			MAKE_PIXEL_TRILINEAR((y && x), pixels[0], *src);  			MAKE_PIXEL_TRILINEAR((y && (x < pxm->index_xl)), pixels[1], src[1]);  			MAKE_PIXEL_TRILINEAR(((y < pxm->index_yl) && x), pixels[2], src[pxm->index_xl]); -			MAKE_PIXEL_TRILINEAR(((y < pxm->index_yl) && (x < pxm->index_xl)), -			                     pixels[3], src[pxm->index_xl + 1]); +			MAKE_PIXEL_TRILINEAR(((y < pxm->index_yl) && (x < pxm->index_xl)), pixels[3], src[pxm->index_xl + 1]); -			/* OptimizeMe */ +			// Optimize Me  			gfx_get_pixel_delta(leftcolor, leftdelta, pixels[0], pixels[2]);  			gfx_get_pixel_delta(rightcolor, rightdelta, pixels[1], pixels[3]); @@ -510,8 +485,3 @@ FUNCNAME_TRILINEAR(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  #undef SIZETYPE  #undef EXTEND_COLOR -/* reset to original optimisations for Win32: */ -/* (does not reset intrinsics) */ -#ifdef WIN32 -#  pragma optimize( "", on ) -#endif diff --git a/engines/sci/gfx/gfx_res_options.cpp b/engines/sci/gfx/gfx_res_options.cpp index d61bfb57e9..db776617bb 100644 --- a/engines/sci/gfx/gfx_res_options.cpp +++ b/engines/sci/gfx/gfx_res_options.cpp @@ -29,11 +29,11 @@  #include <ctype.h> -/*#define DEBUG*/ +//#define DEBUG -static inline int -matches_patternlist(gfx_res_pattern_t *patterns, int nr, int val) { +static inline int matches_patternlist(gfx_res_pattern_t *patterns, int nr, int val) {  	int i; +  	for (i = 0; i < nr; i++)  		if (patterns[i].min <= val  		        && patterns[i].max >= val) @@ -43,21 +43,17 @@ matches_patternlist(gfx_res_pattern_t *patterns, int nr, int val) {  }  #ifdef DEBUG -static void -print_pattern(gfx_res_pattern_t *pat) { -	error("[%d..%d]", -	        pat->min, pat->max); +static void print_pattern(gfx_res_pattern_t *pat) { +	error("[%d..%d]", pat->min, pat->max);  }  #endif -static inline int -resource_matches_patternlists(gfx_res_conf_t *conf, -                              int type, int nr, int loop, int cel) { +static inline int resource_matches_patternlists(gfx_res_conf_t *conf, int type, int nr, int loop, int cel) {  	int loc;  #ifdef DEBUG  	int i; -	error("[DEBUG:gfx-res] Trying to match against %d/%d/%d choices\n", -	        conf->patterns_nr, conf->loops_nr, conf->cels_nr); + +	error("[DEBUG:gfx-res] Trying to match against %d/%d/%d choices\n", conf->patterns_nr, conf->loops_nr, conf->cels_nr);  	for (i = 0; i < conf->patterns_nr; i++) {  		error("[DEBUG:gfx-res] Pat #%d: ", i);  		print_pattern(conf->patterns + i); @@ -76,10 +72,7 @@ resource_matches_patternlists(gfx_res_conf_t *conf,  		error("\n");  	}  #endif -	if (conf->patterns_nr && -	        !matches_patternlist(conf->patterns, -	                             conf->patterns_nr, -	                             nr)) +	if (conf->patterns_nr && !matches_patternlist(conf->patterns, conf->patterns_nr, nr))  		return 0;  	if (type == GFX_RESOURCE_TYPE_CURSOR) @@ -102,17 +95,12 @@ resource_matches_patternlists(gfx_res_conf_t *conf,  	if (!conf->cels_nr)  		return 1; -	return matches_patternlist(conf->patterns + loc, -	                           conf->cels_nr, -	                           cel); +	return matches_patternlist(conf->patterns + loc, conf->cels_nr, cel);  } -static inline gfx_res_conf_t * -find_match(gfx_res_conf_t *conflist, -           int type, int nr, int loop, int cel) { +static inline gfx_res_conf_t *find_match(gfx_res_conf_t *conflist, int type, int nr, int loop, int cel) {  	while (conflist) { -		if (resource_matches_patternlists(conflist, -		                                  type, nr, loop, cel)) { +		if (resource_matches_patternlists(conflist, type, nr, loop, cel)) {  #ifdef DEBUG  			error("[DEBUG:gfx-res] Found match");  #endif @@ -121,12 +109,12 @@ find_match(gfx_res_conf_t *conflist,  		conflist = conflist->next;  	} +  	return NULL;  } -void -apply_assign(gfx_res_assign_t *conf, gfx_pixmap_t *pxm) { -	/* Has a dynamically allocated palette? Must clean up */ +void apply_assign(gfx_res_assign_t *conf, gfx_pixmap_t *pxm) { +	// Has a dynamically allocated palette? Must clean up  	if (!(pxm->flags & GFX_PIXMAP_FLAG_EXTERNAL_PALETTE)) {  		if (pxm->colors)  			free(pxm->colors); @@ -137,19 +125,18 @@ apply_assign(gfx_res_assign_t *conf, gfx_pixmap_t *pxm) {  	pxm->colors = conf->assign.palette.colors;  } -void -apply_mod(gfx_res_mod_t *mod, gfx_pixmap_t *pxm) { +void apply_mod(gfx_res_mod_t *mod, gfx_pixmap_t *pxm) {  	gfx_pixmap_color_t *pal = pxm->colors;  	int i, pal_size = pxm->colors_nr; -	/* Does not have a dynamically allocated palette? Must dup current one */ +	// Does not have a dynamically allocated palette? Must dup current one  	if (pxm->flags & GFX_PIXMAP_FLAG_EXTERNAL_PALETTE) {  		int size = sizeof(gfx_pixmap_color_t) * pal_size;  		pxm->colors = (gfx_pixmap_color_t*)sci_malloc(size);  		memcpy(pxm->colors, pal, size);  		pal = pxm->colors;  		pxm->flags &= ~GFX_PIXMAP_FLAG_EXTERNAL_PALETTE; -		/* Flag for later deallocation */ +		// Flag for later deallocation  	}  	switch (mod->type) { @@ -177,8 +164,7 @@ apply_mod(gfx_res_mod_t *mod, gfx_pixmap_t *pxm) {  	}  } -int -gfx_get_res_config(gfx_options_t *options, gfx_pixmap_t *pxm) { +int gfx_get_res_config(gfx_options_t *options, gfx_pixmap_t *pxm) {  	int restype = GFXR_RES_TYPE(pxm->ID);  	int nr = GFXR_RES_NR(pxm->ID);  	int loop = pxm->loop; @@ -187,23 +173,20 @@ gfx_get_res_config(gfx_options_t *options, gfx_pixmap_t *pxm) {  	gfx_res_conf_t *conf;  #ifdef DEBUG -	error("[DEBUG:gfx-res] Trying to conf %d/%d/%d/%d (ID=%d)\n", -	        restype, nr, loop, cel, pxm->ID); +	error("[DEBUG:gfx-res] Trying to conf %d/%d/%d/%d (ID=%d)\n", restype, nr, loop, cel, pxm->ID);  #endif  	if (pxm->ID < 0 || restype < 0 || restype >= GFX_RESOURCE_TYPES_NR) -		return 1; /* Not appropriate */ +		return 1; // Not appropriate -	conf = find_match(options->res_conf.assign[restype], -	                  restype, nr, loop, cel); +	conf = find_match(options->res_conf.assign[restype], restype, nr, loop, cel);  	if (conf)  		apply_assign(&(conf->conf.assign), pxm);  	conf = options->res_conf.mod[restype];  	while (conf) { -		conf = find_match(conf, -		                  restype, nr, loop, cel); +		conf = find_match(conf, restype, nr, loop, cel);  		if (conf) {  			apply_mod(&(conf->conf.mod), pxm);  			conf = conf->next; diff --git a/engines/sci/gfx/gfx_resource.cpp b/engines/sci/gfx/gfx_resource.cpp index 43e49dcad7..bcdf3f4623 100644 --- a/engines/sci/gfx/gfx_resource.cpp +++ b/engines/sci/gfx/gfx_resource.cpp @@ -38,8 +38,7 @@ gfx_mode_t mode_1x1_color_index = { /* Fake 1x1 mode */  }; -static void -gfxr_free_loop(gfx_driver_t *driver, gfxr_loop_t *loop) { +static void gfxr_free_loop(gfx_driver_t *driver, gfxr_loop_t *loop) {  	int i;  	if (loop->cels) { @@ -51,8 +50,7 @@ gfxr_free_loop(gfx_driver_t *driver, gfxr_loop_t *loop) {  	}  } -void -gfxr_free_view(gfx_driver_t *driver, gfxr_view_t *view) { +void gfxr_free_view(gfx_driver_t *driver, gfxr_view_t *view) {  	int i;  	if (view->colors && !(view->flags & GFX_PIXMAP_FLAG_EXTERNAL_PALETTE)) @@ -67,10 +65,9 @@ gfxr_free_view(gfx_driver_t *driver, gfxr_view_t *view) {  	free(view);  } - -static void -pixmap_endianness_reverse_2_simple(byte *data, int area) { +static void pixmap_endianness_reverse_2_simple(byte *data, int area) {  	int c; +  	for (c = 0; c < area; c++) {  		byte val = *data;  		*data = data[1]; @@ -80,8 +77,7 @@ pixmap_endianness_reverse_2_simple(byte *data, int area) {  	}  } -static void -pixmap_endianness_reverse_2(byte *data, int area) { +static void pixmap_endianness_reverse_2(byte *data, int area) {  	int c;  	int sl = sizeof(unsigned long); @@ -90,14 +86,13 @@ pixmap_endianness_reverse_2(byte *data, int area) {  		memcpy(&temp, data, sl); -		/* The next line will give warnings on 32 bit archs, but -		** that's OK.  */ +		// The next line will give warnings on 32 bit archs, but that's OK.  #if SIZEOF_LONG < 8  		temp = 0;  #else  		temp = ((temp & 0xff00ff00ff00ff00l) >> 8)  		       | ((temp & 0x00ff00ff00ff00ffl) << 8); -#endif /* SIZEOF_INT < 8 */ +#endif  		memcpy(data, &temp, sl); @@ -107,9 +102,9 @@ pixmap_endianness_reverse_2(byte *data, int area) {  	pixmap_endianness_reverse_2_simple(data, area & (sl - 1));  } -static void -pixmap_endianness_reverse_3_simple(byte *data, int area) { +static void pixmap_endianness_reverse_3_simple(byte *data, int area) {  	int c; +  	for (c = 0; c < area; c++) {  		byte val0 = data[0]; @@ -120,9 +115,9 @@ pixmap_endianness_reverse_3_simple(byte *data, int area) {  	}  } -static void -pixmap_endianness_reverse_4_simple(byte *data, int area) { +static void pixmap_endianness_reverse_4_simple(byte *data, int area) {  	int c; +  	for (c = 0; c < area; c++) {  		byte val0 = data[0];  		byte val1 = data[1]; @@ -137,8 +132,7 @@ pixmap_endianness_reverse_4_simple(byte *data, int area) {  	}  } -static void -pixmap_endianness_reverse_4(byte *data, int area) { +static void pixmap_endianness_reverse_4(byte *data, int area) {  	int c;  	int sl = sizeof(unsigned long); @@ -147,8 +141,7 @@ pixmap_endianness_reverse_4(byte *data, int area) {  		memcpy(&temp, data, sl); -		/* The next lines will give warnings on 32 bit archs, but -		** that's OK.  */ +		// The next lines will give warnings on 32 bit archs, but that's OK.  #if SIZEOF_LONG < 8  		temp = 0l;  #else @@ -156,7 +149,7 @@ pixmap_endianness_reverse_4(byte *data, int area) {  		       | ((temp & 0x0000ffff0000ffffl) << 16);  		temp = ((temp & 0xff00ff00ff00ff00l) >> 8)  		       | ((temp & 0x00ff00ff00ff00ffl) << 8); -#endif /* SIZEOF_LONG < 8 */ +#endif  		memcpy(data, &temp, sl); @@ -166,8 +159,7 @@ pixmap_endianness_reverse_4(byte *data, int area) {  	pixmap_endianness_reverse_4_simple(data, area & (sl - 1));  } -gfx_pixmap_t * -gfxr_endianness_adjust(gfx_pixmap_t *pixmap, gfx_mode_t *mode) { +gfx_pixmap_t *gfxr_endianness_adjust(gfx_pixmap_t *pixmap, gfx_mode_t *mode) {  	int bytespp;  	byte *data; @@ -189,13 +181,11 @@ gfxr_endianness_adjust(gfx_pixmap_t *pixmap, gfx_mode_t *mode) {  		break;  	case 2: -		pixmap_endianness_reverse_2(data, pixmap->xl -		                            * pixmap->yl); +		pixmap_endianness_reverse_2(data, pixmap->xl * pixmap->yl);  		break;  	case 3: -		pixmap_endianness_reverse_3_simple(data, pixmap->xl -		                                   * pixmap->yl); +		pixmap_endianness_reverse_3_simple(data, pixmap->xl * pixmap->yl);  		break;  	case 4: @@ -210,8 +200,7 @@ gfxr_endianness_adjust(gfx_pixmap_t *pixmap, gfx_mode_t *mode) {  	return pixmap;  } - -/* Now construct the pixmap scaling functions */ +// Now construct the pixmap scaling functions  #define EXTRA_BYTE_OFFSET 0  #define SIZETYPE guint8  #define FUNCNAME _gfx_xlate_pixmap_unfiltered_1 @@ -232,7 +221,7 @@ gfxr_endianness_adjust(gfx_pixmap_t *pixmap, gfx_mode_t *mode) {  #ifdef WORDS_BIGENDIAN  # undef EXTRA_BYTE_OFFSET  # define EXTRA_BYTE_OFFSET 1 -#endif /* WORDS_BIGENDIAN */ +#endif // WORDS_BIGENDIAN  #define SIZETYPE guint32  #define FUNCNAME _gfx_xlate_pixmap_unfiltered_3  #define FUNCNAME_LINEAR _gfx_xlate_pixmap_linear_3 @@ -243,7 +232,7 @@ gfxr_endianness_adjust(gfx_pixmap_t *pixmap, gfx_mode_t *mode) {  #ifdef WORDS_BIGENDIAN  # undef EXTRA_BYTE_OFFSET  # define EXTRA_BYTE_OFFSET 0 -#endif /* WORDS_BIGENDIAN */ +#endif // WORDS_BIGENDIAN  #define SIZETYPE guint32  #define FUNCNAME _gfx_xlate_pixmap_unfiltered_4 @@ -255,8 +244,7 @@ gfxr_endianness_adjust(gfx_pixmap_t *pixmap, gfx_mode_t *mode) {  #undef EXTRA_BYTE_OFFSET  #undef SIZETYPE -static inline void -_gfx_xlate_pixmap_unfiltered(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) { +static inline void _gfx_xlate_pixmap_unfiltered(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  	switch (mode->bytespp) {  	case 1: @@ -289,9 +277,8 @@ _gfx_xlate_pixmap_unfiltered(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  	}  } -static inline void -_gfx_xlate_pixmap_linear(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) { -	if (mode->palette || !scale) { /* fall back to unfiltered */ +static inline void _gfx_xlate_pixmap_linear(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) { +	if (mode->palette || !scale) { // fall back to unfiltered  		_gfx_xlate_pixmap_unfiltered(mode, pxm, scale);  		return;  	} @@ -324,9 +311,8 @@ _gfx_xlate_pixmap_linear(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  } -static inline void -_gfx_xlate_pixmap_trilinear(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) { -	if (mode->palette || !scale) { /* fall back to unfiltered */ +static inline void _gfx_xlate_pixmap_trilinear(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) { +	if (mode->palette || !scale) { // fall back to unfiltered  		_gfx_xlate_pixmap_unfiltered(mode, pxm, scale);  		return;  	} @@ -335,7 +321,6 @@ _gfx_xlate_pixmap_trilinear(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  	pxm->yl = pxm->index_yl * mode->yfact;  	switch (mode->bytespp) { -  	case 1:  		_gfx_xlate_pixmap_trilinear_1(mode, pxm, scale);  		break; @@ -356,15 +341,12 @@ _gfx_xlate_pixmap_trilinear(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) {  		GFXERROR("Invalid mode->bytespp=%d\n", mode->bytespp);  	} -  } -void -gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode, gfx_xlate_filter_t filter) { +void gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode, gfx_xlate_filter_t filter) {  	int was_allocated = 0; -	if (mode->palette -	        && !(pxm->flags & GFX_PIXMAP_FLAG_PALETTE_ALLOCATED)) { +	if (mode->palette && !(pxm->flags & GFX_PIXMAP_FLAG_PALETTE_ALLOCATED)) {  		int i;  		for (i = 0; i < pxm->colors_nr; i++) { @@ -374,7 +356,7 @@ gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode, gfx_xlate_filter_t filter)  				pxm->colors[i].global_index = 0;  			}  			/* -			GFXDEBUG("alloc(%02x/%02x/%02x) -> %d\n",  pxm->colors[i].r,pxm->colors[i].g,pxm->colors[i].b,pxm->colors[i].global_index); +			GFXDEBUG("alloc(%02x/%02x/%02x) -> %d\n", pxm->colors[i].r, pxm->colors[i].g, pxm->colors[i].b, pxm->colors[i].global_index);  			*/  		} @@ -384,17 +366,16 @@ gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode, gfx_xlate_filter_t filter)  	if (!pxm->data) {  		pxm->data = (byte*)sci_malloc(mode->xfact * mode->yfact * pxm->index_xl * pxm->index_yl * mode->bytespp + 1); -		/* +1: Eases coying on BE machines in 24 bpp packed mode */ -		/* Assume that memory, if allocated already, will be sufficient */ +		// +1: Eases coying on BE machines in 24 bpp packed mode +		// Assume that memory, if allocated already, will be sufficient -		/* Allocate alpha map */ +		// Allocate alpha map  		if (!mode->alpha_mask && pxm->colors_nr < GFX_PIC_COLORS)  			pxm->alpha_map = (byte*)sci_malloc(mode->xfact * mode->yfact * pxm->index_xl * pxm->index_yl + 1);  	} else  		was_allocated = 1;  	switch (filter) { -  	case GFX_XLATE_FILTER_NONE:  		_gfx_xlate_pixmap_unfiltered(mode, pxm, !(pxm->flags & GFX_PIXMAP_FLAG_SCALED_INDEX));  		break; @@ -418,9 +399,7 @@ gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode, gfx_xlate_filter_t filter)  	}  } - -void -gfxr_free_pic(gfx_driver_t *driver, gfxr_pic_t *pic) { +void gfxr_free_pic(gfx_driver_t *driver, gfxr_pic_t *pic) {  	gfx_free_pixmap(driver, pic->visual_map);  	gfx_free_pixmap(driver, pic->priority_map);  	gfx_free_pixmap(driver, pic->control_map); @@ -435,4 +414,3 @@ gfxr_free_pic(gfx_driver_t *driver, gfxr_pic_t *pic) {  	pic->undithered_buffer = 0;  	free(pic);  } - diff --git a/engines/sci/gfx/gfx_support.cpp b/engines/sci/gfx/gfx_support.cpp index 81abaae6d1..77f93e3b41 100644 --- a/engines/sci/gfx/gfx_support.cpp +++ b/engines/sci/gfx/gfx_support.cpp @@ -56,8 +56,7 @@ int gfx_crossblit_alpha_threshold = 128;  #undef PIXELWIDTH  #undef DRAWLINE_FUNC -inline void -gfx_draw_line_buffer(byte *buffer, int linewidth, int pixelwidth, Common::Point start, Common::Point end, unsigned int color) { +inline void gfx_draw_line_buffer(byte *buffer, int linewidth, int pixelwidth, Common::Point start, Common::Point end, unsigned int color) {  	switch (pixelwidth) {  	case 1: @@ -83,19 +82,11 @@ gfx_draw_line_buffer(byte *buffer, int linewidth, int pixelwidth, Common::Point  	}  } - - - -void -gfx_draw_line_pixmap_i(gfx_pixmap_t *pxm, Common::Point start, Common::Point end, int color) { +void gfx_draw_line_pixmap_i(gfx_pixmap_t *pxm, Common::Point start, Common::Point end, int color) {  	gfx_draw_line_buffer(pxm->index_data, pxm->index_xl, 1, start, end, color);  } - - - -void -gfx_draw_box_buffer(byte *buffer, int linewidth, rect_t zone, int color) { +void gfx_draw_box_buffer(byte *buffer, int linewidth, rect_t zone, int color) {  	byte *dest = buffer + zone.x + (linewidth * zone.y);  	int i; @@ -108,16 +99,14 @@ gfx_draw_box_buffer(byte *buffer, int linewidth, rect_t zone, int color) {  	}  } - -void -gfx_draw_box_pixmap_i(gfx_pixmap_t *pxm, rect_t box, int color) { +void gfx_draw_box_pixmap_i(gfx_pixmap_t *pxm, rect_t box, int color) {  	gfx_clip_box_basic(&box, pxm->index_xl - 1, pxm->index_yl - 1);  	gfx_draw_box_buffer(pxm->index_data, pxm->index_xl, box, color);  } -/* Import various crossblit functions */ +// Import various crossblit functions  #undef USE_PRIORITY  #undef FUNCTION_NAME  #undef BYTESPP @@ -174,7 +163,7 @@ gfx_draw_box_pixmap_i(gfx_pixmap_t *pxm, rect_t box, int color) {  #undef FUNCTION_NAME  #undef BYTESPP -/* Reverse alpha versions */ +// Reverse alpha versions  #undef USE_PRIORITY  #undef FUNCTION_NAME  #undef BYTESPP @@ -239,33 +228,30 @@ static void (*crossblit_fns[5])(byte *, byte *, int, int, int, int, byte *, int,          _gfx_crossblit_16,          _gfx_crossblit_24,          _gfx_crossblit_32 -                                                                                                                    }; +};  static void (*crossblit_fns_P[5])(byte *, byte *, int, int, int, int, byte *, int, int, unsigned int, unsigned int, byte *, int, int, int) = { NULL,          _gfx_crossblit_8_P,          _gfx_crossblit_16_P,          _gfx_crossblit_24_P,          _gfx_crossblit_32_P -                                                                                                                                             }; +};  static void (*crossblit_fns_RA[5])(byte *, byte *, int, int, int, int, byte *, int, int, unsigned int, unsigned int) = { NULL,          _gfx_crossblit_8_RA,          _gfx_crossblit_16_RA,          _gfx_crossblit_24_RA,          _gfx_crossblit_32_RA -                                                                                                                       }; +};  static void (*crossblit_fns_P_RA[5])(byte *, byte *, int, int, int, int, byte *, int, int, unsigned int, unsigned int, byte *, int, int, int) = { NULL,          _gfx_crossblit_8_P_RA,          _gfx_crossblit_16_P_RA,          _gfx_crossblit_24_P_RA,          _gfx_crossblit_32_P_RA -                                                                                                                                                }; +}; - -void -_gfx_crossblit_simple(byte *dest, byte *src, int dest_line_width, int src_line_width, -                      int xl, int yl, int bpp) { +void _gfx_crossblit_simple(byte *dest, byte *src, int dest_line_width, int src_line_width, int xl, int yl, int bpp) {  	int line_width = xl * bpp;  	int i; @@ -276,12 +262,8 @@ _gfx_crossblit_simple(byte *dest, byte *src, int dest_line_width, int src_line_w  	}  } -int -gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, -                     rect_t src_coords, -                     rect_t dest_coords, byte *dest, int dest_line_width, -                     byte *priority_dest, int priority_line_width, -                     int priority_skip, int flags) { +int gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, rect_t src_coords, rect_t dest_coords, +						 byte *dest, int dest_line_width, byte *priority_dest, int priority_line_width, int priority_skip, int flags) {  	int maxx = 320 * mode->xfact;  	int maxy = 200 * mode->yfact;  	byte *src = pxm->data; @@ -302,12 +284,12 @@ gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority,  	if (src_coords.y + src_coords.yl > yl)  		src_coords.yl = yl - src_coords.y; -	/** --???-- **/ +	// --???--  	if (src_coords.y > yl)  		return GFX_OK;  	if (src_coords.x > xl)  		return GFX_OK; -	/** --???-- **/ +	// --???--  	if (dest_coords.x + xl >= maxx)  		xl = maxx - dest_coords.x; @@ -323,19 +305,19 @@ gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority,  	if (xl <= 0 || yl <= 0)  		return GFX_OK; -	/* Set destination offsets */ +	// Set destination offsets -	/* Set x offsets */ +	// Set x offsets  	if (!(flags & GFX_CROSSBLIT_FLAG_DATA_IS_HOMED))  		dest += dest_coords.x * bpp;  	priority_pos += dest_coords.x * priority_skip; -	/* Set y offsets */ +	// Set y offsets  	if (!(flags & GFX_CROSSBLIT_FLAG_DATA_IS_HOMED))  		dest += dest_coords.y * dest_line_width;  	priority_pos += dest_coords.y * priority_line_width; -	/* Set source offsets */ +	// Set source offsets  	if (xoffset += src_coords.x) {  		dest_coords.x = 0;  		src += xoffset * bpp; @@ -349,13 +331,13 @@ gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority,  		alpha += yoffset * bytes_per_alpha_line;  	} -	/* Adjust length for clip box */ +	// Adjust length for clip box  	if (xl > src_coords.xl)  		xl = src_coords.xl;  	if (yl > src_coords.yl)  		yl = src_coords.yl; -	/* now calculate alpha */ +	// now calculate alpha  	if (pxm->alpha_map)  		alpha_mask = 0xff;  	else { @@ -388,28 +370,25 @@ gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority,  			alpha_min = ((alpha_mask >> 8) * gfx_crossblit_alpha_threshold) & alpha_mask;  		if (revalpha) -			alpha_min = 255 - alpha_min; /* Since we use it for the reverse effect */ +			alpha_min = 255 - alpha_min; // Since we use it for the reverse effect  		if (!alpha_mask) -			_gfx_crossblit_simple(dest, src, dest_line_width, pxm->xl * bpp, -			                      xl, yl, bpp); +			_gfx_crossblit_simple(dest, src, dest_line_width, pxm->xl * bpp, xl, yl, bpp);  		else  			if (priority == GFX_NO_PRIORITY) {  				if (bpp > 0 && bpp < 5)  					((revalpha) ? crossblit_fns_RA : crossblit_fns)[bpp](dest, src, dest_line_width, pxm->xl * bpp, -					        xl, yl, alpha, bytes_per_alpha_line, bytes_per_alpha_pixel, -					        alpha_mask, alpha_min); +					        xl, yl, alpha, bytes_per_alpha_line, bytes_per_alpha_pixel, alpha_mask, alpha_min);  				else {  					GFXERROR("Invalid mode->bytespp: %d\n", mode->bytespp);  					return GFX_ERROR;  				} -			} else { /* priority */ +			} else { // priority  				if (bpp > 0 && bpp < 5)  					((revalpha) ? crossblit_fns_P_RA : crossblit_fns_P)[bpp](dest, src, dest_line_width, pxm->xl * bpp,  					        xl, yl, alpha, bytes_per_alpha_line, bytes_per_alpha_pixel, -					        alpha_mask, alpha_min, priority_pos, -					        priority_line_width, priority_skip, priority); +					        alpha_mask, alpha_min, priority_pos, priority_line_width, priority_skip, priority);  				else {  					GFXERROR("Invalid mode->bytespp: %d\n", mode->bytespp);  					return GFX_ERROR; @@ -418,7 +397,3 @@ gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority,  	return GFX_OK;  } - - - - diff --git a/engines/sci/gfx/gfx_tools.cpp b/engines/sci/gfx/gfx_tools.cpp index 5cf195f80a..c8f1401907 100644 --- a/engines/sci/gfx/gfx_tools.cpp +++ b/engines/sci/gfx/gfx_tools.cpp @@ -26,18 +26,9 @@  #include "sci/include/sci_memory.h"  #include "sci/include/gfx_tools.h" -/* set optimisations for Win32: */ -#ifdef WIN32 -#	include <memory.h> -#	ifndef SATISFY_PURIFY -#		pragma intrinsic( memcpy, memset ) -#	endif -#endif -  rect_t gfx_rect_fullscreen = {0, 0, 320, 200}; -void -gfx_clip_box_basic(rect_t *box, int maxx, int maxy) { +void gfx_clip_box_basic(rect_t *box, int maxx, int maxy) {  	if (box->x < 0)  		box->x = 0; @@ -51,15 +42,10 @@ gfx_clip_box_basic(rect_t *box, int maxx, int maxy) {  		box->yl = maxy - box->y + 1;  } - -gfx_mode_t * -gfx_new_mode(int xfact, int yfact, int bytespp, unsigned int red_mask, unsigned int green_mask, +gfx_mode_t *gfx_new_mode(int xfact, int yfact, int bytespp, unsigned int red_mask, unsigned int green_mask,               unsigned int blue_mask, unsigned int alpha_mask, int red_shift, int green_shift,               int blue_shift, int alpha_shift, int palette, int flags) { -	gfx_mode_t *mode = (gfx_mode_t*)sci_malloc(sizeof(gfx_mode_t)); -#ifdef SATISFY_PURIFY -	memset(mode, 0, sizeof(gfx_mode_t)); -#endif +	gfx_mode_t *mode = (gfx_mode_t *)sci_malloc(sizeof(gfx_mode_t));  	mode->xfact = xfact;  	mode->yfact = yfact; @@ -75,20 +61,16 @@ gfx_new_mode(int xfact, int yfact, int bytespp, unsigned int red_mask, unsigned  	mode->flags = flags;  	if (palette) { -		mode->palette = (gfx_palette_t*)sci_malloc(sizeof(gfx_palette_t)); -#ifdef SATISFY_PURIFY -		memset(mode->palette, 0, sizeof(gfx_palette_t)); -#endif +		mode->palette = (gfx_palette_t *)sci_malloc(sizeof(gfx_palette_t));  		mode->palette->max_colors_nr = palette; -		mode->palette->colors = (gfx_palette_color_t*)sci_calloc(sizeof(gfx_palette_color_t), palette); /* Initialize with empty entries */ -	} else mode->palette = NULL; +		mode->palette->colors = (gfx_palette_color_t *)sci_calloc(sizeof(gfx_palette_color_t), palette); // Initialize with empty entries +	} else +		mode->palette = NULL;  	return mode;  } - -void -gfx_free_mode(gfx_mode_t *mode) { +void gfx_free_mode(gfx_mode_t *mode) {  	if (mode->palette) {  		free(mode->palette->colors);  		free(mode->palette); @@ -96,10 +78,7 @@ gfx_free_mode(gfx_mode_t *mode) {  	free(mode);  } - - -void -gfx_copy_pixmap_box_i(gfx_pixmap_t *dest, gfx_pixmap_t *src, rect_t box) { +void gfx_copy_pixmap_box_i(gfx_pixmap_t *dest, gfx_pixmap_t *src, rect_t box) {  	int width, height;  	int offset; @@ -122,10 +101,8 @@ gfx_copy_pixmap_box_i(gfx_pixmap_t *dest, gfx_pixmap_t *src, rect_t box) {  	}  } - -gfx_pixmap_t * -gfx_clone_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode) { -	gfx_pixmap_t *clone = (gfx_pixmap_t*)sci_malloc(sizeof(gfx_pixmap_t)); +gfx_pixmap_t *gfx_clone_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode) { +	gfx_pixmap_t *clone = (gfx_pixmap_t *)sci_malloc(sizeof(gfx_pixmap_t));  	*clone = *pxm;  	clone->index_data = NULL;  	clone->colors = NULL; @@ -141,12 +118,8 @@ gfx_clone_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode) {  	return clone;  } -gfx_pixmap_t * -gfx_new_pixmap(int xl, int yl, int resid, int loop, int cel) { -	gfx_pixmap_t *pxm = (gfx_pixmap_t*)sci_malloc(sizeof(gfx_pixmap_t)); -#ifdef SATISFY_PURIFY -	memset(pxm, 0, sizeof(gfx_pixmap_t)); -#endif +gfx_pixmap_t *gfx_new_pixmap(int xl, int yl, int resid, int loop, int cel) { +	gfx_pixmap_t *pxm = (gfx_pixmap_t *)sci_malloc(sizeof(gfx_pixmap_t));  	pxm->alpha_map = NULL;  	pxm->data = NULL; @@ -170,16 +143,13 @@ gfx_new_pixmap(int xl, int yl, int resid, int loop, int cel) {  	return pxm;  } - -void -gfx_free_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm) { +void gfx_free_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm) {  	if (driver) { -		if (driver->mode->palette -		        && pxm->flags & GFX_PIXMAP_FLAG_PALETTE_ALLOCATED -		        && !(pxm->flags & GFX_PIXMAP_FLAG_DONT_UNALLOCATE_PALETTE) -		        && !(pxm->flags & GFX_PIXMAP_FLAG_EXTERNAL_PALETTE)) { +		if (driver->mode->palette && pxm->flags & GFX_PIXMAP_FLAG_PALETTE_ALLOCATED +		        && !(pxm->flags & GFX_PIXMAP_FLAG_DONT_UNALLOCATE_PALETTE) && !(pxm->flags & GFX_PIXMAP_FLAG_EXTERNAL_PALETTE)) {  			int i;  			int error = 0; +  			GFXDEBUG("UNALLOCATING %d\n", pxm->colors_nr);  			for (i = 0; i < pxm->colors_nr; i++)  				if (gfx_free_color(driver->mode->palette, pxm->colors + i)) @@ -207,9 +177,7 @@ gfx_free_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm) {  	free(pxm);  } - -gfx_pixmap_t * -gfx_pixmap_alloc_index_data(gfx_pixmap_t *pixmap) { +gfx_pixmap_t *gfx_pixmap_alloc_index_data(gfx_pixmap_t *pixmap) {  	int size;  	if (pixmap->index_data) { @@ -228,9 +196,7 @@ gfx_pixmap_alloc_index_data(gfx_pixmap_t *pixmap) {  	return pixmap;  } - -gfx_pixmap_t * -gfx_pixmap_free_index_data(gfx_pixmap_t *pixmap) { +gfx_pixmap_t *gfx_pixmap_free_index_data(gfx_pixmap_t *pixmap) {  	if (!pixmap->index_data) {  		GFXWARN("Attempt to free pixmap index data twice");  		return pixmap; @@ -241,9 +207,7 @@ gfx_pixmap_free_index_data(gfx_pixmap_t *pixmap) {  	return pixmap;  } - -gfx_pixmap_t * -gfx_pixmap_alloc_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) { +gfx_pixmap_t *gfx_pixmap_alloc_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) {  	int size;  	if (pixmap->data) { @@ -267,9 +231,7 @@ gfx_pixmap_alloc_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) {  	return pixmap;  } - -gfx_pixmap_t * -gfx_pixmap_free_data(gfx_pixmap_t *pixmap) { +gfx_pixmap_t *gfx_pixmap_free_data(gfx_pixmap_t *pixmap) {  	if (!pixmap->data) {  		GFXWARN("Attempt to free pixmap data twice");  		return pixmap; @@ -277,14 +239,13 @@ gfx_pixmap_free_data(gfx_pixmap_t *pixmap) {  	free(pixmap->data);  	pixmap->data = NULL; +  	return pixmap;  } - -int -gfx_alloc_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) { +int gfx_alloc_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) {  	int i; -	int dr, dg, db; /* deltas */ +	int dr, dg, db;  	int bestdelta = 1 + ((0x100 * 0x100) * 3);  	int bestcolor = -1;  	int firstfree = -1; @@ -338,18 +299,16 @@ gfx_alloc_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) {  		pal->colors[firstfree].lockers = 1;  		color->global_index = firstfree; -		return 42; /* positive value to indicate that this color still needs to be set */ +		return 42; // positive value to indicate that this color still needs to be set  	}  	color->global_index = bestcolor; -//	GFXWARN("Out of palette colors- doing approximated mapping"); +	//GFXWARN("Out of palette colors- doing approximated mapping");  	return GFX_OK;  } - -int -gfx_free_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) { +int gfx_free_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) {  	gfx_palette_color_t *palette_color = pal->colors + color->global_index;  	if (!pal) @@ -362,14 +321,12 @@ gfx_free_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) {  	}  	if (color->global_index >= pal->max_colors_nr) { -		GFXERROR("Attempt to free invalid color index %d (%02x/%02x/%02x)", -		         color->global_index, color->r, color->g, color->b); +		GFXERROR("Attempt to free invalid color index %d (%02x/%02x/%02x)", color->global_index, color->r, color->g, color->b);  		return GFX_ERROR;  	}  	if (!palette_color->lockers) { -		GFXERROR("Attempt to free unused color index %d (%02x/%02x/%02x)", -		         color->global_index, color->r, color->g, color->b); +		GFXERROR("Attempt to free unused color index %d (%02x/%02x/%02x)", color->global_index, color->r, color->g, color->b);  		return GFX_ERROR;  	} @@ -377,12 +334,11 @@ gfx_free_color(gfx_palette_t *pal, gfx_pixmap_color_t *color) {  		--(palette_color->lockers);  	color->global_index = GFX_COLOR_INDEX_UNMAPPED; +  	return GFX_OK;  } - -gfx_pixmap_t * -gfx_pixmap_scale_index_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) { +gfx_pixmap_t *gfx_pixmap_scale_index_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) {  	byte *old_data, *new_data, *initial_new_data;  	byte *linestart;  	int linewidth; @@ -398,7 +354,7 @@ gfx_pixmap_scale_index_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) {  		return NULL;  	if (pixmap->flags & GFX_PIXMAP_FLAG_SCALED_INDEX) -		return pixmap; /* Already done */ +		return pixmap; // Already done  	old_data = pixmap->index_data; @@ -410,7 +366,7 @@ gfx_pixmap_scale_index_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) {  	xl = pixmap->index_xl;  	yl = pixmap->index_yl;  	linewidth = xfact * xl; -	initial_new_data = new_data = (byte *) sci_malloc(linewidth * yfact * yl); +	initial_new_data = new_data = (byte *)sci_malloc(linewidth * yfact * yl);  	for (yc = 0; yc < yl; yc++) {  | 
