diff options
author | Max Horn | 2009-02-15 22:33:36 +0000 |
---|---|---|
committer | Max Horn | 2009-02-15 22:33:36 +0000 |
commit | 921e6ff5cf3944c1a62a3ad9a91c29bb21aa9942 (patch) | |
tree | 1a7e5de58d937174c2c2d84513e0990059881161 /engines/sci/gfx/resource | |
parent | d2e8256439423dcf9721c951de681b69a4e477b5 (diff) | |
download | scummvm-rg350-921e6ff5cf3944c1a62a3ad9a91c29bb21aa9942.tar.gz scummvm-rg350-921e6ff5cf3944c1a62a3ad9a91c29bb21aa9942.tar.bz2 scummvm-rg350-921e6ff5cf3944c1a62a3ad9a91c29bb21aa9942.zip |
SCI: Run astyle to make the code be more compliant with our Code Formatting Guidelines: gfx dir
svn-id: r38321
Diffstat (limited to 'engines/sci/gfx/resource')
-rw-r--r-- | engines/sci/gfx/resource/sci_cursor_0.cpp | 16 | ||||
-rw-r--r-- | engines/sci/gfx/resource/sci_font.cpp | 14 | ||||
-rw-r--r-- | engines/sci/gfx/resource/sci_pal_1.cpp | 29 | ||||
-rw-r--r-- | engines/sci/gfx/resource/sci_pic_0.cpp | 631 | ||||
-rw-r--r-- | engines/sci/gfx/resource/sci_picfill.cpp | 95 | ||||
-rw-r--r-- | engines/sci/gfx/resource/sci_picfill_aux.cpp | 29 | ||||
-rw-r--r-- | engines/sci/gfx/resource/sci_resmgr.cpp | 123 | ||||
-rw-r--r-- | engines/sci/gfx/resource/sci_view_0.cpp | 21 | ||||
-rw-r--r-- | engines/sci/gfx/resource/sci_view_1.cpp | 210 |
9 files changed, 550 insertions, 618 deletions
diff --git a/engines/sci/gfx/resource/sci_cursor_0.cpp b/engines/sci/gfx/resource/sci_cursor_0.cpp index 06a8d2b7aa..99b080ef01 100644 --- a/engines/sci/gfx/resource/sci_cursor_0.cpp +++ b/engines/sci/gfx/resource/sci_cursor_0.cpp @@ -41,12 +41,12 @@ 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}}; + {GFX_COLOR_INDEX_UNMAPPED, 0xaa, 0xaa, 0xaa} +}; static gfx_pixmap_t * -_gfxr_draw_cursor(int id, byte *resource, int size, int sci01) -{ +_gfxr_draw_cursor(int id, byte *resource, int size, int sci01) { int colors[4] = {0, 1, GFX_CURSOR_TRANSPARENT, 1}; int line; byte *data; @@ -62,7 +62,7 @@ _gfxr_draw_cursor(int id, byte *resource, int size, int sci01) retval = gfx_pixmap_alloc_index_data(gfx_new_pixmap(CURSOR_SIZE, CURSOR_SIZE, id, 0, 0)); retval->colors = gfx_sci01_cursor_colors; - retval->colors_nr = sci01? GFX_SCI01_CURSOR_COLORS_NR : GFX_SCI0_CURSOR_COLORS_NR; + retval->colors_nr = sci01 ? GFX_SCI01_CURSOR_COLORS_NR : GFX_SCI0_CURSOR_COLORS_NR; retval->flags |= GFX_PIXMAP_FLAG_EXTERNAL_PALETTE; retval->color_key = GFX_CURSOR_TRANSPARENT; @@ -84,7 +84,7 @@ _gfxr_draw_cursor(int id, byte *resource, int size, int sci01) for (i = 0; i < 16; i++) { int color_code = ((mask_a << i) & 0x8000) - | (((mask_b << i) >> 1) & 0x4000); + | (((mask_b << i) >> 1) & 0x4000); *data++ = colors[color_code >> 14]; } @@ -94,14 +94,12 @@ _gfxr_draw_cursor(int id, byte *resource, int size, int sci01) gfx_pixmap_t * -gfxr_draw_cursor0(int id, byte *resource, int size) -{ +gfxr_draw_cursor0(int id, byte *resource, int size) { return _gfxr_draw_cursor(id, resource, size, 0); } gfx_pixmap_t * -gfxr_draw_cursor01(int id, byte *resource, int size) -{ +gfxr_draw_cursor01(int id, byte *resource, int size) { return _gfxr_draw_cursor(id, resource, size, 1); } diff --git a/engines/sci/gfx/resource/sci_font.cpp b/engines/sci/gfx/resource/sci_font.cpp index f1ae4edb19..adad727324 100644 --- a/engines/sci/gfx/resource/sci_font.cpp +++ b/engines/sci/gfx/resource/sci_font.cpp @@ -38,8 +38,7 @@ extern int font_counter; #define FONT_MAXCHAR_OFFSET 2 static int -calc_char(byte *dest, int total_width, int total_height, byte *src, int size) -{ +calc_char(byte *dest, int total_width, int total_height, byte *src, int size) { int width = src[0]; int height = src[1]; int byte_width = (width + 7) >> 3; @@ -68,8 +67,7 @@ calc_char(byte *dest, int total_width, int total_height, byte *src, int size) gfx_bitmap_font_t * -gfxr_read_font(int id, byte *resource, int size) -{ +gfxr_read_font(int id, byte *resource, int size) { gfx_bitmap_font_t *font = (gfx_bitmap_font_t*)sci_calloc(sizeof(gfx_bitmap_font_t), 1); int chars_nr; int max_width = 0, max_height; @@ -89,7 +87,7 @@ gfxr_read_font(int id, byte *resource, int size) if (chars_nr < 0 || chars_nr > 256 || max_height < 0) { if (chars_nr < 0 || chars_nr > 256) GFXERROR("Font %04x: Invalid number of characters: %d\n", id, - chars_nr); + chars_nr); if (max_height < 0) GFXERROR("Font %04x: Invalid font height: %d\n", id, max_height); gfxr_free_font(font); @@ -98,7 +96,7 @@ gfxr_read_font(int id, byte *resource, int size) if (size < 6 + chars_nr * 2) { GFXERROR("Font %04x: Insufficient space for %d characters in font\n", - id, chars_nr); + id, chars_nr); gfxr_free_font(font); return NULL; } @@ -111,7 +109,7 @@ gfxr_read_font(int id, byte *resource, int size) if (offset >= size) { GFXERROR("Font %04x: Error: Character 0x%02x is at offset 0x%04x (beyond 0x%04x)\n", - id, i, offset, size); + id, i, offset, size); gfxr_free_font(font); return NULL; } @@ -140,7 +138,7 @@ gfxr_read_font(int id, byte *resource, int size) int offset = get_int_16(resource + (i << 1) + 6); if (calc_char(font->data + (font->char_size * i), font->row_size, max_height, - resource + offset, size - offset)) { + resource + offset, size - offset)) { GFXERROR("Problem occured in font %04x, char %d/%d\n", id, i, chars_nr); gfxr_free_font(font); return NULL; diff --git a/engines/sci/gfx/resource/sci_pal_1.cpp b/engines/sci/gfx/resource/sci_pal_1.cpp index 2f12f8180c..97d5f7c296 100644 --- a/engines/sci/gfx/resource/sci_pal_1.cpp +++ b/engines/sci/gfx/resource/sci_pal_1.cpp @@ -38,8 +38,7 @@ #define SCI_PAL_FORMAT_CONSTANT_FLAGS 1 gfx_pixmap_color_t * -gfxr_read_pal11(int id, int *colors_nr, byte *resource, int size) -{ +gfxr_read_pal11(int id, int *colors_nr, byte *resource, int size) { int start_color = resource[25]; int format = resource[32]; int entry_size = 0; @@ -48,8 +47,7 @@ gfxr_read_pal11(int id, int *colors_nr, byte *resource, int size) int _colors_nr = *colors_nr = getUInt16(resource + 29); int i; - switch (format) - { + switch (format) { case SCI_PAL_FORMAT_VARIABLE_FLAGS : entry_size = 4; break; @@ -59,20 +57,17 @@ gfxr_read_pal11(int id, int *colors_nr, byte *resource, int size) } retval = (gfx_pixmap_color_t *) - sci_malloc(sizeof(gfx_pixmap_color_t) * (_colors_nr + start_color)); + sci_malloc(sizeof(gfx_pixmap_color_t) * (_colors_nr + start_color)); memset(retval, 0, sizeof(gfx_pixmap_color_t) * (_colors_nr + start_color)); - for (i = 0; i < start_color; i ++) - { + for (i = 0; i < start_color; i ++) { retval[i].global_index = GFX_COLOR_INDEX_UNMAPPED; retval[i].r = 0; retval[i].g = 0; retval[i].b = 0; } - for (i = start_color; i < start_color + _colors_nr; i ++) - { - switch (format) - { + for (i = start_color; i < start_color + _colors_nr; i ++) { + switch (format) { case SCI_PAL_FORMAT_CONSTANT_FLAGS: retval[i].global_index = GFX_COLOR_INDEX_UNMAPPED; retval[i].r = pal_data[0]; @@ -93,8 +88,7 @@ gfxr_read_pal11(int id, int *colors_nr, byte *resource, int size) } gfx_pixmap_color_t * -gfxr_read_pal1(int id, int *colors_nr, byte *resource, int size) -{ +gfxr_read_pal1(int id, int *colors_nr, byte *resource, int size) { int counter = 0; int pos; unsigned int colors[MAX_COLORS] = {0}; @@ -110,9 +104,9 @@ gfxr_read_pal1(int id, int *colors_nr, byte *resource, int size) while (pos < size/* && resource[pos] == COLOR_OK && counter < MAX_COLORS*/) { int color = resource[pos] - | (resource[pos + 1] << 8) - | (resource[pos + 2] << 16) - | (resource[pos + 3] << 24); + | (resource[pos + 1] << 8) + | (resource[pos + 2] << 16) + | (resource[pos + 3] << 24); pos += 4; @@ -148,8 +142,7 @@ gfxr_read_pal1(int id, int *colors_nr, byte *resource, int size) } gfx_pixmap_color_t * -gfxr_read_pal1_amiga(int *colors_nr, FILE *f) -{ +gfxr_read_pal1_amiga(int *colors_nr, FILE *f) { int i; gfx_pixmap_color_t *retval; diff --git a/engines/sci/gfx/resource/sci_pic_0.cpp b/engines/sci/gfx/resource/sci_pic_0.cpp index 88553b2c9b..158f20b3bb 100644 --- a/engines/sci/gfx/resource/sci_pic_0.cpp +++ b/engines/sci/gfx/resource/sci_pic_0.cpp @@ -51,25 +51,25 @@ int sci0_palette = 0; /* 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 */ + {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 */ {{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 */ - -/* RGB and I intensities (former taken from the GIMP) */ + {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 */ + + /* RGB and I intensities (former taken from the GIMP) */ #define GR 30 #define GG 59 #define GB 11 @@ -80,13 +80,14 @@ gfx_pixmap_color_t gfx_sci0_image_colors[SCI0_MAX_PALETTE+1][GFX_SCI0_IMAGE_COLO #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) }}}; /* Grayscale */ + {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) }} +}; /* Grayscale */ #undef GR #undef GG @@ -115,33 +116,31 @@ int fillmagc = 30000000; /* Color mapping used while scaling embedded views. */ 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} + {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() -{ +gfxr_init_static_palette() { if (!_gfxr_pic0_colors_initialized) { for (int i = 0; i < 256; i++) { gfx_sci0_pic_colors[i].global_index = GFX_COLOR_INDEX_UNMAPPED; gfx_sci0_pic_colors[i].r = INTERCOL(gfx_sci0_image_colors[sci0_palette][i & 0xf].r, - gfx_sci0_image_colors[sci0_palette][i >> 4].r); + gfx_sci0_image_colors[sci0_palette][i >> 4].r); gfx_sci0_pic_colors[i].g = INTERCOL(gfx_sci0_image_colors[sci0_palette][i & 0xf].g, - gfx_sci0_image_colors[sci0_palette][i >> 4].g); + gfx_sci0_image_colors[sci0_palette][i >> 4].g); gfx_sci0_pic_colors[i].b = INTERCOL(gfx_sci0_image_colors[sci0_palette][i & 0xf].b, - gfx_sci0_image_colors[sci0_palette][i >> 4].b); + gfx_sci0_image_colors[sci0_palette][i >> 4].b); } //WARNING("Uncomment me after fixing sci0_palette changes to reset me"); - /* _gfxr_pic0_colors_initialized = 1; */ + /* _gfxr_pic0_colors_initialized = 1; */ } } gfxr_pic_t * -gfxr_init_pic(gfx_mode_t *mode, int ID, int sci1) -{ +gfxr_init_pic(gfx_mode_t *mode, int ID, int sci1) { gfxr_pic_t *pic = (gfxr_pic_t*)sci_malloc(sizeof(gfxr_pic_t)); pic->mode = mode; @@ -149,11 +148,11 @@ gfxr_init_pic(gfx_mode_t *mode, int ID, int sci1) pic->control_map = gfx_pixmap_alloc_index_data(gfx_new_pixmap(320, 200, ID, 2, 0)); pic->priority_map = gfx_pixmap_alloc_index_data(gfx_new_pixmap(mode->xfact * 320, mode->yfact * 200, - ID, 1, 0)); + ID, 1, 0)); pic->visual_map = gfx_pixmap_alloc_index_data(gfx_new_pixmap(320 * mode->xfact, - 200 * mode->yfact, ID, 0, 0)); + 200 * mode->yfact, ID, 0, 0)); pic->visual_map->colors = gfx_sci0_pic_colors; pic->visual_map->colors_nr = GFX_SCI0_PIC_COLORS_NR; pic->visual_map->color_key = GFX_PIXMAP_COLOR_KEY_NONE; @@ -190,8 +189,7 @@ gfxr_init_pic(gfx_mode_t *mode, int ID, int sci1) /****************************/ void -gfxr_clear_pic0(gfxr_pic_t *pic, int sci_titlebar_size) -{ +gfxr_clear_pic0(gfxr_pic_t *pic, int sci_titlebar_size) { memset(pic->visual_map->index_data, 0x00, (320 * pic->mode->xfact * sci_titlebar_size * pic->mode->yfact)); memset(pic->visual_map->index_data + (320 * pic->mode->xfact * sci_titlebar_size * pic->mode->yfact), 0xff, pic->mode->xfact * 320 * pic->mode->yfact * (200 - sci_titlebar_size)); /* white */ @@ -228,8 +226,7 @@ gfxr_clear_pic0(gfxr_pic_t *pic, int sci_titlebar_size) buffer[linewidth * y + x] operation color; static void -_gfxr_auxbuf_line_draw(gfxr_pic_t *pic, rect_t line, int color, int color2, int sci_titlebar_size) -{ +_gfxr_auxbuf_line_draw(gfxr_pic_t *pic, rect_t line, int color, int color2, int sci_titlebar_size) { int dx, dy, incrE, incrNE, d, finalx, finaly; int x = line.x; int y = line.y + sci_titlebar_size; @@ -276,8 +273,7 @@ _gfxr_auxbuf_line_draw(gfxr_pic_t *pic, rect_t line, int color, int color2, int } static void -_gfxr_auxbuf_line_clear(gfxr_pic_t *pic, rect_t line, int color, int sci_titlebar_size) -{ +_gfxr_auxbuf_line_clear(gfxr_pic_t *pic, rect_t line, int color, int sci_titlebar_size) { int dx, dy, incrE, incrNE, d, finalx, finaly; int x = line.x; int y = line.y + sci_titlebar_size; @@ -328,16 +324,15 @@ _gfxr_auxbuf_line_clear(gfxr_pic_t *pic, rect_t line, int color, int sci_titleba #ifdef WITH_PIC_SCALING static void -_gfxr_auxbuf_propagate_changes(gfxr_pic_t *pic, int bitmask) -{ +_gfxr_auxbuf_propagate_changes(gfxr_pic_t *pic, int bitmask) { /* Propagates all filled bits into the planes described by bitmask */ unsigned long *data = (unsigned long *) pic->aux_map; unsigned long clearmask = 0x07070707; unsigned long andmask = - (bitmask << 3) - | (bitmask << (3+8)) - | (bitmask << (3+16)) - | (bitmask << (3+24)); + (bitmask << 3) + | (bitmask << (3 + 8)) + | (bitmask << (3 + 16)) + | (bitmask << (3 + 24)); if (sizeof(unsigned long) == 8) { /* UltraSparc, Alpha, newer MIPSens, etc */ andmask |= (andmask << 32); @@ -355,8 +350,7 @@ _gfxr_auxbuf_propagate_changes(gfxr_pic_t *pic, int bitmask) static inline void -_gfxr_auxbuf_tag_line(gfxr_pic_t *pic, int pos, int width) -{ +_gfxr_auxbuf_tag_line(gfxr_pic_t *pic, int pos, int width) { int i; for (i = 0; i < width; i++) pic->aux_map[i+pos] |= FRESH_PAINT; @@ -365,15 +359,14 @@ _gfxr_auxbuf_tag_line(gfxr_pic_t *pic, int pos, int width) #if 0 // Unreferenced - removed static void -_gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *max_y) -{ +_gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *max_y) { /* Tries to spread by approximating the first derivation of the border function. ** Draws to the current and the last line, thus taking up to twice as long as neccessary. ** Other than that, it's O(n^2) */ int intervals_nr = 0, old_intervals_nr; - int x, y, i, pos = 10*320; + int x, y, i, pos = 10 * 320; struct interval_struct { int xl, xr, tag; } intervals[2][160]; @@ -383,11 +376,11 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma #ifdef FILL_RECURSIVE_DEBUG if (!fillmagc) { - fprintf(stderr,"------------------------------------------------\n"); - fprintf(stderr,"LineID: "); + fprintf(stderr, "------------------------------------------------\n"); + fprintf(stderr, "LineID: "); for (i = 0; i < 5; i++) - fprintf(stderr," %d ", i); - fprintf(stderr,"\n"); + fprintf(stderr, " %d ", i); + fprintf(stderr, "\n"); } #endif @@ -419,10 +412,10 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma i = old_intervals_start_offset; while (!done && i < old_intervals_nr) { - if (intervals[!ivi][i].xl > xr+1) + if (intervals[!ivi][i].xl > xr + 1) done = 1; - else if (intervals[!ivi][i].xr < xl-1) { + else if (intervals[!ivi][i].xr < xl - 1) { int o_xl = intervals[!ivi][i].xl; int o_xr = intervals[!ivi][i].xr; if (o_xr == o_xl && !intervals[!ivi][i].tag) { /* thin bar */ @@ -444,7 +437,7 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma int write_left_width, write_right_width; intervals[!ivi][i].tag = 1; - while (k+1 < old_intervals_nr && intervals[!ivi][k+1].xl <= xr) { + while (k + 1 < old_intervals_nr && intervals[!ivi][k+1].xl <= xr) { ++k; intervals[!ivi][i].tag = 1; } @@ -453,10 +446,10 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma dwidth_r = abs(old_xr - xr); /* Current line */ - write_left_width = (dwidth_l > xl)? xl : dwidth_l; + write_left_width = (dwidth_l > xl) ? xl : dwidth_l; _gfxr_auxbuf_tag_line(pic, pos + xl - write_left_width, write_left_width); - write_right_width = (dwidth_r + xr > 319)? 320 - xr : dwidth_r; + write_right_width = (dwidth_r + xr > 319) ? 320 - xr : dwidth_r; _gfxr_auxbuf_tag_line(pic, pos + xr, write_right_width); if (xl - write_left_width < *min_x) @@ -465,15 +458,15 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma *max_x = xr + write_right_width; /* Previous line */ - write_left_width = (dwidth_l > old_xl)? old_xl : dwidth_l; - write_right_width = (dwidth_r + old_xr > 319)? 320 - old_xr : dwidth_r; + write_left_width = (dwidth_l > old_xl) ? old_xl : dwidth_l; + write_right_width = (dwidth_r + old_xr > 319) ? 320 - old_xr : dwidth_r; if (i == k) { /* Only one predecessor interval */ _gfxr_auxbuf_tag_line(pic, pos - 320 + old_xl - write_left_width, write_left_width); _gfxr_auxbuf_tag_line(pic, pos - 320 + old_xr, write_right_width); } else /* Fill entire line */ _gfxr_auxbuf_tag_line(pic, pos - 320 + old_xl - write_left_width, old_xr - old_xl - + 1 + write_left_width + write_right_width); + + 1 + write_left_width + write_right_width); if (xl - write_left_width < *min_x) *min_x = xl - write_left_width; @@ -489,10 +482,10 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma #ifdef FILL_RECURSIVE_DEBUG if (!fillmagc && intervals_nr) { - fprintf(stderr,"AI L#%03d:", y); + fprintf(stderr, "AI L#%03d:", y); for (int j = 0; j < intervals_nr; j++) - fprintf(stderr, "%c[%03d,%03d]", intervals[ivi][j].tag? ' ':'-', intervals[ivi][j].xl, intervals[ivi][j].xr); - fprintf(stderr,"\n"); + fprintf(stderr, "%c[%03d,%03d]", intervals[ivi][j].tag ? ' ' : '-', intervals[ivi][j].xl, intervals[ivi][j].xr); + fprintf(stderr, "\n"); } #endif @@ -505,7 +498,7 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma pos += 320; } - for (pos = 320*200 - 1; pos >= 320; pos--) + for (pos = 320 * 200 - 1; pos >= 320; pos--) if (pic->aux_map[pos - 320] & 0x40) pic->aux_map[pos] |= 0x40; @@ -560,13 +553,13 @@ enum { #define SCI1_OP_OFFSET 42 enum { - PIC_SCI1_OPX_SET_PALETTE_ENTRIES = 0+SCI1_OP_OFFSET, - PIC_SCI1_OPX_EMBEDDED_VIEW = 1+SCI1_OP_OFFSET, - PIC_SCI1_OPX_SET_PALETTE = 2+SCI1_OP_OFFSET, - PIC_SCI1_OPX_PRIORITY_TABLE_EQDIST = 3+SCI1_OP_OFFSET, - PIC_SCI1_OPX_PRIORITY_TABLE_EXPLICIT = 4+SCI1_OP_OFFSET + PIC_SCI1_OPX_SET_PALETTE_ENTRIES = 0 + SCI1_OP_OFFSET, + PIC_SCI1_OPX_EMBEDDED_VIEW = 1 + SCI1_OP_OFFSET, + PIC_SCI1_OPX_SET_PALETTE = 2 + SCI1_OP_OFFSET, + PIC_SCI1_OPX_PRIORITY_TABLE_EQDIST = 3 + SCI1_OP_OFFSET, + PIC_SCI1_OPX_PRIORITY_TABLE_EXPLICIT = 4 + SCI1_OP_OFFSET }; - + #ifdef GFXR_DEBUG_PIC0 #define p0printf sciprintf @@ -583,15 +576,14 @@ enum { static void _gfxr_fill_ellipse(gfxr_pic_t *pic, byte *buffer, int linewidth, int x, int y, - int rad_x, int rad_y, int color, int fillstyle) -{ + int rad_x, int rad_y, int color, int fillstyle) { int xx = 0, yy = rad_y; int i, x_i, y_i; int xr = 2 * rad_x * rad_x; int yr = 2 * rad_y * rad_y; x_i = 1; - y_i = xr * rad_y -1; + y_i = xr * rad_y - 1; i = y_i >> 1; while (yy >= 0) { @@ -612,11 +604,11 @@ _gfxr_fill_ellipse(gfxr_pic_t *pic, byte *buffer, int linewidth, int x, int y, if (oldyy != yy) { int j; - int offset0 = (y-oldyy) * linewidth; - int offset1 = (y+oldyy) * linewidth; + int offset0 = (y - oldyy) * linewidth; + int offset1 = (y + oldyy) * linewidth; - offset0 += x-oldxx; - offset1 += x-oldxx; + offset0 += x - oldxx; + offset1 += x - oldxx; if (oldyy == 0) offset1 = 0; /* We never have to draw ellipses in the menu bar */ @@ -632,7 +624,7 @@ _gfxr_fill_ellipse(gfxr_pic_t *pic, byte *buffer, int linewidth, int x, int y, break; case ELLIPSE_OR: - for (j=0; j < (oldxx << 1) + 1; j++) { + for (j = 0; j < (oldxx << 1) + 1; j++) { buffer[offset0 + j] |= color; if (offset1) buffer[offset1 + j] |= color; @@ -640,7 +632,7 @@ _gfxr_fill_ellipse(gfxr_pic_t *pic, byte *buffer, int linewidth, int x, int y, break; default: - fprintf(stderr,"%s L%d: Invalid ellipse fill mode!\n", __FILE__, __LINE__); + fprintf(stderr, "%s L%d: Invalid ellipse fill mode!\n", __FILE__, __LINE__); return; } @@ -650,8 +642,7 @@ _gfxr_fill_ellipse(gfxr_pic_t *pic, byte *buffer, int linewidth, int x, int y, static inline void _gfxr_auxplot_brush(gfxr_pic_t *pic, byte *buffer, int yoffset, int offset, int plot, - int color, gfx_brush_mode_t brush_mode, int randseed) -{ + int color, gfx_brush_mode_t brush_mode, int randseed) { /* yoffset 63680, offset 320, plot 1, color 34, brush_mode 0, randseed 432)*/ /* Auxplot: Used by plot_aux_pattern to plot to visual and priority */ int xc, yc; @@ -673,38 +664,38 @@ _gfxr_auxplot_brush(gfxr_pic_t *pic, byte *buffer, int yoffset, int offset, int case GFX_BRUSH_MODE_ELLIPSES: if (plot) { - int x = offset * pic->mode->xfact + ((pic->mode->xfact -1) >> 1); - int y = (yoffset / 320) * pic->mode->yfact + ((pic->mode->yfact -1) >> 1); /* Ouch! */ + int x = offset * pic->mode->xfact + ((pic->mode->xfact - 1) >> 1); + int y = (yoffset / 320) * pic->mode->yfact + ((pic->mode->yfact - 1) >> 1); /* Ouch! */ _gfxr_fill_ellipse(pic, buffer, line_width, x, y, pic->mode->xfact >> 1, pic->mode->yfact >> 1, - color, ELLIPSE_SOLID); + color, ELLIPSE_SOLID); } break; case GFX_BRUSH_MODE_RANDOM_ELLIPSES: if (plot) { - int x = offset * pic->mode->xfact + ((pic->mode->xfact -1) >> 1); - int y = (yoffset / 320) * pic->mode->yfact + ((pic->mode->yfact -1) >> 1); /* Ouch! */ + int x = offset * pic->mode->xfact + ((pic->mode->xfact - 1) >> 1); + int y = (yoffset / 320) * pic->mode->yfact + ((pic->mode->yfact - 1) >> 1); /* Ouch! */ int sizex = pic->mode->xfact >> 1; int sizey = pic->mode->yfact >> 1; srand(randseed); - x -= (int) ((sizex * rand()*1.0)/(RAND_MAX + 1.0)); - x += (int) ((sizex * rand()*1.0)/(RAND_MAX + 1.0)); - y -= (int) ((sizey * rand()*1.0)/(RAND_MAX + 1.0)); - y += (int) ((sizey * rand()*1.0)/(RAND_MAX + 1.0)); - sizex = (int) ((sizex * rand()*1.0)/(RAND_MAX + 1.0)); - sizey = (int) ((sizey * rand()*1.0)/(RAND_MAX + 1.0)); + x -= (int)((sizex * rand() * 1.0) / (RAND_MAX + 1.0)); + x += (int)((sizex * rand() * 1.0) / (RAND_MAX + 1.0)); + y -= (int)((sizey * rand() * 1.0) / (RAND_MAX + 1.0)); + y += (int)((sizey * rand() * 1.0) / (RAND_MAX + 1.0)); + sizex = (int)((sizex * rand() * 1.0) / (RAND_MAX + 1.0)); + sizey = (int)((sizey * rand() * 1.0) / (RAND_MAX + 1.0)); _gfxr_fill_ellipse(pic, buffer, line_width, x, y, pic->mode->xfact >> 1, pic->mode->yfact >> 1, - color, ELLIPSE_SOLID); + color, ELLIPSE_SOLID); srand(time(NULL)); /* Make sure we don't accidently forget to re-init the random number generator */ } break; case GFX_BRUSH_MODE_MORERANDOM: { - int mask = plot? 7 : 1; + int mask = plot ? 7 : 1; srand(randseed); for (yc = 0; yc < pic->mode->yfact; yc++) { for (xc = 0; xc < pic->mode->xfact; xc++) @@ -722,9 +713,8 @@ _gfxr_auxplot_brush(gfxr_pic_t *pic, byte *buffer, int yoffset, int offset, int static void _gfxr_plot_aux_pattern(gfxr_pic_t *pic, int x, int y, int size, int circle, int random, - int mask, int color, int priority, int control, - gfx_brush_mode_t brush_mode, int map_nr) -{ + int mask, int color, int priority, int control, + gfx_brush_mode_t brush_mode, int map_nr) { /* Plots an appropriate pattern to the aux buffer and the control buffer, ** if mask & GFX_MASK_CONTROL ** random should be set to the random index, or -1 to disable @@ -739,13 +729,15 @@ _gfxr_plot_aux_pattern(gfxr_pic_t *pic, int x, int y, int size, int circle, int {4, 4, 4, 3, 1}, {5, 5, 4, 4, 3, 1}, {6, 6, 6, 5, 5, 4, 2}, - {7, 7, 7, 6, 6, 5, 4, 2}}; + {7, 7, 7, 6, 6, 5, 4, 2} + }; /* 'Random' fill patterns, provided by Carl Muckenhoupt: */ byte random_data[32] = { 0x20, 0x94, 0x02, 0x24, 0x90, 0x82, 0xa4, 0xa2, 0x82, 0x09, 0x0a, 0x22, 0x12, 0x10, 0x42, 0x14, 0x91, 0x4a, 0x91, 0x11, 0x08, 0x12, 0x25, 0x10, - 0x22, 0xa8, 0x14, 0x24, 0x00, 0x50, 0x24, 0x04}; + 0x22, 0xa8, 0x14, 0x24, 0x00, 0x50, 0x24, 0x04 + }; /* 'Random' fill offsets, provided by Carl Muckenhoupt: */ byte random_offset[128] = { @@ -773,9 +765,15 @@ _gfxr_plot_aux_pattern(gfxr_pic_t *pic, int x, int y, int size, int circle, int gfx_pixmap_t *map = NULL; switch (map_nr) { - case GFX_MASK_VISUAL: map = pic->visual_map; break; - case GFX_MASK_PRIORITY: map = pic->priority_map; break; - default: map = pic->control_map; break; + case GFX_MASK_VISUAL: + map = pic->visual_map; + break; + case GFX_MASK_PRIORITY: + map = pic->priority_map; + break; + default: + map = pic->control_map; + break; } if (random >= 0) @@ -816,24 +814,24 @@ _gfxr_plot_aux_pattern(gfxr_pic_t *pic, int x, int y, int size, int circle, int if (mask & GFX_MASK_VISUAL) _gfxr_auxplot_brush(pic, pic->visual_map->index_data, - yoffset, x + offset + j, - 1, color, brush_mode, random_index + x); + yoffset, x + offset + j, + 1, color, brush_mode, random_index + x); if (mask & GFX_MASK_PRIORITY) _gfxr_auxplot_brush(pic, pic->priority_map->index_data, - yoffset, x + offset + j, - 1, priority, brush_mode, random_index + x); + yoffset, x + offset + j, + 1, priority, brush_mode, random_index + x); } else { if (mask & GFX_MASK_VISUAL) _gfxr_auxplot_brush(pic, pic->visual_map->index_data, - yoffset, x + offset + j, - 0, color, brush_mode, random_index + x); + yoffset, x + offset + j, + 0, color, brush_mode, random_index + x); if (mask & GFX_MASK_PRIORITY) _gfxr_auxplot_brush(pic, pic->priority_map->index_data, - yoffset, x + offset + j, - 0, priority, brush_mode, random_index + x); + yoffset, x + offset + j, + 0, priority, brush_mode, random_index + x); } random_index = (random_index + 1) & 0xff; } @@ -846,14 +844,13 @@ _gfxr_plot_aux_pattern(gfxr_pic_t *pic, int x, int y, int size, int circle, int static void _gfxr_draw_pattern(gfxr_pic_t *pic, int x, int y, int color, int priority, int control, int drawenable, - int pattern_code, int pattern_size, int pattern_nr, gfx_brush_mode_t brush_mode, - int sci_titlebar_size) -{ + int pattern_code, int pattern_size, int pattern_nr, gfx_brush_mode_t brush_mode, + int sci_titlebar_size) { int xsize = (pattern_size + 1) * pic->mode->xfact - 1; int ysize = (pattern_size + 1) * pic->mode->yfact - 1; int scaled_x, scaled_y; rect_t boundaries; - int max_x = (pattern_code & PATTERN_FLAG_RECTANGLE)? 318 : 319; /* Rectangles' width is size+1 */ + int max_x = (pattern_code & PATTERN_FLAG_RECTANGLE) ? 318 : 319; /* Rectangles' width is size+1 */ p0printf(stderr, "Pattern at (%d,%d) size %d, rand=%d, code=%02x\n", x, y, pattern_size, pattern_nr, pattern_code); @@ -896,15 +893,15 @@ _gfxr_draw_pattern(gfxr_pic_t *pic, int x, int y, int color, int priority, int c if (pattern_code & PATTERN_FLAG_USE_PATTERN) { _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 0, pattern_nr, - drawenable, color, priority, - control, brush_mode, GFX_MASK_CONTROL); + drawenable, color, priority, + control, brush_mode, GFX_MASK_CONTROL); } else { _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 0, - PLOT_AUX_PATTERN_NO_RANDOM, - drawenable, 0, 0, control, - GFX_BRUSH_MODE_SCALED, - GFX_MASK_CONTROL); + PLOT_AUX_PATTERN_NO_RANDOM, + drawenable, 0, 0, control, + GFX_BRUSH_MODE_SCALED, + GFX_MASK_CONTROL); if (drawenable & GFX_MASK_VISUAL) gfx_draw_box_pixmap_i(pic->visual_map, boundaries, color); @@ -919,42 +916,42 @@ _gfxr_draw_pattern(gfxr_pic_t *pic, int x, int y, int color, int priority, int c if (pattern_code & PATTERN_FLAG_USE_PATTERN) { _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 1, pattern_nr, - drawenable, color, priority, - control, brush_mode, GFX_MASK_CONTROL); + drawenable, color, priority, + control, brush_mode, GFX_MASK_CONTROL); } else { _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 1, - PLOT_AUX_PATTERN_NO_RANDOM, - drawenable, 0, 0, control, - GFX_BRUSH_MODE_SCALED, - GFX_MASK_CONTROL); + PLOT_AUX_PATTERN_NO_RANDOM, + drawenable, 0, 0, control, + GFX_BRUSH_MODE_SCALED, + GFX_MASK_CONTROL); if (pic->mode->xfact == 1 && pic->mode->yfact == 1) { if (drawenable & GFX_MASK_VISUAL) _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 1, - PLOT_AUX_PATTERN_NO_RANDOM, - drawenable, 0, 0, color, - GFX_BRUSH_MODE_SCALED, - GFX_MASK_VISUAL); + PLOT_AUX_PATTERN_NO_RANDOM, + drawenable, 0, 0, color, + GFX_BRUSH_MODE_SCALED, + GFX_MASK_VISUAL); if (drawenable & GFX_MASK_PRIORITY) _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 1, - PLOT_AUX_PATTERN_NO_RANDOM, - drawenable, 0, 0, priority, - GFX_BRUSH_MODE_SCALED, - GFX_MASK_PRIORITY); + PLOT_AUX_PATTERN_NO_RANDOM, + drawenable, 0, 0, priority, + GFX_BRUSH_MODE_SCALED, + GFX_MASK_PRIORITY); } else { if (drawenable & GFX_MASK_VISUAL) _gfxr_fill_ellipse(pic, pic->visual_map->index_data, 320 * pic->mode->xfact, - scaled_x, scaled_y, xsize, ysize, - color, ELLIPSE_SOLID); + scaled_x, scaled_y, xsize, ysize, + color, ELLIPSE_SOLID); if (drawenable & GFX_MASK_PRIORITY) _gfxr_fill_ellipse(pic, pic->priority_map->index_data, 320 * pic->mode->xfact, - scaled_x, scaled_y, xsize, ysize, - priority, ELLIPSE_SOLID); + scaled_x, scaled_y, xsize, ysize, + priority, ELLIPSE_SOLID); } } } @@ -962,21 +959,20 @@ _gfxr_draw_pattern(gfxr_pic_t *pic, int x, int y, int color, int priority, int c static inline void -_gfxr_draw_subline(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, int priority, int drawenable) -{ +_gfxr_draw_subline(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, int priority, int drawenable) { point_t start; point_t end; - + start.x = x; start.y = y; end.x = ex; end.y = ey; - if (ex >= pic->visual_map->index_xl || ey >= pic->visual_map->index_yl || x < 0 || y < 0) { - fprintf(stderr,"While drawing pic0: INVALID LINE %d,%d,%d,%d\n", - GFX_PRINT_POINT(start), GFX_PRINT_POINT(end)); - return; - } + if (ex >= pic->visual_map->index_xl || ey >= pic->visual_map->index_yl || x < 0 || y < 0) { + fprintf(stderr, "While drawing pic0: INVALID LINE %d,%d,%d,%d\n", + GFX_PRINT_POINT(start), GFX_PRINT_POINT(end)); + return; + } if (drawenable & GFX_MASK_VISUAL) gfx_draw_line_pixmap_i(pic->visual_map, start, end, color); @@ -988,16 +984,15 @@ _gfxr_draw_subline(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, int static void _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, - int priority, int control, int drawenable, int line_mode, - int cmd, int sci_titlebar_size) -{ + int priority, int control, int drawenable, int line_mode, + int cmd, int sci_titlebar_size) { int scale_x = pic->mode->xfact; int scale_y = pic->mode->yfact; int xc, yc; rect_t line; int mask; int partially_white = (drawenable & GFX_MASK_VISUAL) - && (((color & 0xf0) == 0xf0) || ((color & 0x0f) == 0x0f)); + && (((color & 0xf0) == 0xf0) || ((color & 0x0f) == 0x0f)); line.x = x; line.y = y; @@ -1005,7 +1000,7 @@ _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, line.yl = ey - y; if (x > 319 || y > 199 || x < 0 || y < 0 - || ex > 319 || ey > 199 || ex < 0 || ey < 0) { + || ex > 319 || ey > 199 || ex < 0 || ey < 0) { GFXWARN("While building pic: Attempt to draw line (%d,%d) to (%d,%d): cmd was %d\n", x, y, ex, ey, cmd); return; } @@ -1022,11 +1017,11 @@ _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, /* Calculate everything that is changed to SOLID */ mask = drawenable & - ( - ((color != 0xff)? 1 : 0) - | ((priority)? 2 : 0) - | ((control)? 4 : 0) - ); + ( + ((color != 0xff) ? 1 : 0) + | ((priority) ? 2 : 0) + | ((control) ? 4 : 0) + ); if (mask) { int mask2 = mask; @@ -1037,11 +1032,11 @@ _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, /* Calculate everything that is changed to TRANSPARENT */ mask = drawenable & - ( - ((color == 0xff)? 1 : 0) - | ((!priority)? 2 : 0) - | ((!control)? 4 : 0) - ); + ( + ((color == 0xff) ? 1 : 0) + | ((!priority) ? 2 : 0) + | ((!control) ? 4 : 0) + ); if (mask) _gfxr_auxbuf_line_clear(pic, line, ~mask, sci_titlebar_size); @@ -1093,29 +1088,29 @@ _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, for (xc = 0; xc < width; xc++) _gfxr_draw_subline(pic, - x + xc + x_offset, y + y_offset, - ex + xc + x_offset, ey + y_offset, - color, priority, drawenable); + x + xc + x_offset, y + y_offset, + ex + xc + x_offset, ey + y_offset, + color, priority, drawenable); if (height > 0) for (xc = 0; xc < width; xc++) _gfxr_draw_subline(pic, - x + xc + x_offset, y + height - 1 + y_offset, - ex + xc + x_offset, ey + height - 1 + y_offset, - color, priority, drawenable); + x + xc + x_offset, y + height - 1 + y_offset, + ex + xc + x_offset, ey + height - 1 + y_offset, + color, priority, drawenable); if (height > 1) { for (yc = 1; yc < height - 1; yc++) _gfxr_draw_subline(pic, - x + x_offset, y + yc + y_offset, - ex + x_offset, ey + yc + y_offset, - color, priority, drawenable); + x + x_offset, y + yc + y_offset, + ex + x_offset, ey + yc + y_offset, + color, priority, drawenable); if (width > 0) for (yc = 1; yc < height - 1; yc++) _gfxr_draw_subline(pic, - x + width - 1 + x_offset, y + yc + y_offset, - ex + width - 1 + x_offset, ey + yc + y_offset, - color, priority, drawenable); + x + width - 1 + x_offset, y + yc + y_offset, + ex + width - 1 + x_offset, ey + yc + y_offset, + color, priority, drawenable); } } } @@ -1145,15 +1140,14 @@ _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, static inline int /* returns -1 on failure, 0 on success */ _gfxr_find_fill_point(gfxr_pic_t *pic, int min_x, int min_y, int max_x, int max_y, int x_320, - int y_200, int color, int drawenable, int *x, int *y) -{ + int y_200, int color, int drawenable, int *x, int *y) { int linewidth = pic->mode->xfact * 320; int mpos, ix, iy; int size_x = (max_x - min_x + 1) >> 1; int size_y = (max_y - min_y + 1) >> 1; int mid_x = min_x + size_x; int mid_y = min_y + size_y; - int max_size = (size_x > size_y)? size_x : size_y; + int max_size = (size_x > size_y) ? size_x : size_y; int size; int legalcolor; int legalmask; @@ -1169,7 +1163,7 @@ _gfxr_find_fill_point(gfxr_pic_t *pic, int min_x, int min_y, int max_x, int max_ if ((color & 0xf) == 0xf /* When dithering with white, do more ** conservative checks */ - || (color & 0xf0) == 0xf0) + || (color & 0xf0) == 0xf0) legalcolor = 0xff; else legalcolor = 0xf0; /* Only check the second color */ @@ -1188,7 +1182,7 @@ _gfxr_find_fill_point(gfxr_pic_t *pic, int min_x, int min_y, int max_x, int max_ int i; if (size <= size_y) { - int limited_size = (size > size_x)? size_x : size; + int limited_size = (size > size_x) ? size_x : size; for (i = mid_x - limited_size; i <= mid_x + limited_size; i++) { TEST_POINT(i, mid_y - size); @@ -1197,7 +1191,7 @@ _gfxr_find_fill_point(gfxr_pic_t *pic, int min_x, int min_y, int max_x, int max_ } if (size <= size_x) { - int limited_size = (size - 1 > size_y)? size_y : size - 1; + int limited_size = (size - 1 > size_y) ? size_y : size - 1; for (i = mid_y - limited_size; i <= mid_y + limited_size; i++) { TEST_POINT(mid_x - size, i); @@ -1269,8 +1263,7 @@ _gfxr_find_fill_point(gfxr_pic_t *pic, int min_x, int min_y, int max_x, int max_ inline static void -check_and_remove_artifact(byte *dest, byte* srcp, int legalcolor, byte l, byte r, byte u, byte d) -{ +check_and_remove_artifact(byte *dest, byte* srcp, int legalcolor, byte l, byte r, byte u, byte d) { if (*dest == legalcolor) { if (*srcp == legalcolor) return; @@ -1303,8 +1296,7 @@ check_and_remove_artifact(byte *dest, byte* srcp, int legalcolor, byte l, byte r void -gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src) -{ +gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src) { int x_320, y_200; int bound_x = dest->mode->xfact; int bound_y = dest->mode->yfact; @@ -1330,11 +1322,11 @@ gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src) for (sub_y = 0; sub_y < bound_y; sub_y++) { for (sub_x = 0; sub_x < bound_x; sub_x++) { check_and_remove_artifact(dest->visual_map->index_data + write_offset, - src_visualp, (int)0xff, - (byte)x_320, (byte)(x_320 < 319), (byte)(y_200 > 10), (byte)(y_200 < 199)); + src_visualp, (int)0xff, + (byte)x_320, (byte)(x_320 < 319), (byte)(y_200 > 10), (byte)(y_200 < 199)); check_and_remove_artifact(dest->priority_map->index_data + write_offset, - src_priorityp, 0, - (byte)x_320, (byte)(x_320 < 319), (byte)(y_200 > 10), (byte)(y_200 < 199)); + src_priorityp, 0, + (byte)x_320, (byte)(x_320 < 319), (byte)(y_200 > 10), (byte)(y_200 < 199)); ++write_offset; } write_offset += scaled_line_size - bound_x; @@ -1347,34 +1339,30 @@ gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src) static void view_transparentize(gfx_pixmap_t *view, byte *pic_index_data, - int posx, int posy, - int width, int height) -{ - int i,j; - - for (i=0;i<width;i++) - for (j=0;j<height;j++) - { - if (view->index_data[j*width+i] == view->color_key) - { - view->index_data[j*width+i] = - pic_index_data[(j+posy)*width+i+posx]; + int posx, int posy, + int width, int height) { + int i, j; + + for (i = 0;i < width;i++) + for (j = 0;j < height;j++) { + if (view->index_data[j*width+i] == view->color_key) { + view->index_data[j*width+i] = + pic_index_data[(j+posy)*width+i+posx]; } } } extern gfx_pixmap_t * -gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size, gfxr_view_t *view, int mirrored); + 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); + 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); + _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, gfxr_pic0_params_t *style, int resid, int sci1, - gfx_pixmap_color_t *static_pal, int static_pal_nr) -{ + byte *resource, gfxr_pic0_params_t *style, int resid, int sci1, + gfx_pixmap_color_t *static_pal, int static_pal_nr) { const int default_palette_table[GFXR_PIC0_PALETTE_SIZE] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0x88, @@ -1461,7 +1449,7 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, pal = *(resource + pos++); index = pal % GFXR_PIC0_PALETTE_SIZE; pal /= GFXR_PIC0_PALETTE_SIZE; /* Ignore pal */ - + priority = priority_table[index]; } else priority = *(resource + pos++); @@ -1486,7 +1474,7 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, GET_ABS_COORDS(x, y); _gfxr_draw_pattern(pic, x, y, color, priority, control, drawenable, pattern_code, - pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); + pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); while (*(resource + pos) < PIC_OP_FIRST) { if (pattern_code & PATTERN_FLAG_USE_PATTERN) { @@ -1497,7 +1485,7 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, GET_REL_COORDS(x, y); _gfxr_draw_pattern(pic, x, y, color, priority, control, drawenable, pattern_code, - pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); + pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); } goto end_op_loop; @@ -1507,16 +1495,17 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, GET_ABS_COORDS(oldx, oldy); while (*(resource + pos) < PIC_OP_FIRST) { #if 0 - fprintf(stderr,"Medium-line: [%04x] from %d,%d, data %02x %02x (dx=%d)", pos, oldx, oldy, - 0xff & resource[pos], 0xff & resource[pos+1], *((signed char *) resource + pos + 1)); + fprintf(stderr, "Medium-line: [%04x] from %d,%d, data %02x %02x (dx=%d)", pos, oldx, oldy, + 0xff & resource[pos], 0xff & resource[pos+1], *((signed char *) resource + pos + 1)); #endif GET_MEDREL_COORDS(oldx, oldy); #if 0 fprintf(stderr, " to %d,%d\n", x, y); #endif - _gfxr_draw_line(pic, oldx, oldy, x, y, color, priority, control, drawenable, line_mode, - PIC_OP_MEDIUM_LINES, sci_titlebar_size); - oldx = x; oldy = y; + _gfxr_draw_line(pic, oldx, oldy, x, y, color, priority, control, drawenable, line_mode, + PIC_OP_MEDIUM_LINES, sci_titlebar_size); + oldx = x; + oldy = y; } goto end_op_loop; @@ -1525,10 +1514,11 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, p0printf("Long lines @%d\n", pos); GET_ABS_COORDS(oldx, oldy); while (*(resource + pos) < PIC_OP_FIRST) { - GET_ABS_COORDS(x,y); - _gfxr_draw_line(pic, oldx, oldy, x, y, color, priority, control, drawenable, line_mode, - PIC_OP_LONG_LINES, sci_titlebar_size); - oldx = x; oldy = y; + GET_ABS_COORDS(x, y); + _gfxr_draw_line(pic, oldx, oldy, x, y, color, priority, control, drawenable, line_mode, + PIC_OP_LONG_LINES, sci_titlebar_size); + oldx = x; + oldy = y; } goto end_op_loop; @@ -1536,12 +1526,14 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, case PIC_OP_SHORT_LINES: p0printf("Short lines @%d\n", pos); GET_ABS_COORDS(oldx, oldy); - x = oldx; y = oldy; + x = oldx; + y = oldy; while (*(resource + pos) < PIC_OP_FIRST) { - GET_REL_COORDS(x,y); - _gfxr_draw_line(pic, oldx, oldy, x, y, color, priority, control, drawenable, line_mode, - PIC_OP_SHORT_LINES, sci_titlebar_size); - oldx = x; oldy = y; + GET_REL_COORDS(x, y); + _gfxr_draw_line(pic, oldx, oldy, x, y, color, priority, control, drawenable, line_mode, + PIC_OP_SHORT_LINES, sci_titlebar_size); + oldx = x; + oldy = y; } goto end_op_loop; @@ -1555,14 +1547,14 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, /*fprintf(stderr,"C=(%d,%d)\n", x, y + sci_titlebar_size);*/ #ifdef WITH_PIC_SCALING if (pic->mode->xfact > 1 - || pic->mode->yfact > 1) - _gfxr_fill_any(pic, x, y + sci_titlebar_size, (flags & DRAWPIC01_FLAG_FILL_NORMALLY)? - color : 0, priority, control, drawenable, sci_titlebar_size); + || pic->mode->yfact > 1) + _gfxr_fill_any(pic, x, y + sci_titlebar_size, (flags & DRAWPIC01_FLAG_FILL_NORMALLY) ? + color : 0, priority, control, drawenable, sci_titlebar_size); else #endif - _gfxr_fill_1(pic, x, y + sci_titlebar_size, (flags & DRAWPIC01_FLAG_FILL_NORMALLY)? - color : 0, priority, control, drawenable, sci_titlebar_size); + _gfxr_fill_1(pic, x, y + sci_titlebar_size, (flags & DRAWPIC01_FLAG_FILL_NORMALLY) ? + color : 0, priority, control, drawenable, sci_titlebar_size); if (fill_count++ > SCI_PIC0_MAX_FILL) { sci_sched_yield(); @@ -1571,7 +1563,7 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, #ifdef FILL_RECURSIVE_DEBUG if (!fillmagc) { - int x,y; + int x, y; if (getenv("FOO1")) for (x = 0; x < 320; x++) for (y = 0; y < 200; y++) { @@ -1603,7 +1595,8 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, pic->visual_map->index_data[x + y*320*pic->mode->xfact] = pix; } return; - } --fillmagc; + } + --fillmagc; #endif /* GFXR_DEBUG_PIC0 */ } goto end_op_loop; @@ -1627,7 +1620,7 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, GET_ABS_COORDS(x, y); _gfxr_draw_pattern(pic, x, y, color, priority, control, drawenable, pattern_code, - pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); + pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); } goto end_op_loop; @@ -1655,9 +1648,10 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, GET_ABS_COORDS(oldx, oldy); _gfxr_draw_pattern(pic, oldx, oldy, color, priority, control, drawenable, pattern_code, - pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); + pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); - x = oldx; y = oldy; + x = oldx; + y = oldy; while (*(resource + pos) < PIC_OP_FIRST) { if (pattern_code & PATTERN_FLAG_USE_PATTERN) { pattern_nr = ((*(resource + pos++)) >> 1) & 0x7f; @@ -1667,7 +1661,7 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, GET_MEDREL_COORDS(x, y); _gfxr_draw_pattern(pic, x, y, color, priority, control, drawenable, pattern_code, - pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); + pattern_size, pattern_nr, style->brush_mode, sci_titlebar_size); } goto end_op_loop; @@ -1724,7 +1718,7 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, p0printf("Set palette @%d\n", pos); pic->visual_map->flags &= ~GFX_PIXMAP_FLAG_EXTERNAL_PALETTE; pic->visual_map->colors = gfxr_read_pal1(resid, &pic->visual_map->colors_nr, - resource+pos, SCI1_PALETTE_SIZE); + resource + pos, SCI1_PALETTE_SIZE); pos += SCI1_PALETTE_SIZE; goto end_op_loop; @@ -1748,11 +1742,10 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, case PIC_SCI0_OPX_EMBEDDED_VIEW: - case PIC_SCI1_OPX_EMBEDDED_VIEW: - { + case PIC_SCI1_OPX_EMBEDDED_VIEW: { int posx, posy; int bytesize; -/* byte *vismap = pic->visual_map->index_data; */ + /* byte *vismap = pic->visual_map->index_data; */ int nodraw = 0; gfx_pixmap_t *view; @@ -1762,27 +1755,27 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, /* Set up mode structure for resizing the view */ mode = gfx_new_mode( - pic->visual_map->index_xl/320, - pic->visual_map->index_yl/200, - 1, /* 1bpp, which handles masks and the rest for us */ - 0, 0, 0, 0, 0, 0, 0, 0, 16, 0); + pic->visual_map->index_xl / 320, + pic->visual_map->index_yl / 200, + 1, /* 1bpp, which handles masks and the rest for us */ + 0, 0, 0, 0, 0, 0, 0, 0, 16, 0); GET_ABS_COORDS(posx, posy); - bytesize = (*(resource + pos))+(*(resource + pos + 1) << 8); + bytesize = (*(resource + pos)) + (*(resource + pos + 1) << 8); p0printf("(%d, %d)\n", posx, posy); pos += 2; - if (!sci1 && !nodraw) - view = gfxr_draw_cel0(-1,-1,-1, resource + pos, bytesize, NULL, 0); + 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_nr == GFX_SCI1_AMIGA_COLORS_NR); - pos+=bytesize; + view = gfxr_draw_cel1(-1, -1, -1, 0, resource + pos, bytesize, NULL, + static_pal_nr == GFX_SCI1_AMIGA_COLORS_NR); + pos += bytesize; if (nodraw) continue; - p0printf("(%d, %d)-(%d, %d)\n", - posx, - posy, - posx + view->index_xl, - posy + view->index_yl); + p0printf("(%d, %d)-(%d, %d)\n", + posx, + posy, + posx + view->index_xl, + posy + view->index_yl); /* we can only safely replace the palette if it's static *if it's not for some reason, we should die @@ -1793,7 +1786,7 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, /* For SCI0, use special color mapping to copy the low ** nibble of the color index to the high - ** nibble. + ** nibble. */ if (sci1) { if (static_pal_nr == GFX_SCI1_AMIGA_COLORS_NR) { @@ -1815,35 +1808,33 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, gfx_xlate_pixmap(view, mode, GFX_XLATE_FILTER_NONE); if (flags & DRAWPIC01_FLAG_OVERLAID_PIC) - view_transparentize(view, pic->visual_map->index_data, - posx, sci_titlebar_size+posy, - view->index_xl, view->index_yl); - - _gfx_crossblit_simple(pic->visual_map->index_data+(sci_titlebar_size*320)+ - posy*320+posx, - view->index_data, - pic->visual_map->index_xl, view->index_xl, - view->index_xl, - view->index_yl, - 1); + view_transparentize(view, pic->visual_map->index_data, + posx, sci_titlebar_size + posy, + view->index_xl, view->index_yl); + + _gfx_crossblit_simple(pic->visual_map->index_data + (sci_titlebar_size*320) + + posy*320 + posx, + view->index_data, + pic->visual_map->index_xl, view->index_xl, + view->index_xl, + view->index_yl, + 1); gfx_free_mode(mode); gfx_free_pixmap(NULL, view); } goto end_op_loop; - case PIC_SCI0_OPX_SET_PRIORITY_TABLE: + case PIC_SCI0_OPX_SET_PRIORITY_TABLE: case PIC_SCI1_OPX_PRIORITY_TABLE_EXPLICIT: { int *pri_table; p0printf("Explicit priority table @%d\n", pos); - if (!pic->internal) - { - pic->internal = sci_malloc(16 * sizeof(int)); - } else - { - GFXERROR("pic->internal is not NULL (%08x); this only occurs with overlaid pics, otherwise it's a bug!\n", pic->internal); - } + if (!pic->internal) { + pic->internal = sci_malloc(16 * sizeof(int)); + } else { + GFXERROR("pic->internal is not NULL (%08x); this only occurs with overlaid pics, otherwise it's a bug!\n", pic->internal); + } pri_table = (int*)pic->internal; @@ -1853,32 +1844,30 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, for (int i = 1; i < 15; i++) pri_table[i] = resource[pos++]; } - goto end_op_loop; + goto end_op_loop; - case PIC_SCI1_OPX_PRIORITY_TABLE_EQDIST: - { + case PIC_SCI1_OPX_PRIORITY_TABLE_EQDIST: { int first = getInt16(resource + pos); int last = getInt16(resource + pos + 2); int nr; int *pri_table; - if (!pic->internal) - { - pic->internal = sci_malloc(16 * sizeof(int)); - } else - { - GFXERROR("pic->internal is not NULL (%08x); possible memory corruption!\n", pic->internal); - } + if (!pic->internal) { + pic->internal = sci_malloc(16 * sizeof(int)); + } else { + GFXERROR("pic->internal is not NULL (%08x); possible memory corruption!\n", pic->internal); + } pri_table = (int*)pic->internal; - + for (nr = 0; nr < 16; nr ++) - pri_table[nr] = SCI0_PRIORITY_BAND_FIRST_14_ZONES(nr); + pri_table[nr] = SCI0_PRIORITY_BAND_FIRST_14_ZONES(nr); pos += 4; goto end_op_loop; } - default: sciprintf("%s L%d: Warning: Unknown opx %02x\n", __FILE__, __LINE__, opx); + default: + sciprintf("%s L%d: Warning: Unknown opx %02x\n", __FILE__, __LINE__, opx); return; } goto end_op_loop; @@ -1889,11 +1878,11 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, /* _gfxr_vismap_remove_artifacts(); */ return; - default: GFXWARN("Unknown op %02x\n", op); + default: + GFXWARN("Unknown op %02x\n", op); return; } -end_op_loop: - {} +end_op_loop: {} } GFXWARN("Reached end of pic resource %04x\n", resid); @@ -1901,9 +1890,8 @@ end_op_loop: void gfxr_draw_pic11(gfxr_pic_t *pic, int flags, int default_palette, int size, - byte *resource, gfxr_pic0_params_t *style, int resid, - gfx_pixmap_color_t *static_pal, int static_pal_nr) -{ + byte *resource, gfxr_pic0_params_t *style, int resid, + gfx_pixmap_color_t *static_pal, int static_pal_nr) { int has_bitmap = getUInt16(resource + 4); int vector_data_ptr = getUInt16(resource + 16); int palette_data_ptr = getUInt16(resource + 28); @@ -1913,58 +1901,55 @@ gfxr_draw_pic11(gfxr_pic_t *pic, int flags, int default_palette, int size, gfx_pixmap_t *view = NULL; /* Set up mode structure for resizing the view */ mode = gfx_new_mode( - pic->visual_map->index_xl/320, - pic->visual_map->index_yl/200, - 1, /* 1bpp, which handles masks and the rest for us */ - 0, 0, 0, 0, 0, 0, 0, 0, 16, 0); + pic->visual_map->index_xl / 320, + pic->visual_map->index_yl / 200, + 1, /* 1bpp, which handles masks and the rest for us */ + 0, 0, 0, 0, 0, 0, 0, 0, 16, 0); pic->visual_map->colors = gfxr_read_pal11(-1, &(pic->visual_map->colors_nr), 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); - if (view) - { + if (view) { view->colors = pic->visual_map->colors; view->colors_nr = pic->visual_map->colors_nr; - + gfx_xlate_pixmap(view, mode, GFX_XLATE_FILTER_NONE); - + if (flags & DRAWPIC01_FLAG_OVERLAID_PIC) - view_transparentize(view, pic->visual_map->index_data, - 0, 0, - view->index_xl, view->index_yl); - + view_transparentize(view, pic->visual_map->index_data, + 0, 0, + view->index_xl, view->index_yl); + /* Hack to prevent overflowing the visual map buffer. Yes, this does happen otherwise. */ if (view->index_yl + sci_titlebar_size > 200) sci_titlebar_size = 0; - _gfx_crossblit_simple(pic->visual_map->index_data+sci_titlebar_size*view->index_xl, - view->index_data, - pic->visual_map->index_xl, view->index_xl, - view->index_xl, - view->index_yl, - 1); - } else - { + _gfx_crossblit_simple(pic->visual_map->index_data + sci_titlebar_size*view->index_xl, + view->index_data, + pic->visual_map->index_xl, view->index_xl, + view->index_xl, + view->index_yl, + 1); + } else { GFXWARN("No view was contained in SCI1.1 pic resource"); } - + gfxr_draw_pic01(pic, flags, default_palette, size - vector_data_ptr, - resource + vector_data_ptr, style, resid, 1, - static_pal, static_pal_nr); + resource + vector_data_ptr, style, resid, 1, + static_pal, static_pal_nr); } void -gfxr_dither_pic0(gfxr_pic_t *pic, int dmode, int pattern) -{ +gfxr_dither_pic0(gfxr_pic_t *pic, int dmode, int pattern) { int xl = pic->visual_map->index_xl; int yl = pic->visual_map->index_yl; - int xfrob_max = (pattern == GFXR_DITHER_PATTERN_1)? 1 : pic->mode->xfact; - int yfrob_max = (pattern == GFXR_DITHER_PATTERN_1)? 1 : pic->mode->yfact; + int xfrob_max = (pattern == GFXR_DITHER_PATTERN_1) ? 1 : pic->mode->xfact; + int yfrob_max = (pattern == GFXR_DITHER_PATTERN_1) ? 1 : pic->mode->yfact; int xfrobc = 0, yfrobc = 0; int selection = 0; int x, y; diff --git a/engines/sci/gfx/resource/sci_picfill.cpp b/engines/sci/gfx/resource/sci_picfill.cpp index e791231589..d72d6d2f88 100644 --- a/engines/sci/gfx/resource/sci_picfill.cpp +++ b/engines/sci/gfx/resource/sci_picfill.cpp @@ -56,9 +56,8 @@ static void FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, byte *bounds, - int legalcolor, int legalmask, int color, int priority, int drawenable, - int sci_titlebar_size) -{ + int legalcolor, int legalmask, int color, int priority, int drawenable, + int sci_titlebar_size) { int linewidth = pic->mode->xfact * 320; int miny = pic->mode->yfact * sci_titlebar_size; int maxy = pic->mode->yfact * 200; @@ -83,7 +82,8 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, #ifdef FILL_RECURSIVE_DEBUG if (!fillc) return; - else if (!fillmagc) { --fillc; + else if (!fillmagc) { + --fillc; } #endif /* defined(FILL_RECURSIVE_DEBUG) */ @@ -100,13 +100,13 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, proj_x = old_xl / pic->mode->xfact; proj_xl_bound = proj_x; - if (SCALED_CHECK(pic->aux_map[proj_ytotal + proj_xl_bound] & FRESH_PAINT)){ + if (SCALED_CHECK(pic->aux_map[proj_ytotal + proj_xl_bound] & FRESH_PAINT)) { while (proj_xl_bound - && pic->aux_map[proj_ytotal + proj_xl_bound - 1] & FRESH_PAINT) + && pic->aux_map[proj_ytotal + proj_xl_bound - 1] & FRESH_PAINT) --proj_xl_bound; } else { while (proj_xl_bound < 319 - && !(pic->aux_map[proj_ytotal + proj_xl_bound + 1] & FRESH_PAINT)) + && !(pic->aux_map[proj_ytotal + proj_xl_bound + 1] & FRESH_PAINT)) ++proj_xl_bound; if (proj_xl_bound < 319) @@ -114,19 +114,19 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, } if (proj_xl_bound == 319 - && !(pic->aux_map[proj_ytotal + proj_xl_bound] & FRESH_PAINT)) { + && !(pic->aux_map[proj_ytotal + proj_xl_bound] & FRESH_PAINT)) { PRINT_DEBUG0("ABRT because proj_xl_bound couldn't be found\n"); return; } - proj_xr_bound = (proj_xl_bound > proj_x)? proj_xl_bound : proj_x; + proj_xr_bound = (proj_xl_bound > proj_x) ? proj_xl_bound : proj_x; while ((proj_xr_bound < 319) - && pic->aux_map[proj_ytotal + proj_xr_bound + 1] & FRESH_PAINT) + && pic->aux_map[proj_ytotal + proj_xr_bound + 1] & FRESH_PAINT) ++proj_xr_bound; #ifdef FILL_RECURSIVE_DEBUG if (!fillmagc) { - fprintf(stderr,"l%d: {%d,%d} | ", proj_y, proj_xl_bound, proj_xr_bound); + fprintf(stderr, "l%d: {%d,%d} | ", proj_y, proj_xl_bound, proj_xr_bound); pic->aux_map[proj_y*320 + proj_xl_bound] |= 0x2; pic->aux_map[proj_y*320 + proj_xr_bound] |= 0x2; } @@ -139,7 +139,7 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, if (proj_xr_bound < 319) ++proj_xr_bound; proj_xr_bound *= pic->mode->xfact; - proj_xr_bound += pic->mode->xfact -1; + proj_xr_bound += pic->mode->xfact - 1; old_proj_y = proj_y; } @@ -150,30 +150,30 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, /* Now we have the projected limits, get the real ones: */ - xl = (old_xl > proj_xl_bound)? old_xl : proj_xl_bound; - if (!IS_BOUNDARY(xl, y+1, bounds[ytotal + xl])) { /* go left as far as possible */ - while (xl > proj_xl_bound && (!IS_BOUNDARY(xl-1, y+1, bounds[ytotal + xl - 1]))) + xl = (old_xl > proj_xl_bound) ? old_xl : proj_xl_bound; + if (!IS_BOUNDARY(xl, y + 1, bounds[ytotal + xl])) { /* go left as far as possible */ + while (xl > proj_xl_bound && (!IS_BOUNDARY(xl - 1, y + 1, bounds[ytotal + xl - 1]))) --xl; } else /* go right until the fillable area starts */ - while (xl < proj_xr_bound && (IS_BOUNDARY(xl, y+1, bounds[ytotal + xl]))) + while (xl < proj_xr_bound && (IS_BOUNDARY(xl, y + 1, bounds[ytotal + xl]))) ++xl; PRINT_DEBUG1("<%d,", xl); if ((xl > proj_xr_bound) - || (xl > old_xr)) { + || (xl > old_xr)) { PRINT_DEBUG0("ABRT because xl > xr_bound\n"); return; } - xr = (xl > old_xl)? xl : old_xl; - while (xr < proj_xr_bound && (!IS_BOUNDARY(xr+1, y+1, bounds[ytotal + xr + 1]))) + xr = (xl > old_xl) ? xl : old_xl; + while (xr < proj_xr_bound && (!IS_BOUNDARY(xr + 1, y + 1, bounds[ytotal + xr + 1]))) ++xr; PRINT_DEBUG1("%d> -> ", xr); - if (IS_BOUNDARY(xl, y+1, bounds[ytotal + xl])) { + if (IS_BOUNDARY(xl, y + 1, bounds[ytotal + xl])) { PRINT_DEBUG0("ABRT because xl illegal\n"); return; } @@ -203,14 +203,14 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, state = 0; xcont = xr + 1; while (xcont <= old_xr) { - if (IS_BOUNDARY(xcont, y+1, bounds[ytotal + xcont])) + if (IS_BOUNDARY(xcont, y + 1, bounds[ytotal + xcont])) state = xcont; else if (state) { /* recurse */ PRINT_DEBUG4("[%d[%d,%d],%d]: ", old_xl, xl, xr, old_xr); PRINT_DEBUG4("rec BRANCH %d [%d,%d] l%d\n", dy, state, xcont, y - dy); FILL_FUNCTION_RECURSIVE(pic, state, xcont, y - dy, dy, bounds, legalcolor, - legalmask, color, priority, drawenable, sci_titlebar_size); + legalmask, color, priority, drawenable, sci_titlebar_size); state = 0; } ++xcont; @@ -220,7 +220,7 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, /* left */ if (xl < old_xl - 1) { state = 0; - for (xcont = old_xl-1; xcont >= xl; xcont--) { + for (xcont = old_xl - 1; xcont >= xl; xcont--) { if (IS_BOUNDARY(xcont, y, bounds[oldytotal + xcont])) state = xcont; else if (state) { /* recurse */ @@ -228,8 +228,8 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, PRINT_DEBUG4("rec BACK-LEFT %d [%d,%d] l%d\n", -dy, state, xcont, y); FILL_FUNCTION_RECURSIVE(pic, xcont, state, y, -dy, bounds, - legalcolor, legalmask, color, priority, drawenable, - sci_titlebar_size); + legalcolor, legalmask, color, priority, drawenable, + sci_titlebar_size); state = 0; } } @@ -246,8 +246,8 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, PRINT_DEBUG4("rec BACK-RIGHT %d [%d,%d] l%d\n", -dy, state, xcont, y); FILL_FUNCTION_RECURSIVE(pic, state, xcont, y, -dy, bounds, - legalcolor, legalmask, color, priority, drawenable, - sci_titlebar_size); + legalcolor, legalmask, color, priority, drawenable, + sci_titlebar_size); state = 0; } } @@ -263,8 +263,7 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, static void FILL_FUNCTION(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, int control, int drawenable, - int sci_titlebar_size) -{ + int sci_titlebar_size) { int linewidth = pic->mode->xfact * 320; int x, y; int xl, xr; @@ -291,8 +290,8 @@ FILL_FUNCTION(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, in } AUXBUF_FILL(pic, x_320, y_200, original_drawenable, - (drawenable & GFX_MASK_CONTROL)? control : 0, - sci_titlebar_size); + (drawenable & GFX_MASK_CONTROL) ? control : 0, + sci_titlebar_size); #ifdef DRAW_SCALED _gfxr_auxbuf_spread(pic, &min_x, &min_y, &max_x, &max_y); @@ -321,7 +320,7 @@ FILL_FUNCTION(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, in if ((color & 0xf) == 0xf /* When dithering with white, do more ** conservative checks */ - || (color & 0xf0) == 0xf0) + || (color & 0xf0) == 0xf0) legalcolor = 0xff; else legalcolor = 0xf0; /* Only check the second color */ @@ -359,16 +358,16 @@ FILL_FUNCTION(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, in proj_xl_bound = proj_x; if (SCALED_CHECK(pic->aux_map[proj_ytotal + proj_xl_bound] & FRESH_PAINT)) { while (proj_xl_bound - && SCALED_CHECK(pic->aux_map[proj_ytotal + proj_xl_bound - 1] & FRESH_PAINT)) + && SCALED_CHECK(pic->aux_map[proj_ytotal + proj_xl_bound - 1] & FRESH_PAINT)) --proj_xl_bound; } else while (proj_xl_bound < 319 - && SCALED_CHECK(!(pic->aux_map[proj_ytotal + proj_xl_bound + 1] & FRESH_PAINT))) + && SCALED_CHECK(!(pic->aux_map[proj_ytotal + proj_xl_bound + 1] & FRESH_PAINT))) ++proj_xl_bound; - proj_xr_bound = (proj_xl_bound > proj_x)? proj_xl_bound : proj_x; + proj_xr_bound = (proj_xl_bound > proj_x) ? proj_xl_bound : proj_x; while ((proj_xr_bound < 319) && - SCALED_CHECK(pic->aux_map[proj_ytotal + proj_xr_bound + 1] & FRESH_PAINT)) + SCALED_CHECK(pic->aux_map[proj_ytotal + proj_xr_bound + 1] & FRESH_PAINT)) ++proj_xr_bound; proj_xl = proj_xl_bound; @@ -376,18 +375,18 @@ FILL_FUNCTION(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, in proj_xl_bound *= pic->mode->xfact; if (proj_xl_bound) - proj_xl_bound -= pic->mode->xfact -1; + proj_xl_bound -= pic->mode->xfact - 1; if (proj_xr_bound < 319) ++proj_xr_bound; proj_xr_bound *= pic->mode->xfact; - proj_xr_bound += pic->mode->xfact -1; + proj_xr_bound += pic->mode->xfact - 1; #endif xl = x; - while (xl > proj_xl_bound && (!IS_BOUNDARY(xl-1, y, bounds[ytotal + xl -1]))) + while (xl > proj_xl_bound && (!IS_BOUNDARY(xl - 1, y, bounds[ytotal + xl -1]))) --xl; - while (x < proj_xr_bound && (!IS_BOUNDARY(x+1, y, bounds[ytotal + x + 1]))) + while (x < proj_xr_bound && (!IS_BOUNDARY(x + 1, y, bounds[ytotal + x + 1]))) ++x; xr = x; @@ -398,18 +397,18 @@ FILL_FUNCTION(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, in memset(pic->priority_map->index_data + ytotal + xl, priority, xr - xl + 1); FILL_FUNCTION_RECURSIVE(pic, xl, xr, y, -1, bounds, legalcolor, legalmask, color, priority, drawenable, - sci_titlebar_size); - FILL_FUNCTION_RECURSIVE(pic, xl, xr, y, +1, bounds, legalcolor, legalmask, color, priority, drawenable, - sci_titlebar_size); + sci_titlebar_size); + FILL_FUNCTION_RECURSIVE(pic, xl, xr, y, + 1, bounds, legalcolor, legalmask, color, priority, drawenable, + sci_titlebar_size); } /* Now finish the aux buffer */ bitmask = drawenable & - ( - ((color != 0xff)? 1 : 0) - | ((priority)? 2 : 0) - | ((control)? 4 : 0) - ); + ( + ((color != 0xff) ? 1 : 0) + | ((priority) ? 2 : 0) + | ((control) ? 4 : 0) + ); #ifdef DRAW_SCALED # ifdef FILL_RECURSIVE_DEBUG diff --git a/engines/sci/gfx/resource/sci_picfill_aux.cpp b/engines/sci/gfx/resource/sci_picfill_aux.cpp index 70d8a822da..5fd2f2dac9 100644 --- a/engines/sci/gfx/resource/sci_picfill_aux.cpp +++ b/engines/sci/gfx/resource/sci_picfill_aux.cpp @@ -34,8 +34,7 @@ static void AUXBUF_FILL_HELPER(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, - int clipmask, int control, int sci_titlebar_size) -{ + int clipmask, int control, int sci_titlebar_size) { int xl, xr; int oldytotal = y * 320; #ifdef DRAW_SCALED @@ -65,7 +64,7 @@ AUXBUF_FILL_HELPER(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, if (xl > old_xr) /* No fillable strip above the last one */ return; - if ((ytotal + xl) < 0) { fprintf(stderr,"AARGH-%d\n", __LINE__); BREAKPOINT(); } + if ((ytotal + xl) < 0) { fprintf(stderr, "AARGH-%d\n", __LINE__); BREAKPOINT(); } xr = xl; while (xr < 320 && !(pic->aux_map[ytotal + xr] & clipmask)) { @@ -73,8 +72,9 @@ AUXBUF_FILL_HELPER(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, ++xr; } - if ((ytotal + xr) > 64000) { fprintf(stderr,"AARGH-%d\n", __LINE__); - BREAKPOINT(); + if ((ytotal + xr) > 64000) { + fprintf(stderr, "AARGH-%d\n", __LINE__); + BREAKPOINT(); } --xr; @@ -84,7 +84,7 @@ AUXBUF_FILL_HELPER(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, /* Check whether we need to recurse on branches in the same direction */ if ((y > sci_titlebar_size && dy < 0) - || (y < 199 && dy > 0)) { + || (y < 199 && dy > 0)) { state = 0; xcont = xr + 1; @@ -94,7 +94,7 @@ AUXBUF_FILL_HELPER(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, else if (!state) { /* recurse */ state = 1; AUXBUF_FILL_HELPER(pic, xcont, old_xr, - y - dy, dy, clipmask, control, sci_titlebar_size); + y - dy, dy, clipmask, control, sci_titlebar_size); } ++xcont; } @@ -109,7 +109,7 @@ AUXBUF_FILL_HELPER(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, state = xcont; else if (state) { /* recurse */ AUXBUF_FILL_HELPER(pic, xcont, state, - y, -dy, clipmask, control, sci_titlebar_size); + y, -dy, clipmask, control, sci_titlebar_size); state = 0; } } @@ -123,17 +123,17 @@ AUXBUF_FILL_HELPER(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, state = xcont; else if (state) { /* recurse */ AUXBUF_FILL_HELPER(pic, state, xcont, - y, -dy, clipmask, control, sci_titlebar_size); + y, -dy, clipmask, control, sci_titlebar_size); state = 0; } } } - if ((ytotal + xl) < 0) { fprintf(stderr,"AARGH-%d\n", __LINE__); BREAKPOINT() } - if ((ytotal + xr+1) > 64000) { fprintf(stderr,"AARGH-%d\n", __LINE__); BREAKPOINT(); } + if ((ytotal + xl) < 0) { fprintf(stderr, "AARGH-%d\n", __LINE__); BREAKPOINT() } + if ((ytotal + xr + 1) > 64000) { fprintf(stderr, "AARGH-%d\n", __LINE__); BREAKPOINT(); } if (control) - memset(pic->control_map->index_data + ytotal + xl, control, xr-xl+1); + memset(pic->control_map->index_data + ytotal + xl, control, xr - xl + 1); oldytotal = ytotal; old_xr = xr; @@ -144,8 +144,7 @@ AUXBUF_FILL_HELPER(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, static void -AUXBUF_FILL(gfxr_pic_t *pic, int x, int y, int clipmask, int control, int sci_titlebar_size) -{ +AUXBUF_FILL(gfxr_pic_t *pic, int x, int y, int clipmask, int control, int sci_titlebar_size) { /* Fills the aux buffer and the control map (if control != 0) */ int xl, xr; int ytotal = y * 320; @@ -198,7 +197,7 @@ AUXBUF_FILL(gfxr_pic_t *pic, int x, int y, int clipmask, int control, int sci_ti AUXBUF_FILL_HELPER(pic, xl, xr, y, -1, clipmask, control, sci_titlebar_size); if (y < 199) - AUXBUF_FILL_HELPER(pic, xl, xr, y, +1, clipmask, control, sci_titlebar_size); + AUXBUF_FILL_HELPER(pic, xl, xr, y, + 1, clipmask, control, sci_titlebar_size); } diff --git a/engines/sci/gfx/resource/sci_resmgr.cpp b/engines/sci/gfx/resource/sci_resmgr.cpp index ad756afecd..5ecc05a7ed 100644 --- a/engines/sci/gfx/resource/sci_resmgr.cpp +++ b/engines/sci/gfx/resource/sci_resmgr.cpp @@ -33,9 +33,8 @@ int gfxr_interpreter_options_hash(gfx_resource_type_t type, int version, - gfx_options_t *options, - void *internal, int palette) -{ + gfx_options_t *options, + void *internal, int palette) { switch (type) { case GFX_RESOURCE_TYPE_VIEW: @@ -45,11 +44,11 @@ gfxr_interpreter_options_hash(gfx_resource_type_t type, int version, if (version >= SCI_VERSION_01_VGA) return options->pic_port_bounds.y; else - return (options->pic0_unscaled)? 0x10000 : - (options->pic0_dither_mode << 12) - | (options->pic0_dither_pattern << 8) - | (options->pic0_brush_mode << 4) - | (options->pic0_line_mode); + return (options->pic0_unscaled) ? 0x10000 : + (options->pic0_dither_mode << 12) + | (options->pic0_dither_pattern << 8) + | (options->pic0_brush_mode << 4) + | (options->pic0_line_mode); case GFX_RESOURCE_TYPE_FONT: return 0; @@ -66,32 +65,29 @@ gfxr_interpreter_options_hash(gfx_resource_type_t type, int version, gfxr_pic_t * -gfxr_interpreter_init_pic(int version, gfx_mode_t *mode, int ID, void *internal) -{ +gfxr_interpreter_init_pic(int version, gfx_mode_t *mode, int ID, void *internal) { return gfxr_init_pic(mode, ID, version >= SCI_VERSION_01_VGA); } void -gfxr_interpreter_clear_pic(int version, gfxr_pic_t *pic, void *internal) -{ +gfxr_interpreter_clear_pic(int version, gfxr_pic_t *pic, void *internal) { gfxr_clear_pic0(pic, SCI_TITLEBAR_SIZE); } int gfxr_interpreter_calculate_pic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic, - int flags, int default_palette, int nr, void *internal) -{ + int flags, int default_palette, int nr, void *internal) { resource_mgr_t *resmgr = (resource_mgr_t *) state->misc_payload; resource_t *res = scir_find_resource(resmgr, sci_pic, nr, 0); int need_unscaled = unscaled_pic != NULL; gfxr_pic0_params_t style, basic_style; - + basic_style.line_mode = GFX_LINE_MODE_CORRECT; basic_style.brush_mode = GFX_BRUSH_MODE_SCALED; basic_style.pic_port_bounds = state->options->pic_port_bounds; - + style.line_mode = state->options->pic0_line_mode; style.brush_mode = state->options->pic0_brush_mode; style.pic_port_bounds = state->options->pic_port_bounds; @@ -100,34 +96,33 @@ gfxr_interpreter_calculate_pic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gf return GFX_ERROR; if (state->version >= SCI_VERSION_01_VGA) { - if (need_unscaled) - { + if (need_unscaled) { if (state->version == SCI_VERSION_1_1) gfxr_draw_pic11(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id, - state->static_palette, state->static_palette_entries); + state->static_palette, state->static_palette_entries); else gfxr_draw_pic01(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id, 1, - state->static_palette, state->static_palette_entries); + state->static_palette, state->static_palette_entries); } if (scaled_pic && scaled_pic->undithered_buffer) memcpy(scaled_pic->visual_map->index_data, scaled_pic->undithered_buffer, scaled_pic->undithered_buffer_size); if (state->version == SCI_VERSION_1_1) gfxr_draw_pic11(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id, - state->static_palette, state->static_palette_entries); + state->static_palette, state->static_palette_entries); else gfxr_draw_pic01(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id, state->version, - state->static_palette, state->static_palette_entries); + state->static_palette, state->static_palette_entries); } else { if (need_unscaled) gfxr_draw_pic01(unscaled_pic, flags, default_palette, res->size, res->data, &basic_style, res->id, 0, - state->static_palette, state->static_palette_entries); + state->static_palette, state->static_palette_entries); if (scaled_pic && scaled_pic->undithered_buffer) memcpy(scaled_pic->visual_map->index_data, scaled_pic->undithered_buffer, scaled_pic->undithered_buffer_size); gfxr_draw_pic01(scaled_pic, flags, default_palette, res->size, res->data, &style, res->id, 0, - state->static_palette, state->static_palette_entries); + state->static_palette, state->static_palette_entries); if (need_unscaled) gfxr_remove_artifacts_pic0(scaled_pic, unscaled_pic); @@ -151,27 +146,23 @@ gfxr_interpreter_calculate_pic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gf void -gfxr_palettize_view(gfxr_view_t *view, gfx_pixmap_color_t *source, int source_entries) -{ - int i; - - for (i=0;i<MIN(view->colors_nr,source_entries);i++) - { - if ((view->colors[i].r == 0) && - (view->colors[i].g == 0) && - (view->colors[i].b == 0)) - { - view->colors[i] = source[i]; +gfxr_palettize_view(gfxr_view_t *view, gfx_pixmap_color_t *source, int source_entries) { + int i; + + for (i = 0;i < MIN(view->colors_nr, source_entries);i++) { + if ((view->colors[i].r == 0) && + (view->colors[i].g == 0) && + (view->colors[i].b == 0)) { + view->colors[i] = source[i]; + } } - } } gfxr_view_t * gfxr_draw_view11(int id, byte *resource, int size); gfxr_view_t * -gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int palette) -{ +gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int palette) { resource_mgr_t *resmgr = (resource_mgr_t *) state->misc_payload; resource_t *res = scir_find_resource(resmgr, sci_view, nr, 0); int resid = GFXR_RES_ID(GFX_RESOURCE_TYPE_VIEW, nr); @@ -180,43 +171,39 @@ gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int pal if (!res || !res->data) return NULL; - if (state->version < SCI_VERSION_01) palette=-1; + if (state->version < SCI_VERSION_01) palette = -1; - switch (state->version) - { + switch (state->version) { case SCI_VERSION_0: case SCI_VERSION_01: - result=gfxr_draw_view0(resid, res->data, res->size, palette); + result = gfxr_draw_view0(resid, res->data, res->size, palette); break; case SCI_VERSION_01_VGA: case SCI_VERSION_01_VGA_ODD: case SCI_VERSION_1_EARLY: case SCI_VERSION_1_LATE: - result=gfxr_draw_view1(resid, res->data, res->size, state->static_palette, state->static_palette_entries); + result = gfxr_draw_view1(resid, res->data, res->size, state->static_palette, state->static_palette_entries); break; case SCI_VERSION_1_1: case SCI_VERSION_32: - result=gfxr_draw_view11(resid, res->data, res->size); + result = gfxr_draw_view11(resid, res->data, res->size); break; } - if (state->version >= SCI_VERSION_01_VGA) - { - if (!result->colors) - { + if (state->version >= SCI_VERSION_01_VGA) { + if (!result->colors) { result->colors = (gfx_pixmap_color_t*)sci_malloc(sizeof(gfx_pixmap_color_t) * state->static_palette_entries); memset(result->colors, 0, sizeof(gfx_pixmap_color_t) * state->static_palette_entries); result->colors_nr = state->static_palette_entries; - } - gfxr_palettize_view(result, state->static_palette, state->static_palette_entries); + } + gfxr_palettize_view(result, state->static_palette, state->static_palette_entries); } return result; } gfx_bitmap_font_t * -gfxr_interpreter_get_font(gfx_resstate_t *state, int nr, void *internal) -{ +gfxr_interpreter_get_font(gfx_resstate_t *state, int nr, void *internal) { resource_mgr_t *resmgr = (resource_mgr_t *) state->misc_payload; resource_t *res = scir_find_resource(resmgr, sci_font, nr, 0); if (!res || !res->data) @@ -227,8 +214,7 @@ gfxr_interpreter_get_font(gfx_resstate_t *state, int nr, void *internal) gfx_pixmap_t * -gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal) -{ +gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal) { resource_mgr_t *resmgr = (resource_mgr_t *) state->misc_payload; resource_t *res = scir_find_resource(resmgr, sci_cursor, nr, 0); int resid = GFXR_RES_ID(GFX_RESOURCE_TYPE_CURSOR, nr); @@ -250,8 +236,7 @@ gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal) int * gfxr_interpreter_get_resources(gfx_resstate_t *state, gfx_resource_type_t type, - int version, int *entries_nr, void *internal) -{ + int version, int *entries_nr, void *internal) { resource_mgr_t *resmgr = (resource_mgr_t *) state->misc_payload; int restype; int *resources; @@ -260,16 +245,20 @@ gfxr_interpreter_get_resources(gfx_resstate_t *state, gfx_resource_type_t type, int i; switch (type) { - case GFX_RESOURCE_TYPE_VIEW: restype = sci_view; + case GFX_RESOURCE_TYPE_VIEW: + restype = sci_view; break; - case GFX_RESOURCE_TYPE_PIC: restype = sci_pic; + case GFX_RESOURCE_TYPE_PIC: + restype = sci_pic; break; - case GFX_RESOURCE_TYPE_CURSOR: restype = sci_cursor; + case GFX_RESOURCE_TYPE_CURSOR: + restype = sci_cursor; break; - case GFX_RESOURCE_TYPE_FONT: restype = sci_font; + case GFX_RESOURCE_TYPE_FONT: + restype = sci_font; break; default: @@ -290,8 +279,7 @@ gfxr_interpreter_get_resources(gfx_resstate_t *state, gfx_resource_type_t type, } gfx_pixmap_color_t * -gfxr_interpreter_get_static_palette(gfx_resstate_t *state, int version, int *colors_nr, void *internal) -{ +gfxr_interpreter_get_static_palette(gfx_resstate_t *state, int version, int *colors_nr, void *internal) { if (version >= SCI_VERSION_01_VGA) return gfxr_interpreter_get_palette(state, version, colors_nr, internal, 999); @@ -300,9 +288,8 @@ gfxr_interpreter_get_static_palette(gfx_resstate_t *state, int version, int *col } gfx_pixmap_color_t * -gfxr_interpreter_get_palette(gfx_resstate_t *state, int version, int *colors_nr, - void *internal, int nr) -{ +gfxr_interpreter_get_palette(gfx_resstate_t *state, int version, int *colors_nr, + void *internal, int nr) { resource_mgr_t *resmgr = (resource_mgr_t *) state->misc_payload; resource_t *res; @@ -313,8 +300,7 @@ gfxr_interpreter_get_palette(gfx_resstate_t *state, int version, int *colors_nr, if (!res || !res->data) return NULL; - switch (version) - { + switch (version) { case SCI_VERSION_01_VGA : case SCI_VERSION_01_VGA_ODD : case SCI_VERSION_1_EARLY : @@ -332,8 +318,7 @@ gfxr_interpreter_get_palette(gfx_resstate_t *state, int version, int *colors_nr, } int -gfxr_interpreter_needs_multicolored_pointers(int version, void *internal) -{ +gfxr_interpreter_needs_multicolored_pointers(int version, void *internal) { return (version > SCI_VERSION_1); } diff --git a/engines/sci/gfx/resource/sci_view_0.cpp b/engines/sci/gfx/resource/sci_view_0.cpp index bea6377285..a89fbe8b17 100644 --- a/engines/sci/gfx/resource/sci_view_0.cpp +++ b/engines/sci/gfx/resource/sci_view_0.cpp @@ -38,15 +38,14 @@ gfx_pixmap_t * -gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size, gfxr_view_t *view, int mirrored) -{ +gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size, gfxr_view_t *view, int mirrored) { int xl = get_int_16(resource); int yl = get_int_16(resource + 2); int xhot = ((signed char *) resource)[4]; int yhot = ((signed char *) resource)[5]; int color_key = resource[6]; int pos = 7; - int writepos = mirrored? xl : 0; + int writepos = mirrored ? xl : 0; int pixmap_size = xl * yl; int line_base = 0; gfx_pixmap_t *retval = gfx_pixmap_alloc_index_data(gfx_new_pixmap(xl, yl, id, loop, cel)); @@ -54,15 +53,14 @@ gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size, gfxr_view_t retval->color_key = 255; /* Pick something larger than 15 */ - retval->xoffset = mirrored? xhot : -xhot; + retval->xoffset = mirrored ? xhot : -xhot; retval->yoffset = -yhot; if (view) { retval->colors = view->colors; retval->colors_nr = view->colors_nr; retval->flags |= GFX_PIXMAP_FLAG_EXTERNAL_PALETTE; - } else - { + } else { retval->colors = gfx_sci0_image_colors[sci0_palette]; retval->colors_nr = GFX_SCI0_IMAGE_COLORS_NR; retval->flags |= GFX_PIXMAP_FLAG_EXTERNAL_PALETTE; @@ -131,8 +129,7 @@ gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size, gfxr_view_t } static int -gfxr_draw_loop0(gfxr_loop_t *dest, int id, int loop, byte *resource, int offset, int size, gfxr_view_t *view, int mirrored) -{ +gfxr_draw_loop0(gfxr_loop_t *dest, int id, int loop, byte *resource, int offset, int size, gfxr_view_t *view, int mirrored) { int i; int cels_nr = get_int_16(resource + offset); @@ -179,8 +176,7 @@ gfxr_draw_loop0(gfxr_loop_t *dest, int id, int loop, byte *resource, int offset, #define V0_MIRROR_LIST_OFFSET 2 gfxr_view_t * -gfxr_draw_view0(int id, byte *resource, int size, int palette) -{ +gfxr_draw_view0(int id, byte *resource, int size, int palette) { int i; gfxr_view_t *view; int mirror_bitpos = 1; @@ -202,8 +198,7 @@ gfxr_draw_view0(int id, byte *resource, int size, int palette) view->flags = GFX_PIXMAP_FLAG_EXTERNAL_PALETTE; view->colors = gfx_sci0_image_colors[sci0_palette]; - if ((palette_ofs)&&(palette>=0)) - { + 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++) @@ -218,7 +213,7 @@ gfxr_draw_view0(int id, byte *resource, int size, int palette) return NULL; } - view->loops = (gfxr_loop_t*)sci_malloc(sizeof (gfxr_loop_t) * ((view->loops_nr)? view->loops_nr : 1)); /* Alloc 1 if no loop */ + view->loops = (gfxr_loop_t*)sci_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 error_token = 0; diff --git a/engines/sci/gfx/resource/sci_view_1.cpp b/engines/sci/gfx/resource/sci_view_1.cpp index d0dd660f2f..4d2daa0462 100644 --- a/engines/sci/gfx/resource/sci_view_1.cpp +++ b/engines/sci/gfx/resource/sci_view_1.cpp @@ -42,18 +42,17 @@ #define NEXT_RUNLENGTH_BYTE(n) \ if (literal_pos == runlength_pos) \ literal_pos += n; \ - runlength_pos += n; + runlength_pos += n; #define NEXT_LITERAL_BYTE(n) \ if (literal_pos == runlength_pos) \ runlength_pos += n; \ - literal_pos += n; + literal_pos += n; static int -decompress_sci_view(int id, int loop, int cel, byte *resource, byte *dest, int mirrored, int pixmap_size, int size, - int runlength_pos, int literal_pos, int xl, int yl, int color_key) -{ - int writepos = mirrored? xl : 0; +decompress_sci_view(int id, int loop, int cel, byte *resource, byte *dest, int mirrored, int pixmap_size, int size, + int runlength_pos, int literal_pos, int xl, int yl, int color_key) { + int writepos = mirrored ? xl : 0; if (mirrored) { int linebase = 0; @@ -69,40 +68,36 @@ decompress_sci_view(int id, int loop, int cel, byte *resource, byte *dest, int m if (op & V1_RLE) { bytes = op & 0x3f; op &= (V1_RLE | V1_RLE_BG); - readbytes = (op & V1_RLE_BG)? 0 : 1; + readbytes = (op & V1_RLE_BG) ? 0 : 1; } else { readbytes = bytes = op & 0x3f; op = 0; } - if (runlength_pos + readbytes > size) - { + if (runlength_pos + readbytes > size) { GFXWARN("View %02x:(%d/%d) requires %d bytes to be read when %d are available at pos %d\n", - id, loop, cel, readbytes, size - runlength_pos, runlength_pos-1); + id, loop, cel, readbytes, size - runlength_pos, runlength_pos - 1); return 1; } -/* - if (writepos - bytes < 0) { - GFXWARN("View %02x:(%d/%d) describes more bytes than needed: %d/%d bytes at rel. offset 0x%04x\n", - id, loop, cel, writepos - bytes, pixmap_size, pos - 1); - bytes = pixmap_size - writepos; - } -*/ - if (op==V1_RLE) - { + /* + if (writepos - bytes < 0) { + GFXWARN("View %02x:(%d/%d) describes more bytes than needed: %d/%d bytes at rel. offset 0x%04x\n", + id, loop, cel, writepos - bytes, pixmap_size, pos - 1); + bytes = pixmap_size - writepos; + } + */ + if (op == V1_RLE) { color = resource[literal_pos]; NEXT_LITERAL_BYTE(1); } - if (!op && literal_pos + bytes > size) - { + if (!op && literal_pos + bytes > size) { GFXWARN("View %02x:(%d/%d) requires %d bytes to be read when %d are available at pos %d\n", - id, loop, cel, bytes, size - literal_pos, literal_pos-1); + id, loop, cel, bytes, size - literal_pos, literal_pos - 1); return 1; } - while (bytes--) - { + while (bytes--) { if (op) { if (op & V1_RLE_BG) { writepos--; @@ -115,17 +110,15 @@ decompress_sci_view(int id, int loop, int cel, byte *resource, byte *dest, int m writepos--; *(dest + writepos) = *(resource + literal_pos); NEXT_LITERAL_BYTE(1); - + } - if (writepos == linebase) - { - writepos+=2*xl; - linebase+=xl; + if (writepos == linebase) { + writepos += 2 * xl; + linebase += xl; } } } - } - else { + } else { while (writepos < pixmap_size && literal_pos < size && runlength_pos < size) { int op = resource[runlength_pos]; int bytes; @@ -136,7 +129,7 @@ decompress_sci_view(int id, int loop, int cel, byte *resource, byte *dest, int m if (op & V1_RLE) { bytes = op & 0x3f; op &= (V1_RLE | V1_RLE_BG); - readbytes = (op & V1_RLE_BG)? 0 : 1; + readbytes = (op & V1_RLE_BG) ? 0 : 1; } else { readbytes = bytes = op & 0x3f; op = 0; @@ -148,22 +141,20 @@ decompress_sci_view(int id, int loop, int cel, byte *resource, byte *dest, int m if (writepos + bytes > pixmap_size) { GFXWARN("View %02x:(%d/%d) describes more bytes than needed: %d/%d bytes at rel. offset 0x%04x\n", - id, loop, cel, writepos-bytes, pixmap_size, runlength_pos - 1); + id, loop, cel, writepos - bytes, pixmap_size, runlength_pos - 1); bytes = pixmap_size - writepos; } - if (!op && literal_pos + bytes > size) - { + if (!op && literal_pos + bytes > size) { GFXWARN("View %02x:(%d/%d) requires %d bytes to be read when %d are available at pos %d\n", - id, loop, cel, bytes, size - literal_pos, literal_pos-1); + id, loop, cel, bytes, size - literal_pos, literal_pos - 1); return 1; } - if (writepos + bytes > pixmap_size) - { + if (writepos + bytes > pixmap_size) { GFXWARN("Writing out of bounds: %d bytes at %d > size %d\n", bytes, writepos, pixmap_size); } - + if (op) { if (op & V1_RLE_BG) memset(dest + writepos, color_key, bytes); @@ -187,10 +178,9 @@ decompress_sci_view(int id, int loop, int cel, byte *resource, byte *dest, int m } static int -decompress_sci_view_amiga(int id, int loop, int cel, byte *resource, byte *dest, int mirrored, int pixmap_size, int size, - int pos, int xl, int yl, int color_key) -{ - int writepos = mirrored? xl - 1 : 0; +decompress_sci_view_amiga(int id, int loop, int cel, byte *resource, byte *dest, int mirrored, int pixmap_size, int size, + int pos, int xl, int yl, int color_key) { + int writepos = mirrored ? xl - 1 : 0; while (writepos < pixmap_size && pos < size) { int op = resource[pos++]; @@ -213,8 +203,7 @@ decompress_sci_view_amiga(int id, int loop, int cel, byte *resource, byte *dest, /* Then move to the end of next line */ writepos += 2 * xl; - if (writepos >= pixmap_size && bytes) - { + if (writepos >= pixmap_size && bytes) { GFXWARN("View %02x:(%d/%d) writing out of bounds\n", id, loop, cel); break; } @@ -223,7 +212,7 @@ decompress_sci_view_amiga(int id, int loop, int cel, byte *resource, byte *dest, } else { if (writepos + bytes > pixmap_size) { GFXWARN("View %02x:(%d/%d) describes more bytes than needed: %d/%d bytes at rel. offset 0x%04x\n", - id, loop, cel, writepos-bytes, pixmap_size, pos - 1); + id, loop, cel, writepos - bytes, pixmap_size, pos - 1); bytes = pixmap_size - writepos; } memset(dest + writepos, color, bytes); @@ -232,16 +221,15 @@ decompress_sci_view_amiga(int id, int loop, int cel, byte *resource, byte *dest, } if (writepos < pixmap_size) { - GFXWARN("View %02x:(%d/%d) not enough pixel data in view\n", id, loop, cel); - return 1; + GFXWARN("View %02x:(%d/%d) not enough pixel data in view\n", id, loop, cel); + return 1; } 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) -{ +gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, int size, gfxr_view_t *view, int amiga_game) { int xl = get_int_16(resource); int yl = get_int_16(resource + 2); int xhot = (gint8) resource[4]; @@ -253,14 +241,14 @@ gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, int size int decompress_failed; retval->color_key = resource[6]; - retval->xoffset = (mirrored)? xhot : -xhot; + retval->xoffset = (mirrored) ? xhot : -xhot; retval->yoffset = -yhot; if (view) { retval->colors = view->colors; retval->colors_nr = view->colors_nr; } - + retval->flags |= GFX_PIXMAP_FLAG_EXTERNAL_PALETTE; if (xl <= 0 || yl <= 0) { @@ -271,12 +259,12 @@ gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, int size if (amiga_game) decompress_failed = decompress_sci_view_amiga(id, loop, cel, - resource, dest, mirrored, pixmap_size, size, pos, - xl, yl, retval->color_key); + resource, dest, mirrored, pixmap_size, size, pos, + 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); + resource, dest, mirrored, pixmap_size, size, pos, + pos, xl, yl, retval->color_key); if (decompress_failed) { gfx_free_pixmap(NULL, retval); @@ -287,8 +275,7 @@ gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, int size } static int -gfxr_draw_loop1(gfxr_loop_t *dest, int id, int loop, int mirrored, byte *resource, int offset, int size, gfxr_view_t *view, int amiga_game) -{ +gfxr_draw_loop1(gfxr_loop_t *dest, int id, int loop, int mirrored, byte *resource, int offset, int size, gfxr_view_t *view, int amiga_game) { int i; int cels_nr = get_int_16(resource + offset); @@ -335,8 +322,7 @@ gfxr_draw_loop1(gfxr_loop_t *dest, int id, int loop, int mirrored, byte *resourc gfxr_view_t * gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_t *static_pal, - int static_pal_nr) -{ + int static_pal_nr) { int i; int palette_offset; gfxr_view_t *view; @@ -362,29 +348,28 @@ gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_t *static_pal return NULL; } -/* fprintf(stderr, "View flags are 0x%02x\n", resource[3]);*/ + /* 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]); - } -*/ + /* + 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); - free(view); - return NULL; - } - if (!(view->colors = gfxr_read_pal1(id, &(view->colors_nr), - resource + palette_offset, size - palette_offset))) { - GFXERROR("view %04x: Palette reading failed. Aborting...\n", id); - free(view); - return NULL; - } + if (palette_offset > 0) { + if (palette_offset > size) { + GFXERROR("Palette is outside of view %04x\n", id); + free(view); + return NULL; + } + if (!(view->colors = gfxr_read_pal1(id, &(view->colors_nr), + resource + palette_offset, size - palette_offset))) { + GFXERROR("view %04x: Palette reading failed. Aborting...\n", id); + free(view); + return NULL; + } } else if (static_pal_nr == GFX_SCI1_AMIGA_COLORS_NR) { /* Assume we're running an amiga game. */ amiga_game = 1; @@ -392,12 +377,12 @@ gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_t *static_pal view->colors_nr = static_pal_nr; view->flags |= GFX_PIXMAP_FLAG_EXTERNAL_PALETTE; } else { - GFXWARN("view %04x: Doesn't have a palette. Can FreeSCI handle this?\n", view->ID); - view->colors = NULL; - view->colors_nr = 0; + GFXWARN("view %04x: Doesn't have a palette. Can FreeSCI handle this?\n", view->ID); + view->colors = NULL; + view->colors_nr = 0; } - view->loops = (gfxr_loop_t*)sci_malloc(sizeof (gfxr_loop_t) * view->loops_nr); + view->loops = (gfxr_loop_t*)sci_malloc(sizeof(gfxr_loop_t) * view->loops_nr); for (i = 0; i < view->loops_nr; i++) { int error_token = 0; @@ -408,8 +393,8 @@ gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_t *static_pal error_token = 1; } - if (error_token || gfxr_draw_loop1(view->loops + i, id, i, mirror_mask & (1<<i), - resource, loop_offset, size, view, amiga_game)) { + if (error_token || gfxr_draw_loop1(view->loops + i, id, i, mirror_mask & (1 << i), + resource, loop_offset, size, view, amiga_game)) { /* An error occured */ view->loops_nr = i; gfxr_free_view(NULL, view); @@ -440,8 +425,7 @@ gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_t *static_pal #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) -{ +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 = get_uint_16(cel_base + V2_CEL_WIDTH); int yl = get_uint_16(cel_base + V2_CEL_HEIGHT); int xdisplace = get_uint_16(cel_base + V2_X_DISPLACEMENT); @@ -449,20 +433,20 @@ gfxr_draw_cel11(int id, int loop, int cel, int mirrored, byte *resource_base, by int runlength_offset = get_uint_16(cel_base + V2_RUNLENGTH_OFFSET); int literal_offset = get_uint_16(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->xoffset = (mirrored) ? xdisplace : -xdisplace; retval->yoffset = -ydisplace; if (view) { retval->colors = view->colors; retval->colors_nr = view->colors_nr; } - + retval->flags |= GFX_PIXMAP_FLAG_EXTERNAL_PALETTE; if (xl <= 0 || yl <= 0) { @@ -472,7 +456,7 @@ gfxr_draw_cel11(int id, int loop, int cel, int mirrored, byte *resource_base, by } decompress_failed = decompress_sci_view(id, loop, cel, resource_base, dest, mirrored, pixmap_size, size, - runlength_offset, literal_offset, xl, yl, retval->color_key); + runlength_offset, literal_offset, xl, yl, retval->color_key); if (decompress_failed) { gfx_free_pixmap(NULL, retval); @@ -484,17 +468,15 @@ gfxr_draw_cel11(int id, int loop, int cel, int mirrored, byte *resource_base, by 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) -{ + gfxr_loop_t *result, gfxr_view_t *view, int bytes_per_cel) { byte *seeker = loop_base; int i; result->cels_nr = cels_nr; result->cels = (gfx_pixmap_t **) - sci_malloc(sizeof(gfx_pixmap_t *) * cels_nr); + sci_malloc(sizeof(gfx_pixmap_t *) * cels_nr); - for (i = 0; i < cels_nr; i++) - { + for (i = 0; i < cels_nr; i++) { result->cels[i] = gfxr_draw_cel11(id, loop, i, mirrored, resource_base, seeker, size, view); seeker += bytes_per_cel; } @@ -503,10 +485,9 @@ gfxr_draw_loop11(int id, int loop, int mirrored, byte *resource_base, byte *loop } gfxr_view_t * -gfxr_draw_view11(int id, byte *resource, int size) -{ +gfxr_draw_view11(int id, byte *resource, int size) { gfxr_view_t *view; - int header_size = get_uint_16(resource + V2_HEADER_SIZE); + int header_size = get_uint_16(resource + V2_HEADER_SIZE); int palette_offset = get_uint_16(resource + V2_PALETTE_OFFSET); int bytes_per_loop = resource[V2_BYTES_PER_LOOP]; int loops_num = resource[V2_LOOPS_NUM]; @@ -524,11 +505,10 @@ gfxr_draw_view11(int id, byte *resource, int size) view->loops = (gfxr_loop_t *)calloc(view->loops_nr, sizeof(gfxr_loop_t)); /* There is no indication of size here, but this is certainly large enough */ - view->colors = gfxr_read_pal11(id, &view->colors_nr, resource + palette_offset, 1284); - + view->colors = gfxr_read_pal11(id, &view->colors_nr, resource + palette_offset, 1284); + seeker = resource + header_size; - for (i = 0; i < view->loops_nr; i++) - { + for (i = 0; i < view->loops_nr; i++) { int loop_offset = get_uint_16(seeker + V2_LOOP_OFFSET); int cels = seeker[V2_CELS_NUM]; int mirrored = seeker[V2_IS_MIRROR]; @@ -536,16 +516,16 @@ gfxr_draw_view11(int id, byte *resource, int size) printf("%d\n", mirrored); if (copy_entry == 255) - gfxr_draw_loop11(id, i, 0, resource, resource + loop_offset, size, cels, view->loops + i, - view, bytes_per_cel); else - { - byte *temp = resource + header_size + copy_entry * bytes_per_loop; - loop_offset = get_uint_16(temp + V2_LOOP_OFFSET); - cels = temp[V2_CELS_NUM]; - gfxr_draw_loop11(id, i, 1, resource, resource + loop_offset, size, cels, - view->loops + i, view, bytes_per_cel); - } - + gfxr_draw_loop11(id, i, 0, resource, resource + loop_offset, size, cels, view->loops + i, + view, bytes_per_cel); + else { + byte *temp = resource + header_size + copy_entry * bytes_per_loop; + loop_offset = get_uint_16(temp + V2_LOOP_OFFSET); + cels = temp[V2_CELS_NUM]; + gfxr_draw_loop11(id, i, 1, resource, resource + loop_offset, size, cels, + view->loops + i, view, bytes_per_cel); + } + seeker += bytes_per_loop; } |