From 19fab2e1eff2aea712e40e8854a904c26aa5fd81 Mon Sep 17 00:00:00 2001 From: Zsolt Vasvari Date: Sat, 19 Jan 2008 07:13:31 +0000 Subject: [PATCH] Converted to tilemaps --- src/mame/drivers/atarifb.c | 134 ++++++++++++---------- src/mame/includes/atarifb.h | 30 ++--- src/mame/machine/atarifb.c | 98 ++++++++++------ src/mame/video/atarifb.c | 220 +++++++++++++++++++++--------------- 4 files changed, 289 insertions(+), 193 deletions(-) diff --git a/src/mame/drivers/atarifb.c b/src/mame/drivers/atarifb.c index c531aef1539..f0c34931ff0 100644 --- a/src/mame/drivers/atarifb.c +++ b/src/mame/drivers/atarifb.c @@ -111,9 +111,6 @@ #include "abaseb.lh" -int atarifb_game; - - /************************************* * @@ -153,10 +150,10 @@ static PALETTE_INIT( atarifb ) static ADDRESS_MAP_START( atarifb_map, ADDRESS_SPACE_PROGRAM, 8 ) ADDRESS_MAP_FLAGS( AMEF_ABITS(15) ) AM_RANGE(0x0000, 0x01ff) AM_RAM - AM_RANGE(0x0200, 0x025f) AM_WRITE(MWA8_RAM) AM_BASE(&atarifb_alphap1_vram) AM_SIZE(&atarifb_alphap1_vram_size) + AM_RANGE(0x0200, 0x025f) AM_READWRITE(MRA8_RAM, atarifb_alpha1_videoram_w) AM_BASE(&atarifb_alphap1_videoram) AM_RANGE(0x0260, 0x039f) AM_RAM - AM_RANGE(0x03a0, 0x03ff) AM_WRITE(MWA8_RAM) AM_BASE(&atarifb_alphap2_vram) AM_SIZE(&atarifb_alphap2_vram_size) - AM_RANGE(0x1000, 0x13bf) AM_RAM AM_BASE(&videoram) AM_SIZE(&videoram_size) + AM_RANGE(0x03a0, 0x03ff) AM_READWRITE(MRA8_RAM, atarifb_alpha2_videoram_w) AM_BASE(&atarifb_alphap2_videoram) + AM_RANGE(0x1000, 0x13bf) AM_READWRITE(MRA8_RAM, atarifb_field_videoram_w) AM_BASE(&atarifb_field_videoram) AM_RANGE(0x13c0, 0x13ff) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size) AM_RANGE(0x2000, 0x2000) AM_WRITE(MWA8_RAM) AM_BASE(&atarifb_scroll_register) /* OUT 0 */ AM_RANGE(0x2001, 0x2001) AM_WRITE(atarifb_out1_w) /* OUT 1 */ @@ -171,17 +168,60 @@ static ADDRESS_MAP_START( atarifb_map, ADDRESS_SPACE_PROGRAM, 8 ) ADDRESS_MAP_END +static ADDRESS_MAP_START( atarifb4_map, ADDRESS_SPACE_PROGRAM, 8 ) + ADDRESS_MAP_FLAGS( AMEF_ABITS(15) ) + AM_RANGE(0x0000, 0x01ff) AM_RAM + AM_RANGE(0x0200, 0x025f) AM_READWRITE(MRA8_RAM, atarifb_alpha1_videoram_w) AM_BASE(&atarifb_alphap1_videoram) + AM_RANGE(0x0260, 0x039f) AM_RAM + AM_RANGE(0x03a0, 0x03ff) AM_READWRITE(MRA8_RAM, atarifb_alpha2_videoram_w) AM_BASE(&atarifb_alphap2_videoram) + AM_RANGE(0x1000, 0x13bf) AM_READWRITE(MRA8_RAM, atarifb_field_videoram_w) AM_BASE(&atarifb_field_videoram) + AM_RANGE(0x13c0, 0x13ff) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size) + AM_RANGE(0x2000, 0x2000) AM_WRITE(MWA8_RAM) AM_BASE(&atarifb_scroll_register) /* OUT 0 */ + AM_RANGE(0x2001, 0x2001) AM_WRITE(atarifb4_out1_w) /* OUT 1 */ + AM_RANGE(0x2002, 0x2002) AM_WRITE(atarifb_out2_w) /* OUT 2 */ + AM_RANGE(0x2003, 0x2003) AM_WRITE(atarifb_out3_w) /* OUT 3 */ + AM_RANGE(0x3000, 0x3000) AM_READ(MRA8_RAM) + AM_RANGE(0x3000, 0x3000) AM_WRITE(MWA8_NOP) /* Interrupt Acknowledge */ + AM_RANGE(0x4000, 0x4000) AM_READ(atarifb4_in0_r) + AM_RANGE(0x4001, 0x4001) AM_READ(input_port_1_r) + AM_RANGE(0x4002, 0x4002) AM_READ(atarifb4_in2_r) + AM_RANGE(0x5000, 0x5000) AM_WRITE(watchdog_reset_w) + AM_RANGE(0x6000, 0x7fff) AM_ROM +ADDRESS_MAP_END + + +static ADDRESS_MAP_START( abaseb_map, ADDRESS_SPACE_PROGRAM, 8 ) + ADDRESS_MAP_FLAGS( AMEF_ABITS(15) ) + AM_RANGE(0x0000, 0x01ff) AM_RAM + AM_RANGE(0x0200, 0x025f) AM_READWRITE(MRA8_RAM, atarifb_alpha1_videoram_w) AM_BASE(&atarifb_alphap1_videoram) + AM_RANGE(0x0260, 0x039f) AM_RAM + AM_RANGE(0x03a0, 0x03ff) AM_READWRITE(MRA8_RAM, atarifb_alpha2_videoram_w) AM_BASE(&atarifb_alphap2_videoram) + AM_RANGE(0x1000, 0x13bf) AM_READWRITE(MRA8_RAM, atarifb_field_videoram_w) AM_BASE(&atarifb_field_videoram) + AM_RANGE(0x13c0, 0x13ff) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size) + AM_RANGE(0x2000, 0x2000) AM_WRITE(MWA8_RAM) AM_BASE(&atarifb_scroll_register) /* OUT 0 */ + AM_RANGE(0x2001, 0x2001) AM_WRITE(abaseb_out1_w) /* OUT 1 */ + AM_RANGE(0x2002, 0x2002) AM_WRITE(atarifb_out2_w) /* OUT 2 */ + AM_RANGE(0x2003, 0x2003) AM_WRITE(atarifb_out3_w) /* OUT 3 */ + AM_RANGE(0x3000, 0x3000) AM_READ(MRA8_RAM) + AM_RANGE(0x3000, 0x3000) AM_WRITE(MWA8_NOP) /* Interrupt Acknowledge */ + AM_RANGE(0x4000, 0x4000) AM_READ(atarifb_in0_r) + AM_RANGE(0x4002, 0x4002) AM_READ(atarifb_in2_r) + AM_RANGE(0x5000, 0x5000) AM_WRITE(watchdog_reset_w) + AM_RANGE(0x6000, 0x7fff) AM_ROM +ADDRESS_MAP_END + + static ADDRESS_MAP_START( soccer_map, ADDRESS_SPACE_PROGRAM, 8 ) ADDRESS_MAP_FLAGS( AMEF_ABITS(14) ) AM_RANGE(0x0000, 0x01ff) AM_RAM - AM_RANGE(0x0200, 0x025f) AM_WRITE(MWA8_RAM) AM_BASE(&atarifb_alphap1_vram) AM_SIZE(&atarifb_alphap1_vram_size) + AM_RANGE(0x0200, 0x025f) AM_READWRITE(MRA8_RAM, atarifb_alpha1_videoram_w) AM_BASE(&atarifb_alphap1_videoram) AM_RANGE(0x0260, 0x039f) AM_RAM - AM_RANGE(0x03a0, 0x03ff) AM_WRITE(MWA8_RAM) AM_BASE(&atarifb_alphap2_vram) AM_SIZE(&atarifb_alphap2_vram_size) - AM_RANGE(0x0800, 0x0bbf) AM_RAM AM_BASE(&videoram) AM_SIZE(&videoram_size) + AM_RANGE(0x03a0, 0x03ff) AM_READWRITE(MRA8_RAM, atarifb_alpha2_videoram_w) AM_BASE(&atarifb_alphap2_videoram) + AM_RANGE(0x0800, 0x0bbf) AM_READWRITE(MRA8_RAM, atarifb_field_videoram_w) AM_BASE(&atarifb_field_videoram) AM_RANGE(0x0bc0, 0x0bff) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size) AM_RANGE(0x1000, 0x1000) AM_WRITE(MWA8_RAM) AM_BASE(&atarifb_scroll_register) /* OUT 0 */ - AM_RANGE(0x1001, 0x1001) AM_WRITE(atarifb_out1_w) /* OUT 1 */ - AM_RANGE(0x1002, 0x1002) AM_WRITE(atarifb_out2_w) /* OUT 2 */ + AM_RANGE(0x1001, 0x1001) AM_WRITE(soccer_out1_w) /* OUT 1 */ + AM_RANGE(0x1002, 0x1002) AM_WRITE(soccer_out2_w) /* OUT 2 */ AM_RANGE(0x1004, 0x1004) AM_WRITE(MWA8_NOP) /* Interrupt Acknowledge */ AM_RANGE(0x1005, 0x1005) AM_WRITE(watchdog_reset_w) AM_RANGE(0x1800, 0x1800) AM_READ(atarifb4_in0_r) @@ -485,7 +525,7 @@ static const gfx_layout spritelayout = { 0 }, { 0, 1, 2, 3, 4, 5, 6, 7 }, { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, - 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, + 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, 16*8 }; @@ -498,7 +538,7 @@ static const gfx_layout spritemasklayout = { 0 }, { 0, 1, 2, 3, 4, 5, 6, 7 }, { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, - 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, + 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 }, 16*8 }; @@ -543,7 +583,7 @@ static MACHINE_DRIVER_START( atarifb ) MDRV_PALETTE_LENGTH(12) MDRV_PALETTE_INIT(atarifb) - MDRV_VIDEO_START(generic) + MDRV_VIDEO_START(atarifb) MDRV_VIDEO_UPDATE(atarifb) /* sound hardware */ @@ -555,10 +595,23 @@ static MACHINE_DRIVER_START( atarifb ) MACHINE_DRIVER_END +static MACHINE_DRIVER_START( atarifb4 ) + + /* basic machine hardware */ + MDRV_IMPORT_FROM(atarifb) + MDRV_CPU_MODIFY("main") + MDRV_CPU_PROGRAM_MAP(atarifb4_map,0) +MACHINE_DRIVER_END + + static MACHINE_DRIVER_START( abaseb ) /* basic machine hardware */ MDRV_IMPORT_FROM(atarifb) + MDRV_CPU_PROGRAM_MAP(abaseb_map,0) + + /* video hardware */ + MDRV_VIDEO_UPDATE(abaseb) /* sound hardware */ MDRV_SOUND_REPLACE("discrete", DISCRETE, 0) @@ -577,6 +630,7 @@ static MACHINE_DRIVER_START( soccer ) /* video hardware */ MDRV_SCREEN_VISIBLE_AREA(0*8, 38*8-1, 2*8, 32*8-1) MDRV_GFXDECODE(soccer) + MDRV_VIDEO_UPDATE(soccer) MACHINE_DRIVER_END @@ -729,44 +783,6 @@ ROM_START( soccer ) ROM_END -/************************************* - * - * Driver initialization - * - *************************************/ - -static DRIVER_INIT( atarifb ) -{ - /* Tell the video code to draw the plays for this version */ - atarifb_game = 1; -} - - -static DRIVER_INIT( atarifb4 ) -{ - /* Tell the video code to draw the plays for this version */ - atarifb_game = 2; - - memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x4000, 0, 0, atarifb4_in0_r); - memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x4001, 0x4001, 0, 0, input_port_1_r); - memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x4002, 0x4002, 0, 0, atarifb4_in2_r); -} - - -static DRIVER_INIT( abaseb ) -{ - /* Tell the video code to draw the plays for this version */ - atarifb_game = 3; -} - - -static DRIVER_INIT( soccer ) -{ - /* Tell the video code to draw the plays for this version */ - atarifb_game = 4; -} - - /************************************* * @@ -774,10 +790,10 @@ static DRIVER_INIT( soccer ) * *************************************/ -/* YEAR NAME PARENT MACHINE INPUT INIT MONITOR */ -GAMEL( 1978, atarifb, 0, atarifb, atarifb, atarifb, ROT0, "Atari", "Atari Football (revision 2)", 0, layout_atarifb ) -GAMEL( 1978, atarifb1, atarifb, atarifb, atarifb, atarifb, ROT0, "Atari", "Atari Football (revision 1)", 0, layout_atarifb ) -GAMEL( 1979, atarifb4, atarifb, atarifb, atarifb4, atarifb4, ROT0, "Atari", "Atari Football (4 players)", 0, layout_atarifb4 ) -GAMEL( 1979, abaseb, 0, abaseb, abaseb, abaseb, ROT0, "Atari", "Atari Baseball (set 1)", 0, layout_abaseb ) -GAMEL( 1979, abaseb2, abaseb, abaseb, abaseb, abaseb, ROT0, "Atari", "Atari Baseball (set 2)", 0, layout_abaseb ) -GAME ( 1980, soccer, 0, soccer, soccer, soccer, ROT0, "Atari", "Atari Soccer", 0 ) +/* YEAR NAME PARENT MACHINE INPUT */ +GAMEL( 1978, atarifb, 0, atarifb, atarifb, 0, ROT0, "Atari", "Atari Football (revision 2)", 0, layout_atarifb ) +GAMEL( 1978, atarifb1, atarifb, atarifb, atarifb, 0, ROT0, "Atari", "Atari Football (revision 1)", 0, layout_atarifb ) +GAMEL( 1979, atarifb4, atarifb, atarifb4, atarifb4, 0, ROT0, "Atari", "Atari Football (4 players)", 0, layout_atarifb4 ) +GAMEL( 1979, abaseb, 0, abaseb, abaseb, 0, ROT0, "Atari", "Atari Baseball (set 1)", 0, layout_abaseb ) +GAMEL( 1979, abaseb2, abaseb, abaseb, abaseb, 0, ROT0, "Atari", "Atari Baseball (set 2)", 0, layout_abaseb ) +GAME ( 1980, soccer, 0, soccer, soccer, 0, ROT0, "Atari", "Atari Soccer", 0 ) diff --git a/src/mame/includes/atarifb.h b/src/mame/includes/atarifb.h index b1a93b40f63..d91aa1eddde 100644 --- a/src/mame/includes/atarifb.h +++ b/src/mame/includes/atarifb.h @@ -6,10 +6,6 @@ #include "sound/discrete.h" -#define GAME_IS_FOOTBALL (atarifb_game == 1) -#define GAME_IS_FOOTBALL4 (atarifb_game == 2) -#define GAME_IS_BASEBALL (atarifb_game == 3) -#define GAME_IS_SOCCER (atarifb_game == 4) /* Discrete Sound Input Nodes */ #define ATARIFB_WHISTLE_EN NODE_01 @@ -19,16 +15,18 @@ #define ATARIFB_HIT_EN NODE_05 -/*----------- defined in drivers/atarifb.c -----------*/ - -extern int atarifb_game; - - /*----------- defined in machine/atarifb.c -----------*/ WRITE8_HANDLER( atarifb_out1_w ); +WRITE8_HANDLER( atarifb4_out1_w ); +WRITE8_HANDLER( abaseb_out1_w ); +WRITE8_HANDLER( soccer_out1_w ); + WRITE8_HANDLER( atarifb_out2_w ); +WRITE8_HANDLER( soccer_out2_w ); + WRITE8_HANDLER( atarifb_out3_w ); + READ8_HANDLER( atarifb_in0_r ); READ8_HANDLER( atarifb_in2_r ); READ8_HANDLER( atarifb4_in0_r ); @@ -43,10 +41,16 @@ DISCRETE_SOUND_EXTERN( abaseb ); /*----------- defined in video/atarifb.c -----------*/ -extern size_t atarifb_alphap1_vram_size; -extern size_t atarifb_alphap2_vram_size; -extern UINT8 *atarifb_alphap1_vram; -extern UINT8 *atarifb_alphap2_vram; +extern UINT8 *atarifb_alphap1_videoram; +extern UINT8 *atarifb_alphap2_videoram; +extern UINT8 *atarifb_field_videoram; extern UINT8 *atarifb_scroll_register; +VIDEO_START( atarifb ); VIDEO_UPDATE( atarifb ); +VIDEO_UPDATE( abaseb ); +VIDEO_UPDATE( soccer ); + +WRITE8_HANDLER( atarifb_alpha1_videoram_w ); +WRITE8_HANDLER( atarifb_alpha2_videoram_w ); +WRITE8_HANDLER( atarifb_field_videoram_w ); diff --git a/src/mame/machine/atarifb.c b/src/mame/machine/atarifb.c index 91daec2c4a3..ecb0b2493aa 100644 --- a/src/mame/machine/atarifb.c +++ b/src/mame/machine/atarifb.c @@ -23,55 +23,87 @@ WRITE8_HANDLER( atarifb_out1_w ) discrete_sound_w(ATARIFB_HIT_EN, data & 0x02); // Hit discrete_sound_w(ATARIFB_ATTRACT_EN, data & 0x10); // Attract discrete_sound_w(ATARIFB_NOISE_EN, data & 0x04); // Noise Enable / Kicker +} - if (GAME_IS_SOCCER) + +WRITE8_HANDLER( atarifb4_out1_w ) +{ + CTRLD = data; + + discrete_sound_w(ATARIFB_WHISTLE_EN, data & 0x01); // Whistle + discrete_sound_w(ATARIFB_HIT_EN, data & 0x02); // Hit + discrete_sound_w(ATARIFB_ATTRACT_EN, data & 0x10); // Attract + discrete_sound_w(ATARIFB_NOISE_EN, data & 0x04); // Noise Enable / Kicker + + coin_counter_w (1, data & 0x80); +} + + +WRITE8_HANDLER( abaseb_out1_w ) +{ + CTRLD = data; + + discrete_sound_w(ATARIFB_WHISTLE_EN, data & 0x01); // Whistle + discrete_sound_w(ATARIFB_HIT_EN, data & 0x02); // Hit + discrete_sound_w(ATARIFB_ATTRACT_EN, data & 0x10); // Attract + discrete_sound_w(ATARIFB_NOISE_EN, data & 0x04); // Noise Enable / Kicker + + if (data & 0x80) { - /* bit 0 = whistle */ - /* bit 1 = hit */ - /* bit 2 = kicker */ - /* bit 3 = unused */ - /* bit 4 = 2/4 Player LED */ // Say what? - /* bit 5-6 = trackball CTRL bits */ - /* bit 7 = Rule LED */ -// set_led_status(0,data & 0x10); // !!!!!!!!!! Is this correct???? - set_led_status(1,data & 0x80); + /* Invert video */ + palette_set_color(Machine,1,MAKE_RGB(0x00,0x00,0x00)); /* black */ + palette_set_color(Machine,0,MAKE_RGB(0xff,0xff,0xff)); /* white */ } - - if (GAME_IS_FOOTBALL4) - coin_counter_w (1, data & 0x80); - - if (GAME_IS_BASEBALL) + else { - if (data & 0x80) - { - /* Invert video */ - palette_set_color(Machine,1,MAKE_RGB(0x00,0x00,0x00)); /* black */ - palette_set_color(Machine,0,MAKE_RGB(0xff,0xff,0xff)); /* white */ - } - else - { - /* Regular video */ - palette_set_color(Machine,0,MAKE_RGB(0x00,0x00,0x00)); /* black */ - palette_set_color(Machine,1,MAKE_RGB(0xff,0xff,0xff)); /* white */ - } + /* Regular video */ + palette_set_color(Machine,0,MAKE_RGB(0x00,0x00,0x00)); /* black */ + palette_set_color(Machine,1,MAKE_RGB(0xff,0xff,0xff)); /* white */ } } +WRITE8_HANDLER( soccer_out1_w ) +{ + CTRLD = data; + + /* bit 0 = whistle */ + /* bit 1 = hit */ + /* bit 2 = kicker */ + /* bit 3 = unused */ + /* bit 4 = 2/4 Player LED */ // Say what? + /* bit 5-6 = trackball CTRL bits */ + /* bit 7 = Rule LED */ + + discrete_sound_w(ATARIFB_WHISTLE_EN, data & 0x01); // Whistle + discrete_sound_w(ATARIFB_HIT_EN, data & 0x02); // Hit + discrete_sound_w(ATARIFB_ATTRACT_EN, data & 0x10); // Attract + discrete_sound_w(ATARIFB_NOISE_EN, data & 0x04); // Noise Enable / Kicker + +// set_led_status(0,data & 0x10); // !!!!!!!!!! Is this correct???? + set_led_status(1,data & 0x80); +} + + WRITE8_HANDLER( atarifb_out2_w ) { discrete_sound_w(ATARIFB_CROWD_DATA, data & 0x0f); // Crowd coin_counter_w (0, data & 0x10); - - if (GAME_IS_SOCCER) - { - coin_counter_w (1, data & 0x20); - coin_counter_w (2, data & 0x40); - } } +WRITE8_HANDLER( soccer_out2_w ) +{ + discrete_sound_w(ATARIFB_CROWD_DATA, data & 0x0f); // Crowd + + coin_counter_w (0, data & 0x10); + coin_counter_w (1, data & 0x20); + coin_counter_w (2, data & 0x40); +} + + + /************************************* * * LED control diff --git a/src/mame/video/atarifb.c b/src/mame/video/atarifb.c index 53951d5dbfd..e280e7a6a35 100644 --- a/src/mame/video/atarifb.c +++ b/src/mame/video/atarifb.c @@ -5,114 +5,130 @@ *************************************************************************/ #include "driver.h" -#include "atarifb.h" -#include "ui.h" + /* local */ -size_t atarifb_alphap1_vram_size; -size_t atarifb_alphap2_vram_size; -UINT8 *atarifb_alphap1_vram; -UINT8 *atarifb_alphap2_vram; +UINT8 *atarifb_alphap1_videoram; +UINT8 *atarifb_alphap2_videoram; +UINT8 *atarifb_field_videoram; UINT8 *atarifb_scroll_register; - -static const rectangle bigfield_area = { 4*8, 34*8-1, 0*8, 32*8-1 }; -static const rectangle left_area = { 0*8, 3*8-1, 0*8, 32*8-1 }; -static const rectangle right_area = { 34*8, 38*8-1, 0*8, 32*8-1 }; +static tilemap *alpha1_tilemap; +static tilemap *alpha2_tilemap; +static tilemap *field_tilemap; -VIDEO_UPDATE( atarifb ) + +/************************************* + * + * Tilemap callbacks + * + *************************************/ + +static void get_tile_info_common(running_machine *machine, tile_data *tileinfo, + tilemap_memory_index tile_index, UINT8 *alpha_videoram) { - int offs,obj; - int sprite_bank; + int code = alpha_videoram[tile_index] & 0x3f; + int flip = alpha_videoram[tile_index] & 0x40; + int disable = alpha_videoram[tile_index] & 0x80; - /* Soccer uses a different graphics set for sprites */ - if (atarifb_game == 4) - sprite_bank = 2; - else - sprite_bank = 1; + if (disable) + code = 0; /* I *know* this is a space */ - for (offs = atarifb_alphap1_vram_size - 1;offs >= 0;offs--) - { - int charcode; - int flipbit; - int disable; - int sx,sy; + SET_TILE_INFO(0, code, 0, (flip ? TILE_FLIPX | TILE_FLIPY : 0)); +} - sx = 8 * (offs / 32) + 35*8; - sy = 8 * (offs % 32) + 8; - charcode = atarifb_alphap1_vram[offs] & 0x3f; - flipbit = (atarifb_alphap1_vram[offs] & 0x40) >> 6; - disable = (atarifb_alphap1_vram[offs] & 0x80) >> 7; +static TILE_GET_INFO( alpha1_get_tile_info ) +{ + get_tile_info_common(machine, tileinfo, tile_index, atarifb_alphap1_videoram); +} - if (!disable) - { - drawgfx(bitmap,machine->gfx[0], - charcode, 0, - flipbit,flipbit,sx,sy, - &right_area,TRANSPARENCY_NONE,0); - } - } - for (offs = atarifb_alphap2_vram_size - 1;offs >= 0;offs--) - { - int charcode; - int flipbit; - int disable; - int sx,sy; +static TILE_GET_INFO( alpha2_get_tile_info ) +{ + get_tile_info_common(machine, tileinfo, tile_index, atarifb_alphap2_videoram); +} - sx = 8 * (offs / 32); - sy = 8 * (offs % 32) + 8; - charcode = atarifb_alphap2_vram[offs] & 0x3f; - flipbit = (atarifb_alphap2_vram[offs] & 0x40) >> 6; - disable = (atarifb_alphap2_vram[offs] & 0x80) >> 7; +static TILE_GET_INFO( field_get_tile_info ) +{ + int code = atarifb_field_videoram[tile_index] & 0x3f; + int flipyx = atarifb_field_videoram[tile_index] >> 6; - if (!disable) - { - drawgfx(bitmap,machine->gfx[0], - charcode, 0, - flipbit,flipbit,sx,sy, - &left_area,TRANSPARENCY_NONE,0); - } - } + SET_TILE_INFO(1, code, 0, TILE_FLIPYX(flipyx)); +} - for (offs = videoram_size - 1;offs >= 0;offs--) - { - int charcode; - int flipx,flipy; - int sx,sy; - charcode = videoram[offs] & 0x3f; - flipx = (videoram[offs] & 0x40) >> 6; - flipy = (videoram[offs] & 0x80) >> 7; - sx = 8 * (offs % 32) - *atarifb_scroll_register + 8; - sy = 8 * (offs / 32) + 8; - /* Soccer hack */ - if (atarifb_game == 4) - { - sy += 8; - } +/************************************* + * + * Video RAM writes + * + *************************************/ - /* Baseball hack */ - if (atarifb_game == 0x03) sx -= 8; +WRITE8_HANDLER( atarifb_alpha1_videoram_w ) +{ + atarifb_alphap1_videoram[offset] = data; + tilemap_mark_tile_dirty(alpha1_tilemap, offset); +} - if (sx < 0) sx += 256; - if (sx > 255) sx -= 256; - drawgfx(tmpbitmap,machine->gfx[1], - charcode, 0, - flipx,flipy,sx,sy, - 0,TRANSPARENCY_NONE,0); - } +WRITE8_HANDLER( atarifb_alpha2_videoram_w ) +{ + atarifb_alphap2_videoram[offset] = data; + tilemap_mark_tile_dirty(alpha2_tilemap, offset); +} - /* copy the character mapped graphics */ - copybitmap(bitmap,tmpbitmap,0,0,8*3,0,&bigfield_area,TRANSPARENCY_NONE,0); - /* Draw our motion objects */ +WRITE8_HANDLER( atarifb_field_videoram_w ) +{ + atarifb_field_videoram[offset] = data; + tilemap_mark_tile_dirty(field_tilemap, offset); +} + + + +/************************************* + * + * Video system start + * + *************************************/ + +VIDEO_START( atarifb ) +{ + alpha1_tilemap = tilemap_create(alpha1_get_tile_info, tilemap_scan_cols, TILEMAP_TYPE_PEN, 8,8, 3,32); + alpha2_tilemap = tilemap_create(alpha2_get_tile_info, tilemap_scan_cols, TILEMAP_TYPE_PEN, 8,8, 3,32); + field_tilemap = tilemap_create(field_get_tile_info, tilemap_scan_rows, TILEMAP_TYPE_PEN, 8,8, 32,32); +} + + + +static void draw_playfield_and_alpha(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, + int playfield_x_offset, int playfield_y_offset) +{ + static const rectangle bigfield_area = { 4*8, 34*8-1, 0*8, 32*8-1 }; + + int scroll_x[1]; + int scroll_y[1]; + + scroll_x[0] = - *atarifb_scroll_register + 32 + playfield_x_offset; + scroll_y[0] = 8 + playfield_y_offset; + + copybitmap(bitmap, tilemap_get_pixmap(alpha1_tilemap), 0, 0, 35*8, 1*8, NULL, TRANSPARENCY_NONE, 0); + copybitmap(bitmap, tilemap_get_pixmap(alpha2_tilemap), 0, 0, 0*8, 1*8, NULL, TRANSPARENCY_NONE, 0); + copyscrollbitmap(bitmap, tilemap_get_pixmap(field_tilemap), 1, scroll_x, 1, scroll_y, &bigfield_area, TRANSPARENCY_NONE, 0); +} + + +static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, + int gfx, int is_soccer) +{ + static const rectangle bigfield_area = { 4*8, 34*8-1, 0*8, 32*8-1 }; + + int obj; + for (obj=0;obj<16;obj++) { int charcode; @@ -132,11 +148,11 @@ VIDEO_UPDATE( atarifb ) /* There are 3 sets of 2 bits each, where the 2 bits represent */ /* black, dk grey, grey and white. I think the 3 sets determine the */ /* color of each bit in the sprite, but I haven't implemented it that way. */ - if (atarifb_game == 4) + if (is_soccer) { shade = ((spriteram[obj*2+1 + 0x20]) & 0x07); - drawgfx(bitmap,machine->gfx[sprite_bank+1], + drawgfx(bitmap,machine->gfx[gfx + 1], charcode, shade, flipx,flipy,sx,sy, &bigfield_area,TRANSPARENCY_PEN,0); @@ -144,26 +160,54 @@ VIDEO_UPDATE( atarifb ) shade = ((spriteram[obj*2+1 + 0x20]) & 0x08) >> 3; } - drawgfx(bitmap,machine->gfx[sprite_bank], + drawgfx(bitmap,machine->gfx[gfx], charcode, shade, flipx,flipy,sx,sy, &bigfield_area,TRANSPARENCY_PEN,0); /* If this isn't soccer, handle the multiplexed sprites */ - if (atarifb_game != 4) + if (!is_soccer) { /* The down markers are multiplexed by altering the y location during */ /* mid-screen. We'll fake it by essentially doing the same thing here. */ if ((charcode == 0x11) && (sy == 0x07)) { sy = 0xf1; /* When multiplexed, it's 0x10...why? */ - drawgfx(bitmap,machine->gfx[sprite_bank], + drawgfx(bitmap,machine->gfx[gfx], charcode, 0, flipx,flipy,sx,sy, &bigfield_area,TRANSPARENCY_PEN,0); } } } +} + + +VIDEO_UPDATE( atarifb ) +{ + draw_playfield_and_alpha(machine, bitmap, cliprect, 0, 0); + + draw_sprites(machine, bitmap, cliprect, 1, 0); + + return 0; +} + + +VIDEO_UPDATE( abaseb ) +{ + draw_playfield_and_alpha(machine, bitmap, cliprect, -8, 0); + + draw_sprites(machine, bitmap, cliprect, 1, 0); + + return 0; +} + + +VIDEO_UPDATE( soccer ) +{ + draw_playfield_and_alpha(machine, bitmap, cliprect, 0, 8); + + draw_sprites(machine, bitmap, cliprect, 2, 1); return 0; }