diff options
author | Paweł Kołodziejski | 2009-02-21 10:05:31 +0000 |
---|---|---|
committer | Paweł Kołodziejski | 2009-02-21 10:05:31 +0000 |
commit | 44ea7966108cf56df4a4eb3fd0b2b7df31d937e1 (patch) | |
tree | 82554f9362e0bc66ccf9763f7175f6558ae45c95 | |
parent | 14150200d4e91595f6dece83ec4d5f63ce338114 (diff) | |
download | scummvm-rg350-44ea7966108cf56df4a4eb3fd0b2b7df31d937e1.tar.gz scummvm-rg350-44ea7966108cf56df4a4eb3fd0b2b7df31d937e1.tar.bz2 scummvm-rg350-44ea7966108cf56df4a4eb3fd0b2b7df31d937e1.zip |
formating
svn-id: r38675
-rw-r--r-- | engines/sci/gfx/resource/sci_picfill.cpp | 81 | ||||
-rw-r--r-- | engines/sci/gfx/resource/sci_picfill_aux.cpp | 70 | ||||
-rw-r--r-- | engines/sci/gfx/resource/sci_resmgr.cpp | 82 | ||||
-rw-r--r-- | engines/sci/gfx/resource/sci_view_0.cpp | 37 | ||||
-rw-r--r-- | engines/sci/gfx/resource/sci_view_1.cpp | 86 |
5 files changed, 137 insertions, 219 deletions
diff --git a/engines/sci/gfx/resource/sci_picfill.cpp b/engines/sci/gfx/resource/sci_picfill.cpp index e410bf8788..325ec1c646 100644 --- a/engines/sci/gfx/resource/sci_picfill.cpp +++ b/engines/sci/gfx/resource/sci_picfill.cpp @@ -59,10 +59,8 @@ ) #endif -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) { +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 linewidth = pic->mode->xfact * 320; int miny = pic->mode->yfact * sci_titlebar_size; int maxy = pic->mode->yfact * 200; @@ -90,7 +88,7 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, else if (!fillmagc) { --fillc; } -#endif /* defined(FILL_RECURSIVE_DEBUG) */ +#endif if (y < miny || y >= maxy) { PRINT_DEBUG0("ABRT on failed initial assertion!\n"); @@ -100,18 +98,16 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, proj_y = y / pic->mode->yfact; if (proj_y != old_proj_y) { - /* First, find the projected coordinates, unless known already: */ + // First, find the projected coordinates, unless known already: proj_ytotal = proj_y * 320; 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)) { - while (proj_xl_bound - && pic->aux_map[proj_ytotal + proj_xl_bound - 1] & FRESH_PAINT) + while (proj_xl_bound && 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)) + while (proj_xl_bound < 319 && !(pic->aux_map[proj_ytotal + proj_xl_bound + 1] & FRESH_PAINT)) ++proj_xl_bound; if (proj_xl_bound < 319) @@ -153,13 +149,13 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, # define proj_xr_bound 319 #endif - /* Now we have the projected limits, get the real ones: */ + // 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 */ + 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 */ + } else // go right until the fillable area starts while (xl < proj_xr_bound && (IS_BOUNDARY(xl, y + 1, bounds[ytotal + xl]))) ++xl; @@ -204,13 +200,13 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, memset(pic->priority_map->index_data + ytotal + xl, priority, xr - xl + 1); - /* Check whether we need to recurse on branches in the same direction */ + // Check whether we need to recurse on branches in the same direction state = 0; xcont = xr + 1; while (xcont <= old_xr) { if (IS_BOUNDARY(xcont, y + 1, bounds[ytotal + xcont])) state = xcont; - else if (state) { /* recurse */ + 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); @@ -221,14 +217,14 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, ++xcont; } - /* Check whether we need to recurse on backward branches: */ - /* left */ + // Check whether we need to recurse on backward branches: + // left if (xl < old_xl - 1) { state = 0; for (xcont = old_xl - 1; xcont >= xl; xcont--) { if (IS_BOUNDARY(xcont, y, bounds[oldytotal + xcont])) state = xcont; - else if (state) { /* recurse */ + else if (state) { // recurse PRINT_DEBUG4("[%d[%d,%d],%d]: ", old_xl, xl, xr, old_xr); PRINT_DEBUG4("rec BACK-LEFT %d [%d,%d] l%d\n", -dy, state, xcont, y); @@ -240,13 +236,13 @@ FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, } } - /* right */ + // right if (xr > old_xr + 1) { state = 0; for (xcont = old_xr + 1; xcont <= xr; xcont++) { if (IS_BOUNDARY(xcont, y, bounds[oldytotal + xcont])) state = xcont; - else if (state) { /* recurse */ + else if (state) { // recurse PRINT_DEBUG4("[%d[%d,%d],%d]: ", old_xl, xl, xr, old_xr); PRINT_DEBUG4("rec BACK-RIGHT %d [%d,%d] l%d\n", -dy, state, xcont, y); @@ -266,8 +262,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, +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 linewidth = pic->mode->xfact * 320; int x, y; @@ -279,10 +274,10 @@ FILL_FUNCTION(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, in #ifdef DRAW_SCALED int min_x, min_y, max_x, max_y; #endif - int original_drawenable = drawenable; /* Backup, since we need the unmodified value - ** for filling the aux and control map */ + int original_drawenable = drawenable; // Backup, since we need the unmodified value + // for filling the aux and control map - /* Restrict drawenable not to restrict itself to zero */ + // Restrict drawenable not to restrict itself to zero if (pic->control_map->index_data[y_200 * 320 + x_320] != 0) drawenable &= ~GFX_MASK_CONTROL; @@ -294,15 +289,14 @@ FILL_FUNCTION(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, in original_drawenable &= ~GFX_MASK_PRIORITY; } - AUXBUF_FILL(pic, x_320, y_200, original_drawenable, - (drawenable & GFX_MASK_CONTROL) ? control : 0, + AUXBUF_FILL(pic, x_320, y_200, original_drawenable, (drawenable & GFX_MASK_CONTROL) ? control : 0, sci_titlebar_size); #ifdef DRAW_SCALED _gfxr_auxbuf_spread(pic, &min_x, &min_y, &max_x, &max_y); if (_gfxr_find_fill_point(pic, min_x, min_y, max_x, max_y, x_320, y_200, color, drawenable, &x, &y)) { - /* GFXWARN("Could not find scaled fill point, but unscaled fill point was available!\n"); */ + //GFXWARN("Could not find scaled fill point, but unscaled fill point was available!\n"); drawenable &= GFX_MASK_PRIORITY; if (!drawenable) _gfxr_auxbuf_propagate_changes(pic, 0); @@ -320,15 +314,15 @@ FILL_FUNCTION(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, in if (drawenable & GFX_MASK_VISUAL) { bounds = pic->visual_map->index_data; #if 0 - /* Code disabled, as removing it fixes qg1 pic.095 (unscaled). However, - ** it MAY be of relevance to scaled pic drawing... */ + // Code disabled, as removing it fixes qg1 pic.095 (unscaled). However, + // it MAY be of relevance to scaled pic drawing... - if ((color & 0xf) == 0xf /* When dithering with white, do more - ** conservative checks */ + if ((color & 0xf) == 0xf // When dithering with white, do more + // conservative checks || (color & 0xf0) == 0xf0) legalcolor = 0xff; else - legalcolor = 0xf0; /* Only check the second color */ + legalcolor = 0xf0; // Only check the second color #endif #ifdef DRAW_SCALED legalcolor = 0xff; @@ -362,17 +356,14 @@ 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)) + while (proj_xl_bound && 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))) + while (proj_xl_bound < 319 && 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; - while ((proj_xr_bound < 319) && - SCALED_CHECK(pic->aux_map[proj_ytotal + proj_xr_bound + 1] & FRESH_PAINT)) + while ((proj_xr_bound < 319) && SCALED_CHECK(pic->aux_map[proj_ytotal + proj_xr_bound + 1] & FRESH_PAINT)) ++proj_xr_bound; proj_xl = proj_xl_bound; @@ -407,13 +398,8 @@ FILL_FUNCTION(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, in sci_titlebar_size); } - /* Now finish the aux buffer */ - bitmask = drawenable & - ( - ((color != 0xff) ? 1 : 0) - | ((priority) ? 2 : 0) - | ((control) ? 4 : 0) - ); + // Now finish the aux buffer + bitmask = drawenable & (((color != 0xff) ? 1 : 0) | ((priority) ? 2 : 0) | ((control) ? 4 : 0)); #ifdef DRAW_SCALED # ifdef FILL_RECURSIVE_DEBUG @@ -430,6 +416,3 @@ FILL_FUNCTION(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, in # undef proj_xl_bound # undef proj_xr_bound #endif - - - diff --git a/engines/sci/gfx/resource/sci_picfill_aux.cpp b/engines/sci/gfx/resource/sci_picfill_aux.cpp index d7b1db24c5..1760d233c8 100644 --- a/engines/sci/gfx/resource/sci_picfill_aux.cpp +++ b/engines/sci/gfx/resource/sci_picfill_aux.cpp @@ -37,8 +37,7 @@ #define CLIPMASK_HARD_BOUND 0x80 /* ensures that we don't re-fill filled stuff */ -static void -AUXBUF_FILL_HELPER(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, +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 xl, xr; int oldytotal = y * 320; @@ -59,17 +58,20 @@ AUXBUF_FILL_HELPER(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, return; xl = old_xl; - if (!(pic->aux_map[ytotal + xl] & clipmask)) { /* go left */ + if (!(pic->aux_map[ytotal + xl] & clipmask)) { // go left while (xl && !(pic->aux_map[ytotal + xl - 1] & clipmask)) --xl; - } else /* go right and look for the first valid spot */ + } else // go right and look for the first valid spot while ((xl <= old_xr) && (pic->aux_map[ytotal + xl] & clipmask)) ++xl; - if (xl > old_xr) /* No fillable strip above the last one */ + 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)) { @@ -87,55 +89,56 @@ AUXBUF_FILL_HELPER(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, if (xr < xl) return; - /* Check whether we need to recurse on branches in the same direction */ - if ((y > sci_titlebar_size && dy < 0) - || (y < 199 && dy > 0)) { - + // Check whether we need to recurse on branches in the same direction + if ((y > sci_titlebar_size && dy < 0) || (y < 199 && dy > 0)) { state = 0; xcont = xr + 1; while (xcont <= old_xr) { if (pic->aux_map[ytotal + xcont] & clipmask) state = 0; - else if (!state) { /* recurse */ + else if (!state) { // recurse state = 1; - AUXBUF_FILL_HELPER(pic, xcont, old_xr, - y - dy, dy, clipmask, control, sci_titlebar_size); + AUXBUF_FILL_HELPER(pic, xcont, old_xr, y - dy, dy, clipmask, control, sci_titlebar_size); } ++xcont; } } - /* Check whether we need to recurse on backward branches: */ - /* left */ + // Check whether we need to recurse on backward branches: + // left if (xl < old_xl - 1) { state = 0; for (xcont = old_xl - 1; xcont >= xl; xcont--) { if (pic->aux_map[oldytotal + xcont] & clipmask) state = xcont; - else if (state) { /* recurse */ - AUXBUF_FILL_HELPER(pic, xcont, state, - y, -dy, clipmask, control, sci_titlebar_size); + else if (state) { // recurse + AUXBUF_FILL_HELPER(pic, xcont, state, y, -dy, clipmask, control, sci_titlebar_size); state = 0; } } } - /* right */ + // right if (xr > old_xr + 1) { state = 0; for (xcont = old_xr + 1; xcont <= xr; xcont++) { if (pic->aux_map[oldytotal + xcont] & clipmask) state = xcont; - else if (state) { /* recurse */ - AUXBUF_FILL_HELPER(pic, state, xcont, - y, -dy, clipmask, control, sci_titlebar_size); + else if (state) { // recurse + AUXBUF_FILL_HELPER(pic, state, xcont, 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); @@ -148,9 +151,8 @@ 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) { - /* Fills the aux buffer and the control map (if control != 0) */ +static void 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; #ifdef DRAW_SCALED @@ -161,19 +163,19 @@ AUXBUF_FILL(gfxr_pic_t *pic, int x, int y, int clipmask, int control, int sci_ti #ifndef DRAW_SCALED if (!control || !(clipmask & 4)) - return; /* Without pic scaling, we only do this to fill the control map */ + return; // Without pic scaling, we only do this to fill the control map #endif if (clipmask & 1) - clipmask = 1; /* vis */ + clipmask = 1; // vis else if (clipmask & 2) - clipmask = 2; /* pri */ + clipmask = 2; // pri else if (clipmask & 4) - clipmask = 4; /* ctl */ + clipmask = 4; // ctl else return; #ifdef DRAW_SCALED - clipmask |= fillmask; /* Bits 3-5 */ + clipmask |= fillmask; // Bits 3-5 #endif if (pic->aux_map[ytotal + x] & clipmask) @@ -193,9 +195,9 @@ AUXBUF_FILL(gfxr_pic_t *pic, int x, int y, int clipmask, int control, int sci_ti pic->aux_map[ytotal + xr] |= fillmask; } - clipmask |= CLIPMASK_HARD_BOUND; /* Guarantee clipping */ + clipmask |= CLIPMASK_HARD_BOUND; // Guarantee clipping - if (control) /* Draw the same strip on the control map */ + if (control) // Draw the same strip on the control map memset(pic->control_map->index_data + ytotal + xl, control, xr - xl + 1); if (y > sci_titlebar_size) diff --git a/engines/sci/gfx/resource/sci_resmgr.cpp b/engines/sci/gfx/resource/sci_resmgr.cpp index 7f7ba30acc..f66ecec332 100644 --- a/engines/sci/gfx/resource/sci_resmgr.cpp +++ b/engines/sci/gfx/resource/sci_resmgr.cpp @@ -23,7 +23,7 @@ * */ -/* The interpreter-specific part of the resource manager, for SCI */ +// The interpreter-specific part of the resource manager, for SCI #include "sci/include/sci_memory.h" #include "sci/include/sciresource.h" @@ -33,12 +33,8 @@ #include "common/util.h" -int -gfxr_interpreter_options_hash(gfx_resource_type_t type, int version, - gfx_options_t *options, - void *internal, int palette) { +int gfxr_interpreter_options_hash(gfx_resource_type_t type, int version, gfx_options_t *options, void *internal, int palette) { switch (type) { - case GFX_RESOURCE_TYPE_VIEW: return palette; @@ -46,11 +42,8 @@ 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; @@ -65,23 +58,17 @@ 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_pic_t *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) { +void 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 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) { - ResourceManager *resmgr = (ResourceManager *) state->misc_payload; + ResourceManager *resmgr = (ResourceManager *)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; @@ -136,7 +123,7 @@ gfxr_interpreter_calculate_pic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gf gfxr_dither_pic0(scaled_pic, state->options->pic0_dither_mode, state->options->pic0_dither_pattern); } - /* Mark default palettes */ + // Mark default palettes if (scaled_pic) scaled_pic->visual_map->loop = default_palette; @@ -146,25 +133,19 @@ gfxr_interpreter_calculate_pic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gf return GFX_OK; } - -void -gfxr_palettize_view(gfxr_view_t *view, gfx_pixmap_color_t *source, int source_entries) { +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)) { + 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_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_view_t *gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int palette) { ResourceManager *resmgr = (ResourceManager *) state->misc_payload; resource_t *res = scir_find_resource(resmgr, sci_view, nr, 0); int resid = GFXR_RES_ID(GFX_RESOURCE_TYPE_VIEW, nr); @@ -194,7 +175,7 @@ gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int pal 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); + 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; } @@ -203,10 +184,8 @@ gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int pal return result; } - -gfx_bitmap_font_t * -gfxr_interpreter_get_font(gfx_resstate_t *state, int nr, void *internal) { - ResourceManager *resmgr = (ResourceManager *) state->misc_payload; +gfx_bitmap_font_t *gfxr_interpreter_get_font(gfx_resstate_t *state, int nr, void *internal) { + ResourceManager *resmgr = (ResourceManager *)state->misc_payload; resource_t *res = scir_find_resource(resmgr, sci_font, nr, 0); if (!res || !res->data) return NULL; @@ -214,9 +193,7 @@ gfxr_interpreter_get_font(gfx_resstate_t *state, int nr, void *internal) { return gfxr_read_font(res->id, res->data, res->size); } - -gfx_pixmap_t * -gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal) { +gfx_pixmap_t *gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal) { ResourceManager *resmgr = (ResourceManager *) state->misc_payload; resource_t *res = scir_find_resource(resmgr, sci_cursor, nr, 0); int resid = GFXR_RES_ID(GFX_RESOURCE_TYPE_CURSOR, nr); @@ -235,10 +212,7 @@ gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal) { return gfxr_draw_cursor01(resid, res->data, res->size); } - -int * -gfxr_interpreter_get_resources(gfx_resstate_t *state, gfx_resource_type_t type, - int version, int *entries_nr, void *internal) { +int *gfxr_interpreter_get_resources(gfx_resstate_t *state, gfx_resource_type_t type, int version, int *entries_nr, void *internal) { ResourceManager *resmgr = (ResourceManager *) state->misc_payload; int restype; int *resources; @@ -265,11 +239,10 @@ gfxr_interpreter_get_resources(gfx_resstate_t *state, gfx_resource_type_t type, default: GFXDEBUG("Unsupported resource %d\n", type); - return NULL; /* unsupported resource */ - + return NULL; } - resources = (int*)sci_malloc(sizeof(int) * top); + resources = (int *)sci_malloc(sizeof(int) * top); for (i = 0; i < top; i++) if (scir_test_resource(resmgr, restype, i)) @@ -280,8 +253,7 @@ gfxr_interpreter_get_resources(gfx_resstate_t *state, gfx_resource_type_t type, return resources; } -gfx_pixmap_color_t * -gfxr_interpreter_get_static_palette(gfx_resstate_t *state, int version, int *colors_nr, void *internal) { +gfx_pixmap_color_t *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); @@ -289,10 +261,8 @@ gfxr_interpreter_get_static_palette(gfx_resstate_t *state, int version, int *col return gfx_sci0_pic_colors; } -gfx_pixmap_color_t * -gfxr_interpreter_get_palette(gfx_resstate_t *state, int version, int *colors_nr, - void *internal, int nr) { - ResourceManager *resmgr = (ResourceManager *) state->misc_payload; +gfx_pixmap_color_t *gfxr_interpreter_get_palette(gfx_resstate_t *state, int version, int *colors_nr, void *internal, int nr) { + ResourceManager *resmgr = (ResourceManager *)state->misc_payload; resource_t *res; if (version < SCI_VERSION_01_VGA) @@ -319,10 +289,6 @@ gfxr_interpreter_get_palette(gfx_resstate_t *state, int version, int *colors_nr, } } -int -gfxr_interpreter_needs_multicolored_pointers(int version, void *internal) { +int 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 afd1e01d56..82b3e5d9d2 100644 --- a/engines/sci/gfx/resource/sci_view_0.cpp +++ b/engines/sci/gfx/resource/sci_view_0.cpp @@ -23,24 +23,16 @@ * */ -/* set optimisations for Win32: */ -#ifdef WIN32 -# include <memory.h> -//# pragma intrinsic( memcpy, memset ) -#endif - #include "sci/include/sci_memory.h" #include "sci/include/gfx_system.h" #include "sci/include/gfx_resource.h" #include "sci/include/gfx_tools.h" - -gfx_pixmap_t * -gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size, gfxr_view_t *view, int mirrored) { +gfx_pixmap_t *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 xhot = ((signed char *)resource)[4]; + int yhot = ((signed char *)resource)[5]; int color_key = resource[6]; int pos = 7; int writepos = mirrored ? xl : 0; @@ -49,7 +41,7 @@ gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size, gfxr_view_t gfx_pixmap_t *retval = gfx_pixmap_alloc_index_data(gfx_new_pixmap(xl, yl, id, loop, cel)); byte *dest = retval->index_data; - retval->color_key = 255; /* Pick something larger than 15 */ + retval->color_key = 255; // Pick something larger than 15 retval->xoffset = mirrored ? xhot : -xhot; retval->yoffset = -yhot; @@ -71,7 +63,6 @@ gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size, gfxr_view_t } if (mirrored) { - while (yl && pos < size) { int op = resource[pos++]; int count = op >> 4; @@ -126,8 +117,7 @@ gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size, gfxr_view_t return retval; } -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) { +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) { int i; int cels_nr = get_int_16(resource + offset); @@ -168,13 +158,11 @@ gfxr_draw_loop0(gfxr_loop_t *dest, int id, int loop, byte *resource, int offset, return 0; } - #define V0_LOOPS_NR_OFFSET 0 #define V0_FIRST_LOOP_OFFSET 8 #define V0_MIRROR_LIST_OFFSET 2 -gfxr_view_t * -gfxr_draw_view0(int id, byte *resource, int size, int palette) { +gfxr_view_t *gfxr_draw_view0(int id, byte *resource, int size, int palette) { int i; gfxr_view_t *view; int mirror_bitpos = 1; @@ -186,12 +174,12 @@ gfxr_draw_view0(int id, byte *resource, int size, int palette) { return NULL; } - view = (gfxr_view_t*)sci_malloc(sizeof(gfxr_view_t)); + view = (gfxr_view_t *)sci_malloc(sizeof(gfxr_view_t)); view->ID = id; view->loops_nr = resource[V0_LOOPS_NR_OFFSET]; - /* Set palette */ + // Set palette view->colors_nr = GFX_SCI0_IMAGE_COLORS_NR; view->flags = GFX_PIXMAP_FLAG_EXTERNAL_PALETTE; view->colors = gfx_sci0_image_colors[sci0_palette]; @@ -229,7 +217,7 @@ gfxr_draw_view0(int id, byte *resource, int size, int palette) { } if (error_token || gfxr_draw_loop0(view->loops + i, id, i, resource, loop_offset, size, view, mirrored)) { - /* An error occured */ + // An error occured view->loops_nr = i; gfxr_free_view(NULL, view); return NULL; @@ -238,10 +226,3 @@ gfxr_draw_view0(int id, byte *resource, int size, int palette) { return view; } - - - - - - - diff --git a/engines/sci/gfx/resource/sci_view_1.cpp b/engines/sci/gfx/resource/sci_view_1.cpp index eb926c5eae..ce038c11da 100644 --- a/engines/sci/gfx/resource/sci_view_1.cpp +++ b/engines/sci/gfx/resource/sci_view_1.cpp @@ -23,7 +23,7 @@ * */ -/* SCI 1 view resource defrobnicator */ +// SCI 1 view resource defrobnicator #include "sci/include/sci_memory.h" #include "sci/include/gfx_system.h" @@ -35,21 +35,20 @@ #define V1_PALETTE_OFFSET 6 #define V1_FIRST_LOOP_OFFSET 8 -#define V1_RLE 0x80 /* run-length encode? */ -#define V1_RLE_BG 0x40 /* background fill */ +#define V1_RLE 0x80 // run-length encode? +#define V1_RLE_BG 0x40 // background fill #define NEXT_RUNLENGTH_BYTE(n) \ - if (literal_pos == runlength_pos) \ - literal_pos += n; \ - runlength_pos += n; + if (literal_pos == runlength_pos) \ + literal_pos += n; \ + runlength_pos += n; #define NEXT_LITERAL_BYTE(n) \ - if (literal_pos == runlength_pos) \ - runlength_pos += n; \ - literal_pos += n; + if (literal_pos == runlength_pos) \ + runlength_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, +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; @@ -79,11 +78,11 @@ decompress_sci_view(int id, int loop, int cel, byte *resource, byte *dest, int m 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 (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]; @@ -176,8 +175,7 @@ decompress_sci_view(int id, int loop, int cel, byte *resource, byte *dest, int m return 0; } -static int -decompress_sci_view_amiga(int id, int loop, int cel, byte *resource, byte *dest, int mirrored, int pixmap_size, int size, +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; @@ -197,9 +195,9 @@ decompress_sci_view_amiga(int id, int loop, int cel, byte *resource, byte *dest, if (mirrored) { while (bytes--) { dest[writepos--] = color; - /* If we've just written the first pixel of a line... */ + // If we've just written the first pixel of a line... if (!((writepos + 1) % xl)) { - /* Then move to the end of next line */ + // Then move to the end of next line writepos += 2 * xl; if (writepos >= pixmap_size && bytes) { @@ -227,8 +225,7 @@ decompress_sci_view_amiga(int id, int loop, int cel, byte *resource, byte *dest, 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) { +gfx_pixmap_t *gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, int size, gfxr_view_t *view, int amiga_game) { int xl = get_int_16(resource); int yl = get_int_16(resource + 2); int xhot = (gint8) resource[4]; @@ -257,12 +254,10 @@ 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, + decompress_failed = decompress_sci_view_amiga(id, loop, cel, 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, + decompress_failed = decompress_sci_view(id, loop, cel, resource, dest, mirrored, pixmap_size, size, pos, pos, xl, yl, retval->color_key); if (decompress_failed) { @@ -273,8 +268,7 @@ gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, int size return retval; } -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) { +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) { int i; int cels_nr = get_int_16(resource + offset); @@ -284,7 +278,7 @@ gfxr_draw_loop1(gfxr_loop_t *dest, int id, int loop, int mirrored, byte *resourc if (cels_nr * 2 + 4 + offset > size) { GFXERROR("View %02x:(%d): Offset array for %d cels extends beyond resource space\n", id, loop, cels_nr); - dest->cels_nr = 0; /* Mark as "delete no cels" */ + dest->cels_nr = 0; // Mark as "delete no cels" dest->cels = NULL; return 1; } @@ -314,13 +308,11 @@ gfxr_draw_loop1(gfxr_loop_t *dest, int id, int loop, int mirrored, byte *resourc return 0; } - #define V1_FIRST_MAGIC 1 #define V1_MAGICS_NR 5 -/*static byte view_magics[V1_MAGICS_NR] = {0x80, 0x00, 0x00, 0x00, 0x00};*/ +//static byte view_magics[V1_MAGICS_NR] = {0x80, 0x00, 0x00, 0x00, 0x00}; -gfxr_view_t * -gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_t *static_pal, +gfxr_view_t *gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_t *static_pal, int static_pal_nr) { int i; int palette_offset; @@ -347,13 +339,12 @@ gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_t *static_pal return NULL; } - /* error("View flags are 0x%02x\n", resource[3]);*/ + //error("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]); + GFXWARN("View %04x: View magic #%d should be %02x but is %02x\n", id, i, view_magics[i], resource[V1_FIRST_MAGIC + i]); } */ @@ -370,7 +361,7 @@ gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_t *static_pal return NULL; } } else if (static_pal_nr == GFX_SCI1_AMIGA_COLORS_NR) { - /* Assume we're running an amiga game. */ + // Assume we're running an amiga game. amiga_game = 1; view->colors = static_pal; view->colors_nr = static_pal_nr; @@ -392,9 +383,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)) { - /* An error occured */ + 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); return NULL; @@ -423,8 +413,7 @@ gfxr_draw_view1(int id, byte *resource, int size, gfx_pixmap_color_t *static_pal #define V2_RUNLENGTH_OFFSET 24 #define V2_LITERAL_OFFSET 28 -gfx_pixmap_t * -gfxr_draw_cel11(int id, int loop, int cel, int mirrored, byte *resource_base, byte *cel_base, int size, gfxr_view_t *view) { +gfx_pixmap_t *gfxr_draw_cel11(int id, int loop, int cel, int mirrored, byte *resource_base, byte *cel_base, int size, gfxr_view_t *view) { int xl = 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); @@ -465,15 +454,13 @@ gfxr_draw_cel11(int id, int loop, int cel, int mirrored, byte *resource_base, by return retval; } -gfxr_loop_t * -gfxr_draw_loop11(int id, int loop, int mirrored, byte *resource_base, byte *loop_base, int size, int cels_nr, +gfxr_loop_t *gfxr_draw_loop11(int id, int loop, int mirrored, byte *resource_base, byte *loop_base, int size, int cels_nr, gfxr_loop_t *result, gfxr_view_t *view, int bytes_per_cel) { byte *seeker = loop_base; int i; result->cels_nr = cels_nr; - result->cels = (gfx_pixmap_t **) - sci_malloc(sizeof(gfx_pixmap_t *) * cels_nr); + result->cels = (gfx_pixmap_t **)sci_malloc(sizeof(gfx_pixmap_t *) * cels_nr); for (i = 0; i < cels_nr; i++) { result->cels[i] = gfxr_draw_cel11(id, loop, i, mirrored, resource_base, seeker, size, view); @@ -483,8 +470,7 @@ gfxr_draw_loop11(int id, int loop, int mirrored, byte *resource_base, byte *loop return result; } -gfxr_view_t * -gfxr_draw_view11(int id, byte *resource, int size) { +gfxr_view_t *gfxr_draw_view11(int id, byte *resource, int size) { gfxr_view_t *view; int header_size = get_uint_16(resource + V2_HEADER_SIZE); int palette_offset = get_uint_16(resource + V2_PALETTE_OFFSET); @@ -494,7 +480,7 @@ gfxr_draw_view11(int id, byte *resource, int size) { int i; byte *seeker; - view = (gfxr_view_t*)sci_malloc(sizeof(gfxr_view_t)); + view = (gfxr_view_t *)sci_malloc(sizeof(gfxr_view_t)); memset(view, 0, sizeof(gfxr_view_t)); view->ID = id; @@ -503,7 +489,7 @@ gfxr_draw_view11(int id, byte *resource, int size) { view->loops_nr = loops_num; 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 */ + // 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); seeker = resource + header_size; |