summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/dac76.cpp
diff options
context:
space:
mode:
author Dirk Best <mail@dirk-best.de>2016-12-12 01:07:45 +0100
committer Dirk Best <mail@dirk-best.de>2016-12-12 01:08:29 +0100
commit92ce7cd13c68c063b1b03d1f7f7c6dac4f77dd4e (patch)
treeb6438472344884b46d2ebf133dd47f6f741e98ad /src/devices/sound/dac76.cpp
parenta5729bb5d971527f4e36c076553a2600a188397d (diff)
beezer: Rewrite driver
- Uses the standard 6840 PTM core for sound generation - New MM583 Noise Generator device - New DAC-76 DAC sound - Use resistor network values for colors - Use bankdev device for banking
Diffstat (limited to 'src/devices/sound/dac76.cpp')
-rw-r--r--src/devices/sound/dac76.cpp91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/devices/sound/dac76.cpp b/src/devices/sound/dac76.cpp
new file mode 100644
index 00000000000..965b74473e6
--- /dev/null
+++ b/src/devices/sound/dac76.cpp
@@ -0,0 +1,91 @@
+// license: GPL-2.0+
+// copyright-holders: Dirk Best
+/***************************************************************************
+
+ PMI DAC-76 COMDAC
+
+ Companding D/A Converter
+
+***************************************************************************/
+
+#include "dac76.h"
+
+
+//**************************************************************************
+// CONSTEXPR DEFINITIONS
+//**************************************************************************
+
+constexpr int dac76_device::m_level[];
+
+
+//**************************************************************************
+// DEVICE DEFINITIONS
+//**************************************************************************
+
+const device_type DAC76 = &device_creator<dac76_device>;
+
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+//-------------------------------------------------
+// dac76_device - constructor
+//-------------------------------------------------
+
+dac76_device::dac76_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, DAC76, "DAC-76 COMDAC", tag, owner, clock, "dac76", __FILE__),
+ device_sound_interface(mconfig, *this),
+ m_stream(nullptr),
+ m_chord(0),
+ m_step(0),
+ m_sb(false)
+{
+}
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void dac76_device::device_start()
+{
+ // create sound stream
+ m_stream = machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate() * 8);
+
+ // register for save states
+ save_item(NAME(m_chord));
+ save_item(NAME(m_step));
+ save_item(NAME(m_sb));
+}
+
+//-------------------------------------------------
+// device_reset - device-specific reset
+//-------------------------------------------------
+
+void dac76_device::device_reset()
+{
+ m_chord = 0;
+ m_step = 0;
+ m_sb = false;
+}
+
+//-------------------------------------------------
+// sound_stream_update - handle update requests for
+// our sound stream
+//-------------------------------------------------
+
+void dac76_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
+{
+ // get current output level
+ int step_size = (2 << m_chord);
+ stream_sample_t vout = m_level[m_chord] + m_step * step_size;
+
+ // apply sign bit
+ vout *= (m_sb ? +1 : -1);
+
+ // range is 0-8031, normalize to about 0-32768 range
+ vout *= 4;
+
+ for (int i = 0; i < samples; i++)
+ outputs[0][i] = vout;
+}