From 1a408445ad227a6f3ec7aace057d1c0913157dbf Mon Sep 17 00:00:00 2001 From: hap Date: Fri, 16 Dec 2022 15:12:24 +0100 Subject: tmnt: improve sound nmi --- src/mame/konami/asterix.cpp | 2 +- src/mame/konami/overdriv.cpp | 2 +- src/mame/konami/tmnt.cpp | 67 +++++++++++++++++--------------------------- src/mame/konami/tmnt.h | 7 ++--- 4 files changed, 30 insertions(+), 48 deletions(-) diff --git a/src/mame/konami/asterix.cpp b/src/mame/konami/asterix.cpp index e552c89f1f8..ad9c6f198a0 100644 --- a/src/mame/konami/asterix.cpp +++ b/src/mame/konami/asterix.cpp @@ -59,7 +59,7 @@ INTERRUPT_GEN_MEMBER(asterix_state::asterix_interrupt) void asterix_state::sound_arm_nmi_w(uint8_t data) { - // see notes in simpsons driver (though judging from disasm, it seems asterix does not rely on it) + // see notes in simpsons driver m_audiocpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE); m_nmi_blocked->adjust(m_audiocpu->cycles_to_attotime(4)); } diff --git a/src/mame/konami/overdriv.cpp b/src/mame/konami/overdriv.cpp index 9db471482f6..84b54f9f1c3 100644 --- a/src/mame/konami/overdriv.cpp +++ b/src/mame/konami/overdriv.cpp @@ -143,7 +143,7 @@ static const uint16_t overdriv_default_eeprom[64] = void overdriv_state::eeprom_w(offs_t offset, uint16_t data, uint16_t mem_mask) { -//logerror("%s: write %04x to eeprom_w\n",machine().describe_context(),data); + //logerror("%s: write %04x to eeprom_w\n",machine().describe_context(),data); if (ACCESSING_BITS_0_7) { /* bit 0 is data */ diff --git a/src/mame/konami/tmnt.cpp b/src/mame/konami/tmnt.cpp index 92bf180f813..184f724521b 100644 --- a/src/mame/konami/tmnt.cpp +++ b/src/mame/konami/tmnt.cpp @@ -326,27 +326,17 @@ SAMPLES_START_CB_MEMBER(tmnt_state::tmnt_decode_sample) } } -#if 0 -static int sound_nmi_enabled; - -void tmnt_state::sound_nmi_callback( int param ) -{ - m_audiocpu->set_input_line(INPUT_LINE_NMI, ( sound_nmi_enabled ) ? CLEAR_LINE : ASSERT_LINE ); - - sound_nmi_enabled = 0; -} -#endif - -TIMER_CALLBACK_MEMBER(tmnt_state::audio_nmi) +void tmnt_state::sound_arm_nmi_w(uint8_t data) { - m_audiocpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); + // see notes in simpsons driver + m_audiocpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE); + m_nmi_blocked->adjust(m_audiocpu->cycles_to_attotime(4)); } -void tmnt_state::sound_arm_nmi_w(uint8_t data) +void tmnt_state::z80_nmi_w(int state) { -// sound_nmi_enabled = 1; - m_audiocpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE); - m_audio_nmi_timer->adjust(attotime::from_usec(50)); /* kludge until the K053260 is emulated correctly */ + if (state && !m_nmi_blocked->enabled()) + m_audiocpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); } @@ -1994,16 +1984,22 @@ void tmnt_state::machine_start() save_item(NAME(m_sorted_layer)); save_item(NAME(m_irq5_mask)); - m_audio_nmi_timer = timer_alloc(FUNC(tmnt_state::audio_nmi), this); + m_nmi_blocked = timer_alloc(timer_expired_delegate()); } -MACHINE_RESET_MEMBER(tmnt_state,common) +void tmnt_state::machine_reset() { m_toggle = 0; m_last = 0; m_tmnt_soundlatch = 0; m_irq5_mask = 0; - m_audio_nmi_timer->adjust(attotime::never); + + if (m_audiocpu && m_k053260) + { + // Z80 _NMI goes low at same time as reset + m_audiocpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); + m_audiocpu->pulse_input_line(INPUT_LINE_RESET, attotime::zero); + } } void tmnt_state::cuebrick(machine_config &config) @@ -2013,8 +2009,6 @@ void tmnt_state::cuebrick(machine_config &config) m_maincpu->set_addrmap(AS_PROGRAM, &tmnt_state::cuebrick_main_map); m_maincpu->set_vblank_int("screen", FUNC(tmnt_state::tmnt_interrupt)); - MCFG_MACHINE_RESET_OVERRIDE(tmnt_state,common) - WATCHDOG_TIMER(config, "watchdog"); /* video hardware */ @@ -2066,8 +2060,6 @@ void tmnt_state::mia(machine_config &config) Z80(config, m_audiocpu, XTAL(3'579'545)); m_audiocpu->set_addrmap(AS_PROGRAM, &tmnt_state::mia_audio_map); - MCFG_MACHINE_RESET_OVERRIDE(tmnt_state,common) - WATCHDOG_TIMER(config, "watchdog"); /* video hardware */ @@ -2112,6 +2104,8 @@ void tmnt_state::mia(machine_config &config) MACHINE_RESET_MEMBER(tmnt_state,tmnt) { + machine_reset(); + /* the UPD7759 control flip-flops are cleared: /ST is 1, /RESET is 0 */ m_upd7759->start_w(0); m_upd7759->reset_w(1); @@ -2204,8 +2198,6 @@ void tmnt_state::punkshot(machine_config &config) m_audiocpu->set_addrmap(AS_PROGRAM, &tmnt_state::punkshot_audio_map); /* NMIs are generated by the 053260 */ - MCFG_MACHINE_RESET_OVERRIDE(tmnt_state,common) - WATCHDOG_TIMER(config, "watchdog"); /* video hardware */ @@ -2241,6 +2233,7 @@ void tmnt_state::punkshot(machine_config &config) K053260(config, m_k053260, XTAL(3'579'545)); m_k053260->add_route(ALL_OUTPUTS, "mono", 0.70); + m_k053260->sh1_cb().set(FUNC(tmnt_state::z80_nmi_w)); } void tmnt_state::lgtnfght(machine_config &config) @@ -2253,8 +2246,6 @@ void tmnt_state::lgtnfght(machine_config &config) Z80(config, m_audiocpu, XTAL(3'579'545)); m_audiocpu->set_addrmap(AS_PROGRAM, &tmnt_state::lgtnfght_audio_map); - MCFG_MACHINE_RESET_OVERRIDE(tmnt_state,common) - WATCHDOG_TIMER(config, "watchdog"); /* video hardware */ @@ -2293,6 +2284,7 @@ void tmnt_state::lgtnfght(machine_config &config) K053260(config, m_k053260, XTAL(3'579'545)); m_k053260->add_route(0, "lspeaker", 0.70); m_k053260->add_route(1, "rspeaker", 0.70); + m_k053260->sh1_cb().set(FUNC(tmnt_state::z80_nmi_w)); } void tmnt_state::blswhstl(machine_config &config) @@ -2306,8 +2298,6 @@ void tmnt_state::blswhstl(machine_config &config) m_audiocpu->set_addrmap(AS_PROGRAM, &tmnt_state::ssriders_audio_map); /* NMIs are generated by the 053260 */ - MCFG_MACHINE_RESET_OVERRIDE(tmnt_state,common) - EEPROM_ER5911_8BIT(config, "eeprom"); WATCHDOG_TIMER(config, "watchdog"); @@ -2350,6 +2340,7 @@ void tmnt_state::blswhstl(machine_config &config) K053260(config, m_k053260, XTAL(3'579'545)); m_k053260->add_route(0, "rspeaker", 0.50); /* fixed inverted stereo channels */ m_k053260->add_route(1, "lspeaker", 0.50); + m_k053260->sh1_cb().set(FUNC(tmnt_state::z80_nmi_w)); } @@ -2369,8 +2360,6 @@ void glfgreat_state::glfgreat(machine_config &config) m_audiocpu->set_addrmap(AS_PROGRAM, &glfgreat_state::glfgreat_audio_map); /* NMIs are generated by the 053260 */ - MCFG_MACHINE_RESET_OVERRIDE(glfgreat_state,common) - WATCHDOG_TIMER(config, "watchdog"); adc0804_device &adc(ADC0804(config, "adc", RES_K(10), CAP_P(150))); @@ -2416,6 +2405,7 @@ void glfgreat_state::glfgreat(machine_config &config) K053260(config, m_k053260, XTAL(3'579'545)); m_k053260->add_route(0, "lspeaker", 1.0); m_k053260->add_route(1, "rspeaker", 1.0); + m_k053260->sh1_cb().set(FUNC(glfgreat_state::z80_nmi_w)); } void prmrsocr_state::machine_start() @@ -2436,8 +2426,6 @@ void prmrsocr_state::prmrsocr(machine_config &config) m_audiocpu->set_addrmap(AS_PROGRAM, &prmrsocr_state::prmrsocr_audio_map); /* NMIs are generated by the 054539 */ - MCFG_MACHINE_RESET_OVERRIDE(prmrsocr_state,common) - EEPROM_ER5911_8BIT(config, "eeprom"); WATCHDOG_TIMER(config, "watchdog"); @@ -2500,8 +2488,6 @@ void tmnt_state::tmnt2(machine_config &config) m_audiocpu->set_addrmap(AS_PROGRAM, &tmnt_state::ssriders_audio_map); /* NMIs are generated by the 053260 */ - MCFG_MACHINE_RESET_OVERRIDE(tmnt_state,common) - EEPROM_ER5911_8BIT(config, "eeprom"); WATCHDOG_TIMER(config, "watchdog"); @@ -2542,6 +2528,7 @@ void tmnt_state::tmnt2(machine_config &config) K053260(config, m_k053260, XTAL(3'579'545)); m_k053260->add_route(0, "lspeaker", 0.75); m_k053260->add_route(1, "rspeaker", 0.75); + m_k053260->sh1_cb().set(FUNC(tmnt_state::z80_nmi_w)); } void tmnt_state::ssriders(machine_config &config) @@ -2555,8 +2542,6 @@ void tmnt_state::ssriders(machine_config &config) m_audiocpu->set_addrmap(AS_PROGRAM, &tmnt_state::ssriders_audio_map); /* NMIs are generated by the 053260 */ - MCFG_MACHINE_RESET_OVERRIDE(tmnt_state,common) - EEPROM_ER5911_8BIT(config, "eeprom"); WATCHDOG_TIMER(config, "watchdog"); @@ -2597,6 +2582,7 @@ void tmnt_state::ssriders(machine_config &config) K053260(config, m_k053260, XTAL(3'579'545)); m_k053260->add_route(0, "lspeaker", 0.70); m_k053260->add_route(1, "rspeaker", 0.70); + m_k053260->sh1_cb().set(FUNC(tmnt_state::z80_nmi_w)); } void tmnt_state::sunsetbl(machine_config &config) @@ -2606,8 +2592,6 @@ void tmnt_state::sunsetbl(machine_config &config) m_maincpu->set_addrmap(AS_PROGRAM, &tmnt_state::sunsetbl_main_map); m_maincpu->set_vblank_int("screen", FUNC(tmnt_state::irq4_line_hold)); - MCFG_MACHINE_RESET_OVERRIDE(tmnt_state,common) - EEPROM_ER5911_8BIT(config, "eeprom"); /* video hardware */ @@ -2657,8 +2641,6 @@ void tmnt_state::thndrx2(machine_config &config) m_audiocpu->set_addrmap(AS_PROGRAM, &tmnt_state::thndrx2_audio_map); /* NMIs are generated by the 053260 */ - MCFG_MACHINE_RESET_OVERRIDE(tmnt_state,common) - EEPROM_ER5911_8BIT(config, "eeprom"); /* video hardware */ @@ -2697,6 +2679,7 @@ void tmnt_state::thndrx2(machine_config &config) K053260(config, m_k053260, XTAL(3'579'545)); m_k053260->add_route(0, "lspeaker", 0.50); m_k053260->add_route(1, "rspeaker", 0.50); + m_k053260->sh1_cb().set(FUNC(tmnt_state::z80_nmi_w)); } diff --git a/src/mame/konami/tmnt.h b/src/mame/konami/tmnt.h index c29db69a80e..7b64cfbd721 100644 --- a/src/mame/konami/tmnt.h +++ b/src/mame/konami/tmnt.h @@ -64,8 +64,7 @@ public: protected: virtual void machine_start() override; - - TIMER_CALLBACK_MEMBER(audio_nmi); + virtual void machine_reset() override; /* memory pointers */ optional_shared_ptr m_spriteram; @@ -89,7 +88,7 @@ protected: int m_dim_v = 0; /* lgtnfght, ssriders, tmnt2 only */ /* misc */ - emu_timer *m_audio_nmi_timer = nullptr; + emu_timer *m_nmi_blocked = nullptr; int m_tmnt_soundlatch = 0; int m_toggle = 0; int m_last = 0; @@ -127,6 +126,7 @@ protected: uint8_t tmnt_sres_r(); void tmnt_sres_w(uint8_t data); void sound_arm_nmi_w(uint8_t data); + void z80_nmi_w(int state); uint16_t punkshot_kludge_r(); uint16_t ssriders_protection_r(address_space &space); void ssriders_protection_w(address_space &space, offs_t offset, uint16_t data); @@ -149,7 +149,6 @@ protected: void tmnt_upd_start_w(uint8_t data); uint8_t tmnt_upd_busy_r(); - DECLARE_MACHINE_RESET(common); DECLARE_VIDEO_START(cuebrick); DECLARE_VIDEO_START(mia); DECLARE_MACHINE_RESET(tmnt); -- cgit v1.2.3