Skip to content

Commit 3eaedf2

Browse files
committed
taito/tc0060dca.cpp: Added support for Taito TC0060DCA volume control and hooked up to Operation Wolf. (Github #13369) [R. Belmont, Stephen Leary]
1 parent a3bdebb commit 3eaedf2

File tree

3 files changed

+109
-12
lines changed

3 files changed

+109
-12
lines changed

src/mame/taito/opwolf.cpp

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ register. So what is controlling priority.
276276
#include "taitosnd.h"
277277
#include "taitoipt.h"
278278
#include "taitocchip.h"
279+
#include "tc0060dca.h"
279280
#include "pc080sn.h"
280281
#include "pc090oj.h"
281282

@@ -314,6 +315,7 @@ class opwolf_state : public driver_device
314315
m_pc080sn(*this, "pc080sn"),
315316
m_pc090oj(*this, "pc090oj"),
316317
m_msm(*this, "msm%u", 0),
318+
m_tc0060dca(*this, "tc0060dca%u", 0),
317319
m_lspeaker(*this, "lspeaker"),
318320
m_rspeaker(*this, "rspeaker"),
319321
m_z80bank(*this, "z80bank"),
@@ -384,6 +386,7 @@ class opwolf_state : public driver_device
384386
required_device<pc080sn_device> m_pc080sn;
385387
required_device<pc090oj_device> m_pc090oj;
386388
required_device_array<msm5205_device, 2> m_msm;
389+
required_device_array<tc0060dca_device, 2> m_tc0060dca;
387390
required_device<speaker_device> m_lspeaker;
388391
required_device<speaker_device> m_rspeaker;
389392
required_memory_bank m_z80bank;
@@ -755,7 +758,7 @@ void opwolf_state::opwolf_adpcm_b_w(offs_t offset, uint8_t data)
755758
m_adpcm_pos[0] = start;
756759
m_adpcm_end[0] = end;
757760
m_msm[0]->reset_w(0);
758-
m_msm[0]->set_output_gain(0, m_adpcm_b[5] / 255.0);
761+
m_tc0060dca[0]->set_level(m_adpcm_b[5]);
759762
//logerror("TRIGGER MSM1\n");
760763
}
761764

@@ -778,7 +781,7 @@ void opwolf_state::opwolf_adpcm_c_w(offs_t offset, uint8_t data)
778781
m_adpcm_pos[1] = start;
779782
m_adpcm_end[1] = end;
780783
m_msm[1]->reset_w(0);
781-
m_msm[1]->set_output_gain(0, m_adpcm_c[5] / 255.0);
784+
m_tc0060dca[1]->set_level(m_adpcm_c[5]);
782785
//logerror("TRIGGER MSM2\n");
783786
}
784787

@@ -931,17 +934,25 @@ void opwolf_state::opwolf(machine_config &config)
931934
ymsnd.add_route(0, "lspeaker", 1.0);
932935
ymsnd.add_route(1, "rspeaker", 1.0);
933936

937+
TC0060DCA(config, m_tc0060dca[0], 384000);
938+
m_tc0060dca[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0);
939+
m_tc0060dca[0]->add_route(ALL_OUTPUTS, "rspeaker", 1.0);
940+
934941
MSM5205(config, m_msm[0], 384000);
935942
m_msm[0]->vck_legacy_callback().set(FUNC(opwolf_state::msm5205_vck_w<0>));
936943
m_msm[0]->set_prescaler_selector(msm5205_device::S48_4B); /* 8 kHz */
937-
m_msm[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0);
938-
m_msm[0]->add_route(ALL_OUTPUTS, "rspeaker", 1.0);
944+
m_msm[0]->add_route(ALL_OUTPUTS, m_tc0060dca[0], 1.0);
945+
m_msm[0]->add_route(ALL_OUTPUTS, m_tc0060dca[0], 1.0);
946+
947+
TC0060DCA(config, m_tc0060dca[1], 384000);
948+
m_tc0060dca[1]->add_route(ALL_OUTPUTS, "lspeaker", 1.0);
949+
m_tc0060dca[1]->add_route(ALL_OUTPUTS, "rspeaker", 1.0);
939950

940951
MSM5205(config, m_msm[1], 384000);
941952
m_msm[1]->vck_legacy_callback().set(FUNC(opwolf_state::msm5205_vck_w<1>));
942953
m_msm[1]->set_prescaler_selector(msm5205_device::S48_4B); /* 8 kHz */
943-
m_msm[1]->add_route(ALL_OUTPUTS, "lspeaker", 1.0);
944-
m_msm[1]->add_route(ALL_OUTPUTS, "rspeaker", 1.0);
954+
m_msm[1]->add_route(ALL_OUTPUTS, m_tc0060dca[1], 1.0);
955+
m_msm[1]->add_route(ALL_OUTPUTS, m_tc0060dca[1], 1.0);
945956

