diff options
author | Aaron Giles <aaron@aarongiles.com> | 2009-01-14 05:16:23 +0000 |
---|---|---|
committer | Aaron Giles <aaron@aarongiles.com> | 2009-01-14 05:16:23 +0000 |
commit | f449ec61001f69cb9cb8f9d1460487b65c1a2eeb (patch) | |
tree | 8c79e1e0589dcd1ae72003cf83dac6657c4e8cb8 /src | |
parent | a9f31c600373949b5370bd68b8c7d5d405fd0b24 (diff) |
Added new function gfx_element_build_temporary() to safely build a temporary
gfx_element. Updated the drivers that did this to use the new function, fixing
random crashes.
Fixed a couple of other minor regressions with recent drawgfx changes.
Diffstat (limited to 'src')
-rw-r--r-- | src/emu/drawgfx.c | 44 | ||||
-rw-r--r-- | src/emu/drawgfx.h | 3 | ||||
-rw-r--r-- | src/mame/drivers/igs017.c | 20 | ||||
-rw-r--r-- | src/mame/drivers/limenko.c | 20 | ||||
-rw-r--r-- | src/mame/video/hyprduel.c | 41 | ||||
-rw-r--r-- | src/mame/video/metro.c | 42 | ||||
-rw-r--r-- | src/mame/video/snk.c | 5 |
7 files changed, 62 insertions, 113 deletions
diff --git a/src/emu/drawgfx.c b/src/emu/drawgfx.c index bafeff0886f..6a5e092754c 100644 --- a/src/emu/drawgfx.c +++ b/src/emu/drawgfx.c @@ -215,6 +215,42 @@ void gfx_element_free(gfx_element *gfx) } +/*------------------------------------------------- + gfx_element_build_temporary - create a + temporary one-off gfx_element +-------------------------------------------------*/ + +void gfx_element_build_temporary(gfx_element *gfx, running_machine *machine, UINT8 *base, UINT32 width, UINT32 height, UINT32 rowbytes, UINT32 color_base, UINT32 color_granularity, UINT32 flags) +{ + static UINT8 not_dirty = 0; + + gfx->width = width; + gfx->height = height; + gfx->startx = 0; + gfx->starty = 0; + + gfx->origwidth = width; + gfx->origheight = height; + gfx->flags = flags; + gfx->total_elements = 1; + + gfx->color_base = color_base; + gfx->color_depth = color_granularity; + gfx->color_granularity = color_granularity; + gfx->total_colors = (machine->config->total_colors - color_base) / color_granularity; + + gfx->pen_usage = NULL; + + gfx->gfxdata = base; + gfx->line_modulo = rowbytes; + gfx->char_modulo = 0; + gfx->srcdata = base; + gfx->dirty = ¬_dirty; + gfx->dirtyseq = 0; + + gfx->machine = machine; +} + /*------------------------------------------------- calc_penusage - calculate the pen usage for @@ -1893,8 +1929,8 @@ void copyscrollbitmap_trans(bitmap_t *dest, bitmap_t *src, UINT32 numrows, const break; /* compute the cliprect for this group */ - subclip.min_x = col * colwidth; - subclip.max_x = (col + groupcols) * colwidth - 1; + subclip.min_x = col * colwidth + xscroll; + subclip.max_x = (col + groupcols) * colwidth - 1 + xscroll; sect_rect(&subclip, cliprect); /* iterate over all portions of the scroll that overlap the destination */ @@ -1927,8 +1963,8 @@ void copyscrollbitmap_trans(bitmap_t *dest, bitmap_t *src, UINT32 numrows, const break; /* compute the cliprect for this group */ - subclip.min_y = row * rowheight; - subclip.max_y = (row + grouprows) * rowheight - 1; + subclip.min_y = row * rowheight + yscroll; + subclip.max_y = (row + grouprows) * rowheight - 1 + yscroll; sect_rect(&subclip, cliprect); /* iterate over all portions of the scroll that overlap the destination */ diff --git a/src/emu/drawgfx.h b/src/emu/drawgfx.h index 4e8c2ee4b20..7c9e469b8cb 100644 --- a/src/emu/drawgfx.h +++ b/src/emu/drawgfx.h @@ -178,6 +178,9 @@ void gfx_element_decode(const gfx_element *gfx, UINT32 code); /* free a gfx_element */ void gfx_element_free(gfx_element *gfx); +/* create a temporary one-off gfx_element */ +void gfx_element_build_temporary(gfx_element *gfx, running_machine *machine, UINT8 *base, UINT32 width, UINT32 height, UINT32 rowbytes, UINT32 color_base, UINT32 color_granularity, UINT32 flags); + /* ----- core graphics drawing ----- */ diff --git a/src/mame/drivers/igs017.c b/src/mame/drivers/igs017.c index 57e6fdb3a56..e793475cbde 100644 --- a/src/mame/drivers/igs017.c +++ b/src/mame/drivers/igs017.c @@ -173,27 +173,13 @@ static void draw_sprite(running_machine *machine, bitmap_t *bitmap,const rectang { // prepare GfxElement on the fly gfx_element gfx; - UINT8 dirty = 0; - - gfx.machine = machine; - gfx.width = dimx; - gfx.height = dimy; - gfx.total_elements = 1; - gfx.color_depth = 32; - gfx.color_granularity = 32; - gfx.color_base = 0x100; - gfx.total_colors = 8; - gfx.pen_usage = NULL; - gfx.gfxdata = sprites_gfx + addr; - gfx.dirty = &dirty; - gfx.line_modulo = dimx; - gfx.char_modulo = 0; // doesn't matter - gfx.flags = 0; - + // Bounds checking if ( addr + dimx * dimy >= sprites_gfx_size ) return; + gfx_element_build_temporary(&gfx, machine, sprites_gfx + addr, dimx, dimy, dimx, 0x100, 32, 0); + drawgfx( bitmap,&gfx, 0, color, flipx, flipy, diff --git a/src/mame/drivers/limenko.c b/src/mame/drivers/limenko.c index 24ab3b1abd0..c4604967d5d 100644 --- a/src/mame/drivers/limenko.c +++ b/src/mame/drivers/limenko.c @@ -355,7 +355,6 @@ static void draw_sprites(running_machine *machine, UINT32 *sprites, const rectan for(i = 0; i <= count*2; i += 2) { int x, width, flipx, y, height, flipy, code, color, pri; - UINT8 dirty = 0; if(~sprites[i] & 0x80000000) continue; @@ -381,26 +380,13 @@ static void draw_sprites(running_machine *machine, UINT32 *sprites, const rectan gfxdata = base_gfx + 64 * code; - /* prepare GfxElement on the fly */ - gfx.machine = machine; - gfx.width = width; - gfx.height = height; - gfx.total_elements = 1; - gfx.color_depth = 256; - gfx.color_granularity = 256; - gfx.color_base = 0; - gfx.total_colors = 0x10; - gfx.pen_usage = NULL; - gfx.gfxdata = gfxdata; - gfx.line_modulo = width; - gfx.char_modulo = 0; /* doesn't matter */ - gfx.flags = 0; - gfx.dirty = &dirty; - /* Bounds checking */ if ( (gfxdata + width * height - 1) >= gfx_max ) continue; + /* prepare GfxElement on the fly */ + gfx_element_build_temporary(&gfx, machine, gfxdata, width, height, width, 0, 256, 0); + draw_single_sprite(sprites_bitmap,&gfx,0,color,flipx,flipy,x,y,cliprect,pri); // wrap around x diff --git a/src/mame/video/hyprduel.c b/src/mame/video/hyprduel.c index c29474ad82c..5b8390cf2e9 100644 --- a/src/mame/video/hyprduel.c +++ b/src/mame/video/hyprduel.c @@ -418,6 +418,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta for ( ; src >= end; src -= 8/2 ) { int x,y, attr,code,color,flipx,flipy, zoom, curr_pri,width,height; + gfx_element gfx; UINT8 *gfxdata; /* Exponential zoom table extracted from daitoride */ @@ -469,28 +470,12 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta if (color == 0xf) /* 8bpp */ { - /* prepare GfxElement on the fly */ - gfx_element gfx; - gfx.machine = machine; - gfx.width = width; - gfx.height = height; - gfx.total_elements = 1; - gfx.color_depth = 256; - gfx.color_granularity = 256; - gfx.color_base = 0; - gfx.total_colors = 0x20; - gfx.pen_usage = NULL; - gfx.gfxdata = gfxdata; - gfx.line_modulo = width; - gfx.char_modulo = 0; /* doesn't matter */ - gfx.flags = 0; - gfx.dirty = &dirty; - gfx.machine = machine; - /* Bounds checking */ if ( (gfxdata + width * height - 1) >= gfx_max ) continue; + gfx_element_build_temporary(&gfx, machine, gfxdata, width, height, width, 0, 256, 0); + pdrawgfxzoom( bitmap,&gfx, 0, color_start >> 4, @@ -502,28 +487,12 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta } else { - /* prepare GfxElement on the fly */ - gfx_element gfx; - gfx.machine = machine; - gfx.width = width; - gfx.height = height; - gfx.total_elements = 1; - gfx.color_depth = 16; - gfx.color_granularity = 16; - gfx.color_base = 0; - gfx.total_colors = 0x200; - gfx.pen_usage = NULL; - gfx.gfxdata = gfxdata; - gfx.line_modulo = width/2; - gfx.char_modulo = 0; /* doesn't matter */ - gfx.flags = GFX_ELEMENT_PACKED; - gfx.dirty = &dirty; - gfx.machine = machine; - /* Bounds checking */ if ( (gfxdata + width/2 * height - 1) >= gfx_max ) continue; + gfx_element_build_temporary(&gfx, machine, gfxdata, width, height, width/2, 0, 16, GFX_ELEMENT_PACKED); + pdrawgfxzoom( bitmap,&gfx, 0, (color ^ 0x0f) + color_start, diff --git a/src/mame/video/metro.c b/src/mame/video/metro.c index 52853b0bad1..9a372a8d49a 100644 --- a/src/mame/video/metro.c +++ b/src/mame/video/metro.c @@ -622,6 +622,8 @@ void metro_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectan for (i=0; i<0x20; i++) { + gfx_element gfx; + if (!(metro_videoregs[0x02/2] & 0x8000)) { src = spriteram16 + (sprites - 1) * (8/2); @@ -690,28 +692,12 @@ void metro_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectan if (support_8bpp && color == 0xf) /* 8bpp */ { - /* prepare GfxElement on the fly */ - gfx_element gfx; - gfx.machine = machine; - gfx.width = width; - gfx.height = height; - gfx.total_elements = 1; - gfx.color_depth = 256; - gfx.color_granularity = 256; - gfx.color_base = 0; - gfx.total_colors = 0x20; - gfx.pen_usage = NULL; - gfx.gfxdata = gfxdata; - gfx.line_modulo = width; - gfx.char_modulo = 0; /* doesn't matter */ - gfx.flags = 0; - gfx.dirty = &dirty; - gfx.machine = machine; - /* Bounds checking */ if ( (gfxdata + width * height - 1) >= gfx_max ) continue; + gfx_element_build_temporary(&gfx, machine, gfxdata, width, height, width, 0, 256, 0); + pdrawgfxzoom( bitmap,&gfx, 0, color_start >> 4, @@ -723,28 +709,12 @@ void metro_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectan } else { - /* prepare GfxElement on the fly */ - gfx_element gfx; - gfx.machine = machine; - gfx.width = width; - gfx.height = height; - gfx.total_elements = 1; - gfx.color_depth = 16; - gfx.color_granularity = 16; - gfx.color_base = 0; - gfx.total_colors = 0x200; - gfx.pen_usage = NULL; - gfx.gfxdata = gfxdata; - gfx.line_modulo = width/2; - gfx.char_modulo = 0; /* doesn't matter */ - gfx.flags = GFX_ELEMENT_PACKED; - gfx.dirty = &dirty; - gfx.machine = machine; - /* Bounds checking */ if ( (gfxdata + width/2 * height - 1) >= gfx_max ) continue; + gfx_element_build_temporary(&gfx, machine, gfxdata, width, height, width/2, 0, 16, GFX_ELEMENT_PACKED); + pdrawgfxzoom( bitmap,&gfx, 0, color + color_start, diff --git a/src/mame/video/snk.c b/src/mame/video/snk.c index d1929e8d6d8..5a31a6cb91a 100644 --- a/src/mame/video/snk.c +++ b/src/mame/video/snk.c @@ -209,7 +209,7 @@ static VIDEO_START( snk_4bpp_shadow ) /* prepare shadow draw table */ for(i = 0; i <= 13; i++) drawmode_table[i] = DRAWMODE_SOURCE; - drawmode_table[14] = (machine->config->video_attributes & VIDEO_HAS_SHADOWS) ? DRAWMODE_SHADOW : DRAWMODE_SOURCE; + drawmode_table[14] = DRAWMODE_SHADOW; drawmode_table[15] = DRAWMODE_NONE; /* all palette entries are not affected by shadow sprites... */ @@ -358,9 +358,8 @@ VIDEO_START( gwar ) VIDEO_START( tdfever ) { - VIDEO_START_CALL(snk_4bpp_shadow); - VIDEO_START_CALL(gwar); + VIDEO_START_CALL(snk_4bpp_shadow); } /**************************************************************************************/ |