From 8c875845a79e20b12dfee6d1dea5bf0e0dc0834f Mon Sep 17 00:00:00 2001 From: hap Date: Sun, 4 Nov 2018 16:14:07 +0100 Subject: [PATCH] k054321: remember initial speaker input gains, this fixes volume balance in xmen (nw) --- src/devices/machine/k054321.cpp | 34 +++++++++++++++++++++++++-------- src/devices/machine/k054321.h | 3 +++ src/mame/drivers/rungun.cpp | 4 ++-- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/devices/machine/k054321.cpp b/src/devices/machine/k054321.cpp index a47addbafb5..21e02e9042f 100644 --- a/src/devices/machine/k054321.cpp +++ b/src/devices/machine/k054321.cpp @@ -56,15 +56,29 @@ void k054321_device::sound_map(address_map &map) map(0x3, 0x3).r(FUNC(k054321_device::main2_r)); } -k054321_device::k054321_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, K054321, tag, owner, clock), - m_left(*this, finder_base::DUMMY_TAG), - m_right(*this, finder_base::DUMMY_TAG) +k054321_device::k054321_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, K054321, tag, owner, clock), + m_left(*this, finder_base::DUMMY_TAG), + m_right(*this, finder_base::DUMMY_TAG) { } void k054321_device::device_start() { + // make sure that device_sound_interface is configured + if (!m_left->inputs() && !m_right->inputs()) + throw device_missing_dependencies(); + + // remember initial input gains + m_left_gains = std::make_unique(m_left->inputs()); + m_right_gains = std::make_unique(m_right->inputs()); + + for (int i = 0; i < m_left->inputs(); i++) + m_left_gains[i] = m_left->input_gain(i); + for (int i = 0; i < m_right->inputs(); i++) + m_right_gains[i] = m_right->input_gain(i); + + // register for savestates save_item(NAME(m_main1)); save_item(NAME(m_main2)); save_item(NAME(m_sound1)); @@ -110,8 +124,12 @@ WRITE8_MEMBER(k054321_device::volume_reset_w) WRITE8_MEMBER(k054321_device::volume_up_w) { - m_volume ++; - propagate_volume(); + // assume that max volume is 64 + if (data && m_volume < 64) + { + m_volume++; + propagate_volume(); + } } READ8_MEMBER(k054321_device::busy_r) @@ -136,7 +154,7 @@ void k054321_device::propagate_volume() double vol = pow(2, (m_volume - 40)/10.0); for (int i = 0; i < m_left->inputs(); i++) - m_left->set_input_gain(i, m_active & 2 ? vol : 0.0); + m_left->set_input_gain(i, m_active & 2 ? vol * m_left_gains[i] : 0.0); for (int i = 0; i < m_right->inputs(); i++) - m_right->set_input_gain(i, m_active & 1 ? vol : 0.0); + m_right->set_input_gain(i, m_active & 1 ? vol * m_right_gains[i] : 0.0); } diff --git a/src/devices/machine/k054321.h b/src/devices/machine/k054321.h index 78097b559da..2fe51758d26 100644 --- a/src/devices/machine/k054321.h +++ b/src/devices/machine/k054321.h @@ -29,6 +29,9 @@ private: required_device m_left; required_device m_right; + std::unique_ptr m_left_gains; + std::unique_ptr m_right_gains; + u8 m_main1; u8 m_main2; u8 m_sound1; diff --git a/src/mame/drivers/rungun.cpp b/src/mame/drivers/rungun.cpp index 0968954f148..3d88523a831 100644 --- a/src/mame/drivers/rungun.cpp +++ b/src/mame/drivers/rungun.cpp @@ -459,8 +459,8 @@ MACHINE_CONFIG_START(rungun_state::rng) // BGM, volumes handtuned to make SFXs audible (still not 100% right tho) MCFG_DEVICE_ADD("k054539_2", K054539, 18.432_MHz_XTAL) MCFG_DEVICE_ADDRESS_MAP(0, k054539_map) - MCFG_SOUND_ROUTE(0, "rspeaker", 0.25) - MCFG_SOUND_ROUTE(1, "lspeaker", 0.25) + MCFG_SOUND_ROUTE(0, "rspeaker", 0.6) + MCFG_SOUND_ROUTE(1, "lspeaker", 0.6) MACHINE_CONFIG_END // for dual-screen output Run and Gun requires the video de-multiplexer board connected to the Jamma output, this gives you 2 Jamma connectors, one for each screen.