946957
pc060ha_device &ciu(PC060HA(config, "ciu", 0));
947958
ciu.nmi_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI);
@@ -1002,17 +1013,25 @@ void opwolf_state::opwolfb(machine_config &config) /* OSC clocks unknown for the
10021013
ymsnd.add_route(0, "lspeaker", 1.0);
10031014
ymsnd.add_route(1, "rspeaker", 1.0);
10041015

1016+
TC0060DCA(config, m_tc0060dca[0], 384000);
1017+
m_tc0060dca[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0);
1018+
m_tc0060dca[0]->add_route(ALL_OUTPUTS, "rspeaker", 1.0);
1019+
10051020
MSM5205(config, m_msm[0], 384000);
10061021
m_msm[0]->vck_legacy_callback().set(FUNC(opwolf_state::msm5205_vck_w<0>));
1007-
m_msm[0]->set_prescaler_selector(msm5205_device::S48_4B); /* 8 kHz */
1008-
m_msm[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0);
1009-
m_msm[0]->add_route(ALL_OUTPUTS, "rspeaker", 1.0);
1022+
m_msm[0]->set_prescaler_selector(msm5205_device::S48_4B); /* 8 kHz */
1023+
m_msm[0]->add_route(ALL_OUTPUTS, m_tc0060dca[0], 1.0);
1024+
m_msm[0]->add_route(ALL_OUTPUTS, m_tc0060dca[0], 1.0);
1025+
1026+
TC0060DCA(config, m_tc0060dca[1], 384000);
1027+
m_tc0060dca[1]->add_route(ALL_OUTPUTS, "lspeaker", 1.0);
1028+
m_tc0060dca[1]->add_route(ALL_OUTPUTS, "rspeaker", 1.0);
10101029

10111030
MSM5205(config, m_msm[1], 384000);
10121031
m_msm[1]->vck_legacy_callback().set(FUNC(opwolf_state::msm5205_vck_w<1>));
1013-
m_msm[1]->set_prescaler_selector(msm5205_device::S48_4B); /* 8 kHz */
1014-
m_msm[1]->add_route(ALL_OUTPUTS, "lspeaker", 1.0);
1015-
m_msm[1]->add_route(ALL_OUTPUTS, "rspeaker", 1.0);
1032+
m_msm[1]->set_prescaler_selector(msm5205_device::S48_4B); /* 8 kHz */
1033+
m_msm[1]->add_route(ALL_OUTPUTS, m_tc0060dca[1], 1.0);
1034+
m_msm[1]->add_route(ALL_OUTPUTS, m_tc0060dca[1], 1.0);
10161035

10171036
pc060ha_device &ciu(PC060HA(config, "ciu", 0));
10181037
ciu.nmi_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI);

src/mame/taito/tc0060dca.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// license:BSD-3-Clause
2+
// copyright-holders:R. Belmont
3+
/***************************************************************************
4+
5+
tc0060dca.cpp - Taito TC0060DCA programmable volume control
6+
Emulation by R. Belmont, volume curve measured by Stephen Leary
7+
8+
***************************************************************************/
9+
10+
#include "emu.h"
11+
#include "tc0060dca.h"
12+
13+
#include <cmath>
14+
15+
DEFINE_DEVICE_TYPE(TC0060DCA, tc0060dca_device, "tc0060dca", "Taito TC0060DCA programmable volume control")
16+
17+
tc0060dca_device::tc0060dca_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
18+
device_t(mconfig, TC0060DCA, tag, owner, clock),
19+
device_sound_interface(mconfig, *this),
20+
m_stream(nullptr),
21+
m_level(0)
22+
{
23+
}
24+
25+
void tc0060dca_device::device_start()
26+
{
27+
m_stream = stream_alloc(8, 2, clock(), STREAM_DEFAULT_FLAGS);
28+
29+
for (int x = 0; x < 256; x++)
30+
{
31+
m_atten_table[x] = 1.0 / (1.0 + exp(-10 * ((x / 256.0) - 0.6)));
32+
}
33+
34+
save_item(NAME(m_level));
35+
}
36+
37+
void tc0060dca_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
38+
{
39+
for (int i = 0; i < inputs[0].samples(); i++)
40+
{
41+
const stream_buffer::sample_t l = inputs[0].get(i);
42+
const stream_buffer::sample_t r = inputs[1].get(i);
43+
outputs[0].put(i, l * m_atten_table[m_level]);
44+
outputs[1].put(i, r * m_atten_table[m_level]);
45+
}
46+
}
47+
48+

src/mame/taito/tc0060dca.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// license:BSD-3-Clause
2+
// copyright-holders:R. Belmont
3+
#ifndef MAME_TAITO_TC0060DCA_H
4+
#define MAME_TAITO_TC0060DCA_H
5+
6+
#pragma once
7+
8+
class tc0060dca_device : public device_t, public device_sound_interface
9+
{
10+
public:
11+
tc0060dca_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
12+
13+
void set_level(u8 level) { m_level = level; }
14+
15+
protected:
16+
// device_t override
17+
virtual void device_start() override ATTR_COLD;
18+
19+
// device_sound_interface override
20+
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
21+
22+
private:
23+
sound_stream *m_stream;
24+
u8 m_level;
25+
float m_atten_table[256];
26+
};
27+
28+
DECLARE_DEVICE_TYPE(TC0060DCA, tc0060dca_device)
29+
30+
#endif // MAME_TAITO_TC0060DCA_H

0 commit comments

Comments
 (0)