summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/k054321.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/machine/k054321.cpp')
-rw-r--r--src/devices/machine/k054321.cpp38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/devices/machine/k054321.cpp b/src/devices/machine/k054321.cpp
index ec59ae89d94..d53fd8d346f 100644
--- a/src/devices/machine/k054321.cpp
+++ b/src/devices/machine/k054321.cpp
@@ -33,13 +33,14 @@
#include "emu.h"
#include "k054321.h"
-#include <math.h>
+#include <cmath>
DEFINE_DEVICE_TYPE(K054321, k054321_device, "k054321", "K054321 Maincpu-Soundcpu interface")
void k054321_device::main_map(address_map &map)
{
map(0x0, 0x0).w(FUNC(k054321_device::active_w));
+ //map(0x1, 0x1) Used but unknown, xexex(0xd6002) writes 0x0000
map(0x2, 0x2).w(FUNC(k054321_device::volume_reset_w));
map(0x3, 0x3).w(FUNC(k054321_device::volume_up_w));
map(0x4, 0x4).w(FUNC(k054321_device::dummy_w));
@@ -58,8 +59,7 @@ void k054321_device::sound_map(address_map &map)
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),
+ m_speaker(*this, finder_base::DUMMY_TAG),
m_soundlatch(*this, "soundlatch%u", 0)
{
}
@@ -67,36 +67,36 @@ k054321_device::k054321_device(const machine_config &mconfig, const char *tag, d
void k054321_device::device_start()
{
// make sure that device_sound_interface is configured
- if (!m_left->inputs() && !m_right->inputs())
+ if (!m_speaker->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);
+ m_left_gain = m_speaker->input_gain(0);
+ m_right_gain = m_speaker->input_gain(1);
// register for savestates
save_item(NAME(m_volume));
save_item(NAME(m_active));
}
+void k054321_device::device_reset()
+{
+ m_volume = 0;
+}
+
void k054321_device::device_add_mconfig(machine_config &config)
{
for (int i = 0; i < 3; i++)
GENERIC_LATCH_8(config, m_soundlatch[i]);
}
-WRITE8_MEMBER(k054321_device::volume_reset_w)
+void k054321_device::volume_reset_w(u8 data)
{
m_volume = 0;
propagate_volume();
}
-WRITE8_MEMBER(k054321_device::volume_up_w)
+void k054321_device::volume_up_w(u8 data)
{
// assume that max volume is 64
if (data && m_volume < 64)
@@ -106,18 +106,18 @@ WRITE8_MEMBER(k054321_device::volume_up_w)
}
}
-READ8_MEMBER(k054321_device::busy_r)
+u8 k054321_device::busy_r()
{
return 0; // bit0 = 1 means busy
}
-WRITE8_MEMBER(k054321_device::active_w)
+void k054321_device::active_w(u8 data)
{
m_active = data;
propagate_volume();
}
-WRITE8_MEMBER(k054321_device::dummy_w)
+void k054321_device::dummy_w(u8 data)
{
if(data != 0x4a)
logerror("unexpected dummy_w %02x\n", data);
@@ -127,8 +127,6 @@ 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 * 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 * m_right_gains[i] : 0.0);
+ m_speaker->set_input_gain(0, m_active & 2 ? vol * m_left_gain : 0.0);
+ m_speaker->set_input_gain(1, m_active & 1 ? vol * m_right_gain : 0.0);
}