diff options
Diffstat (limited to 'src/devices/sound/namco_163.cpp')
-rw-r--r-- | src/devices/sound/namco_163.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/devices/sound/namco_163.cpp b/src/devices/sound/namco_163.cpp index 11ff6ed1eb5..7f20a25928c 100644 --- a/src/devices/sound/namco_163.cpp +++ b/src/devices/sound/namco_163.cpp @@ -11,13 +11,14 @@ #include "emu.h" #include "namco_163.h" +#include <algorithm> + DEFINE_DEVICE_TYPE(NAMCO_163, namco_163_sound_device, "namco_163_sound", "Namco 163 (Sound)") namco_163_sound_device::namco_163_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, NAMCO_163, tag, owner, clock) , device_sound_interface(mconfig, *this) - , m_ram(nullptr) , m_reg_addr(0x78) , m_addr(0) , m_inc(false) @@ -33,10 +34,11 @@ namco_163_sound_device::namco_163_sound_device(const machine_config &mconfig, co void namco_163_sound_device::device_start() { - m_ram = make_unique_clear<u8[]>(0x80); - m_stream = machine().sound().stream_alloc(*this, 0, 1, clock() / 15); + std::fill(std::begin(m_ram), std::end(m_ram), 0); + + m_stream = stream_alloc(0, 1, clock() / 15); - save_pointer(NAME(m_ram), 0x80); + save_item(NAME(m_ram)); save_item(NAME(m_reg_addr)); save_item(NAME(m_addr)); save_item(NAME(m_inc)); @@ -61,7 +63,7 @@ inline s8 namco_163_sound_device::get_sample(u16 addr) } -WRITE_LINE_MEMBER(namco_163_sound_device::disable_w) +void namco_163_sound_device::disable_w(int state) { m_disable = state; } @@ -135,23 +137,21 @@ void namco_163_sound_device::data_w(u8 data) u8 namco_163_sound_device::data_r() { - u8 val = m_ram[m_addr]; - if (m_inc) + const u8 val = m_ram[m_addr]; + if (!machine().side_effects_disabled() && m_inc) m_addr = (m_addr + 1) & 0x7f; return val; } -void namco_163_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) +void namco_163_sound_device::sound_stream_update(sound_stream &stream) { - std::fill_n(&outputs[0][0], samples, 0); - if (m_disable) return; // Slightly noisy but closer to real hardware behavior - for (int s = 0; s < samples; s++) + for (int s = 0; s < stream.samples(); s++) { u32 phase = (m_ram[m_reg_addr + 5] << 16) | (m_ram[m_reg_addr + 3] << 8) | m_ram[m_reg_addr + 1]; const u32 freq = ((m_ram[m_reg_addr + 4] & 0x3) << 16) | (m_ram[m_reg_addr + 2] << 8) | m_ram[m_reg_addr + 0]; @@ -171,6 +171,6 @@ void namco_163_sound_device::sound_stream_update(sound_stream &stream, stream_sa { m_reg_addr = 0x78 - ((m_ram[0x7f] & 0x70) >> 1); } - outputs[0][s] = (output << 8); + stream.put_int(0, s, output, 128); } } |