diff options
Diffstat (limited to 'src/mame/video/argus.c')
-rw-r--r-- | src/mame/video/argus.c | 1376 |
1 files changed, 483 insertions, 893 deletions
diff --git a/src/mame/video/argus.c b/src/mame/video/argus.c index 005d9302fc2..4dff4a7d901 100644 --- a/src/mame/video/argus.c +++ b/src/mame/video/argus.c @@ -114,13 +114,7 @@ BG0 palette intensity ( $C47F, $C4FF ) ***************************************************************************/ #include "driver.h" - -#include "jalblend.c" - -#define BUTASAN_TEXT_RAMSIZE 0x0800 -#define BUTASAN_BG0_RAMSIZE 0x0800 -#define BUTASAN_TXBACK_RAMSIZE 0x0800 -#define BUTASAN_BG0BACK_RAMSIZE 0x0800 +#include "jalblend.h" UINT8 *argus_paletteram; @@ -132,34 +126,37 @@ UINT8 *argus_bg1_scrollx; UINT8 *argus_bg1_scrolly; UINT8 *butasan_bg1ram; +static int bg0_scrollx, bg0_scrolly; +static int bg1_scrollx, bg1_scrolly; + static UINT8 *argus_dummy_bg0ram; static UINT8 *butasan_txram; static UINT8 *butasan_bg0ram; static UINT8 *butasan_bg0backram; static UINT8 *butasan_txbackram; +static UINT8 *butasan_pagedram[2]; +static UINT8 butasan_page_latch; static tilemap *tx_tilemap = NULL; static tilemap *bg0_tilemap = NULL; static tilemap *bg1_tilemap = NULL; -static tilemap *bombsa_bg_tilemap = NULL; static UINT8 argus_bg_status; static UINT8 butasan_bg1_status; -static UINT8 argus_bg_purple = 0; -static UINT8 argus_flipscreen = 0; +static UINT8 argus_flipscreen; -static int argus_palette_intensity = 0; +static UINT16 argus_palette_intensity; /* VROM scroll related for Argus */ -static int lowbitscroll = 0; -static int prvscrollx = 0; - -static UINT8 bombsa_ram_page; -static UINT8* bomba_otherram; +static int lowbitscroll; +static int prvscrollx; -static int valtric_mosaic=0; +static UINT8 valtric_mosaic; static bitmap_t *mosaicbitmap; +static UINT8 valtric_unknown; +static UINT8 butasan_unknown; + /*************************************************************************** Callbacks for the tilemap code @@ -167,10 +164,12 @@ static bitmap_t *mosaicbitmap; static TILE_GET_INFO( argus_get_tx_tile_info ) { - int hi, lo; + UINT8 hi, lo; + + tile_index <<= 1; - lo = argus_txram[ tile_index << 1 ]; - hi = argus_txram[ (tile_index << 1) + 1 ]; + lo = argus_txram[tile_index]; + hi = argus_txram[tile_index + 1]; SET_TILE_INFO( 3, @@ -181,10 +180,12 @@ static TILE_GET_INFO( argus_get_tx_tile_info ) static TILE_GET_INFO( argus_get_bg0_tile_info ) { - int hi, lo; + UINT8 hi, lo; - lo = argus_dummy_bg0ram[ tile_index << 1 ]; - hi = argus_dummy_bg0ram[ (tile_index << 1) + 1 ]; + tile_index <<= 1; + + lo = argus_dummy_bg0ram[tile_index]; + hi = argus_dummy_bg0ram[tile_index + 1]; SET_TILE_INFO( 1, @@ -195,10 +196,12 @@ static TILE_GET_INFO( argus_get_bg0_tile_info ) static TILE_GET_INFO( argus_get_bg1_tile_info ) { - int hi, lo; + UINT8 hi, lo; + + tile_index <<= 1; - lo = argus_bg1ram[ tile_index << 1 ]; - hi = argus_bg1ram[ (tile_index << 1) + 1 ]; + lo = argus_bg1ram[tile_index]; + hi = argus_bg1ram[tile_index + 1]; SET_TILE_INFO( 2, @@ -209,10 +212,12 @@ static TILE_GET_INFO( argus_get_bg1_tile_info ) static TILE_GET_INFO( valtric_get_tx_tile_info ) { - int hi, lo; + UINT8 hi, lo; - lo = argus_txram[ tile_index << 1 ]; - hi = argus_txram[ (tile_index << 1) + 1 ]; + tile_index <<= 1; + + lo = argus_txram[tile_index]; + hi = argus_txram[tile_index + 1]; SET_TILE_INFO( 2, @@ -223,29 +228,29 @@ static TILE_GET_INFO( valtric_get_tx_tile_info ) static TILE_GET_INFO( valtric_get_bg_tile_info ) { - int hi, lo, color, tile; + UINT8 hi, lo; - lo = argus_bg1ram[ tile_index << 1 ]; - hi = argus_bg1ram[ (tile_index << 1) + 1 ]; + tile_index <<= 1; - tile = ((hi & 0xc0) << 2) | ((hi & 0x20) << 5) | lo; - color = hi & 0x0f; + lo = argus_bg1ram[tile_index]; + hi = argus_bg1ram[tile_index + 1]; SET_TILE_INFO( 1, - tile, - color, + ((hi & 0xc0) << 2) | ((hi & 0x20) << 5) | lo, + hi & 0x0f, 0); } static TILE_GET_INFO( butasan_get_tx_tile_info ) { - int hi, lo; + UINT8 hi, lo; tile_index ^= 0x3e0; + tile_index <<= 1; - lo = butasan_txram[ tile_index << 1 ]; - hi = butasan_txram[ (tile_index << 1) + 1 ]; + lo = butasan_txram[tile_index]; + hi = butasan_txram[tile_index + 1]; SET_TILE_INFO( 3, @@ -256,15 +261,15 @@ static TILE_GET_INFO( butasan_get_tx_tile_info ) static TILE_GET_INFO( butasan_get_bg0_tile_info ) { - int hi, lo; + UINT8 hi, lo; int attrib; - attrib = (tile_index & 0x00f) | ((tile_index & 0x1e0) >> 1); - attrib |= ((tile_index & 0x200) >> 1) | ((tile_index & 0x010) << 5); + attrib = (tile_index & 0x00f) | ((tile_index & 0x3e0) >> 1) | ((tile_index & 0x010) << 5); attrib ^= 0x0f0; + attrib <<= 1; - lo = butasan_bg0ram[ attrib << 1 ]; - hi = butasan_bg0ram[ (attrib << 1) + 1 ]; + lo = butasan_bg0ram[attrib]; + hi = butasan_bg0ram[attrib + 1]; SET_TILE_INFO( 1, @@ -273,27 +278,19 @@ static TILE_GET_INFO( butasan_get_bg0_tile_info ) TILE_FLIPYX((hi & 0x30) >> 4)); } - - - - - static TILE_GET_INFO( butasan_get_bg1_tile_info ) { - int bank, tile, attrib, color; + int attrib, tile; - attrib = (tile_index & 0x00f) | ((tile_index & 0x3e0) >> 1) - | ((tile_index & 0x010) << 5); + attrib = (tile_index & 0x00f) | ((tile_index & 0x3e0) >> 1) | ((tile_index & 0x010) << 5); attrib ^= 0x0f0; - bank = (butasan_bg1_status & 0x02) << 7; - tile = butasan_bg1ram[ attrib ] | bank; - color = (tile & 0x80) >> 7; + tile = butasan_bg1ram[attrib] | ((butasan_bg1_status & 2) << 7); SET_TILE_INFO( 2, tile, - color, + (tile & 0x80) >> 7, 0); } @@ -302,27 +299,28 @@ static TILE_GET_INFO( butasan_get_bg1_tile_info ) Initialize and destroy video hardware emulation ***************************************************************************/ -static void reset_common(void) +static void reset_common(running_machine *machine) { argus_bg_status = 0x01; - argus_bg_purple = 0; argus_flipscreen = 0; argus_palette_intensity = 0; + + if (jal_blend_table != NULL) + memset(jal_blend_table, 0, 0xc00); } VIDEO_START( argus ) { - /* info offset type w h col row */ - bg0_tilemap = tilemap_create(argus_get_bg0_tile_info, tilemap_scan_cols, 16, 16, 32, 32); - bg1_tilemap = tilemap_create(argus_get_bg1_tile_info, tilemap_scan_cols, 16, 16, 32, 32); - tx_tilemap = tilemap_create(argus_get_tx_tile_info, tilemap_scan_cols, 8, 8, 32, 32); + /* info offset w h col row */ + bg0_tilemap = tilemap_create(argus_get_bg0_tile_info, tilemap_scan_cols, 16, 16, 32, 32); + bg1_tilemap = tilemap_create(argus_get_bg1_tile_info, tilemap_scan_cols, 16, 16, 32, 32); + tx_tilemap = tilemap_create(argus_get_tx_tile_info, tilemap_scan_cols, 8, 8, 32, 32); - /* dummy RAM for back ground */ - argus_dummy_bg0ram = auto_malloc( 0x800 ); + tilemap_set_transparent_pen(bg1_tilemap, 15); + tilemap_set_transparent_pen(tx_tilemap, 15); - tilemap_set_transparent_pen( bg0_tilemap, 15 ); - tilemap_set_transparent_pen( bg1_tilemap, 15 ); - tilemap_set_transparent_pen( tx_tilemap, 15 ); + /* dummy RAM for back ground */ + argus_dummy_bg0ram = auto_malloc(0x800); jal_blend_table = auto_malloc(0xc00); } @@ -331,200 +329,135 @@ VIDEO_RESET( argus ) { lowbitscroll = 0; prvscrollx = 0; - - memset( argus_dummy_bg0ram, 0, 0x800 ); - memset( argus_bg0_scrollx, 0x00, 2 ); - - memset(jal_blend_table,0,0xc00); - reset_common(); + argus_bg0_scrollx[0] = 0; + argus_bg0_scrollx[1] = 0; + memset(argus_dummy_bg0ram, 0, 0x800); + reset_common(machine); } VIDEO_START( valtric ) { - /* info offset w h col row */ - bg1_tilemap = tilemap_create(valtric_get_bg_tile_info, tilemap_scan_cols, 16, 16, 32, 32); - tx_tilemap = tilemap_create(valtric_get_tx_tile_info, tilemap_scan_cols, 8, 8, 32, 32); + /* info offset w h col row */ + bg1_tilemap = tilemap_create(valtric_get_bg_tile_info, tilemap_scan_cols, 16, 16, 32, 32); + tx_tilemap = tilemap_create(valtric_get_tx_tile_info, tilemap_scan_cols, 8, 8, 32, 32); + + tilemap_set_transparent_pen(tx_tilemap, 15); - tilemap_set_transparent_pen( bg1_tilemap, 15 ); - tilemap_set_transparent_pen( tx_tilemap, 15 ); mosaicbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + jal_blend_table = auto_malloc(0xc00); } VIDEO_RESET( valtric ) { - valtric_mosaic = 0; - memset(jal_blend_table,0,0xc00); - reset_common(); + valtric_mosaic = 0x0f; + reset_common(machine); } VIDEO_START( butasan ) { - /* info offset type w h col row */ - bg0_tilemap = tilemap_create(butasan_get_bg0_tile_info, tilemap_scan_rows, 16, 16, 32, 32); - bg1_tilemap = tilemap_create(butasan_get_bg1_tile_info, tilemap_scan_rows, 16, 16, 32, 32); - tx_tilemap = tilemap_create(butasan_get_tx_tile_info, tilemap_scan_rows, 8, 8, 32, 32); + /* info offset w h col row */ + bg0_tilemap = tilemap_create(butasan_get_bg0_tile_info, tilemap_scan_rows, 16, 16, 32, 32); + bg1_tilemap = tilemap_create(butasan_get_bg1_tile_info, tilemap_scan_rows, 16, 16, 32, 32); + tx_tilemap = tilemap_create(butasan_get_tx_tile_info, tilemap_scan_rows, 8, 8, 32, 32); - butasan_txram = auto_malloc( BUTASAN_TEXT_RAMSIZE ); - butasan_bg0ram = auto_malloc( BUTASAN_BG0_RAMSIZE ); - butasan_txbackram = auto_malloc( BUTASAN_TXBACK_RAMSIZE ); - butasan_bg0backram = auto_malloc( BUTASAN_BG0BACK_RAMSIZE ); + tilemap_set_transparent_pen(bg1_tilemap, 15); + tilemap_set_transparent_pen(tx_tilemap, 15); - tilemap_set_transparent_pen( tx_tilemap, 15 ); + butasan_pagedram[0] = auto_malloc(0x1000); + butasan_pagedram[1] = auto_malloc(0x1000); + + butasan_bg0ram = &butasan_pagedram[0][0x000]; + butasan_bg0backram = &butasan_pagedram[0][0x800]; + butasan_txram = &butasan_pagedram[1][0x000]; + butasan_txbackram = &butasan_pagedram[1][0x800]; jal_blend_table = auto_malloc(0xc00); + //jal_blend_table = NULL; } VIDEO_RESET( butasan ) { + butasan_page_latch = 0; butasan_bg1_status = 0x01; - - memset( butasan_txram, 0x00, BUTASAN_TEXT_RAMSIZE ); - memset( butasan_bg0ram, 0x00, BUTASAN_BG0_RAMSIZE ); - memset( butasan_txbackram, 0x00, BUTASAN_TXBACK_RAMSIZE ); - memset( butasan_bg0backram, 0x00, BUTASAN_BG0BACK_RAMSIZE ); - - memset(jal_blend_table,0,0xc00); - reset_common(); -} - -#if 0 -static TILE_GET_INFO( bombsa_get_tx_alt_tile_info ) -{ - int hi, lo; - - lo = bombsa_tx_alt_ram[ tile_index << 1 ]; - hi = bombsa_tx_alt_ram[ (tile_index << 1) + 1 ]; - - SET_TILE_INFO( - 2, - ((hi & 0xc0) << 2) | lo, - hi & 0x0f, - TILE_FLIPYX((hi & 0x30) >> 4)); -} -#endif - -static TILE_GET_INFO( bombsa_get_bg_tile_info ) -{ - int tileno; - int col; - - tileno = bomba_otherram[tile_index*2] | ( bomba_otherram[tile_index*2+1]<<8); - col = 0; - - SET_TILE_INFO( - 1, - tileno, - col, - 0); + memset(butasan_pagedram[0], 0, 0x1000); + memset(butasan_pagedram[1], 0, 0x1000); + reset_common(machine); } -VIDEO_START( bombsa ) -{ - /* info offset type w h col row */ -// bg1_tilemap = tilemap_create(valtric_get_bg_tile_info, tilemap_scan_cols, 16, 16, 32, 32); - tx_tilemap = tilemap_create(valtric_get_tx_tile_info, tilemap_scan_cols, 8, 8, 32, 32); - -#if 0 - /* this might be wrong.. but it looks like there may be a tilemap here that can change between 8x8 and 16x16 mode.. */ - /* when you start the game it gets 'corrupted' with data for another layer.. */ - tx_alt_tilemap = tilemap_create(bombsa_get_tx_alt_tile_info, tilemap_scan_cols, 8, 8, 32, 32); -#endif - - bombsa_bg_tilemap = tilemap_create(bombsa_get_bg_tile_info, tilemap_scan_cols, 16, 16, 64, 32); - -#if 0 - bombsa_tx_alt_ram = auto_malloc(0x800); -#endif - -// tilemap_set_transparent_pen( bg1_tilemap, 15 ); - tilemap_set_transparent_pen( tx_tilemap, 15 ); -#if 0 - tilemap_set_transparent_pen( tx_alt_tilemap, 15 ); -#endif -// jal_blend_table = auto_malloc(0xc00); -// memset(jal_blend_table,0,0xc00) ; - - bomba_otherram = auto_malloc(0x1000); -} - -VIDEO_RESET( bombsa ) -{ - bombsa_ram_page = 0; - memset(bomba_otherram, 0, 0x1000); - reset_common(); -} - /*************************************************************************** Functions for handler of MAP roms in Argus and palette color ***************************************************************************/ /* Write bg0 pattern data to dummy bg0 ram */ -static void argus_write_dummy_rams( running_machine *machine, int dramoffs, int vromoffs ) +static void argus_write_dummy_rams(running_machine *machine, int dramoffs, int vromoffs) { int i; int voffs; int offs; - UINT8 *VROM1 = memory_region( machine, "user1" ); /* "ag_15.bin" */ - UINT8 *VROM2 = memory_region( machine, "user2" ); /* "ag_16.bin" */ + UINT8 *VROM1 = memory_region(machine, "user1"); /* "ag_15.bin" */ + UINT8 *VROM2 = memory_region(machine, "user2"); /* "ag_16.bin" */ /* offset in pattern data */ - offs = VROM1[ vromoffs ] | ( VROM1[ vromoffs + 1 ] << 8 ); + offs = VROM1[vromoffs] | (VROM1[vromoffs + 1] << 8); offs &= 0x7ff; voffs = offs * 16; - for (i = 0 ; i < 8 ; i ++) + for (i = 0; i < 8; i++) { - argus_dummy_bg0ram[ dramoffs ] = VROM2[ voffs ]; - argus_dummy_bg0ram[ dramoffs + 1 ] = VROM2[ voffs + 1 ]; - tilemap_mark_tile_dirty( bg0_tilemap, dramoffs >> 1 ); + argus_dummy_bg0ram[dramoffs] = VROM2[voffs]; + argus_dummy_bg0ram[dramoffs + 1] = VROM2[voffs + 1]; + tilemap_mark_tile_dirty(bg0_tilemap, dramoffs >> 1); dramoffs += 2; voffs += 2; } } - -static void bombsa_change_palette(running_machine *machine, int color, int data) +static void argus_change_palette(running_machine *machine, int color, int lo_offs, int hi_offs) { - palette_set_color_rgb(machine, color, pal4bit(data >> 12), pal4bit(data >> 8), pal4bit(data >> 4)); + UINT8 lo = argus_paletteram[lo_offs]; + UINT8 hi = argus_paletteram[hi_offs]; + if (jal_blend_table != NULL) jal_blend_table[color] = hi & 0x0f; + palette_set_color_rgb(machine, color, pal4bit(lo >> 4), pal4bit(lo), pal4bit(hi >> 4)); } - -static void argus_change_palette(running_machine *machine, int color, int data) +static void argus_change_bg_palette(running_machine *machine, int color, int lo_offs, int hi_offs) { - jal_blend_table[color] = data & 0x0f ; + UINT8 r,g,b,lo,hi,ir,ig,ib,ix; + rgb_t rgb,irgb; - palette_set_color_rgb(machine, color, pal4bit(data >> 12), pal4bit(data >> 8), pal4bit(data >> 4)); -} - -static void argus_change_bg_palette(running_machine *machine, int color, int data) -{ - int r, g, b; - int ir, ig, ib; + /* red,green,blue intensities */ + ir = pal4bit(argus_palette_intensity >> 12); + ig = pal4bit(argus_palette_intensity >> 8); + ib = pal4bit(argus_palette_intensity >> 4); + ix = argus_palette_intensity & 0x0f; - r = (data >> 12) & 0x0f; - g = (data >> 8) & 0x0f; - b = (data >> 4) & 0x0f; + irgb = MAKE_RGB(ir,ig,ib); - ir = (argus_palette_intensity >> 12) & 0x0f; - ig = (argus_palette_intensity >> 8) & 0x0f; - ib = (argus_palette_intensity >> 4) & 0x0f; + lo = argus_paletteram[lo_offs]; + hi = argus_paletteram[hi_offs]; - r = (r - ir > 0) ? r - ir : 0; - g = (g - ig > 0) ? g - ig : 0; - b = (b - ib > 0) ? b - ib : 0; + /* red,green,blue component */ + r = pal4bit(lo >> 4); + g = pal4bit(lo); + b = pal4bit(hi >> 4); - if (argus_bg_status & 2) /* Gray / purple scale */ + /* Grey background enable */ + if (argus_bg_status & 2) + { + UINT8 val = (r + g + b) / 3; + rgb = MAKE_RGB(val,val,val); + } + else { - r = (r + g + b) / 3; - g = b = r; - if (argus_bg_purple == 2) /* Purple */ - g = 0; + rgb = MAKE_RGB(r,g,b); } - palette_set_color_rgb(machine, color, pal4bit(r), pal4bit(g), pal4bit(b)); + rgb = jal_blend_func(rgb,irgb,ix); + + palette_set_color(machine,color,rgb); } @@ -532,196 +465,55 @@ static void argus_change_bg_palette(running_machine *machine, int color, int dat Memory handler ***************************************************************************/ -WRITE8_HANDLER(valtric_mosaic_w) -{ - if(data!=0x80) - { - valtric_mosaic=0x0f-(data&0x0f); - - if(valtric_mosaic!=0) - { - valtric_mosaic++; - } - - if(data&0x80) - { - valtric_mosaic*=-1; - } - } -} - - -WRITE8_HANDLER( bombsa_pageselect_w ) +WRITE8_HANDLER( valtric_mosaic_w ) { - bombsa_ram_page = data; + valtric_mosaic = data; } READ8_HANDLER( argus_txram_r ) { - return argus_txram[ offset ]; + return argus_txram[offset]; } WRITE8_HANDLER( argus_txram_w ) { - argus_txram[ offset ] = data; - tilemap_mark_tile_dirty(tx_tilemap, offset >> 1); -} - -READ8_HANDLER( bombsa_txram_r ) -{ -#if 0 - if (bombsa_ram_page == 1) - { - return argus_txram[ offset ]; - } - else - { - return bombsa_tx_alt_ram[ offset ]; - } -#endif - - return argus_txram[ offset ]; - -} - -WRITE8_HANDLER( bombsa_txram_w ) -{ -#if 0 - if (bombsa_ram_page == 1) - { - argus_txram[ offset ] = data; - tilemap_mark_tile_dirty(tx_tilemap, offset >> 1); - } - else - { - /* 8x8 .. */ - bombsa_tx_alt_ram[ offset ] = data; - tilemap_mark_tile_dirty(tx_alt_tilemap, offset >> 1); - /* also 16x16 ..? */ - } -#endif - argus_txram[ offset ] = data; + argus_txram[offset] = data; tilemap_mark_tile_dirty(tx_tilemap, offset >> 1); } -READ8_HANDLER( butasan_txram_r ) -{ - return butasan_txram[ offset ]; -} - -WRITE8_HANDLER( butasan_txram_w ) -{ - butasan_txram[ offset ] = data; - tilemap_mark_tile_dirty(tx_tilemap, (offset ^ 0x7c0) >> 1); -} - READ8_HANDLER( argus_bg1ram_r ) { - return argus_bg1ram[ offset ]; + return argus_bg1ram[offset]; } WRITE8_HANDLER( argus_bg1ram_w ) { - argus_bg1ram[ offset ] = data; + argus_bg1ram[offset] = data; tilemap_mark_tile_dirty(bg1_tilemap, offset >> 1); } -READ8_HANDLER( butasan_bg0ram_r ) -{ - return butasan_bg0ram[ offset ]; -} - -WRITE8_HANDLER( butasan_bg0ram_w ) -{ - int idx; - - butasan_bg0ram[ offset ] = data; - - idx = ((offset & 0x01f) >> 1) | ((offset & 0x400) >> 6); - idx |= (offset & 0x3e0) ^ 0x1e0; - - tilemap_mark_tile_dirty(bg0_tilemap, idx); -} - -READ8_HANDLER( butasan_bg1ram_r ) -{ - return butasan_bg1ram[ offset ]; -} - -WRITE8_HANDLER( butasan_bg1ram_w ) +WRITE8_HANDLER( argus_bg0_scrollx_w ) { - int idx; - - butasan_bg1ram[ offset ] = data; - - idx = (offset & 0x00f) | ((offset & 0x200) >> 5) | ((offset & 0x1f0) << 1); - idx ^= 0x0f0; - - tilemap_mark_tile_dirty(bg1_tilemap, idx); -} - -WRITE8_HANDLER ( argus_bg0_scrollx_w ) -{ - if (argus_bg0_scrollx[ offset ] != data) - { - argus_bg0_scrollx[ offset ] = data; - } + argus_bg0_scrollx[offset] = data; + bg0_scrollx = argus_bg0_scrollx[0] | (argus_bg0_scrollx[1] << 8); } WRITE8_HANDLER( argus_bg0_scrolly_w ) { - if (argus_bg0_scrolly[ offset ] != data) - { - int scrolly; - argus_bg0_scrolly[ offset ] = data; - scrolly = argus_bg0_scrolly[0] | ( (argus_bg0_scrolly[1] & 0x01) << 8); - if (!argus_flipscreen) - tilemap_set_scrolly( bg0_tilemap, 0, scrolly ); - else - tilemap_set_scrolly( bg0_tilemap, 0, (scrolly + 256) & 0x1ff ); - } -} - -WRITE8_HANDLER( butasan_bg0_scrollx_w ) -{ - if (argus_bg0_scrollx[ offset ] != data) - { - int scrollx; - argus_bg0_scrollx[ offset ] = data; - scrollx = argus_bg0_scrollx[0] | ( (argus_bg0_scrollx[1] & 0x01) << 8); - if (!argus_flipscreen) - tilemap_set_scrollx( bg0_tilemap, 0, scrollx ); - else - tilemap_set_scrollx( bg0_tilemap, 0, (scrollx + 256) & 0x1ff ); - } + argus_bg0_scrolly[offset] = data; + bg0_scrolly = argus_bg0_scrolly[0] | (argus_bg0_scrolly[1] << 8); } WRITE8_HANDLER( argus_bg1_scrollx_w ) { - if (argus_bg1_scrollx[ offset ] != data) - { - int scrollx; - argus_bg1_scrollx[ offset ] = data; - scrollx = argus_bg1_scrollx[0] | ( (argus_bg1_scrollx[1] & 0x01) << 8); - if (!argus_flipscreen) - tilemap_set_scrollx( bg1_tilemap, 0, scrollx ); - else - tilemap_set_scrollx( bg1_tilemap, 0, (scrollx + 256) & 0x1ff ); - } + argus_bg1_scrollx[offset] = data; + bg1_scrollx = argus_bg1_scrollx[0] | (argus_bg1_scrollx[1] << 8); } WRITE8_HANDLER( argus_bg1_scrolly_w ) { - if (argus_bg1_scrolly[ offset ] != data) - { - int scrolly; - argus_bg1_scrolly[ offset ] = data; - scrolly = argus_bg1_scrolly[0] | ( (argus_bg1_scrolly[1] & 0x01) << 8); - if (!argus_flipscreen) - tilemap_set_scrolly( bg1_tilemap, 0, scrolly ); - else - tilemap_set_scrolly( bg1_tilemap, 0, (scrolly + 256) & 0x1ff ); - } + argus_bg1_scrolly[offset] = data; + bg1_scrolly = argus_bg1_scrolly[0] | (argus_bg1_scrolly[1] << 8); } WRITE8_HANDLER( argus_bg_status_w ) @@ -730,18 +522,14 @@ WRITE8_HANDLER( argus_bg_status_w ) { argus_bg_status = data; - /* Backgound enable */ - tilemap_set_enable(bg1_tilemap, argus_bg_status & 1); - /* Gray / purple scale */ if (argus_bg_status & 2) { int offs; - for (offs = 0x400 ; offs < 0x500 ; offs ++) + for (offs = 0x400; offs < 0x500; offs++) { - argus_change_bg_palette( machine, (offs - 0x0400) + 128, - (argus_paletteram[offs] << 8) | argus_paletteram[offs + 0x0400] ); + argus_change_bg_palette(machine, (offs - 0x400) + 0x080, offs, offs + 0x400); } } } @@ -753,18 +541,14 @@ WRITE8_HANDLER( valtric_bg_status_w ) { argus_bg_status = data; - /* Backgound enable */ - tilemap_set_enable(bg1_tilemap, argus_bg_status & 1); - /* Gray / purple scale */ if (argus_bg_status & 2) { int offs; - for (offs = 0x400 ; offs < 0x600 ; offs += 2) + for (offs = 0x400; offs < 0x600; offs += 2) { - argus_change_bg_palette( machine, ((offs - 0x0400) >> 1) + 256, - argus_paletteram[offs | 1] | (argus_paletteram[offs & ~1] << 8)); + argus_change_bg_palette(machine, ((offs - 0x400) >> 1) + 0x100, offs & ~1, offs | 1); } } } @@ -772,269 +556,193 @@ WRITE8_HANDLER( valtric_bg_status_w ) WRITE8_HANDLER( butasan_bg0_status_w ) { - if (argus_bg_status != data) + argus_bg_status = data; +} + +WRITE8_HANDLER( butasan_bg1_status_w ) +{ + if (butasan_bg1_status != data) { - argus_bg_status = data; + butasan_bg1_status = data; - /* Backgound enable */ - tilemap_set_enable(bg0_tilemap, argus_bg_status & 1); + /* Bank changed */ + tilemap_mark_all_tiles_dirty(bg1_tilemap); } } WRITE8_HANDLER( argus_flipscreen_w ) { - if (argus_flipscreen != (data >> 7)) - { - argus_flipscreen = data >> 7; - tilemap_set_flip( ALL_TILEMAPS, (argus_flipscreen) ? TILEMAP_FLIPY | TILEMAP_FLIPX : 0); - if (!argus_flipscreen) - { - int scrollx, scrolly; - - if (bg0_tilemap != NULL) - { - scrollx = argus_bg0_scrollx[0] | ( (argus_bg0_scrollx[1] & 0x01) << 8); - tilemap_set_scrollx(bg0_tilemap, 0, scrollx & 0x1ff); - - scrolly = argus_bg0_scrolly[0] | ( (argus_bg0_scrolly[1] & 0x01) << 8); - tilemap_set_scrolly(bg0_tilemap, 0, scrolly); - } - scrollx = argus_bg1_scrollx[0] | ( (argus_bg1_scrollx[1] & 0x01) << 8); - tilemap_set_scrollx(bg1_tilemap, 0, scrollx); - - scrolly = argus_bg1_scrolly[0] | ( (argus_bg1_scrolly[1] & 0x01) << 8); - tilemap_set_scrolly(bg1_tilemap, 0, scrolly); - } - else - { - int scrollx, scrolly; - - if (bg0_tilemap != NULL) - { - scrollx = argus_bg0_scrollx[0] | ( (argus_bg0_scrollx[1] & 0x01) << 8); - tilemap_set_scrollx(bg0_tilemap, 0, (scrollx + 256) & 0x1ff); - - scrolly = argus_bg0_scrolly[0] | ( (argus_bg0_scrolly[1] & 0x01) << 8); - tilemap_set_scrolly(bg0_tilemap, 0, (scrolly + 256) & 0x1ff); - } - scrollx = argus_bg1_scrollx[0] | ( (argus_bg1_scrollx[1] & 0x01) << 8); - tilemap_set_scrollx(bg1_tilemap, 0, (scrollx + 256) & 0x1ff); - - scrolly = argus_bg1_scrolly[0] | ( (argus_bg1_scrolly[1] & 0x01) << 8); - tilemap_set_scrolly(bg1_tilemap, 0, (scrolly + 256) & 0x1ff); - } - } + argus_flipscreen = data & 0x80; } READ8_HANDLER( argus_paletteram_r ) { - return argus_paletteram[ offset ]; + return argus_paletteram[offset]; } WRITE8_HANDLER( argus_paletteram_w ) { int offs; - argus_paletteram[ offset ] = data; + argus_paletteram[offset] = data; - if (offset != 0x007f && offset != 0x00ff) + if (offset <= 0x0ff) /* sprite color */ { - if (offset >= 0x0000 && offset <= 0x00ff) /* sprite color */ - { - if (offset & 0x80) - offset -= 0x80; + offset &= 0x07f; - argus_change_palette( machine, offset, - (argus_paletteram[offset] << 8) | argus_paletteram[offset + 0x80] ); - } + argus_change_palette(machine, offset, offset, offset + 0x080); - else if ( (offset >= 0x0400 && offset <= 0x04ff) || - (offset >= 0x0800 && offset <= 0x08ff) ) /* BG0 color */ + if (offset == 0x07f || offset == 0x0ff) { - if (offset >= 0x0800) - offset -= 0x0400; + argus_palette_intensity = argus_paletteram[0x0ff] | (argus_paletteram[0x07f] << 8); - argus_change_bg_palette( machine, (offset - 0x0400) + 128, - (argus_paletteram[offset] << 8) | argus_paletteram[offset + 0x0400] ); + for (offs = 0x400; offs < 0x500; offs++) + argus_change_bg_palette(machine, (offs & 0xff) + 0x080, offs, offs + 0x400); } + } + else if ((offset >= 0x400 && offset <= 0x4ff) || + (offset >= 0x800 && offset <= 0x8ff)) /* BG0 color */ + { + offs = offset & 0xff; + offset = offs | 0x400; - else if ( (offset >= 0x0500 && offset <= 0x05ff) || - (offset >= 0x0900 && offset <= 0x09ff) ) /* BG1 color */ - { - if (offset >= 0x0900) - offset -= 0x0400; - - argus_change_palette( machine, (offset - 0x0500) + 384, - (argus_paletteram[offset] << 8) | argus_paletteram[offset + 0x0400] ); - } - - else if ( (offset >= 0x0700 && offset <= 0x07ff) || - (offset >= 0x0b00 && offset <= 0x0bff) ) /* text color */ - { - if (offset >= 0x0b00) - offset -= 0x0400; - - argus_change_palette( machine, (offset - 0x0700) + 640, - (argus_paletteram[offset] << 8) | argus_paletteram[offset + 0x0400] ); - } + argus_change_bg_palette(machine, offs + 0x080, offset, offset + 0x400); } - else + else if ((offset >= 0x500 && offset <= 0x5ff) || + (offset >= 0x900 && offset <= 0x9ff)) /* BG1 color */ { - argus_palette_intensity = (argus_paletteram[0x007f] << 8) | argus_paletteram[0x00ff]; + offs = offset & 0xff; + offset = offs | 0x500; - for (offs = 0x400 ; offs < 0x500 ; offs ++) - { - argus_change_bg_palette( machine, (offs - 0x0400) + 128, - (argus_paletteram[offs] << 8) | argus_paletteram[offs + 0x0400] ); - } + argus_change_palette(machine, offs + 0x180, offset, offset + 0x400); + } + else if ((offset >= 0x700 && offset <= 0x7ff) || + (offset >= 0xb00 && offset <= 0xbff)) /* text color */ + { + offs = offset & 0xff; + offset = offs | 0x700; - argus_bg_purple = argus_paletteram[0x0ff] & 0x0f; + argus_change_palette(machine, offs + 0x280, offset, offset + 0x400); } } WRITE8_HANDLER( valtric_paletteram_w ) { - int offs; - - argus_paletteram[ offset ] = data; + argus_paletteram[offset] = data; - if (offset != 0x01fe && offset != 0x01ff) + if (offset <= 0x1ff) /* Sprite color */ { - if (offset >= 0x0000 && offset <= 0x01ff) - { - argus_change_palette( machine, offset >> 1, - argus_paletteram[offset | 1] | (argus_paletteram[offset & ~1] << 8)); - } - else if (offset >= 0x0400 && offset <= 0x05ff ) - { - argus_change_bg_palette( machine, ((offset - 0x0400) >> 1) + 256, - argus_paletteram[offset | 1] | (argus_paletteram[offset & ~1] << 8)); - } - else if (offset >= 0x0600 && offset <= 0x07ff ) + argus_change_palette(machine, offset >> 1, offset & ~1, offset | 1); + + if (offset == 0x1fe || offset == 0x1ff) { - argus_change_palette( machine, ((offset - 0x0600) >> 1) + 512, - argus_paletteram[offset | 1] | (argus_paletteram[offset & ~1] << 8)); + int offs; + + argus_palette_intensity = argus_paletteram[0x1ff] | (argus_paletteram[0x1fe] << 8); + + for (offs = 0x400; offs < 0x600; offs += 2) + argus_change_bg_palette(machine, ((offs & 0x1ff) >> 1) + 0x100, offs & ~1, offs | 1); } } - else + else if (offset >= 0x400 && offset <= 0x5ff) /* BG color */ { - argus_palette_intensity = (argus_paletteram[0x01fe] << 8) | argus_paletteram[0x01ff]; - - for (offs = 0x400 ; offs < 0x600 ; offs += 2) - { - argus_change_bg_palette( machine, ((offs - 0x0400) >> 1) + 256, - argus_paletteram[offs | 1] | (argus_paletteram[offs & ~1] << 8)); - } - - argus_bg_purple = argus_paletteram[0x01ff] & 0x0f; + argus_change_bg_palette(machine, ((offset & 0x1ff) >> 1) + 0x100, offset & ~1, offset | 1); + } + else if (offset >= 0x600 && offset <= 0x7ff) /* Text color */ + { + argus_change_palette(machine, ((offset & 0x1ff) >> 1) + 0x200, offset & ~1, offset | 1); } } WRITE8_HANDLER( butasan_paletteram_w ) { - argus_paletteram[ offset ] = data; + argus_paletteram[offset] = data; - if (offset < 0x0200 ) /* BG1 color */ + if (offset <= 0x1ff) /* BG0 color */ { - argus_change_palette( machine, ((offset - 0x0000) >> 1) + 256, - argus_paletteram[offset | 1] | (argus_paletteram[offset & ~1] << 8)); + argus_change_palette(machine, (offset >> 1) + 0x100, offset & ~1, offset | 1); } - else if (offset < 0x0240 ) /* BG0 color */ + else if (offset <= 0x23f) /* BG1 color */ { - argus_change_palette( machine, ((offset - 0x0200) >> 1) + 192, - argus_paletteram[offset | 1] | (argus_paletteram[offset & ~1] << 8)); + argus_change_palette(machine, ((offset & 0x3f) >> 1) + 0x0c0, offset & ~1, offset | 1); } - else if (offset >= 0x0400 && offset <= 0x04ff ) /* Sprite color */ - { - if (offset < 0x0480) /* 16 colors */ - argus_change_palette( machine, ((offset - 0x0400) >> 1) + 0, - argus_paletteram[offset | 1] | (argus_paletteram[offset & ~1] << 8)); - else /* 8 colors */ - { - argus_change_palette( machine, (offset & 0x70) + ((offset & 0x00f) >> 1) + 64, - argus_paletteram[offset | 1] | (argus_paletteram[offset & ~1] << 8)); - argus_change_palette( machine, (offset & 0x70) + ((offset & 0x00f) >> 1) + 72, - argus_paletteram[offset | 1] | (argus_paletteram[offset & ~1] << 8)); - } + else if (offset >= 0x400 && offset <= 0x47f) /* Sprite color */ + { /* 16 colors */ + argus_change_palette(machine, (offset & 0x7f) >> 1, offset & ~1, offset | 1); } - else if (offset >= 0x0600 && offset <= 0x07ff ) /* Text color */ - { - argus_change_palette( machine, ((offset - 0x0600) >> 1) + 512, - argus_paletteram[offset | 1] | (argus_paletteram[offset & ~1] << 8)); - } -} + else if (offset >= 0x480 && offset <= 0x4ff) /* Sprite color */ + { /* 8 colors */ + int offs = (offset & 0x070) | ((offset & 0x00f) >> 1); -READ8_HANDLER( bombsa_paletteram_r ) -{ - if (bombsa_ram_page==1) - { - return argus_paletteram[ offset ]; - } - else if (bombsa_ram_page==0) - { - return bomba_otherram[ offset ]; + argus_change_palette(machine, offs + 0x040, offset & ~1, offset | 1); + argus_change_palette(machine, offs + 0x048, offset & ~1, offset | 1); } - else + else if (offset >= 0x600 && offset <= 0x7ff) /* Text color */ { - mame_printf_debug("unknown bombsa_paletteram_r %02x %04x\n",bombsa_ram_page,offset); - return 0x00; + argus_change_palette(machine, ((offset & 0x1ff) >> 1) + 0x200, offset & ~1, offset | 1); } + else if (offset >= 0x240 && offset <= 0x25f) // dummy + argus_change_palette(machine, ((offset & 0x1f) >> 1) + 0xe0, offset & ~1, offset | 1); + else if (offset >= 0x500 && offset <= 0x51f) // dummy + argus_change_palette(machine, ((offset & 0x1f) >> 1) + 0xf0, offset & ~1, offset | 1); } -WRITE8_HANDLER( bombsa_paletteram_w ) +READ8_HANDLER( butasan_bg1ram_r ) { - if (bombsa_ram_page==1) - { - argus_paletteram[ offset ] = data; - bombsa_change_palette( machine, offset>>1, argus_paletteram[offset | 1] | (argus_paletteram[offset & ~1] << 8)); - } - else if (bombsa_ram_page==0) - { - bomba_otherram[offset] = data; - - tilemap_mark_tile_dirty(bombsa_bg_tilemap, offset/2); - } - else - { - mame_printf_debug("unknown bombsa_paletteram_w %02x %04x %02x\n",bombsa_ram_page,offset, data); - } + return butasan_bg1ram[offset]; } -READ8_HANDLER( butasan_txbackram_r ) +WRITE8_HANDLER( butasan_bg1ram_w ) { - return butasan_txbackram[ offset ]; + int idx; + + butasan_bg1ram[offset] = data; + + idx = (offset & 0x00f) | ((offset & 0x200) >> 5) | ((offset & 0x1f0) << 1); + idx ^= 0x0f0; + + tilemap_mark_tile_dirty(bg1_tilemap, idx); } -WRITE8_HANDLER( butasan_txbackram_w ) +WRITE8_HANDLER( butasan_pageselect_w ) { - if (butasan_txbackram[ offset ] != data) - { - butasan_txbackram[ offset ] = data; - } + butasan_page_latch = data & 1; } -READ8_HANDLER( butasan_bg0backram_r ) +READ8_HANDLER( butasan_pagedram_r ) { - return butasan_bg0backram[ offset ]; + return butasan_pagedram[butasan_page_latch][offset]; } -WRITE8_HANDLER( butasan_bg0backram_w ) +WRITE8_HANDLER( butasan_pagedram_w ) { - if (butasan_bg0backram[ offset ] != data) + butasan_pagedram[butasan_page_latch][offset] = data; + + if (!butasan_page_latch) { - butasan_bg0backram[ offset ] = data; + if (offset <= 0x07ff) + { + int idx; + idx = ((offset & 0x01e) >> 1) | ((offset & 0x400) >> 6) | (offset & 0x3e0); + idx ^= 0x1e0; + tilemap_mark_tile_dirty(bg0_tilemap, idx); + } + } + else + { + if (offset <= 0x07ff) + tilemap_mark_tile_dirty(tx_tilemap, (offset ^ 0x7c0) >> 1); } } -WRITE8_HANDLER( butasan_bg1_status_w ) +WRITE8_HANDLER( valtric_unknown_w ) { - if (butasan_bg1_status != data) - { - butasan_bg1_status = data; + valtric_unknown = data; +} - tilemap_set_enable(bg1_tilemap, butasan_bg1_status & 0x01); /* Set enable flag */ - tilemap_mark_all_tiles_dirty( bg1_tilemap ); /* Bank changed */ - } +WRITE8_HANDLER( butasan_unknown_w ) +{ + butasan_unknown = data; } @@ -1042,18 +750,42 @@ WRITE8_HANDLER( butasan_bg1_status_w ) Screen refresh ***************************************************************************/ -static void argus_bg0_scroll_handle( running_machine *machine ) +static void bg_setting(void) +{ + tilemap_set_flip(ALL_TILEMAPS, argus_flipscreen ? TILEMAP_FLIPY|TILEMAP_FLIPX : 0); + + if (!argus_flipscreen) + { + if (bg0_tilemap != NULL) + { + tilemap_set_scrollx(bg0_tilemap, 0, bg0_scrollx & 0x1ff); + tilemap_set_scrolly(bg0_tilemap, 0, bg0_scrolly & 0x1ff); + } + tilemap_set_scrollx(bg1_tilemap, 0, bg1_scrollx & 0x1ff); + tilemap_set_scrolly(bg1_tilemap, 0, bg1_scrolly & 0x1ff); + } + else + { + if (bg0_tilemap != NULL) + { + tilemap_set_scrollx(bg0_tilemap, 0, (bg0_scrollx + 256) & 0x1ff); + tilemap_set_scrolly(bg0_tilemap, 0, (bg0_scrolly + 256) & 0x1ff); + } + tilemap_set_scrollx(bg1_tilemap, 0, (bg1_scrollx + 256) & 0x1ff); + tilemap_set_scrolly(bg1_tilemap, 0, (bg1_scrolly + 256) & 0x1ff); + } +} + +static void argus_bg0_scroll_handle(running_machine *machine) { int delta; - int scrollx; int dcolumn; /* Deficit between previous and current scroll value */ - scrollx = argus_bg0_scrollx[0] | (argus_bg0_scrollx[1] << 8); - delta = scrollx - prvscrollx; - prvscrollx = scrollx; + delta = bg0_scrollx - prvscrollx; + prvscrollx = bg0_scrollx; - if ( delta == 0 ) + if (delta == 0) return; if (delta > 0) @@ -1063,7 +795,7 @@ static void argus_bg0_scroll_handle( running_machine *machine ) if (lowbitscroll >= 16) { - dcolumn ++; + dcolumn++; lowbitscroll -= 16; } @@ -1072,18 +804,18 @@ static void argus_bg0_scroll_handle( running_machine *machine ) int i, j; int col, woffs, roffs; - col = ( (scrollx / 16) + 16 ) % 32; + col = ((bg0_scrollx / 16) + 16) % 32; woffs = 32 * 2 * col; - roffs = ( ( (scrollx / 16) + 16 ) * 8 ) % 0x8000; + roffs = (((bg0_scrollx / 16) + 16) * 8) % 0x8000; - if ( dcolumn >= 18 ) + if (dcolumn >= 18) dcolumn = 18; - for ( i = 0 ; i < dcolumn ; i ++ ) + for (i = 0; i < dcolumn; i++) { - for ( j = 0 ; j < 4 ; j ++ ) + for (j = 0; j < 4; j++) { - argus_write_dummy_rams( machine, woffs, roffs ); + argus_write_dummy_rams(machine, woffs, roffs); woffs += 16; roffs += 2; } @@ -1103,7 +835,7 @@ static void argus_bg0_scroll_handle( running_machine *machine ) if (lowbitscroll <= 0) { - dcolumn ++; + dcolumn++; lowbitscroll += 16; } @@ -1112,20 +844,20 @@ static void argus_bg0_scroll_handle( running_machine *machine ) int i, j; int col, woffs, roffs; - col = ( (scrollx / 16) + 31 ) % 32; + col = ((bg0_scrollx / 16) + 31) % 32; woffs = 32 * 2 * col; - roffs = ( (scrollx / 16) - 1 ) * 8; + roffs = ((bg0_scrollx / 16) - 1) * 8; if (roffs < 0) roffs += 0x08000; if (dcolumn >= 18) dcolumn = 18; - for ( i = 0 ; i < dcolumn ; i ++ ) + for (i = 0; i < dcolumn; i++) { - for ( j = 0 ; j < 4 ; j ++ ) + for (j = 0; j < 4; j++) { - argus_write_dummy_rams( machine, woffs, roffs ); + argus_write_dummy_rams(machine, woffs, roffs); woffs += 16; roffs += 2; } @@ -1136,12 +868,6 @@ static void argus_bg0_scroll_handle( running_machine *machine ) } } } - - if (!argus_flipscreen) - tilemap_set_scrollx(bg0_tilemap, 0, scrollx & 0x1ff); - else - tilemap_set_scrollx(bg0_tilemap, 0, (scrollx + 256) & 0x1ff); - } static void argus_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int priority) @@ -1149,42 +875,27 @@ static void argus_draw_sprites(running_machine *machine, bitmap_t *bitmap, const int offs; /* Draw the sprites */ - for (offs = 11 ; offs < spriteram_size ; offs += 16) + for (offs = 0; offs < spriteram_size; offs += 16) { - if ( !(spriteram[offs+4] == 0 && spriteram[offs] == 0xf0) ) + if (!(spriteram[offs+15] == 0 && spriteram[offs+11] == 0xf0)) { int sx, sy, tile, flipx, flipy, color, pri; - sx = spriteram[offs + 1]; - sy = spriteram[offs]; + sx = spriteram[offs+12]; if (spriteram[offs+13] & 0x01) sx -= 256; + sy = spriteram[offs+11]; if (!(spriteram[offs+13] & 0x02)) sy -= 256; + + tile = spriteram[offs+14] | ((spriteram[offs+13] & 0xc0) << 2); + flipx = spriteram[offs+13] & 0x10; + flipy = spriteram[offs+13] & 0x20; + color = spriteram[offs+15] & 0x07; + pri = (spriteram[offs+15] & 0x08) >> 3; if (argus_flipscreen) { sx = 240 - sx; sy = 240 - sy; - } - - if (!argus_flipscreen) - { - if ( spriteram[offs+2] & 0x01) sx -= 256; - if (!(spriteram[offs+2] & 0x02)) sy -= 256; - } - else - { - if ( spriteram[offs+2] & 0x01) sx += 256; - if (!(spriteram[offs+2] & 0x02)) sy += 256; - } - - tile = spriteram[offs+3] + ((spriteram[offs+2] & 0xc0) << 2); - flipx = spriteram[offs+2] & 0x10; - flipy = spriteram[offs+2] & 0x20; - color = spriteram[offs+4] & 0x07; - pri = (spriteram[offs+4] & 0x08) >> 3; - - if (argus_flipscreen) - { - flipx ^= 0x10; - flipy ^= 0x20; + flipx = !flipx; + flipy = !flipy; } if (priority != pri) @@ -1195,52 +906,130 @@ static void argus_draw_sprites(running_machine *machine, bitmap_t *bitmap, const flipx, flipy, sx, sy, cliprect, - TRANSPARENCY_PEN, 15 - ); + TRANSPARENCY_PEN, 15); + } + } +} + +#if 1 +static void valtric_draw_mosaic(const device_config *screen, bitmap_t *bitmap, const rectangle *cliprect) +{ + static int mosaic=0; + + if (valtric_mosaic!=0x80) + { + mosaic=0x0f-(valtric_mosaic&0x0f); + if (mosaic!=0) mosaic++; + if (valtric_mosaic&0x80) mosaic*=-1; + } + + if (mosaic==0) + tilemap_draw(bitmap, cliprect, bg1_tilemap, 0, 0); + else + { + tilemap_draw(mosaicbitmap, cliprect, bg1_tilemap, 0, 0); + { + int step=mosaic; + UINT32 *dest; + int x,y,xx,yy; + int width = video_screen_get_width(screen); + int height = video_screen_get_height(screen); + + if (mosaic<0)step*=-1; + + for (y=0;y<width+step;y+=step) + for (x=0;x<height+step;x+=step) + { + static int c=0; + + if (y<height && x< width) + c=*BITMAP_ADDR32(mosaicbitmap, y, x); + + if (mosaic<0) + if (y+step-1<height && x+step-1< width) + c = *BITMAP_ADDR32(mosaicbitmap, y+step-1, x+step-1); + + for (yy=0;yy<step;yy++) + for (xx=0;xx<step;xx++) + { + if (xx+x < width && yy+y<height) + { + dest=BITMAP_ADDR32(bitmap, y+yy, x+xx); + *dest=c; + } + } + } + } + } +} +#else +static void valtric_draw_mosaic(const device_config *screen, bitmap_t *bitmap, const rectangle *cliprect) +{ + int step = 0x10 - (valtric_mosaic & 0x0f); + + if (step == 1) + tilemap_draw(bitmap, cliprect, bg1_tilemap, 0, 0); + else + { + tilemap_draw(mosaicbitmap, cliprect, bg1_tilemap, 0, 0); + { + UINT32 *dest; + int x,y,xx,yy; + int width = video_screen_get_width(screen); + int height = video_screen_get_height(screen); + + for (y = 0; y < width+step; y += step) + for (x = 0; x < height+step; x += step) + { + static int c = 0; + + if (y < height && x < width) + c = *BITMAP_ADDR32(mosaicbitmap, y, x); + + if (valtric_mosaic & 0x80) + if (y+step-1 < height && x+step-1 < width) + c = *BITMAP_ADDR32(mosaicbitmap, y+step-1, x+step-1); + + for (yy = 0; yy < step; yy++) + for (xx = 0; xx < step; xx++) + { + if (xx+x < width && yy+y < height) + { + dest = BITMAP_ADDR32(bitmap, y+yy, x+xx); + *dest = c; + } + } + } } } } +#endif static void valtric_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) { int offs; /* Draw the sprites */ - for (offs = 11 ; offs < spriteram_size ; offs += 16) + for (offs = 0; offs < spriteram_size; offs += 16) { - if ( !(spriteram[offs+4] == 0 && spriteram[offs] == 0xf0) ) + if (!(spriteram[offs+15] == 0 && spriteram[offs+11] == 0xf0)) { int sx, sy, tile, flipx, flipy, color; - sx = spriteram[offs + 1]; - sy = spriteram[offs]; + sx = spriteram[offs+12]; if (spriteram[offs+13] & 0x01) sx -= 256; + sy = spriteram[offs+11]; if (!(spriteram[offs+13] & 0x02)) sy -= 256; + + tile = spriteram[offs+14] | ((spriteram[offs+13] & 0xc0) << 2); + flipx = spriteram[offs+13] & 0x10; + flipy = spriteram[offs+13] & 0x20; + color = spriteram[offs+15] & 0x0f; if (argus_flipscreen) { sx = 240 - sx; sy = 240 - sy; - } - - if (!argus_flipscreen) - { - if ( spriteram[offs+2] & 0x01) sx -= 256; - if (!(spriteram[offs+2] & 0x02)) sy -= 256; - } - else - { - if ( spriteram[offs+2] & 0x01) sx += 256; - if (!(spriteram[offs+2] & 0x02)) sy += 256; - } - - tile = spriteram[offs+3] + ((spriteram[offs+2] & 0xc0) << 2); - flipx = spriteram[offs+2] & 0x10; - flipy = spriteram[offs+2] & 0x20; - color = spriteram[offs+4] & 0x0f; - - if (argus_flipscreen) - { - flipx ^= 0x10; - flipy ^= 0x20; + flipx = !flipx; + flipy = !flipy; } jal_blend_drawgfx(machine, @@ -1260,115 +1049,39 @@ static void butasan_draw_sprites(running_machine *machine, bitmap_t *bitmap, con int offs; /* Draw the sprites */ - for (offs = 8 ; offs < spriteram_size ; offs += 16) + for (offs = 0; offs < spriteram_size; offs += 16) { int sx, sy, tile, flipx, flipy, color; + int fx, fy; - sx = spriteram[offs + 2]; - sy = 240 - spriteram[offs + 4]; + tile = spriteram[offs+14] | ((spriteram[offs+15] & 0x0f) << 8); + flipx = spriteram[offs+8] & 0x01; + flipy = spriteram[offs+8] & 0x04; + color = spriteram[offs+9] & 0x0f; - if (spriteram[offs + 3] & 0x01) sx -= 256; - if (spriteram[offs + 5] & 0x01) sy += 256; + sx = spriteram[offs+10]; + sy = spriteram[offs+12]; - tile = spriteram[offs + 6] + ((spriteram[offs + 7] & 0x0f) << 8); - flipx = spriteram[offs + 0] & 0x01; - flipy = spriteram[offs + 0] & 0x04; - color = spriteram[offs + 1] & 0x0f; - - if (!argus_flipscreen) - { - if ( (offs >= 0x100 && offs < 0x300) || (offs >= 0x400 && offs < 0x580) ) - { - jal_blend_drawgfx(machine, - bitmap,machine->gfx[0], - tile, - color, - flipx, flipy, - sx, sy, - cliprect, - TRANSPARENCY_PEN, 7); - } - else if ( (offs >= 0x000 && offs < 0x100) || (offs >= 0x300 && offs < 0x400) ) - { - int i; + if (spriteram[offs+11] & 0x01) sx-=256; + if (spriteram[offs+13] & 0x01) sy-=256; - for ( i = 0 ; i <= 1 ; i ++ ) - { - int td; + sy = 240 - sy; - td = (flipx) ? (1 - i) : i; + fx = flipx; + fy = flipy; - jal_blend_drawgfx(machine, - bitmap,machine->gfx[0], - tile + td, - color, - flipx, flipy, - sx + i * 16, sy, - cliprect, - TRANSPARENCY_PEN, 7); - } - } - else if ( offs >= 0x580 && offs < 0x620 ) - { - int i, j; - - for ( i = 0 ; i <= 1 ; i ++ ) - { - for ( j = 0 ; j <= 1 ; j ++ ) - { - int td; - - if ( !flipy ) - td = (flipx) ? (i * 2) + 1 - j : i * 2 + j; - else - td = (flipx) ? ( (1 - i) * 2 ) + 1 - j : (1 - i) * 2 + j; - - jal_blend_drawgfx(machine, - bitmap,machine->gfx[0], - tile + td, - color, - flipx, flipy, - sx + j * 16, sy - i * 16, - cliprect, - TRANSPARENCY_PEN, 7); - } - } - } - else if ( offs >= 0x620 && offs < 0x680 ) - { - int i, j; - - for ( i = 0 ; i <= 3 ; i ++ ) - { - for ( j = 0 ; j <= 3 ; j ++ ) - { - int td; - - if ( !flipy ) - td = (flipx) ? (i * 4) + 3 - j : i * 4 + j; - else - td = (flipx) ? ( (3 - i) * 4 ) + 3 - j : (3 - i) * 4 + j; - - jal_blend_drawgfx(machine, - bitmap,machine->gfx[0], - tile + td, - color, - flipx, flipy, - sx + j * 16, sy - i * 16, - cliprect, - TRANSPARENCY_PEN, 7); - } - } - } - } - else + if (argus_flipscreen) { sx = 240 - sx; sy = 240 - sy; - flipx ^= 0x01; - flipy ^= 0x04; + flipx = !flipx; + flipy = !flipy; + } + + { + int i, j, td; - if ( (offs >= 0x100 && offs < 0x300) || (offs >= 0x400 && offs < 0x580) ) + if ((offs >= 0x100 && offs <= 0x2ff) || (offs >= 0x400 && offs <= 0x57f)) { jal_blend_drawgfx(machine, bitmap,machine->gfx[0], @@ -1379,73 +1092,61 @@ static void butasan_draw_sprites(running_machine *machine, bitmap_t *bitmap, con cliprect, TRANSPARENCY_PEN, 7); } - else if ( (offs >= 0x000 && offs < 0x100) || (offs >= 0x300 && offs < 0x400) ) + else if ((offs >= 0x000 && offs <= 0x0ff) || (offs >= 0x300 && offs <= 0x3ff)) { - int i; - - for ( i = 0 ; i <= 1 ; i ++ ) + for (i = 0; i <= 1; i++) { - int td; - - td = (flipx) ? i : (1 - i); + td = (fx) ? (1 - i) : i; jal_blend_drawgfx(machine, bitmap,machine->gfx[0], tile + td, color, flipx, flipy, - sx - i * 16, sy, + sx + i * 16, sy, cliprect, TRANSPARENCY_PEN, 7); } } - else if ( offs >= 0x580 && offs < 0x620 ) + else if (offs >= 0x580 && offs <= 0x61f) { - int i, j; - - for ( i = 0 ; i <= 1 ; i ++ ) + for (i = 0; i <= 1; i++) { - for ( j = 0 ; j <= 1 ; j ++ ) + for (j = 0; j <= 1; j++) { - int td; - - if ( !flipy ) - td = (flipx) ? (1 - i) * 2 + j : ( (1 - i) * 2 ) + 1 - j; + if (fy) + td = (fx) ? ((1 - i) * 2) + 1 - j : (1 - i) * 2 + j; else - td = (flipx) ? i * 2 + j : (i * 2) + 1 - j; + td = (fx) ? (i * 2) + 1 - j : i * 2 + j; jal_blend_drawgfx(machine, bitmap,machine->gfx[0], tile + td, color, flipx, flipy, - sx - j * 16, sy + i * 16, + sx + j * 16, sy - i * 16, cliprect, TRANSPARENCY_PEN, 7); } } } - else if ( offs >= 0x620 && offs < 0x680 ) + else if (offs >= 0x620 && offs <= 0x67f) { - int i, j; - - for ( i = 0 ; i <= 3 ; i ++ ) + for (i = 0; i <= 3; i++) { - for ( j = 0 ; j <= 3 ; j ++ ) + for (j = 0; j <= 3; j++) { - int td; - - if ( !flipy ) - td = (flipx) ? (3 - i) * 4 + j : ( (3 - i) * 4 ) + 3 - j; + if (fy) + td = (fx) ? ((3 - i) * 4) + 3 - j : (3 - i) * 4 + j; else - td = (flipx) ? i * 4 + j : (i * 4) + 3 - j; + td = (fx) ? (i * 4) + 3 - j : i * 4 + j; jal_blend_drawgfx(machine, bitmap,machine->gfx[0], tile + td, color, flipx, flipy, - sx - j * 16, sy + i * 16, + sx + j * 16, sy - i * 16, cliprect, TRANSPARENCY_PEN, 7); } @@ -1461,15 +1162,15 @@ static void butasan_log_vram(void) { int offs; - if ( input_code_pressed(KEYCODE_M) ) + if (input_code_pressed(KEYCODE_M)) { int i; logerror("\nSprite RAM\n"); logerror("---------------------------------------\n"); logerror(" +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +a +b +c +d +e +f\n"); - for (offs = 0 ; offs < spriteram_size ; offs += 16) + for (offs = 0; offs < spriteram_size; offs += 16) { - for (i = 0 ; i < 16 ; i ++) + for (i = 0; i < 16; i++) { if (i == 0) { @@ -1487,9 +1188,9 @@ static void butasan_log_vram(void) logerror("\nColor RAM\n"); logerror("---------------------------------------\n"); logerror(" +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +a +b +c +d +e +f\n"); - for (offs = 0 ; offs < 0xbf0 ; offs += 16) + for (offs = 0; offs < 0xbf0; offs += 16) { - for (i = 0 ; i < 16 ; i ++) + for (i = 0; i < 16; i++) { if (i == 0) { @@ -1508,79 +1209,17 @@ static void butasan_log_vram(void) } #endif -static void bombsa_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) -{ - int offs; - - /* Draw the sprites */ - for (offs = 11 ; offs < spriteram_size ; offs += 16) - { - if ( !(spriteram[offs+4] == 0 && spriteram[offs] == 0xf0) ) - { - int sx, sy, tile, flipx, flipy, color, size; - - sx = spriteram[offs + 1]; - sy = spriteram[offs]; - - if (spriteram[offs+2] & 0x01) sx += 256; - if (spriteram[offs+2] & 0x02) sy += 256; - - - tile = spriteram[offs+3] + ((spriteram[offs+2] & 0xc0) << 2); - flipx = spriteram[offs+2] & 0x10; - flipy = spriteram[offs+2] & 0x20; - color = spriteram[offs+4] & 0x0f; - size = spriteram[offs+2] & 0x08; - - if(!size) - { - drawgfx(bitmap,machine->gfx[0],tile,color,flipx,flipy,sx,sy,cliprect,TRANSPARENCY_PEN,15); - } - else - { - if (!flipy && !flipx) - { - drawgfx(bitmap,machine->gfx[0],tile+0,color,flipx,flipy,sx,sy,cliprect,TRANSPARENCY_PEN,15); - drawgfx(bitmap,machine->gfx[0],tile+1,color,flipx,flipy,sx,sy+16,cliprect,TRANSPARENCY_PEN,15); - drawgfx(bitmap,machine->gfx[0],tile+2,color,flipx,flipy,sx+16,sy,cliprect,TRANSPARENCY_PEN,15); - drawgfx(bitmap,machine->gfx[0],tile+3,color,flipx,flipy,sx+16,sy+16,cliprect,TRANSPARENCY_PEN,15); - } - else if (!flipy && flipx) - { - drawgfx(bitmap,machine->gfx[0],tile+0,color,flipx,flipy,sx+16,sy,cliprect,TRANSPARENCY_PEN,15); - drawgfx(bitmap,machine->gfx[0],tile+1,color,flipx,flipy,sx+16,sy+16,cliprect,TRANSPARENCY_PEN,15); - drawgfx(bitmap,machine->gfx[0],tile+2,color,flipx,flipy,sx,sy,cliprect,TRANSPARENCY_PEN,15); - drawgfx(bitmap,machine->gfx[0],tile+3,color,flipx,flipy,sx,sy+16,cliprect,TRANSPARENCY_PEN,15); - } - else if (flipy && !flipx) - { - drawgfx(bitmap,machine->gfx[0],tile+0,color,flipx,flipy,sx,sy+16,cliprect,TRANSPARENCY_PEN,15); - drawgfx(bitmap,machine->gfx[0],tile+1,color,flipx,flipy,sx,sy,cliprect,TRANSPARENCY_PEN,15); - drawgfx(bitmap,machine->gfx[0],tile+2,color,flipx,flipy,sx+16,sy+16,cliprect,TRANSPARENCY_PEN,15); - drawgfx(bitmap,machine->gfx[0],tile+3,color,flipx,flipy,sx+16,sy,cliprect,TRANSPARENCY_PEN,15); - } - else if (flipy && flipx) - { - drawgfx(bitmap,machine->gfx[0],tile+0,color,flipx,flipy,sx+16,sy+16,cliprect,TRANSPARENCY_PEN,15); - drawgfx(bitmap,machine->gfx[0],tile+1,color,flipx,flipy,sx+16,sy,cliprect,TRANSPARENCY_PEN,15); - drawgfx(bitmap,machine->gfx[0],tile+2,color,flipx,flipy,sx,sy+16,cliprect,TRANSPARENCY_PEN,15); - drawgfx(bitmap,machine->gfx[0],tile+3,color,flipx,flipy,sx,sy,cliprect,TRANSPARENCY_PEN,15); - } - } - } - } -} - VIDEO_UPDATE( argus ) { + bg_setting(); + /* scroll BG0 and render tile at proper position */ argus_bg0_scroll_handle(screen->machine); - fillbitmap(bitmap, screen->machine->pens[0], cliprect); - tilemap_draw(bitmap, cliprect, bg0_tilemap, 0, 0); argus_draw_sprites(screen->machine, bitmap, cliprect, 0); - tilemap_draw(bitmap, cliprect, bg1_tilemap, 0, 0); + if (argus_bg_status & 1) /* Backgound enable */ + tilemap_draw(bitmap, cliprect, bg1_tilemap, 0, 0); argus_draw_sprites(screen->machine, bitmap, cliprect, 1); tilemap_draw(bitmap, cliprect, tx_tilemap, 0, 0); return 0; @@ -1588,47 +1227,12 @@ VIDEO_UPDATE( argus ) VIDEO_UPDATE( valtric ) { - fillbitmap(bitmap, screen->machine->pens[0], cliprect); + bg_setting(); - if(valtric_mosaic==0) - tilemap_draw(bitmap, cliprect, bg1_tilemap, 0, 0); + if (argus_bg_status & 1) /* Backgound enable */ + valtric_draw_mosaic(screen, bitmap, cliprect); else - { - tilemap_draw(mosaicbitmap, cliprect, bg1_tilemap, 0, 0); - { - int step=valtric_mosaic; - UINT32 *dest; - int x,y,xx,yy; - int width = video_screen_get_width(screen); - int height = video_screen_get_height(screen); - - if(valtric_mosaic<0)step*=-1; - - for(y=0;y<width+step;y+=step) - for(x=0;x<height+step;x+=step) - { - static int c=0; - - if(y<height && x< width) - c=*BITMAP_ADDR32(mosaicbitmap, y, x); - - if(valtric_mosaic<0) - if(y+step-1<height && x+step-1< width) - c = *BITMAP_ADDR32(mosaicbitmap, y+step-1, x+step-1); - - for(yy=0;yy<step;yy++) - for(xx=0;xx<step;xx++) - { - if(xx+x < width && yy+y<height) - { - dest=BITMAP_ADDR32(bitmap, y+yy, x+xx); - *dest=c; - } - } - } - } - } - + fillbitmap(bitmap, get_black_pen(screen->machine), cliprect); valtric_draw_sprites(screen->machine, bitmap, cliprect); tilemap_draw(bitmap, cliprect, tx_tilemap, 0, 0); return 0; @@ -1636,10 +1240,13 @@ VIDEO_UPDATE( valtric ) VIDEO_UPDATE( butasan ) { - fillbitmap(bitmap, screen->machine->pens[0], cliprect); + bg_setting(); - tilemap_draw(bitmap, cliprect, bg1_tilemap, 0, 0); - tilemap_draw(bitmap, cliprect, bg0_tilemap, 0, 0); + if (argus_bg_status & 1) /* Backgound enable */ + tilemap_draw(bitmap, cliprect, bg0_tilemap, 0, 0); + else + fillbitmap(bitmap, get_black_pen(screen->machine), cliprect); + if (butasan_bg1_status & 1) tilemap_draw(bitmap, cliprect, bg1_tilemap, 0, 0); butasan_draw_sprites(screen->machine, bitmap, cliprect); tilemap_draw(bitmap, cliprect, tx_tilemap, 0, 0); @@ -1648,20 +1255,3 @@ VIDEO_UPDATE( butasan ) #endif return 0; } - - -VIDEO_UPDATE( bombsa ) -{ - fillbitmap(bitmap, screen->machine->pens[0], cliprect); - -// tilemap_draw(bitmap, cliprect, bg1_tilemap, 0, 0); -// valtric_draw_sprites(screen->bitmap, cliprect); - tilemap_draw(bitmap, cliprect, bombsa_bg_tilemap, 0, 0); - -#if 0 - tilemap_draw(bitmap, cliprect, tx_alt_tilemap, 0, 0); -#endif - tilemap_draw(bitmap, cliprect, tx_tilemap, 0, 0); - bombsa_draw_sprites(screen->machine, bitmap,cliprect); - return 0; -} |