From ce03bc23a2e428d898da5463681753f49fe81e2a Mon Sep 17 00:00:00 2001 From: Angelo Salese Date: Wed, 22 Jul 2009 20:36:29 +0000 Subject: [PATCH] Did the following changes to the tankbatt.c driver [Angelo Salese]: * Cleaned-up the irq / nmi firing and fixed irq acks; * Cleaned-up the memory map; * Added coin counter, coin lockouts and added a second coin chute; * Documented some unclear i/os; * Flagged the game as GAME_IMPERFECT_SOUND since it uses samples instead of proper discrete sound emulation; --- src/mame/drivers/tankbatt.c | 80 +++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 31 deletions(-) diff --git a/src/mame/drivers/tankbatt.c b/src/mame/drivers/tankbatt.c index fca31a8eb2e..af0d58eb322 100644 --- a/src/mame/drivers/tankbatt.c +++ b/src/mame/drivers/tankbatt.c @@ -40,6 +40,7 @@ Write: $2000-$3fff : ROM TODO: + . Needs proper discrete emulation . Resistor values on the color prom need to be verified Changes: @@ -104,11 +105,7 @@ static WRITE8_HANDLER( tankbatt_interrupt_enable_w ) { tankbatt_nmi_enable = !data; tankbatt_sound_enable = !data; - if (data != 0) - { - cputag_set_input_line(space->machine, "maincpu", 0, CLEAR_LINE); - cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_NMI, CLEAR_LINE); - } + /* hack - turn off the engine noise if the normal game nmi's are disabled */ if (data) sample_stop (devtag_get_device(space->machine, "samples"), 2); // interrupt_enable_w (offset, !data); @@ -117,11 +114,6 @@ static WRITE8_HANDLER( tankbatt_interrupt_enable_w ) static WRITE8_HANDLER( tankbatt_demo_interrupt_enable_w ) { tankbatt_nmi_enable = data; - if (data != 0) - { - cputag_set_input_line(space->machine, "maincpu", 0, CLEAR_LINE); - cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_NMI, CLEAR_LINE); - } // interrupt_enable_w (offset, data); } @@ -156,32 +148,57 @@ static WRITE8_HANDLER( tankbatt_sh_fire_w ) } } +static WRITE8_HANDLER( tankbatt_irq_ack_w ) +{ + /* 0x6e written at the end of the irq routine, could be either irq ack or a coin sample */ + cputag_set_input_line(space->machine, "maincpu", 0, CLEAR_LINE); +} + +static WRITE8_HANDLER( tankbatt_coin_counter_w ) +{ + coin_counter_w(0,data & 1); + coin_counter_w(1,data & 1); +} + +static WRITE8_HANDLER( tankbatt_coin_lockout_w ) +{ + coin_lockout_w(0,data & 1); + coin_lockout_w(1,data & 1); +} + static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x01ff) AM_READ(SMH_RAM) - AM_RANGE(0x0000, 0x000f) AM_WRITE(SMH_RAM) AM_BASE(&tankbatt_bulletsram) AM_SIZE(&tankbatt_bulletsram_size) - AM_RANGE(0x0010, 0x01ff) AM_WRITE(SMH_RAM) - AM_RANGE(0x0800, 0x0bff) AM_WRITE(tankbatt_videoram_w) AM_BASE(&videoram) + AM_RANGE(0x0000, 0x000f) AM_RAM AM_BASE(&tankbatt_bulletsram) AM_SIZE(&tankbatt_bulletsram_size) + AM_RANGE(0x0010, 0x01ff) AM_RAM + AM_RANGE(0x0200, 0x07ff) AM_RAM + AM_RANGE(0x0800, 0x0bff) AM_RAM_WRITE(tankbatt_videoram_w) AM_BASE(&videoram) AM_RANGE(0x0c00, 0x0c07) AM_READ(tankbatt_in0_r) AM_RANGE(0x0c00, 0x0c01) AM_WRITE(tankbatt_led_w) + AM_RANGE(0x0c02, 0x0c02) AM_WRITE(tankbatt_coin_counter_w) + AM_RANGE(0x0c03, 0x0c03) AM_WRITE(tankbatt_coin_lockout_w) AM_RANGE(0x0c08, 0x0c0f) AM_READ(tankbatt_in1_r) + AM_RANGE(0x0c08, 0x0c08) AM_WRITENOP //coin counter mirror? AM_RANGE(0x0c0a, 0x0c0a) AM_WRITE(tankbatt_interrupt_enable_w) AM_RANGE(0x0c0b, 0x0c0b) AM_WRITE(tankbatt_sh_engine_w) AM_RANGE(0x0c0c, 0x0c0c) AM_WRITE(tankbatt_sh_fire_w) - AM_RANGE(0x0c0d, 0x0c0d) AM_WRITE(tankbatt_sh_expl_w) + AM_RANGE(0x0c0d, 0x0c0d) AM_WRITE(tankbatt_sh_expl_w) // bit 7 == led for the start 2 button + AM_RANGE(0x0c0e, 0x0c0e) AM_WRITENOP //bit 7 == led for the start 1 button AM_RANGE(0x0c0f, 0x0c0f) AM_WRITE(tankbatt_demo_interrupt_enable_w) + AM_RANGE(0x0c10, 0x0c10) AM_WRITE(tankbatt_irq_ack_w) AM_RANGE(0x0c18, 0x0c1f) AM_READ(tankbatt_dsw_r) AM_RANGE(0x0c18, 0x0c18) AM_WRITENOP /* watchdog ?? */ - AM_RANGE(0x0200, 0x0bff) AM_READ(SMH_RAM) - AM_RANGE(0x0200, 0x07ff) AM_WRITE(SMH_RAM) - AM_RANGE(0x2000, 0x3fff) AM_WRITE(SMH_ROM) - AM_RANGE(0x6000, 0x7fff) AM_READ(SMH_ROM) - AM_RANGE(0xf800, 0xffff) AM_READ(SMH_ROM) /* for the reset / interrupt vectors */ + AM_RANGE(0x6000, 0x7fff) AM_ROM AM_REGION("maincpu",0) + AM_RANGE(0xe000, 0xffff) AM_ROM AM_REGION("maincpu",0) //mirror for the reset/irq vectors + AM_RANGE(0x2000, 0xffff) AM_READNOP //anything else might be left-over for a diagnostic ROM or something related to the discrete sound HW ADDRESS_MAP_END static INTERRUPT_GEN( tankbatt_interrupt ) { - if ((input_port_read(device->machine, "P1") & 0x60) == 0) cpu_set_input_line(device,0,HOLD_LINE); - else if (tankbatt_nmi_enable) cpu_set_input_line(device,INPUT_LINE_NMI,PULSE_LINE); + if (tankbatt_nmi_enable) cpu_set_input_line(device,INPUT_LINE_NMI,PULSE_LINE); +} + +static INPUT_CHANGED( coin_inserted ) +{ + cputag_set_input_line(field->port->machine, "maincpu", 0, ASSERT_LINE); } static INPUT_PORTS_START( tankbatt ) @@ -191,7 +208,8 @@ static INPUT_PORTS_START( tankbatt ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) - PORT_BIT( 0x60, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(2) + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_CHANGED(coin_inserted, 0) + PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_CHANGED(coin_inserted, 0) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_TILT ) PORT_START("P2") /* IN1 */ @@ -318,20 +336,20 @@ MACHINE_DRIVER_END ***************************************************************************/ ROM_START( tankbatt ) - ROM_REGION( 0x10000, "maincpu", 0 ) - ROM_LOAD( "tb1-1.1a", 0x6000, 0x0800, CRC(278a0b8c) SHA1(11ea8fe8401b3cd986616a30a759c0ac1a5ce73b) ) - ROM_LOAD( "tb1-2.1b", 0x6800, 0x0800, CRC(e0923370) SHA1(8d3dbea877bed9f9c267d8002dc180f6eb1e5a8f) ) - ROM_LOAD( "tb1-3.1c", 0x7000, 0x0800, CRC(85005ea4) SHA1(91583081803a5ef600fb90bee34be9edd87f157e) ) - ROM_LOAD( "tb1-4.1d", 0x7800, 0x0800, CRC(3dfb5bcf) SHA1(aa24bf74f4d5dc81baf3843196c837e0b731077b) ) - ROM_RELOAD( 0xf800, 0x0800 ) /* for the reset and interrupt vectors */ + ROM_REGION( 0x2000, "maincpu", 0 ) + ROM_LOAD( "tb1-1.1a", 0x0000, 0x0800, CRC(278a0b8c) SHA1(11ea8fe8401b3cd986616a30a759c0ac1a5ce73b) ) + ROM_LOAD( "tb1-2.1b", 0x0800, 0x0800, CRC(e0923370) SHA1(8d3dbea877bed9f9c267d8002dc180f6eb1e5a8f) ) + ROM_LOAD( "tb1-3.1c", 0x1000, 0x0800, CRC(85005ea4) SHA1(91583081803a5ef600fb90bee34be9edd87f157e) ) + ROM_LOAD( "tb1-4.1d", 0x1800, 0x0800, CRC(3dfb5bcf) SHA1(aa24bf74f4d5dc81baf3843196c837e0b731077b) ) ROM_REGION( 0x0800, "gfx1", 0 ) ROM_LOAD( "tb1-5.2k", 0x0000, 0x0800, CRC(aabd4fb1) SHA1(5cff659b531d0f1b6faa503f7c06045c3a209a84) ) - ROM_REGION( 0x0100, "proms", 0 ) + ROM_REGION( 0x0200, "proms", 0 ) ROM_LOAD( "bct1-1.l3", 0x0000, 0x0100, CRC(d17518bc) SHA1(f3b0deffa586808bc59e9a24ec1699c54ebe84cc) ) /* prom is a Fujitsu MB7052 or equivalent */ + ROM_LOAD( "prom.2d", 0x0100, 0x0100, NO_DUMP ) ROM_END -GAME( 1980, tankbatt, 0, tankbatt, tankbatt, 0, ROT90, "Namco", "Tank Battalion", 0 ) +GAME( 1980, tankbatt, 0, tankbatt, tankbatt, 0, ROT90, "Namco", "Tank Battalion", GAME_IMPERFECT_SOUND )