From a6682d49f1a00ab3a0b1ce4bb3580d39845082c7 Mon Sep 17 00:00:00 2001 From: AJR Date: Thu, 31 Aug 2017 23:57:52 -0400 Subject: [PATCH] bking: Soundlatch modernization (nw) --- src/mame/drivers/bking.cpp | 23 ++++++++--------------- src/mame/includes/bking.h | 9 ++++----- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/mame/drivers/bking.cpp b/src/mame/drivers/bking.cpp index e8609acad97..3b0bc074f84 100644 --- a/src/mame/drivers/bking.cpp +++ b/src/mame/drivers/bking.cpp @@ -31,26 +31,18 @@ DIP Locations verified for: READ8_MEMBER(bking_state::bking_sndnmi_disable_r) { - m_sound_nmi_enable = 0; + m_soundnmi->in_w<1>(0); return 0; } WRITE8_MEMBER(bking_state::bking_sndnmi_enable_w) { - m_sound_nmi_enable = 1; + m_soundnmi->in_w<1>(1); } WRITE8_MEMBER(bking_state::bking_soundlatch_w) { - int i, code = 0; - - for (i = 0;i < 8;i++) - if (data & (1 << i)) - code |= 0x80 >> i; - - m_soundlatch->write(space, offset, code); - if (m_sound_nmi_enable) - m_audiocpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE); + m_soundlatch->write(space, offset, BITSWAP8(data, 0, 1, 2, 3, 4, 5, 6, 7)); } WRITE8_MEMBER(bking_state::bking3_addr_l_w) @@ -347,9 +339,6 @@ void bking_state::machine_start() save_item(NAME(m_palette_bank)); save_item(NAME(m_controller)); save_item(NAME(m_hit)); - - /* sound */ - save_item(NAME(m_sound_nmi_enable)); } MACHINE_START_MEMBER(bking_state,bking3) @@ -384,7 +373,7 @@ void bking_state::machine_reset() m_hit = 0; /* sound */ - m_sound_nmi_enable = 1; + m_soundnmi->in_w<1>(0); } MACHINE_RESET_MEMBER(bking_state,bking3) @@ -432,6 +421,10 @@ static MACHINE_CONFIG_START( bking ) MCFG_SPEAKER_STANDARD_MONO("speaker") MCFG_GENERIC_LATCH_8_ADD("soundlatch") + MCFG_GENERIC_LATCH_DATA_PENDING_CB(DEVWRITELINE("soundnmi", input_merger_device, in_w<0>)) + + MCFG_INPUT_MERGER_ALL_HIGH("soundnmi") + MCFG_INPUT_MERGER_OUTPUT_HANDLER(INPUTLINE("audiocpu", INPUT_LINE_NMI)) MCFG_SOUND_ADD("ay1", AY8910, XTAL_6MHz/4) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "speaker", 0.25) diff --git a/src/mame/includes/bking.h b/src/mame/includes/bking.h index 44a7c521589..c3483ec7ece 100644 --- a/src/mame/includes/bking.h +++ b/src/mame/includes/bking.h @@ -3,6 +3,7 @@ #include "machine/taito68705interface.h" #include "machine/gen_latch.h" +#include "machine/input_merger.h" #include "screen.h" class bking_state : public driver_device @@ -16,7 +17,8 @@ public: m_gfxdecode(*this, "gfxdecode"), m_screen(*this, "screen"), m_palette(*this, "palette"), - m_soundlatch(*this, "soundlatch") + m_soundlatch(*this, "soundlatch"), + m_soundnmi(*this, "soundnmi") { } @@ -43,10 +45,6 @@ public: int m_controller; int m_hit; - /* sound-related */ - int m_sound_nmi_enable; - int m_pending_nmi; - /* misc */ int m_addr_h; int m_addr_l; @@ -58,6 +56,7 @@ public: required_device m_screen; required_device m_palette; required_device m_soundlatch; + required_device m_soundnmi; DECLARE_READ8_MEMBER(bking_sndnmi_disable_r); DECLARE_WRITE8_MEMBER(bking_sndnmi_enable_w);