diff --git a/src/mame/drivers/taito_f3.c b/src/mame/drivers/taito_f3.c index ab26bc4d26e..4b9f2a4b6f9 100644 --- a/src/mame/drivers/taito_f3.c +++ b/src/mame/drivers/taito_f3.c @@ -348,7 +348,7 @@ static const gfx_layout spriteram_layout = { 16,16, RGN_FRAC(1,2), - 6, + 6, /* Palettes have 4 bpp indexes despite up to 6 bpp data */ { RGN_FRAC(1,2)+0, RGN_FRAC(1,2)+1, 0, 1, 2, 3 }, { 4, 0, 12, 8, @@ -364,7 +364,7 @@ static const gfx_layout tile_layout = { 16,16, RGN_FRAC(1,2), - 6, + 6, /* Palettes have 4 bpp indexes despite up to 6 bpp data */ { RGN_FRAC(1,2)+2, RGN_FRAC(1,2)+3, 0, 1, 2, 3 }, { 4, 0, 16+4, 16+0, @@ -378,10 +378,10 @@ static const gfx_layout tile_layout = }; static GFXDECODE_START( taito_f3 ) - GFXDECODE_ENTRY( 0, 0x000000, charlayout, 0, 64 ) /* Dynamically modified */ - GFXDECODE_ENTRY( REGION_GFX2, 0x000000, tile_layout, 0, 512 ) /* Tiles area */ - GFXDECODE_ENTRY( REGION_GFX1, 0x000000, spriteram_layout, 4096, 256 ) /* Sprites area */ - GFXDECODE_ENTRY( 0, 0x000000, pivotlayout, 0, 64 ) /* Dynamically modified */ + GFXDECODE_ENTRY( 0, 0x000000, charlayout, 0x0000, 0x400>>4 ) /* Dynamically modified */ + GFXDECODE_ENTRY( REGION_GFX2, 0x000000, tile_layout, 0x0000, 0x2000>>4 ) /* Tiles area */ + GFXDECODE_ENTRY( REGION_GFX1, 0x000000, spriteram_layout, 0x1000, 0x1000>>4 ) /* Sprites area */ + GFXDECODE_ENTRY( 0, 0x000000, pivotlayout, 0x0000, 0x400>>4 ) /* Dynamically modified */ GFXDECODE_END /******************************************************************************/ @@ -462,7 +462,7 @@ static MACHINE_DRIVER_START( f3 ) MDRV_SCREEN_VISIBLE_AREA(46, 40*8-1 + 46, 24, 24+232-1) MDRV_GFXDECODE(taito_f3) - MDRV_PALETTE_LENGTH(8192) + MDRV_PALETTE_LENGTH(0x2000) MDRV_VIDEO_START(f3) MDRV_VIDEO_EOF(f3) @@ -3251,13 +3251,13 @@ ROM_END /******************************************************************************/ -static void tile_decode(running_machine *machine, int uses_5bpp_tiles) +static void tile_decode(running_machine *machine) { UINT8 lsb,msb; UINT32 offset,i; UINT8 *gfx = memory_region(machine, REGION_GFX2); int size=memory_region_length(machine, REGION_GFX2); - int half=size/2,data; + int data; /* Setup ROM formats: @@ -3266,10 +3266,12 @@ static void tile_decode(running_machine *machine, int uses_5bpp_tiles) are tied low on the game board if unused. This is backed up by the fact the palette indices are always related to 4 bpp data, even in 6 bpp games. + Most (all?) games with 5bpp tiles have the sixth bit set. Also, in Arabian Magic + sprites 1200-120f contain 6bpp data which is probably bogus. + VIDEO_START( f3 ) clears the fifth and sixth bit of the decoded graphics according + to the bit depth specified in f3_config_table. + */ - if (uses_5bpp_tiles) - for (i=half; i>(16+9))&0x1f; + int color_mask; + + // if tiles use more than 4bpp, the bottom bits of the color code must be masked out. + // This fixes (at least) the rain in round 6 of Arabian Magic. + color_mask = ~((1 << (f3_game_config->tile_bpp - 4)) - 1); SET_TILE_INFO( 1, tile&0xffff, - (tile>>16)&0x1ff, + (tile>>16) & 0x1ff & color_mask, TILE_FLIPYX( tile >> 30 )); tileinfo->category = abtype&1; /* alpha blending type */ } @@ -617,10 +624,14 @@ VIDEO_START( f3 ) tilemap_set_transparent_pen(vram_layer,0); tilemap_set_transparent_pen(pixel_layer,0); - /* Palettes have 4 bpp indexes despite up to 6 bpp data */ + // Palettes have 4 bpp indexes despite up to 6 bpp data. The unused + // top bits in the gfx data are cleared later. machine->gfx[1]->color_granularity=16; machine->gfx[2]->color_granularity=16; + assert(f3_game_config->tile_bpp >= 4 && f3_game_config->tile_bpp <= 6); + assert(f3_game_config->sprite_bpp >= 4 && f3_game_config->sprite_bpp <= 6); + flipscreen = 0; memset(spriteram32_buffered,0,spriteram_size); memset(spriteram32,0,spriteram_size); @@ -642,6 +653,7 @@ VIDEO_START( f3 ) { const gfx_element *sprite_gfx = machine->gfx[2]; int c; + int bpp_mask = (1 << f3_game_config->sprite_bpp) - 1; for (c = 0;c < sprite_gfx->total_elements;c++) { @@ -652,6 +664,9 @@ VIDEO_START( f3 ) { for (x = 0;x < sprite_gfx->width;x++) { + // clear unused top bits from gfx data + dp[x] &= bpp_mask; + if(!dp[x]) chk_trans_or_opa|=2; else chk_trans_or_opa|=1; } @@ -666,6 +681,7 @@ VIDEO_START( f3 ) { const gfx_element *pf_gfx = machine->gfx[1]; int c; + int bpp_mask = (1 << f3_game_config->tile_bpp) - 1; for (c = 0;c < pf_gfx->total_elements;c++) { @@ -676,6 +692,9 @@ VIDEO_START( f3 ) { for (x = 0;x < pf_gfx->width;x++) { + // clear unused top bits from gfx data + dp[x] &= bpp_mask; + if(!dp[x]) chk_trans_or_opa|=2; else chk_trans_or_opa|=1; } @@ -3157,9 +3176,15 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta { const struct tempsprite *sprite_ptr; const gfx_element *sprite_gfx = machine->gfx[2]; + int color_mask; sprite_ptr = sprite_end; sprite_pri_usage=0; + + // if sprites use more than 4bpp, the bottom bits of the color code must be masked out. + // This fixes (at least) stage 1 battle ships and attract mode explosions in Ray Force. + color_mask = ~((1 << (f3_game_config->sprite_bpp - 4)) - 1); + while (sprite_ptr != spritelist) { int pri; @@ -3172,7 +3197,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta f3_drawgfx(machine, bitmap,sprite_gfx, sprite_ptr->code, - sprite_ptr->color, + sprite_ptr->color & color_mask, sprite_ptr->flipx,sprite_ptr->flipy, sprite_ptr->x,sprite_ptr->y, cliprect, @@ -3181,7 +3206,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta f3_drawgfxzoom(machine, bitmap,sprite_gfx, sprite_ptr->code, - sprite_ptr->color, + sprite_ptr->color & color_mask, sprite_ptr->flipx,sprite_ptr->flipy, sprite_ptr->x,sprite_ptr->y, cliprect,