From 6bc1260b03cd8ee28d351c12307f47559be90a37 Mon Sep 17 00:00:00 2001 From: David Haywood Date: Wed, 28 Dec 2016 18:17:03 +0000 Subject: [PATCH] refactored new taito68705interface to use newer 68705 code (with integrated peripherals) and refactored some drivers to use it --- src/mame/drivers/bublbobl.cpp | 64 ++--- src/mame/drivers/slapfght.cpp | 70 +++--- src/mame/includes/40love.h | 2 - src/mame/includes/bking.h | 11 - src/mame/includes/bublbobl.h | 32 +-- src/mame/includes/buggychl.h | 2 - src/mame/includes/slapfght.h | 30 +-- src/mame/machine/bublbobl.cpp | 93 ------- src/mame/machine/slapfght.cpp | 133 +--------- src/mame/machine/taito68705interface.cpp | 308 +++++++++++++---------- src/mame/machine/taito68705interface.h | 74 ++++-- 11 files changed, 299 insertions(+), 520 deletions(-) diff --git a/src/mame/drivers/bublbobl.cpp b/src/mame/drivers/bublbobl.cpp index 434cc015df9..63ea6bf6330 100644 --- a/src/mame/drivers/bublbobl.cpp +++ b/src/mame/drivers/bublbobl.cpp @@ -389,9 +389,19 @@ static ADDRESS_MAP_START( tokio_map, AS_PROGRAM, 8, bublbobl_state ) AM_RANGE(0xfb00, 0xfb00) AM_WRITE(tokio_videoctrl_w) AM_RANGE(0xfb80, 0xfb80) AM_WRITE(bublbobl_nmitrigger_w) AM_RANGE(0xfc00, 0xfc00) AM_READWRITE(bublbobl_sound_status_r, bublbobl_sound_command_w) - AM_RANGE(0xfe00, 0xfe00) AM_READWRITE(tokio_mcu_r, tokio_mcu_w) ADDRESS_MAP_END +static ADDRESS_MAP_START( tokio_map_mcu, AS_PROGRAM, 8, bublbobl_state ) + AM_IMPORT_FROM(tokio_map) + AM_RANGE(0xfe00, 0xfe00) AM_DEVREADWRITE("bmcu", taito68705_mcu_device, mcu_r, mcu_w) +ADDRESS_MAP_END + +static ADDRESS_MAP_START( tokio_map_bootleg, AS_PROGRAM, 8, bublbobl_state ) + AM_IMPORT_FROM(tokio_map) + AM_RANGE(0xfe00, 0xfe00) AM_READ( tokiob_mcu_r ) +ADDRESS_MAP_END + + static ADDRESS_MAP_START( tokio_slave_map, AS_PROGRAM, 8, bublbobl_state ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x8000, 0x97ff) AM_RAM AM_SHARE("share1") @@ -619,7 +629,7 @@ static INPUT_PORTS_START( dland ) PORT_DIPSETTING( 0x20, "100 (Cheat)") INPUT_PORTS_END -static INPUT_PORTS_START( tokio ) +static INPUT_PORTS_START( tokio_base ) PORT_START("DSW0") PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW A:1") PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) @@ -669,8 +679,8 @@ static INPUT_PORTS_START( tokio ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_IMPULSE(1) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_COIN2 ) PORT_IMPULSE(1) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, bublbobl_state,tokio_main_sent_r, nullptr) - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, bublbobl_state,tokio_mcu_sent_r, nullptr) + PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_SPECIAL ) // see INPUT_PORTS_START( tokio ) + PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SPECIAL ) // see INPUT_PORTS_START( tokio ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) @@ -695,7 +705,13 @@ static INPUT_PORTS_START( tokio ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) INPUT_PORTS_END +static INPUT_PORTS_START( tokio ) + PORT_INCLUDE( tokio_base ) + PORT_MODIFY("IN0") + PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("bmcu", taito68705_mcu_device, main_sent_r, nullptr) + PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER("bmcu", taito68705_mcu_device, mcu_sent_r, nullptr) +INPUT_PORTS_END /************************************* * @@ -744,15 +760,6 @@ MACHINE_RESET_MEMBER(bublbobl_state,common) MACHINE_START_MEMBER(bublbobl_state,tokio) { MACHINE_START_CALL_MEMBER(common); - - - save_item(NAME(m_mcu_sent)); - save_item(NAME(m_main_sent)); - save_item(NAME(m_from_main)); - save_item(NAME(m_from_mcu)); - save_item(NAME(m_from_mcu_latch)); - save_item(NAME(m_to_mcu_latch)); - save_item(NAME(m_old_portB)); } @@ -767,7 +774,7 @@ static MACHINE_CONFIG_START( tokio, bublbobl_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", Z80, MAIN_XTAL/4) // 6 MHz - MCFG_CPU_PROGRAM_MAP(tokio_map) + MCFG_CPU_PROGRAM_MAP(tokio_map_mcu) MCFG_CPU_VBLANK_INT_DRIVER("screen", bublbobl_state, irq0_line_hold) MCFG_CPU_ADD("slave", Z80, MAIN_XTAL/4) // 6 MHz @@ -777,12 +784,7 @@ static MACHINE_CONFIG_START( tokio, bublbobl_state ) MCFG_CPU_ADD("audiocpu", Z80, MAIN_XTAL/8) // 3 MHz MCFG_CPU_PROGRAM_MAP(tokio_sound_map) // NMIs are triggered by the main CPU, IRQs are triggered by the YM2203 - MCFG_CPU_ADD("mcu", M68705_NEW, MAIN_XTAL/8) // 3 Mhz - MCFG_M68705_PORTA_R_CB(READ8(bublbobl_state, tokio_mcu_porta_r)) - MCFG_M68705_PORTA_W_CB(WRITE8(bublbobl_state, tokio_mcu_porta_w)) - MCFG_M68705_PORTB_W_CB(WRITE8(bublbobl_state, tokio_mcu_portb_w)) - MCFG_M68705_PORTC_R_CB(READ8(bublbobl_state, tokio_mcu_portc_r)) - + MCFG_DEVICE_ADD("bmcu", TAITO68705_MCU, MAIN_XTAL/8) // 3 Mhz MCFG_QUANTUM_PERFECT_CPU("maincpu") @@ -816,9 +818,16 @@ static MACHINE_CONFIG_START( tokio, bublbobl_state ) MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( tokiob, tokio ) - MCFG_DEVICE_REMOVE("mcu") + + MCFG_DEVICE_REMOVE("maincpu") + MCFG_DEVICE_REMOVE("bmcu") + + MCFG_CPU_ADD("maincpu", Z80, MAIN_XTAL/4) // 6 MHz + MCFG_CPU_PROGRAM_MAP(tokio_map_bootleg) + MCFG_CPU_VBLANK_INT_DRIVER("screen", bublbobl_state, irq0_line_hold) MACHINE_CONFIG_END + MACHINE_START_MEMBER(bublbobl_state,bublbobl) { MACHINE_START_CALL_MEMBER(common); @@ -999,7 +1008,7 @@ ROM_START( tokio ) // newer japan set, has -1 revision of roms 02, 03 and 06 ROM_REGION( 0x10000, "audiocpu", 0 ) /* audio CPU */ ROM_LOAD( "a71-07.ic10", 0x0000, 0x08000, CRC(f298cc7b) SHA1(ebf5c804aa07b7f198ec3e1f8d1e111cd89ebdf3) ) - ROM_REGION( 0x0800, "mcu", 0 ) /* 2k for the microcontroller (68705P5) */ + ROM_REGION( 0x0800, "bmcu:mcu", 0 ) /* 2k for the microcontroller (68705P5) */ ROM_LOAD( "a71__24.ic57", 0x0000, 0x0800, CRC(0f4b25de) SHA1(e2d82aa8d8cc6a86aaf5715ef9cb62f526fd5b11) ) ROM_REGION( 0x80000, "gfx1", ROMREGION_INVERT ) /* gfx roms, on gfx board */ @@ -1042,7 +1051,7 @@ ROM_START( tokioo ) // older japan set, has older roms 02, 03, 06 ROM_REGION( 0x10000, "audiocpu", 0 ) /* audio CPU */ ROM_LOAD( "a71-07.ic10", 0x0000, 0x08000, CRC(f298cc7b) SHA1(ebf5c804aa07b7f198ec3e1f8d1e111cd89ebdf3) ) - ROM_REGION( 0x0800, "mcu", 0 ) /* 2k for the microcontroller (68705P5) */ + ROM_REGION( 0x0800, "bmcu:mcu", 0 ) /* 2k for the microcontroller (68705P5) */ ROM_LOAD( "a71__24.ic57", 0x0000, 0x0800, CRC(0f4b25de) SHA1(e2d82aa8d8cc6a86aaf5715ef9cb62f526fd5b11) ) ROM_REGION( 0x80000, "gfx1", ROMREGION_INVERT ) /* gfx roms, on gfx board */ @@ -1085,7 +1094,7 @@ ROM_START( tokiou ) ROM_REGION( 0x10000, "audiocpu", 0 ) /* audio CPU */ ROM_LOAD( "a71-07.ic10", 0x0000, 0x08000, CRC(f298cc7b) SHA1(ebf5c804aa07b7f198ec3e1f8d1e111cd89ebdf3) ) - ROM_REGION( 0x0800, "mcu", 0 ) /* 2k for the microcontroller (68705P5) */ + ROM_REGION( 0x0800, "bmcu:mcu", 0 ) /* 2k for the microcontroller (68705P5) */ ROM_LOAD( "a71__24.ic57", 0x0000, 0x0800, CRC(0f4b25de) SHA1(e2d82aa8d8cc6a86aaf5715ef9cb62f526fd5b11) ) ROM_REGION( 0x80000, "gfx1", ROMREGION_INVERT ) /* gfx roms, on gfx board */ @@ -1871,12 +1880,7 @@ DRIVER_INIT_MEMBER(bublbobl_state,tokio) m_video_enable = 1; } -DRIVER_INIT_MEMBER(bublbobl_state,tokiob) -{ - DRIVER_INIT_CALL(tokio); - m_maincpu->space(AS_PROGRAM).install_read_handler(0xfe00, 0xfe00, read8_delegate(FUNC(bublbobl_state::tokiob_mcu_r),this) ); -} DRIVER_INIT_MEMBER(bublbobl_state,dland) { @@ -1902,7 +1906,7 @@ DRIVER_INIT_MEMBER(bublbobl_state,dland) GAME( 1986, tokio, 0, tokio, tokio, bublbobl_state, tokio, ROT90, "Taito Corporation", "Tokio / Scramble Formation (newer)", MACHINE_SUPPORTS_SAVE ) GAME( 1986, tokioo, tokio, tokio, tokio, bublbobl_state, tokio, ROT90, "Taito Corporation", "Tokio / Scramble Formation (older)", MACHINE_SUPPORTS_SAVE ) GAME( 1986, tokiou, tokio, tokio, tokio, bublbobl_state, tokio, ROT90, "Taito America Corporation (Romstar license)", "Tokio / Scramble Formation (US)", MACHINE_SUPPORTS_SAVE ) -GAME( 1986, tokiob, tokio, tokiob, tokio, bublbobl_state, tokiob, ROT90, "bootleg", "Tokio / Scramble Formation (bootleg)", MACHINE_SUPPORTS_SAVE ) +GAME( 1986, tokiob, tokio, tokiob, tokio_base, bublbobl_state, tokio, ROT90, "bootleg", "Tokio / Scramble Formation (bootleg)", MACHINE_SUPPORTS_SAVE ) GAME( 1986, bublbobl, 0, bublbobl, bublbobl, bublbobl_state, bublbobl, ROT0, "Taito Corporation", "Bubble Bobble (Japan, Ver 0.1)", MACHINE_SUPPORTS_SAVE ) GAME( 1986, bublbobl1, bublbobl, bublbobl, bublbobl, bublbobl_state, bublbobl, ROT0, "Taito Corporation", "Bubble Bobble (Japan, Ver 0.0)", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/slapfght.cpp b/src/mame/drivers/slapfght.cpp index 65520599436..ee1b1118165 100644 --- a/src/mame/drivers/slapfght.cpp +++ b/src/mame/drivers/slapfght.cpp @@ -290,11 +290,15 @@ static ADDRESS_MAP_START( tigerh_map, AS_PROGRAM, 8, slapfght_state ) AM_RANGE(0xe800, 0xe800) AM_WRITE(scrollx_lo_w) AM_RANGE(0xe801, 0xe801) AM_WRITE(scrollx_hi_w) AM_RANGE(0xe802, 0xe802) AM_WRITE(scrolly_w) - AM_RANGE(0xe803, 0xe803) AM_READWRITE(tigerh_mcu_r, tigerh_mcu_w) AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(fixram_w) AM_SHARE("fixvideoram") AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(fixcol_w) AM_SHARE("fixcolorram") ADDRESS_MAP_END +static ADDRESS_MAP_START( tigerh_map_mcu, AS_PROGRAM, 8, slapfght_state ) + AM_RANGE(0xe803, 0xe803) AM_DEVREADWRITE("bmcu", taito68705_mcu_device, mcu_r, mcu_w) + AM_IMPORT_FROM( tigerh_map ) +ADDRESS_MAP_END + static ADDRESS_MAP_START( tigerhb1_map, AS_PROGRAM, 8, slapfght_state ) AM_RANGE(0xe803, 0xe803) AM_READWRITE(tigerhb1_prot_r, tigerhb1_prot_w) AM_IMPORT_FROM( tigerh_map ) @@ -317,11 +321,15 @@ static ADDRESS_MAP_START( slapfigh_map, AS_PROGRAM, 8, slapfght_state ) AM_RANGE(0xe800, 0xe800) AM_WRITE(scrollx_lo_w) AM_RANGE(0xe801, 0xe801) AM_WRITE(scrollx_hi_w) AM_RANGE(0xe802, 0xe802) AM_WRITE(scrolly_w) - AM_RANGE(0xe803, 0xe803) AM_READWRITE(tigerh_mcu_r, tigerh_mcu_w) AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(fixram_w) AM_SHARE("fixvideoram") AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(fixcol_w) AM_SHARE("fixcolorram") ADDRESS_MAP_END +static ADDRESS_MAP_START( slapfigh_map_mcu, AS_PROGRAM, 8, slapfght_state ) + AM_RANGE(0xe803, 0xe803) AM_DEVREADWRITE("bmcu", taito68705_mcu_device, mcu_r, mcu_w) + AM_IMPORT_FROM( slapfigh_map ) +ADDRESS_MAP_END + static ADDRESS_MAP_START( slapfighb1_map, AS_PROGRAM, 8, slapfght_state ) AM_RANGE(0xe803, 0xe803) AM_NOP // no MCU AM_IMPORT_FROM( slapfigh_map ) @@ -733,13 +741,7 @@ void slapfght_state::machine_start() m_main_irq_enabled = false; m_sound_nmi_enabled = false; - m_mcu_sent = false; - m_main_sent = false; - m_from_main = 0; - m_from_mcu = 0; - m_from_mcu_latch = 0; - m_to_mcu_latch = 0; - m_old_portB = 0; + m_getstar_status = 0; m_getstar_sequence_index = 0; @@ -758,14 +760,6 @@ void slapfght_state::machine_start() save_item(NAME(m_main_irq_enabled)); save_item(NAME(m_sound_nmi_enabled)); - save_item(NAME(m_mcu_sent)); - save_item(NAME(m_main_sent)); - save_item(NAME(m_from_main)); - save_item(NAME(m_from_mcu)); - - save_item(NAME(m_from_mcu_latch)); - save_item(NAME(m_to_mcu_latch)); - save_item(NAME(m_old_portB)); save_item(NAME(m_getstar_status)); save_item(NAME(m_getstar_sequence_index)); @@ -791,7 +785,7 @@ void slapfght_state::machine_reset() MACHINE_RESET_MEMBER(slapfght_state,getstar) { // don't boot the mcu since we don't have a dump yet - m_mcu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE); +// m_mcu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE); machine_reset(); } @@ -978,7 +972,7 @@ static MACHINE_CONFIG_START( tigerh, slapfght_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu", Z80, XTAL_36MHz/6) // 6MHz - MCFG_CPU_PROGRAM_MAP(tigerh_map) + MCFG_CPU_PROGRAM_MAP(tigerh_map_mcu) MCFG_CPU_IO_MAP(tigerh_io_map) MCFG_CPU_VBLANK_INT_DRIVER("screen", slapfght_state, vblank_irq) @@ -986,13 +980,7 @@ static MACHINE_CONFIG_START( tigerh, slapfght_state ) MCFG_CPU_PROGRAM_MAP(tigerh_sound_map) MCFG_CPU_PERIODIC_INT_DRIVER(slapfght_state, sound_nmi, 360) // music speed, verified with pcb recording - MCFG_CPU_ADD("mcu", M68705_NEW, XTAL_36MHz/12) // 3MHz - MCFG_M68705_PORTA_R_CB(READ8(slapfght_state, tigerh_mcu_porta_r)) - MCFG_M68705_PORTA_W_CB(WRITE8(slapfght_state, tigerh_mcu_porta_w)) - MCFG_M68705_PORTB_W_CB(WRITE8(slapfght_state, tigerh_mcu_portb_w)) - MCFG_M68705_PORTC_R_CB(READ8(slapfght_state, tigerh_mcu_portc_r)) - - + MCFG_DEVICE_ADD("bmcu", TAITO68705_MCU_TIGER, XTAL_36MHz/12) // 3MHz MCFG_QUANTUM_PERFECT_CPU("maincpu") @@ -1033,7 +1021,7 @@ static MACHINE_CONFIG_DERIVED( tigerhb1, tigerh ) MCFG_CPU_PROGRAM_MAP(tigerhb1_map) MCFG_CPU_IO_MAP(tigerhb_io_map) - MCFG_DEVICE_REMOVE("mcu") + MCFG_DEVICE_REMOVE("bmcu") MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( tigerhb2, tigerhb1 ) @@ -1048,7 +1036,7 @@ static MACHINE_CONFIG_START( slapfigh, slapfght_state ) /* basic machine hardware */ MCFG_CPU_ADD("maincpu",Z80, XTAL_36MHz/6) // 6MHz - MCFG_CPU_PROGRAM_MAP(slapfigh_map) + MCFG_CPU_PROGRAM_MAP(slapfigh_map_mcu) MCFG_CPU_IO_MAP(slapfigh_io_map) MCFG_CPU_VBLANK_INT_DRIVER("screen", slapfght_state, vblank_irq) @@ -1056,11 +1044,8 @@ static MACHINE_CONFIG_START( slapfigh, slapfght_state ) MCFG_CPU_PROGRAM_MAP(tigerh_sound_map) MCFG_CPU_PERIODIC_INT_DRIVER(slapfght_state, sound_nmi, 180) - MCFG_CPU_ADD("mcu", M68705_NEW, XTAL_36MHz/12) // 3MHz - MCFG_M68705_PORTA_R_CB(READ8(slapfght_state, tigerh_mcu_porta_r)) - MCFG_M68705_PORTA_W_CB(WRITE8(slapfght_state, tigerh_mcu_porta_w)) - MCFG_M68705_PORTB_W_CB(WRITE8(slapfght_state, slapfght_mcu_portb_w)) - MCFG_M68705_PORTC_R_CB(READ8(slapfght_state, slapfght_mcu_portc_r)) + MCFG_DEVICE_ADD("bmcu", TAITO68705_MCU_SLAP, XTAL_36MHz/12) // 3MHz + MCFG_TAITO_M68705_EXTENSION_CB(WRITE8(slapfght_state, scroll_from_mcu_w)) MCFG_QUANTUM_PERFECT_CPU("maincpu") @@ -1101,7 +1086,7 @@ static MACHINE_CONFIG_DERIVED( slapfighb1, slapfigh ) MCFG_CPU_PROGRAM_MAP(slapfighb1_map) MCFG_CPU_IO_MAP(slapfighb1_io_map) - MCFG_DEVICE_REMOVE("mcu") + MCFG_DEVICE_REMOVE("bmcu") MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( slapfighb2, slapfighb1 ) @@ -1118,6 +1103,9 @@ static MACHINE_CONFIG_DERIVED( getstar, slapfigh ) MCFG_CPU_PROGRAM_MAP(getstar_map) MCFG_CPU_IO_MAP(getstar_io_map) + MCFG_DEVICE_MODIFY("bmcu:mcu") + MCFG_DEVICE_DISABLE() + MCFG_MACHINE_RESET_OVERRIDE(slapfght_state, getstar) MACHINE_CONFIG_END @@ -1302,7 +1290,7 @@ ROM_START( tigerh ) ROM_REGION( 0x10000, "audiocpu", 0 ) ROM_LOAD( "a47_03.12d", 0x0000, 0x2000, CRC(d105260f) SHA1(f6a0e393e29354bb37fb723828f3267d030a45ea) ) - ROM_REGION( 0x0800, "mcu", 0 ) + ROM_REGION( 0x0800, "bmcu:mcu", 0 ) ROM_LOAD( "a47_14.6a", 0x0000, 0x0800, CRC(4042489f) SHA1(b977e0821b6b1aa5a0a0f349cd78150af1a231df) ) ROM_REGION( 0x04000, "gfx1", 0 ) @@ -1339,7 +1327,7 @@ ROM_START( tigerhj ) ROM_REGION( 0x10000, "audiocpu", 0 ) ROM_LOAD( "a47_03.12d", 0x0000, 0x2000, CRC(d105260f) SHA1(f6a0e393e29354bb37fb723828f3267d030a45ea) ) - ROM_REGION( 0x0800, "mcu", 0 ) + ROM_REGION( 0x0800, "bmcu:mcu", 0 ) ROM_LOAD( "a47_14.6a", 0x0000, 0x0800, CRC(4042489f) SHA1(b977e0821b6b1aa5a0a0f349cd78150af1a231df) ) ROM_REGION( 0x04000, "gfx1", 0 ) @@ -1561,7 +1549,7 @@ ROM_START( alcon ) ROM_REGION( 0x10000, "audiocpu", 0 ) ROM_LOAD( "a77_02.12d", 0x0000, 0x2000, CRC(87f4705a) SHA1(a90d5644ce268f3321047a4f96df96ac294d2f1b) ) - ROM_REGION( 0x0800, "mcu", 0 ) + ROM_REGION( 0x0800, "bmcu:mcu", 0 ) ROM_LOAD( "a77_13.6a", 0x0000, 0x0800, CRC(a70c81d9) SHA1(f155ffd25a946b0459216a8f80ded16e6e2f9258) ) ROM_REGION( 0x04000, "gfx1", 0 ) @@ -1595,7 +1583,7 @@ ROM_START( slapfigh ) ROM_REGION( 0x10000, "audiocpu", 0 ) ROM_LOAD( "a77_02.12d", 0x0000, 0x2000, CRC(87f4705a) SHA1(a90d5644ce268f3321047a4f96df96ac294d2f1b) ) - ROM_REGION( 0x0800, "mcu", 0 ) /* 2k for the microcontroller */ + ROM_REGION( 0x0800, "bmcu:mcu", 0 ) /* 2k for the microcontroller */ ROM_LOAD( "a77_13.6a", 0x0000, 0x0800, CRC(a70c81d9) SHA1(f155ffd25a946b0459216a8f80ded16e6e2f9258) ) ROM_REGION( 0x04000, "gfx1", 0 ) @@ -1637,7 +1625,7 @@ ROM_START( slapfigha ) ROM_REGION( 0x10000, "audiocpu", 0 ) ROM_LOAD( "a76_03.12d", 0x0000, 0x2000, CRC(87f4705a) SHA1(a90d5644ce268f3321047a4f96df96ac294d2f1b) ) - ROM_REGION( 0x0800, "mcu", 0 ) + ROM_REGION( 0x0800, "bmcu:mcu", 0 ) ROM_LOAD( "a76_14.6a", 0x0000, 0x0800, NO_DUMP ) /* A77 MCU not compatible with this set */ ROM_REGION( 0x04000, "gfx1", 0 ) @@ -1899,7 +1887,7 @@ ROM_START( grdian ) ROM_REGION( 0x10000, "audiocpu", 0 ) /* Region 3 - sound cpu code */ ROM_LOAD( "a68-03.12d", 0x0000, 0x2000, CRC(18daa44c) SHA1(1a3d22a186c591321d1b836ee30d89fba4771122) ) - ROM_REGION( 0x0800, "mcu", 0 ) /* 2k for the microcontroller */ + ROM_REGION( 0x0800, "bmcu:mcu", 0 ) /* 2k for the microcontroller */ ROM_LOAD( "a68_14.6a", 0x0000, 0x0800, NO_DUMP ) ROM_REGION( 0x04000, "gfx1", 0 ) /* Region 1 - temporary for gfx */ @@ -1933,7 +1921,7 @@ ROM_START( getstarj ) ROM_REGION( 0x10000, "audiocpu", 0 ) /* Region 3 - sound cpu code */ ROM_LOAD( "a68-03.12d", 0x00000, 0x2000, CRC(18daa44c) SHA1(1a3d22a186c591321d1b836ee30d89fba4771122) ) - ROM_REGION( 0x0800, "mcu", 0 ) /* 2k for the microcontroller */ + ROM_REGION( 0x0800, "bmcu:mcu", 0 ) /* 2k for the microcontroller */ ROM_LOAD( "68705.6a", 0x0000, 0x0800, NO_DUMP ) ROM_REGION( 0x04000, "gfx1", 0 ) /* Region 1 - temporary for gfx */ diff --git a/src/mame/includes/40love.h b/src/mame/includes/40love.h index 3d9fc5ede9a..c420887828d 100644 --- a/src/mame/includes/40love.h +++ b/src/mame/includes/40love.h @@ -18,7 +18,6 @@ public: m_mcu_ram(*this, "mcu_ram"), m_audiocpu(*this, "audiocpu"), m_maincpu(*this, "maincpu"), - //m_mcu(*this, "mcu"), m_bmcu(*this, "bmcu"), m_msm(*this, "msm"), m_gfxdecode(*this, "gfxdecode"), @@ -75,7 +74,6 @@ public: /* devices */ required_device m_audiocpu; required_device m_maincpu; - //optional_device m_mcu; optional_device m_bmcu; required_device m_msm; required_device m_gfxdecode; diff --git a/src/mame/includes/bking.h b/src/mame/includes/bking.h index 985826eefca..03b13033fe3 100644 --- a/src/mame/includes/bking.h +++ b/src/mame/includes/bking.h @@ -11,7 +11,6 @@ public: : driver_device(mconfig, type, tag), m_playfield_ram(*this, "playfield_ram"), m_audiocpu(*this, "audiocpu"), - //m_mcu(*this, "mcu"), m_bmcu(*this, "bmcu"), m_gfxdecode(*this, "gfxdecode"), m_screen(*this, "screen"), @@ -51,22 +50,12 @@ public: /* devices */ required_device m_audiocpu; - //optional_device m_mcu; optional_device m_bmcu; required_device m_gfxdecode; required_device m_screen; required_device m_palette; required_device m_soundlatch; -#if 0 - /* 68705 */ - uint8_t m_port_a_in; - uint8_t m_port_a_out; - uint8_t m_ddr_a; - uint8_t m_port_b_in; - uint8_t m_port_b_out; - uint8_t m_ddr_b; -#endif DECLARE_READ8_MEMBER(bking_sndnmi_disable_r); DECLARE_WRITE8_MEMBER(bking_sndnmi_enable_w); DECLARE_WRITE8_MEMBER(bking_soundlatch_w); diff --git a/src/mame/includes/bublbobl.h b/src/mame/includes/bublbobl.h index 26168aca158..554508c3a19 100644 --- a/src/mame/includes/bublbobl.h +++ b/src/mame/includes/bublbobl.h @@ -2,6 +2,7 @@ // copyright-holders:Chris Moore, Nicola Salmoria #include "machine/gen_latch.h" +#include "machine/taito68705interface.h" class bublbobl_state : public driver_device { @@ -17,13 +18,6 @@ public: m_videoram(*this, "videoram"), m_objectram(*this, "objectram"), m_mcu_sharedram(*this, "mcu_sharedram"), - m_mcu_sent(false), - m_main_sent(false), - m_from_main(0), - m_from_mcu(0), - m_from_mcu_latch(0), - m_to_mcu_latch(0), - m_old_portB(0), m_maincpu(*this, "maincpu"), m_mcu(*this, "mcu"), m_audiocpu(*this, "audiocpu"), @@ -73,14 +67,6 @@ public: /* Bobble Bobble */ int m_ic43_a; int m_ic43_b; - /* Tokio */ - bool m_mcu_sent; - bool m_main_sent; - uint8_t m_from_main; - uint8_t m_from_mcu; - uint8_t m_from_mcu_latch; - uint8_t m_to_mcu_latch; - uint8_t m_old_portB; /* devices */ required_device m_maincpu; @@ -95,8 +81,6 @@ public: DECLARE_WRITE8_MEMBER(tokio_bankswitch_w); DECLARE_WRITE8_MEMBER(tokio_videoctrl_w); DECLARE_WRITE8_MEMBER(bublbobl_nmitrigger_w); - DECLARE_READ8_MEMBER(tokio_mcu_r); - DECLARE_WRITE8_MEMBER(tokio_mcu_w); DECLARE_READ8_MEMBER(tokiob_mcu_r); DECLARE_WRITE8_MEMBER(bublbobl_sound_command_w); @@ -132,20 +116,6 @@ public: DECLARE_WRITE8_MEMBER(bublbobl_68705_port_b_w); DECLARE_WRITE8_MEMBER(bublbobl_68705_ddr_b_w); - - - - DECLARE_CUSTOM_INPUT_MEMBER(tokio_mcu_sent_r); - DECLARE_CUSTOM_INPUT_MEMBER(tokio_main_sent_r); - - - DECLARE_READ8_MEMBER(tokio_mcu_porta_r); - DECLARE_READ8_MEMBER(tokio_mcu_portc_r); - DECLARE_WRITE8_MEMBER(tokio_mcu_porta_w); - DECLARE_WRITE8_MEMBER(tokio_mcu_portb_w); - - - DECLARE_DRIVER_INIT(tokiob); DECLARE_DRIVER_INIT(tokio); DECLARE_DRIVER_INIT(dland); DECLARE_DRIVER_INIT(bublbobl); diff --git a/src/mame/includes/buggychl.h b/src/mame/includes/buggychl.h index a8c663a85b4..1941889a646 100644 --- a/src/mame/includes/buggychl.h +++ b/src/mame/includes/buggychl.h @@ -20,7 +20,6 @@ public: m_scrollh(*this, "scrollh"), m_audiocpu(*this, "audiocpu"), m_maincpu(*this, "maincpu"), - // m_mcu(*this, "mcu"), m_bmcu(*this, "bmcu"), m_msm(*this, "msm"), m_gfxdecode(*this, "gfxdecode"), @@ -53,7 +52,6 @@ public: /* devices */ required_device m_audiocpu; required_device m_maincpu; - //required_device m_mcu; required_device m_bmcu; required_device m_msm; required_device m_gfxdecode; diff --git a/src/mame/includes/slapfght.h b/src/mame/includes/slapfght.h index 9b3a66f37cf..a370a5e6186 100644 --- a/src/mame/includes/slapfght.h +++ b/src/mame/includes/slapfght.h @@ -8,7 +8,7 @@ #include "cpu/z80/z80.h" #include "video/bufsprite.h" - +#include "machine/taito68705interface.h" class slapfght_state : public driver_device { @@ -17,7 +17,7 @@ public: : driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), m_audiocpu(*this, "audiocpu"), - m_mcu(*this, "mcu"), + m_bmcu(*this, "bmcu"), m_gfxdecode(*this, "gfxdecode"), m_screen(*this, "screen"), m_palette(*this, "palette"), @@ -31,7 +31,7 @@ public: // devices, memory pointers required_device m_maincpu; required_device m_audiocpu; - optional_device m_mcu; + optional_device m_bmcu; required_device m_gfxdecode; required_device m_screen; required_device m_palette; @@ -61,15 +61,6 @@ public: bool m_main_irq_enabled; bool m_sound_nmi_enabled; - bool m_mcu_sent; - bool m_main_sent; - uint8_t m_from_main; - uint8_t m_from_mcu; - - uint8_t m_from_mcu_latch; - uint8_t m_to_mcu_latch; - uint8_t m_old_portB; - int m_getstar_status; int m_getstar_sequence_index; int m_getstar_status_state; @@ -79,6 +70,7 @@ public: uint8_t m_gs_e; uint8_t m_tigerhb_cmd; + DECLARE_READ8_MEMBER(tigerh_mcu_status_r); DECLARE_WRITE8_MEMBER(sound_reset_w); DECLARE_WRITE8_MEMBER(irq_enable_w); DECLARE_WRITE8_MEMBER(prg_bank_w); @@ -94,19 +86,7 @@ public: DECLARE_WRITE8_MEMBER(flipscreen_w); DECLARE_WRITE8_MEMBER(palette_bank_w); - DECLARE_WRITE8_MEMBER(tigerh_mcu_w); - DECLARE_READ8_MEMBER(tigerh_mcu_r); - DECLARE_READ8_MEMBER(tigerh_mcu_status_r); - - DECLARE_READ8_MEMBER(tigerh_mcu_porta_r); - DECLARE_WRITE8_MEMBER(tigerh_mcu_porta_w); - - DECLARE_WRITE8_MEMBER(tigerh_mcu_portb_w); - DECLARE_WRITE8_MEMBER(slapfght_mcu_portb_w); - - DECLARE_READ8_MEMBER(tigerh_mcu_portc_r); - DECLARE_READ8_MEMBER(slapfght_mcu_portc_r); - + DECLARE_WRITE8_MEMBER(scroll_from_mcu_w); DECLARE_READ8_MEMBER(getstar_mcusim_r); DECLARE_WRITE8_MEMBER(getstar_mcusim_w); diff --git a/src/mame/machine/bublbobl.cpp b/src/mame/machine/bublbobl.cpp index 76a76af1f4d..1bfa9e97bdc 100644 --- a/src/mame/machine/bublbobl.cpp +++ b/src/mame/machine/bublbobl.cpp @@ -58,99 +58,6 @@ WRITE8_MEMBER(bublbobl_state::bublbobl_nmitrigger_w) -CUSTOM_INPUT_MEMBER(bublbobl_state::tokio_mcu_sent_r) -{ - if (m_mcu_sent) return 0; - else return 1; -} - -CUSTOM_INPUT_MEMBER(bublbobl_state::tokio_main_sent_r) -{ - if (m_main_sent) return 0; - else return 1; -} - - -READ8_MEMBER(bublbobl_state::tokio_mcu_r) -{ - if (!m_mcu) - return 0x00; - - m_mcu_sent = false; - -// printf("%s: tokio_mcu_r %02x\n", space.machine().describe_context(), m_from_mcu); - - return m_from_mcu; -} - -WRITE8_MEMBER(bublbobl_state::tokio_mcu_w) -{ - if (!m_mcu) - return; - -// printf("%s: tokio_mcu_w %02x\n", space.machine().describe_context(), data); - - m_from_main = data; - m_main_sent = true; - m_mcu->set_input_line(0, ASSERT_LINE); - -} - - -READ8_MEMBER(bublbobl_state::tokio_mcu_porta_r) -{ -// printf("tokio_mcu_porta_r\n"); - return m_to_mcu_latch; -} - -WRITE8_MEMBER(bublbobl_state::tokio_mcu_porta_w) -{ -// printf("tokio_mcu_porta_w %02x\n", data); - m_from_mcu_latch = data; -} - - -READ8_MEMBER(bublbobl_state::tokio_mcu_portc_r) -{ - uint8_t ret = 0; - - if (!m_main_sent) - ret |= 0x01; - if (m_mcu_sent) - ret |= 0x02; - - ret ^= 0x3; // inverted logic compared to tigerh - -// printf("%s: tokio_mcu_portc_r %02x\n", space.machine().describe_context(), ret); - - return ret; -} - - -WRITE8_MEMBER(bublbobl_state::tokio_mcu_portb_w) -{ -// printf("tokio_mcu_portb_w %02x\n", data); - - if ((mem_mask & 0x02) && (~data & 0x02) && (m_old_portB & 0x02)) - { - if (m_main_sent) - m_mcu->set_input_line(0, CLEAR_LINE); - - m_to_mcu_latch = m_from_main; - m_main_sent = false; - } - if ((mem_mask & 0x04) && (data & 0x04) && (~m_old_portB & 0x04)) - { - m_from_mcu = m_from_mcu_latch; - m_mcu_sent = true; - // printf("sent %02x\n", m_from_mcu); - } - - m_old_portB = data; - -} - - diff --git a/src/mame/machine/slapfght.cpp b/src/mame/machine/slapfght.cpp index c8243414810..d362a1a76c6 100644 --- a/src/mame/machine/slapfght.cpp +++ b/src/mame/machine/slapfght.cpp @@ -12,26 +12,6 @@ #include "includes/slapfght.h" -/*************************************************************************** - - Tiger Heli MCU - -***************************************************************************/ - -READ8_MEMBER(slapfght_state::tigerh_mcu_r) -{ - m_mcu_sent = false; - return m_from_mcu; -} - -WRITE8_MEMBER(slapfght_state::tigerh_mcu_w) -{ - m_from_main = data; - m_main_sent = true; - m_mcu->set_input_line(0, ASSERT_LINE); -} - - /**************************************************************************/ READ8_MEMBER(slapfght_state::tigerh_mcu_status_r) @@ -39,115 +19,24 @@ READ8_MEMBER(slapfght_state::tigerh_mcu_status_r) // d0 is vblank uint8_t res = m_screen->vblank() ? 1 : 0; - if (!m_main_sent) - res |= 0x02; - if (!m_mcu_sent) - res |= 0x04; + if (m_bmcu) + { + if (!m_bmcu->get_main_sent()) + res |= 0x02; + if (!m_bmcu->get_mcu_sent()) + res |= 0x04; + } return res; } - -/*************************************************************************** - - MCU port handlers (general) - -***************************************************************************/ - - -READ8_MEMBER(slapfght_state::tigerh_mcu_porta_r) +WRITE8_MEMBER(slapfght_state::scroll_from_mcu_w) { - return m_to_mcu_latch; -} - -WRITE8_MEMBER(slapfght_state::tigerh_mcu_porta_w) -{ - m_from_mcu_latch = data; -} - - -/*************************************************************************** - - MCU port handlers (Tiger Heli) - -***************************************************************************/ - -WRITE8_MEMBER(slapfght_state::tigerh_mcu_portb_w) -{ - if ((mem_mask & 0x02) && (~data & 0x02) && (m_old_portB & 0x02)) + switch (offset) { - if (m_main_sent) - m_mcu->set_input_line(0, CLEAR_LINE); - - m_to_mcu_latch = m_from_main; - m_main_sent = false; + case 0x00: m_scrollx_lo = data; break; + case 0x01: m_scrollx_hi = data; break; } - if ((mem_mask & 0x04) && (data & 0x04) && (~m_old_portB & 0x04)) - { - m_from_mcu = m_from_mcu_latch; - m_mcu_sent = true; - } - - m_old_portB = data; -} - -READ8_MEMBER(slapfght_state::tigerh_mcu_portc_r) -{ - uint8_t ret = 0; - - if (!m_main_sent) - ret |= 0x01; - if (m_mcu_sent) - ret |= 0x02; - - return ret; -} - -/*************************************************************************** - - MCU port handlers (Slap Fight) - -***************************************************************************/ - -WRITE8_MEMBER(slapfght_state::slapfght_mcu_portb_w) -{ - if ((mem_mask & 0x02) && (~data & 0x02) && (m_old_portB & 0x02)) - { - if (m_main_sent) - m_mcu->set_input_line(0, CLEAR_LINE); - - m_to_mcu_latch = m_from_main; - m_main_sent = false; - } - if ((mem_mask & 0x04) && (data & 0x04) && (~m_old_portB & 0x04)) - { - m_from_mcu = m_from_mcu_latch; - m_mcu_sent = true; - } - if ((mem_mask & 0x08) && (~data & 0x08) && (m_old_portB & 0x08)) - { - m_scrollx_lo = m_from_mcu_latch; - } - if ((mem_mask & 0x10) && (~data & 0x10) && (m_old_portB & 0x10)) - { - m_scrollx_hi = m_from_mcu_latch; - } - - m_old_portB = data; -} - -READ8_MEMBER(slapfght_state::slapfght_mcu_portc_r) -{ - uint8_t ret = 0; - - if (!m_main_sent) - ret |= 0x01; - if (m_mcu_sent) - ret |= 0x02; - - ret ^= 0x3; // inverted logic compared to tigerh - - return ret; } /*************************************************************************** diff --git a/src/mame/machine/taito68705interface.cpp b/src/mame/machine/taito68705interface.cpp index 5cebd83e8cd..08423f814a8 100644 --- a/src/mame/machine/taito68705interface.cpp +++ b/src/mame/machine/taito68705interface.cpp @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Ernesto Corvi, Nicola Salmoria +// copyright-holders:Ernesto Corvi, Nicola Salmoria, David Haywood #include "emu.h" #include "cpu/z80/z80.h" #include "machine/taito68705interface.h" @@ -12,45 +12,52 @@ buggychl.cpp - buggychl bking.cpp - bking3 40love.cpp - 40love + bublbobl.cpp - tokio + slapfght.cpp - tigerh + + and the following with slight changes: + slapfght.cpp - slapfght */ const device_type TAITO68705_MCU = &device_creator; +const device_type TAITO68705_MCU_SLAP = &device_creator; +const device_type TAITO68705_MCU_TIGER = &device_creator; taito68705_mcu_device::taito68705_mcu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, TAITO68705_MCU, "Taito M68705 MCU Interface", tag, owner, clock, "taito68705", __FILE__), - m_port_a_in(0), - m_port_a_out(0), - m_ddr_a(0), - m_port_b_in(0), - m_port_b_out(0), - m_ddr_b(0), - m_port_c_in(0), - m_port_c_out(0), - m_ddr_c(0), + m_mcu_sent(false), + m_main_sent(false), m_from_main(0), m_from_mcu(0), - m_mcu_sent(0), - m_main_sent(0), + m_from_mcu_latch(0), + m_to_mcu_latch(0), + m_old_portB(0), m_mcu(*this, "mcu") { } -ADDRESS_MAP_START( taito68705_mcu_map, AS_PROGRAM, 8, taito68705_mcu_device ) - ADDRESS_MAP_GLOBAL_MASK(0x7ff) - AM_RANGE(0x0000, 0x0000) AM_READWRITE(buggychl_68705_port_a_r, buggychl_68705_port_a_w) - AM_RANGE(0x0001, 0x0001) AM_READWRITE(buggychl_68705_port_b_r, buggychl_68705_port_b_w) - AM_RANGE(0x0002, 0x0002) AM_READWRITE(buggychl_68705_port_c_r, buggychl_68705_port_c_w) - AM_RANGE(0x0004, 0x0004) AM_WRITE(buggychl_68705_ddr_a_w) - AM_RANGE(0x0005, 0x0005) AM_WRITE(buggychl_68705_ddr_b_w) - AM_RANGE(0x0006, 0x0006) AM_WRITE(buggychl_68705_ddr_c_w) - AM_RANGE(0x0010, 0x007f) AM_RAM - AM_RANGE(0x0080, 0x07ff) AM_ROM -ADDRESS_MAP_END +taito68705_mcu_device::taito68705_mcu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, u32 clock, const char *shortname, const char *source) + : device_t(mconfig, type, name, tag, owner, clock, shortname, source), + m_mcu_sent(false), + m_main_sent(false), + m_from_main(0), + m_from_mcu(0), + m_from_mcu_latch(0), + m_to_mcu_latch(0), + m_old_portB(0), + m_mcu(*this, "mcu") +{ +} + + static MACHINE_CONFIG_FRAGMENT( taito68705 ) - MCFG_CPU_ADD("mcu", M68705, DERIVED_CLOCK(1,1)) - MCFG_CPU_PROGRAM_MAP(taito68705_mcu_map) + MCFG_CPU_ADD("mcu", M68705_NEW, DERIVED_CLOCK(1,1)) // 3 Mhz + MCFG_M68705_PORTA_R_CB(READ8(taito68705_mcu_device, mcu_porta_r)) + MCFG_M68705_PORTA_W_CB(WRITE8(taito68705_mcu_device, mcu_porta_w)) + MCFG_M68705_PORTB_W_CB(WRITE8(taito68705_mcu_device, mcu_portb_w)) + MCFG_M68705_PORTC_R_CB(READ8(taito68705_mcu_device, mcu_portc_r)) MACHINE_CONFIG_END machine_config_constructor taito68705_mcu_device::device_mconfig_additions() const @@ -75,19 +82,13 @@ void taito68705_mcu_device::device_config_complete() void taito68705_mcu_device::device_start() { - save_item(NAME(m_from_main)); - save_item(NAME(m_from_mcu)); save_item(NAME(m_mcu_sent)); save_item(NAME(m_main_sent)); - save_item(NAME(m_port_a_in)); - save_item(NAME(m_port_a_out)); - save_item(NAME(m_ddr_a)); - save_item(NAME(m_port_b_in)); - save_item(NAME(m_port_b_out)); - save_item(NAME(m_ddr_b)); - save_item(NAME(m_port_c_in)); - save_item(NAME(m_port_c_out)); - save_item(NAME(m_ddr_c)); + save_item(NAME(m_from_main)); + save_item(NAME(m_from_mcu)); + save_item(NAME(m_from_mcu_latch)); + save_item(NAME(m_to_mcu_latch)); + save_item(NAME(m_old_portB)); } //------------------------------------------------- @@ -96,19 +97,13 @@ void taito68705_mcu_device::device_start() void taito68705_mcu_device::device_reset() { - m_mcu_sent = 0; - m_main_sent = 0; + m_mcu_sent = false; + m_main_sent = false; m_from_main = 0; m_from_mcu = 0; - m_port_a_in = 0; - m_port_a_out = 0; - m_ddr_a = 0; - m_port_b_in = 0; - m_port_b_out = 0; - m_ddr_b = 0; - m_port_c_in = 0; - m_port_c_out = 0; - m_ddr_c = 0; + m_from_mcu_latch = 0; + m_to_mcu_latch = 0; + m_old_portB = 0; m_mcu->set_input_line(0, CLEAR_LINE); } @@ -122,24 +117,6 @@ void taito68705_mcu_device::device_reset() ***************************************************************************/ -READ8_MEMBER( taito68705_mcu_device::buggychl_68705_port_a_r ) -{ - //logerror("%04x: 68705 port A read %02x\n", m_mcu->safe_pc(), m_port_a_in); - return (m_port_a_out & m_ddr_a) | (m_port_a_in & ~m_ddr_a); -} - -WRITE8_MEMBER( taito68705_mcu_device::buggychl_68705_port_a_w ) -{ - //logerror("%04x: 68705 port A write %02x\n", m_mcu->safe_pc(), data); - m_port_a_out = data; -} - -WRITE8_MEMBER( taito68705_mcu_device::buggychl_68705_ddr_a_w ) -{ - m_ddr_a = data; -} - - /* * Port B connections: @@ -160,86 +137,82 @@ WRITE8_MEMBER( taito68705_mcu_device::buggychl_68705_ddr_a_w ) */ -READ8_MEMBER( taito68705_mcu_device::buggychl_68705_port_b_r ) + + + +READ8_MEMBER(taito68705_mcu_device::mcu_r) { - return (m_port_b_out & m_ddr_b) | (m_port_b_in & ~m_ddr_b); -} + m_mcu_sent = false; -WRITE8_MEMBER( taito68705_mcu_device::buggychl_68705_port_b_w ) -{ - logerror("%s: 68705 port B write %02x\n", machine().describe_context(), data); +// logerror("%s: mcu_r %02x\n", space.machine().describe_context(), m_from_mcu); - if ((m_ddr_b & 0x02) && (~data & 0x02) && (m_port_b_out & 0x02)) - { - m_port_a_in = m_from_main; - if (m_main_sent) - m_mcu->set_input_line(0, CLEAR_LINE); - m_main_sent = 0; - logerror("read command %02x from main cpu\n", m_port_a_in); - } - if ((m_ddr_b & 0x04) && (data & 0x04) && (~m_port_b_out & 0x04)) - { - logerror("send command %02x to main cpu\n", m_port_a_out); - m_from_mcu = m_port_a_out; - m_mcu_sent = 1; - } - - m_port_b_out = data; -} - -WRITE8_MEMBER( taito68705_mcu_device::buggychl_68705_ddr_b_w ) -{ - m_ddr_b = data; -} - - -/* - * Port C connections: - * - * all bits are logical 1 when read (+5V pullup) - * - * 0 R 1 when pending command Z80->68705 - * 1 R 0 when pending command 68705->Z80 - */ - -READ8_MEMBER( taito68705_mcu_device::buggychl_68705_port_c_r ) -{ - m_port_c_in = 0; - if (m_main_sent) - m_port_c_in |= 0x01; - if (!m_mcu_sent) - m_port_c_in |= 0x02; - logerror("$s: 68705 port C read %02x\n", machine().describe_context(), m_port_c_in); - return (m_port_c_out & m_ddr_c) | (m_port_c_in & ~m_ddr_c); -} - -WRITE8_MEMBER( taito68705_mcu_device::buggychl_68705_port_c_w ) -{ - logerror("%s: 68705 port C write %02x\n", machine().describe_context(), data); - m_port_c_out = data; -} - -WRITE8_MEMBER( taito68705_mcu_device::buggychl_68705_ddr_c_w ) -{ - m_ddr_c = data; -} - - -WRITE8_MEMBER( taito68705_mcu_device::mcu_w ) -{ - logerror("%s: mcu_w %02x\n", machine().describe_context(), data); - m_from_main = data; - m_main_sent = 1; - m_mcu->set_input_line(0, ASSERT_LINE); -} - -READ8_MEMBER( taito68705_mcu_device::mcu_r ) -{ - logerror("%s: mcu_r %02x\n", machine().describe_context(), m_from_mcu); - m_mcu_sent = 0; return m_from_mcu; } +WRITE8_MEMBER(taito68705_mcu_device::mcu_w) +{ +// logerror("%s: mcu_w %02x\n", space.machine().describe_context(), data); + + m_from_main = data; + m_main_sent = true; + m_mcu->set_input_line(0, ASSERT_LINE); + +} + + +READ8_MEMBER(taito68705_mcu_device::mcu_porta_r) +{ +// logerror("mcu_porta_r\n"); + return m_to_mcu_latch; +} + +WRITE8_MEMBER(taito68705_mcu_device::mcu_porta_w) +{ +// logerror("mcu_porta_w %02x\n", data); + m_from_mcu_latch = data; +} + + +READ8_MEMBER(taito68705_mcu_device::mcu_portc_r) +{ + uint8_t ret = 0; + + if (m_main_sent) + ret |= 0x01; + if (!m_mcu_sent) + ret |= 0x02; + +// logerror("%s: mcu_portc_r %02x\n", space.machine().describe_context(), ret); + + return ret; +} + + +WRITE8_MEMBER(taito68705_mcu_device::mcu_portb_w) +{ +// logerror("mcu_portb_w %02x\n", data); + + if ((mem_mask & 0x02) && (~data & 0x02) && (m_old_portB & 0x02)) + { + if (m_main_sent) + m_mcu->set_input_line(0, CLEAR_LINE); + + m_to_mcu_latch = m_from_main; + m_main_sent = false; + } + if ((mem_mask & 0x04) && (data & 0x04) && (~m_old_portB & 0x04)) + { + m_from_mcu = m_from_mcu_latch; + m_mcu_sent = true; + // logerror("sent %02x\n", m_from_mcu); + } + + m_old_portB = data; + +} + +/* Status readbacks for MAIN cpu - these hook up in various ways depending on the host (provide 2 lines instead?) */ + READ8_MEMBER( taito68705_mcu_device::mcu_status_r ) { int res = 0; @@ -255,3 +228,60 @@ READ8_MEMBER( taito68705_mcu_device::mcu_status_r ) return res; } +CUSTOM_INPUT_MEMBER(taito68705_mcu_device::mcu_sent_r) +{ + if (!m_mcu_sent) return 0; + else return 1; +} + +CUSTOM_INPUT_MEMBER(taito68705_mcu_device::main_sent_r) +{ + if (!m_main_sent) return 0; + else return 1; +} + +/* The Slap Fight interface has some extensions, handle them here */ + +taito68705_mcu_slap_device::taito68705_mcu_slap_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : taito68705_mcu_device(mconfig, TAITO68705_MCU_SLAP, "Taito M68705 MCU Interface (Slap Fight)", tag, owner, clock, "taito68705slap", __FILE__), + m_extension_cb_w(*this) +{ +} + +WRITE8_MEMBER(taito68705_mcu_slap_device::mcu_portb_w) +{ + if ((mem_mask & 0x08) && (~data & 0x08) && (m_old_portB & 0x08)) + { + m_extension_cb_w(0,m_from_mcu_latch, 0xff); // m_scrollx_lo + } + if ((mem_mask & 0x10) && (~data & 0x10) && (m_old_portB & 0x10)) + { + m_extension_cb_w(1,m_from_mcu_latch, 0xff); // m_scrollx_hi + } + + taito68705_mcu_device::mcu_portb_w(space,offset,data); +} + +void taito68705_mcu_slap_device::device_start() +{ + taito68705_mcu_device::device_start(); + m_extension_cb_w.resolve_safe(); +} + + +/* The Tiger Heli interface has some extensions, handle them here */ + +taito68705_mcu_tiger_device::taito68705_mcu_tiger_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : taito68705_mcu_device(mconfig, TAITO68705_MCU_TIGER, "Taito M68705 MCU Interface (Tiger Heli)", tag, owner, clock, "taito68705tiger", __FILE__) +{ +} + +READ8_MEMBER(taito68705_mcu_tiger_device::mcu_portc_r) +{ + uint8_t ret = taito68705_mcu_device::mcu_portc_r(space,offset); + + // Tiger Heli has these status bits inverted MCU-side + ret ^= 0x3; + + return ret; +} diff --git a/src/mame/machine/taito68705interface.h b/src/mame/machine/taito68705interface.h index 270cd0bc9c7..1cf57621274 100644 --- a/src/mame/machine/taito68705interface.h +++ b/src/mame/machine/taito68705interface.h @@ -1,5 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Ernesto Corvi, Nicola Salmoria +// copyright-holders:Ernesto Corvi, Nicola Salmoria, David Haywood #include "cpu/m6805/m6805.h" @@ -7,20 +7,24 @@ class taito68705_mcu_device : public device_t { public: taito68705_mcu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + taito68705_mcu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, u32 clock, const char *shortname, const char *source); + ~taito68705_mcu_device() {} DECLARE_WRITE8_MEMBER( mcu_w ); DECLARE_READ8_MEMBER( mcu_r ); + DECLARE_READ8_MEMBER( mcu_porta_r ); + virtual DECLARE_READ8_MEMBER( mcu_portc_r ); + DECLARE_WRITE8_MEMBER( mcu_porta_w ); + virtual DECLARE_WRITE8_MEMBER( mcu_portb_w ); + DECLARE_READ8_MEMBER( mcu_status_r ); - DECLARE_READ8_MEMBER( buggychl_68705_port_a_r ); - DECLARE_WRITE8_MEMBER( buggychl_68705_port_a_w ); - DECLARE_WRITE8_MEMBER( buggychl_68705_ddr_a_w ); - DECLARE_READ8_MEMBER( buggychl_68705_port_b_r ); - DECLARE_WRITE8_MEMBER( buggychl_68705_port_b_w ); - DECLARE_WRITE8_MEMBER( buggychl_68705_ddr_b_w ); - DECLARE_READ8_MEMBER( buggychl_68705_port_c_r ); - DECLARE_WRITE8_MEMBER( buggychl_68705_port_c_w ); - DECLARE_WRITE8_MEMBER( buggychl_68705_ddr_c_w ); + DECLARE_CUSTOM_INPUT_MEMBER( mcu_sent_r ); + DECLARE_CUSTOM_INPUT_MEMBER( main_sent_r ); + + bool get_main_sent() { return m_main_sent; }; + bool get_mcu_sent() { return m_mcu_sent; }; + protected: // device-level overrides @@ -29,22 +33,44 @@ protected: virtual void device_start() override; virtual void device_reset() override; -private: // internal state - uint8_t m_port_a_in; - uint8_t m_port_a_out; - uint8_t m_ddr_a; - uint8_t m_port_b_in; - uint8_t m_port_b_out; - uint8_t m_ddr_b; - uint8_t m_port_c_in; - uint8_t m_port_c_out; - uint8_t m_ddr_c; - uint8_t m_from_main; - uint8_t m_from_mcu; - int m_mcu_sent; - int m_main_sent; + bool m_mcu_sent; + bool m_main_sent; + uint8_t m_from_main; + uint8_t m_from_mcu; + uint8_t m_from_mcu_latch; + uint8_t m_to_mcu_latch; + uint8_t m_old_portB; + required_device m_mcu; }; extern const device_type TAITO68705_MCU; + +#define MCFG_TAITO_M68705_EXTENSION_CB(_devcb) \ + taito68705_mcu_slap_device::set_extension_cb(*device, DEVCB_##_devcb); + +class taito68705_mcu_slap_device : public taito68705_mcu_device +{ +public: + taito68705_mcu_slap_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + virtual DECLARE_WRITE8_MEMBER( mcu_portb_w ) override; + + template static devcb_base &set_extension_cb(device_t &device, _Object object) { return downcast(device).m_extension_cb_w.set_callback(object); } + + devcb_write8 m_extension_cb_w; + +protected: + virtual void device_start() override; +}; + +extern const device_type TAITO68705_MCU_SLAP; + +class taito68705_mcu_tiger_device : public taito68705_mcu_device +{ +public: + taito68705_mcu_tiger_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + virtual DECLARE_READ8_MEMBER( mcu_portc_r ) override; +}; + +extern const device_type TAITO68705_MCU_TIGER;