tc0060dca: make stream alloc adaptive, make chip stereo, and do table lookup at write instead of at stream update

This commit is contained in:
hap 2025-02-22 17:49:08 +01:00
parent f55e7d697c
commit 4f7ed89ece
3 changed files with 33 additions and 32 deletions

View File

@ -758,7 +758,7 @@ void opwolf_state::opwolf_adpcm_b_w(offs_t offset, uint8_t data)
m_adpcm_pos[0] = start;
m_adpcm_end[0] = end;
m_msm[0]->reset_w(0);
m_tc0060dca[0]->set_level(m_adpcm_b[5]);
m_tc0060dca[0]->level_w(3, m_adpcm_b[5]);
//logerror("TRIGGER MSM1\n");
}
@ -781,7 +781,7 @@ void opwolf_state::opwolf_adpcm_c_w(offs_t offset, uint8_t data)
m_adpcm_pos[1] = start;
m_adpcm_end[1] = end;
m_msm[1]->reset_w(0);
m_tc0060dca[1]->set_level(m_adpcm_c[5]);
m_tc0060dca[1]->level_w(3, m_adpcm_c[5]);
//logerror("TRIGGER MSM2\n");
}
@ -934,9 +934,9 @@ void opwolf_state::opwolf(machine_config &config)
ymsnd.add_route(0, "lspeaker", 1.0);
ymsnd.add_route(1, "rspeaker", 1.0);
TC0060DCA(config, m_tc0060dca[0], 384000);
m_tc0060dca[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0);
m_tc0060dca[0]->add_route(ALL_OUTPUTS, "rspeaker", 1.0);
TC0060DCA(config, m_tc0060dca[0]);
m_tc0060dca[0]->add_route(0, "lspeaker", 1.0);
m_tc0060dca[0]->add_route(1, "rspeaker", 1.0);
MSM5205(config, m_msm[0], 384000);
m_msm[0]->vck_legacy_callback().set(FUNC(opwolf_state::msm5205_vck_w<0>));
@ -944,9 +944,9 @@ void opwolf_state::opwolf(machine_config &config)
m_msm[0]->add_route(ALL_OUTPUTS, m_tc0060dca[0], 1.0);
m_msm[0]->add_route(ALL_OUTPUTS, m_tc0060dca[0], 1.0);
TC0060DCA(config, m_tc0060dca[1], 384000);
m_tc0060dca[1]->add_route(ALL_OUTPUTS, "lspeaker", 1.0);
m_tc0060dca[1]->add_route(ALL_OUTPUTS, "rspeaker", 1.0);
TC0060DCA(config, m_tc0060dca[1]);
m_tc0060dca[1]->add_route(0, "lspeaker", 1.0);
m_tc0060dca[1]->add_route(1, "rspeaker", 1.0);
MSM5205(config, m_msm[1], 384000);
m_msm[1]->vck_legacy_callback().set(FUNC(opwolf_state::msm5205_vck_w<1>));
@ -1013,9 +1013,9 @@ void opwolf_state::opwolfb(machine_config &config) /* OSC clocks unknown for the
ymsnd.add_route(0, "lspeaker", 1.0);
ymsnd.add_route(1, "rspeaker", 1.0);
TC0060DCA(config, m_tc0060dca[0], 384000);
m_tc0060dca[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0);
m_tc0060dca[0]->add_route(ALL_OUTPUTS, "rspeaker", 1.0);
TC0060DCA(config, m_tc0060dca[0]);
m_tc0060dca[0]->add_route(0, "lspeaker", 1.0);
m_tc0060dca[0]->add_route(1, "rspeaker", 1.0);
MSM5205(config, m_msm[0], 384000);
m_msm[0]->vck_legacy_callback().set(FUNC(opwolf_state::msm5205_vck_w<0>));
@ -1023,9 +1023,9 @@ void opwolf_state::opwolfb(machine_config &config) /* OSC clocks unknown for the
m_msm[0]->add_route(ALL_OUTPUTS, m_tc0060dca[0], 1.0);
m_msm[0]->add_route(ALL_OUTPUTS, m_tc0060dca[0], 1.0);
TC0060DCA(config, m_tc0060dca[1], 384000);
m_tc0060dca[1]->add_route(ALL_OUTPUTS, "lspeaker", 1.0);
m_tc0060dca[1]->add_route(ALL_OUTPUTS, "rspeaker", 1.0);
TC0060DCA(config, m_tc0060dca[1]);
m_tc0060dca[1]->add_route(0, "lspeaker", 1.0);
m_tc0060dca[1]->add_route(1, "rspeaker", 1.0);
MSM5205(config, m_msm[1], 384000);
m_msm[1]->vck_legacy_callback().set(FUNC(opwolf_state::msm5205_vck_w<1>));

View File

@ -2,7 +2,7 @@
// copyright-holders:R. Belmont
/***************************************************************************
tc0060dca.cpp - Taito TC0060DCA programmable volume control
tc0060dca.cpp - Taito TC0060DCA stereo programmable volume control
Emulation by R. Belmont, volume curve measured by Stephen Leary
***************************************************************************/
@ -12,43 +12,44 @@
#include <cmath>
DEFINE_DEVICE_TYPE(TC0060DCA, tc0060dca_device, "tc0060dca", "Taito TC0060DCA programmable volume control")
DEFINE_DEVICE_TYPE(TC0060DCA, tc0060dca_device, "tc0060dca", "Taito TC0060DCA")
tc0060dca_device::tc0060dca_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, TC0060DCA, tag, owner, clock),
device_sound_interface(mconfig, *this),
m_stream(nullptr),
m_level(0)
m_stream(nullptr)
{
}
void tc0060dca_device::set_level(u8 level)
void tc0060dca_device::level_w(offs_t offset, u8 data)
{
m_stream->update();
m_level = level;
for (int i = 0; i < 2; i++)
{
if (BIT(offset, i))
m_gain[i] = m_atten_table[data];
}
}
void tc0060dca_device::device_start()
{
m_stream = stream_alloc(8, 2, clock(), STREAM_DEFAULT_FLAGS);
m_stream = stream_alloc(2, 2, SAMPLE_RATE_OUTPUT_ADAPTIVE);
for (int x = 0; x < 256; x++)
{
m_atten_table[x] = 1.0 / (1.0 + exp(-10 * ((x / 256.0) - 0.6)));
}
save_item(NAME(m_level));
m_gain[0] = m_gain[1] = m_atten_table[0xff];
save_item(NAME(m_gain));
}
void tc0060dca_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
for (int i = 0; i < inputs[0].samples(); i++)
for (int i = 0; i < outputs[0].samples(); i++)
{
const stream_buffer::sample_t l = inputs[0].get(i);
const stream_buffer::sample_t r = inputs[1].get(i);
outputs[0].put(i, l * m_atten_table[m_level]);
outputs[1].put(i, r * m_atten_table[m_level]);
outputs[0].put(i, l * m_gain[0]);
outputs[1].put(i, r * m_gain[1]);
}
}

View File

@ -8,9 +8,9 @@
class tc0060dca_device : public device_t, public device_sound_interface
{
public:
tc0060dca_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
tc0060dca_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
void set_level(u8 level);
void level_w(offs_t offset, u8 data);
protected:
// device_t override
@ -21,7 +21,7 @@ protected:
private:
sound_stream *m_stream;
u8 m_level;
float m_gain[2];
float m_atten_table[256];
};