k054321: remember initial speaker input gains, this fixes volume balance in xmen (nw)

This commit is contained in:
hap 2018-11-04 16:14:07 +01:00
parent ecf0c22f7d
commit 8c875845a7
3 changed files with 31 additions and 10 deletions

View File

@ -56,15 +56,29 @@ void k054321_device::sound_map(address_map &map)
map(0x3, 0x3).r(FUNC(k054321_device::main2_r)); 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) k054321_device::k054321_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
: device_t(mconfig, K054321, tag, owner, clock), device_t(mconfig, K054321, tag, owner, clock),
m_left(*this, finder_base::DUMMY_TAG), m_left(*this, finder_base::DUMMY_TAG),
m_right(*this, finder_base::DUMMY_TAG) m_right(*this, finder_base::DUMMY_TAG)
{ {
} }
void k054321_device::device_start() 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<float[]>(m_left->inputs());
m_right_gains = std::make_unique<float[]>(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_main1));
save_item(NAME(m_main2)); save_item(NAME(m_main2));
save_item(NAME(m_sound1)); save_item(NAME(m_sound1));
@ -110,8 +124,12 @@ WRITE8_MEMBER(k054321_device::volume_reset_w)
WRITE8_MEMBER(k054321_device::volume_up_w) WRITE8_MEMBER(k054321_device::volume_up_w)
{ {
m_volume ++; // assume that max volume is 64
propagate_volume(); if (data && m_volume < 64)
{
m_volume++;
propagate_volume();
}
} }
READ8_MEMBER(k054321_device::busy_r) READ8_MEMBER(k054321_device::busy_r)
@ -136,7 +154,7 @@ void k054321_device::propagate_volume()
double vol = pow(2, (m_volume - 40)/10.0); double vol = pow(2, (m_volume - 40)/10.0);
for (int i = 0; i < m_left->inputs(); i++) 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++) 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);
} }

View File

@ -29,6 +29,9 @@ private:
required_device<device_sound_interface> m_left; required_device<device_sound_interface> m_left;
required_device<device_sound_interface> m_right; required_device<device_sound_interface> m_right;
std::unique_ptr<float[]> m_left_gains;
std::unique_ptr<float[]> m_right_gains;
u8 m_main1; u8 m_main1;
u8 m_main2; u8 m_main2;
u8 m_sound1; u8 m_sound1;

View File

@ -459,8 +459,8 @@ MACHINE_CONFIG_START(rungun_state::rng)
// BGM, volumes handtuned to make SFXs audible (still not 100% right tho) // BGM, volumes handtuned to make SFXs audible (still not 100% right tho)
MCFG_DEVICE_ADD("k054539_2", K054539, 18.432_MHz_XTAL) MCFG_DEVICE_ADD("k054539_2", K054539, 18.432_MHz_XTAL)
MCFG_DEVICE_ADDRESS_MAP(0, k054539_map) MCFG_DEVICE_ADDRESS_MAP(0, k054539_map)
MCFG_SOUND_ROUTE(0, "rspeaker", 0.25) MCFG_SOUND_ROUTE(0, "rspeaker", 0.6)
MCFG_SOUND_ROUTE(1, "lspeaker", 0.25) MCFG_SOUND_ROUTE(1, "lspeaker", 0.6)
MACHINE_CONFIG_END 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. // 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.