From 5a14b6f516f1ce6c8ab29c5a147199dc09059145 Mon Sep 17 00:00:00 2001 From: Nicola Salmoria Date: Fri, 22 Aug 2008 18:55:28 +0000 Subject: [PATCH] snk.c rewrite (WIP) fixed sprite-sprite priorities --- src/mame/drivers/snk.c | 11 +++-------- src/mame/includes/snk.h | 2 +- src/mame/video/snk.c | 31 +++++++++++-------------------- 3 files changed, 15 insertions(+), 29 deletions(-) diff --git a/src/mame/drivers/snk.c b/src/mame/drivers/snk.c index bd41873af4a..1b5ab362418 100644 --- a/src/mame/drivers/snk.c +++ b/src/mame/drivers/snk.c @@ -125,11 +125,6 @@ Notes: TODO: ----- -- gwar, gwara, bermudat, worldwar, etc: unknown writes to CAC0. These appear to - control sprite/sprite relative priorities, but it's not clear how. - There seem to be some wrong priorities e.g. the volcanoes shooting fireballs in - worldwar. - - Fighting Golf: unknown writes to CF00, probably video related. - The Fighting Golf flyer shows a different gameplay, where button A is pressed @@ -988,7 +983,7 @@ static ADDRESS_MAP_START( bermudat_cpuA_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0xca00, 0xca00) AM_WRITE(turbocheck16_1_w) AM_RANGE(0xca40, 0xca40) AM_WRITE(turbocheck16_2_w) AM_RANGE(0xca80, 0xca80) AM_WRITE(gwara_sp_scroll_msb_w) - AM_RANGE(0xcac0, 0xcac0) AM_WRITE(gwar_unknown_video_w) // controls sprite priorities somehow? + AM_RANGE(0xcac0, 0xcac0) AM_WRITE(gwar_sprite_split_point_w) AM_RANGE(0xcb00, 0xcb00) AM_READ(turbocheck16_1_r) AM_RANGE(0xcb10, 0xcb10) AM_READ(turbocheck16_2_r) AM_RANGE(0xcb20, 0xcb20) AM_READ(turbocheck16_3_r) @@ -1047,7 +1042,7 @@ static ADDRESS_MAP_START( gwar_cpuA_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0xc9c0, 0xc9c0) AM_WRITE(snk_sp32_scrollx_w) AM_RANGE(0xca00, 0xca00) AM_WRITENOP // always 0? AM_RANGE(0xca40, 0xca40) AM_WRITENOP // always 0? - AM_RANGE(0xcac0, 0xcac0) AM_WRITE(gwar_unknown_video_w) // controls sprite priorities somehow? + AM_RANGE(0xcac0, 0xcac0) AM_WRITE(gwar_sprite_split_point_w) AM_RANGE(0xd000, 0xdfff) AM_RAM_WRITE(snk_bg_videoram_w) AM_SHARE(1) AM_BASE(&snk_bg_videoram) // + work RAM AM_RANGE(0xe000, 0xf7ff) AM_RAM AM_SHARE(2) AM_BASE(&spriteram) // + work ram AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(snk_fg_videoram_w) AM_SHARE(3) AM_BASE(&snk_fg_videoram) // + work RAM @@ -1085,7 +1080,7 @@ static ADDRESS_MAP_START( gwara_cpuA_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0xf980, 0xf980) AM_WRITE(snk_sp32_scrolly_w) AM_RANGE(0xf9c0, 0xf9c0) AM_WRITE(snk_sp32_scrollx_w) AM_RANGE(0xfa80, 0xfa80) AM_WRITE(gwara_sp_scroll_msb_w) - AM_RANGE(0xfac0, 0xfac0) AM_WRITE(gwar_unknown_video_w) // controls sprite priorities somehow? + AM_RANGE(0xfac0, 0xfac0) AM_WRITE(gwar_sprite_split_point_w) ADDRESS_MAP_END static ADDRESS_MAP_START( gwara_cpuB_map, ADDRESS_SPACE_PROGRAM, 8 ) diff --git a/src/mame/includes/snk.h b/src/mame/includes/snk.h index 420115b5d4a..e819f6c9156 100644 --- a/src/mame/includes/snk.h +++ b/src/mame/includes/snk.h @@ -52,7 +52,7 @@ extern WRITE8_HANDLER( ikari_sp_scroll_msb_w ); extern WRITE8_HANDLER( ikari_unknown_video_w ); extern WRITE8_HANDLER( gwar_fg_bank_w ); extern WRITE8_HANDLER( gwar_videoattrs_w ); -extern WRITE8_HANDLER( gwar_unknown_video_w ); +extern WRITE8_HANDLER( gwar_sprite_split_point_w ); extern WRITE8_HANDLER( gwara_videoattrs_w ); extern WRITE8_HANDLER( gwara_sp_scroll_msb_w ); diff --git a/src/mame/video/snk.c b/src/mame/video/snk.c index 0adf66b5533..6fe7d0cad87 100644 --- a/src/mame/video/snk.c +++ b/src/mame/video/snk.c @@ -35,7 +35,7 @@ static tilemap *fg_tilemap; static tilemap *bg_tilemap; static int fg_bank; static int bg_scrollx, bg_scrolly, sp16_scrollx, sp16_scrolly, sp32_scrollx, sp32_scrolly; -static UINT8 unknown_reg; +static UINT8 sprite_split_point; static UINT8 empty_tile[16*16]; @@ -407,10 +407,9 @@ WRITE8_HANDLER( gwara_sp_scroll_msb_w ) sp16_scrolly = (sp16_scrolly & 0xff) | ((data & 0x04) << 6); } -WRITE8_HANDLER( gwar_unknown_video_w ) +WRITE8_HANDLER( gwar_sprite_split_point_w ) { -//popmessage("%02x",data); - unknown_reg = data; + sprite_split_point = data; } /**************************************************************************************/ @@ -570,12 +569,13 @@ byte3: attributes -xx-x--- (bank number) x------- (x offset bit8) */ -static void tdfever_draw_sp(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int xscroll, int yscroll, int mode, int flip ) +static void tdfever_draw_sp(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int xscroll, int yscroll, int mode, + int flip, int from, int to ) { const UINT8 *source = spriteram + ((mode==2)?0x800:0x000); const gfx_element *gfx = machine->gfx[(mode==1)?3:2]; int tile_number, attributes, sx, sy, color, pen_mode; - int which, finish, sp_size; + int which, sp_size; int flipx, flipy; if(mode < 0 || mode > 2) return; @@ -584,16 +584,14 @@ static void tdfever_draw_sp(running_machine *machine, bitmap_t *bitmap, const re if(mode == 2) { - finish = 64 * 4; sp_size = 16; } else { - finish = 32 * 4; sp_size = 32; } - for(which = 0; which < finish; which+=4) + for(which = from*4; which < to*4; which+=4) { if(*(UINT32*)(source+which) == 0 || *(UINT32*)(source+which) == -1) continue; @@ -698,7 +696,7 @@ VIDEO_UPDATE( tdfever ) tdfever_draw_bg(screen->machine, bitmap, cliprect, bg_scroll_x, bg_scroll_y ); spriteram = snk_rambase + 0x1000; - tdfever_draw_sp(screen->machine, bitmap, cliprect, sp16_scroll_x, sp16_scroll_y, 0, 1 ); + tdfever_draw_sp(screen->machine, bitmap, cliprect, sp16_scroll_x, sp16_scroll_y, 0, 1, 0, 32 ); tdfever_draw_tx(screen->machine, bitmap, cliprect, tx_attributes, 0, 0, 0xf800 ); return 0; @@ -743,16 +741,9 @@ VIDEO_UPDATE( gwar ) tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0); - if(unknown_reg & 0xf8) // improves priority - { - tdfever_draw_sp(screen->machine, bitmap, cliprect, -sp16_scrollx - 9, -sp16_scrolly - 15, 2, 0 ); - tdfever_draw_sp(screen->machine, bitmap, cliprect, -sp32_scrollx - 9, -sp32_scrolly - 31, 1, 0 ); - } - else - { - tdfever_draw_sp(screen->machine, bitmap, cliprect, -sp32_scrollx - 9, -sp32_scrolly - 31, 1, 0 ); - tdfever_draw_sp(screen->machine, bitmap, cliprect, -sp16_scrollx - 9, -sp16_scrolly - 15, 2, 0 ); - } + tdfever_draw_sp(screen->machine, bitmap, cliprect, -sp16_scrollx - 9, -sp16_scrolly - 15, 2, 0, 0, sprite_split_point ); + tdfever_draw_sp(screen->machine, bitmap, cliprect, -sp32_scrollx - 9, -sp32_scrolly - 31, 1, 0, 0, 32 ); + tdfever_draw_sp(screen->machine, bitmap, cliprect, -sp16_scrollx - 9, -sp16_scrolly - 15, 2, 0, sprite_split_point, 64 ); tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);