summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/mm5837.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/sound/mm5837.cpp')
-rw-r--r--src/devices/sound/mm5837.cpp81
1 files changed, 53 insertions, 28 deletions
diff --git a/src/devices/sound/mm5837.cpp b/src/devices/sound/mm5837.cpp
index ac48a540194..74f90d01599 100644
--- a/src/devices/sound/mm5837.cpp
+++ b/src/devices/sound/mm5837.cpp
@@ -1,5 +1,5 @@
-// license: GPL-2.0+
-// copyright-holders: Dirk Best
+// license:BSD-3-Clause
+// copyright-holders:Dirk Best
/***************************************************************************
National Semiconductor MM5837
@@ -13,21 +13,15 @@
//**************************************************************************
-// CONSTEXPR DEFINITIONS
-//**************************************************************************
-
-constexpr int mm5837_device::m_frequency[];
-
-
-//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
DEFINE_DEVICE_TYPE(MM5837, mm5837_device, "mm5837", "MM5837 Digital Noise Source")
+DEFINE_DEVICE_TYPE(MM5837_STREAM, mm5837_stream_device, "mm5837_stream", "MM5837 Digital Noise Stream")
//**************************************************************************
-// LIVE DEVICE
+// MM5837 DEVICE
//**************************************************************************
//-------------------------------------------------
@@ -37,55 +31,86 @@ DEFINE_DEVICE_TYPE(MM5837, mm5837_device, "mm5837", "MM5837 Digital Noise Source
mm5837_device::mm5837_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, MM5837, tag, owner, clock),
m_output_cb(*this),
- m_vdd(0),
m_timer(nullptr),
- m_shift(0)
+ m_vdd(-12)
{
}
+
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void mm5837_device::device_start()
{
- // resolve callbacks
- m_output_cb.resolve_safe();
-
// get timer
- m_timer = timer_alloc(0);
+ m_timer = timer_alloc(FUNC(mm5837_device::update_clock_output), this);
// register for save states
- save_item(NAME(m_shift));
+ save_item(NAME(m_source.m_shift));
}
+
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void mm5837_device::device_reset()
{
- // initialize with something
- m_shift = 123456;
+ m_source.reset();
if (m_vdd < 16)
- m_timer->adjust(attotime::zero, 0, attotime::from_hz(m_frequency[m_vdd]));
+ m_timer->adjust(attotime::zero, 0, attotime::from_hz(mm5837_source::frequency(m_vdd)));
else
throw emu_fatalerror("%s: Invalid voltage: %d\n", tag(), m_vdd);
}
+
//-------------------------------------------------
-// device_timer - handle timer callbacks
+// update_clock_output -
//-------------------------------------------------
-void mm5837_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+TIMER_CALLBACK_MEMBER(mm5837_device::update_clock_output)
{
- int tap_14 = BIT(m_shift, 13);
- int tap_17 = BIT(m_shift, 16);
- int zero = (m_shift == 0) ? 1 : 0;
+ m_output_cb(m_source.clock());
+}
+
+
+
+//**************************************************************************
+// MM5837 STREAM DEVICE
+//**************************************************************************
- m_shift <<= 1;
- m_shift |= tap_14 ^ tap_17 ^ zero;
+//-------------------------------------------------
+// mm5837_stream_device - constructor
+//-------------------------------------------------
- m_output_cb(BIT(m_shift, 16));
+mm5837_stream_device::mm5837_stream_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, MM5837_STREAM, tag, owner, clock),
+ device_sound_interface(mconfig, *this),
+ m_stream(nullptr),
+ m_vdd(-12)
+{
+}
+
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void mm5837_stream_device::device_start()
+{
+ m_stream = stream_alloc(0, 1, mm5837_source::frequency(m_vdd));
+ save_item(NAME(m_source.m_shift));
+}
+
+
+//-------------------------------------------------
+// sound_stream_update - fill the sound buffer
+//-------------------------------------------------
+
+void mm5837_stream_device::sound_stream_update(sound_stream &stream)
+{
+ for (int sampindex = 0; sampindex < stream.samples(); sampindex++)
+ stream.put(0, sampindex, m_source.clock() ? 1.0 : 0.0);
}