diff --git a/src/mame/drivers/neogeo.c b/src/mame/drivers/neogeo.c index 35c17b64ecd..d796218d565 100644 --- a/src/mame/drivers/neogeo.c +++ b/src/mame/drivers/neogeo.c @@ -304,14 +304,21 @@ void neogeo_state::start_interrupt_timers() * *************************************/ -void neogeo_state::audio_cpu_assert_nmi() +void neogeo_state::audio_cpu_check_nmi() { - m_audiocpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); + m_audiocpu->set_input_line(INPUT_LINE_NMI, (m_audio_cpu_nmi_enabled && m_audio_cpu_nmi_pending) ? ASSERT_LINE : CLEAR_LINE ); } -void neogeo_state::audio_cpu_clear_nmi() +WRITE8_MEMBER(neogeo_state::audio_cpu_enable_nmi_w) { - m_audiocpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE); + m_audio_cpu_nmi_enabled = true; + audio_cpu_check_nmi(); +} + +WRITE8_MEMBER(neogeo_state::audio_cpu_disable_nmi_w) +{ + m_audio_cpu_nmi_enabled = false; + audio_cpu_check_nmi(); } @@ -333,9 +340,9 @@ CUSTOM_INPUT_MEMBER(neogeo_state::multiplexed_controller_r) int port = (FPTR)param; static const char *const cntrl[2][2] = - { - { "IN0-0", "IN0-1" }, { "IN1-0", "IN1-1" } - }; + { + { "IN0-0", "IN0-1" }, { "IN1-0", "IN1-1" } + }; return ioport(cntrl[port][m_controller_select & 0x01])->read_safe(0x00); } @@ -542,7 +549,8 @@ WRITE16_MEMBER(neogeo_state::audio_command_w) { soundlatch_write(data >> 8); - audio_cpu_assert_nmi(); + m_audio_cpu_nmi_pending = true; + audio_cpu_check_nmi(); /* boost the interleave to let the audio CPU read the command */ machine().scheduler().boost_interleave(attotime::zero, attotime::from_usec(50)); @@ -550,14 +558,12 @@ WRITE16_MEMBER(neogeo_state::audio_command_w) } - - - READ8_MEMBER(neogeo_state::audio_command_r) { UINT8 ret = soundlatch_read(); - audio_cpu_clear_nmi(); + m_audio_cpu_nmi_pending = false; + audio_cpu_check_nmi(); return ret; } @@ -875,6 +881,8 @@ void neogeo_state::machine_start() m_vblank_level = 1; m_raster_level = 2; + m_audio_cpu_nmi_pending = false; + /* start with an IRQ3 - but NOT on a reset */ m_irq3_pending = 1; @@ -884,6 +892,8 @@ void neogeo_state::machine_start() save_item(NAME(m_vblank_interrupt_pending)); save_item(NAME(m_display_position_interrupt_pending)); save_item(NAME(m_irq3_pending)); + save_item(NAME(m_audio_cpu_nmi_enabled)); + save_item(NAME(m_audio_cpu_nmi_pending)); save_item(NAME(m_controller_select)); save_item(NAME(m_main_cpu_bank_address)); save_item(NAME(m_save_ram_unlocked)); @@ -914,6 +924,11 @@ void neogeo_state::machine_reset() for (offs = 0; offs < 8; offs++) system_control_w(space, offs, 0, 0x00ff); + // disable audiocpu nmi + m_audio_cpu_nmi_enabled = false; + m_audio_cpu_nmi_pending = false; + audio_cpu_check_nmi(); + m_maincpu->reset(); // FIXME: this doesn't belong in the base system @@ -990,10 +1005,10 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( audio_io_map, AS_IO, 8, neogeo_state ) AM_RANGE(0x00, 0x00) AM_MIRROR(0xff00) AM_READWRITE(audio_command_r, soundlatch_clear_byte_w) AM_RANGE(0x04, 0x07) AM_MIRROR(0xff00) AM_DEVREADWRITE("ymsnd", ym2610_device, read, write) - // AM_RANGE(0x08, 0x08) AM_MIRROR(0xff00) /* write - NMI enable / acknowledge? (the data written doesn't matter) */ + AM_RANGE(0x08, 0x08) AM_MIRROR(0xff00) AM_WRITE(audio_cpu_enable_nmi_w) AM_RANGE(0x08, 0x0b) AM_MIRROR(0xfff0) AM_MASK(0xff03) AM_READ(audio_cpu_bank_select_r) AM_RANGE(0x0c, 0x0c) AM_MIRROR(0xff00) AM_WRITE(soundlatch2_byte_w) - // AM_RANGE(0x18, 0x18) AM_MIRROR(0xff00) /* write - NMI disable? (the data written doesn't matter) */ + AM_RANGE(0x18, 0x18) AM_MIRROR(0xff00) AM_WRITE(audio_cpu_disable_nmi_w) ADDRESS_MAP_END @@ -1189,7 +1204,7 @@ MACHINE_CONFIG_START( neogeo_base, neogeo_state ) MCFG_CPU_ADD("audiocpu", Z80, NEOGEO_AUDIO_CPU_CLOCK) MCFG_CPU_PROGRAM_MAP(audio_map) MCFG_CPU_IO_MAP(audio_io_map) - + /* video hardware */ MCFG_DEFAULT_LAYOUT(layout_neogeo) diff --git a/src/mame/includes/neogeo.h b/src/mame/includes/neogeo.h index 11aa8e50692..d7ae7d1a71a 100644 --- a/src/mame/includes/neogeo.h +++ b/src/mame/includes/neogeo.h @@ -40,7 +40,8 @@ public: m_upd4990a(*this, "upd4990a"), m_save_ram(*this, "saveram"), m_screen(*this, "screen"), - m_palette(*this, "palette") { } + m_palette(*this, "palette") + { } DECLARE_WRITE16_MEMBER(io_control_w); DECLARE_READ16_MEMBER(memcard_r); @@ -49,6 +50,8 @@ public: DECLARE_READ8_MEMBER(audio_command_r); DECLARE_WRITE16_MEMBER(main_cpu_bank_select_w); DECLARE_READ8_MEMBER(audio_cpu_bank_select_r); + DECLARE_WRITE8_MEMBER(audio_cpu_enable_nmi_w); + DECLARE_WRITE8_MEMBER(audio_cpu_disable_nmi_w); DECLARE_WRITE16_MEMBER(system_control_w); DECLARE_READ16_MEMBER(neogeo_unmapped_r); DECLARE_READ16_MEMBER(neogeo_paletteram_r); @@ -188,8 +191,7 @@ protected: void create_sprite_line_timer( ); void start_sprite_line_timer( ); UINT16 get_video_control( ); - void audio_cpu_assert_nmi(); - void audio_cpu_clear_nmi(); + void audio_cpu_check_nmi(); void select_controller( UINT8 data ); void set_save_ram_unlock( UINT8 data ); void set_outputs( ); @@ -345,6 +347,8 @@ protected: UINT32 m_main_cpu_bank_address; UINT8 m_controller_select; bool m_recurse; + bool m_audio_cpu_nmi_enabled; + bool m_audio_cpu_nmi_pending; // MVS-specific state UINT8 m_save_ram_unlocked;