diff options
Diffstat (limited to 'src/devices/sound/nes_apu.cpp')
-rw-r--r-- | src/devices/sound/nes_apu.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/devices/sound/nes_apu.cpp b/src/devices/sound/nes_apu.cpp index 1e79304fb3a..483b337475f 100644 --- a/src/devices/sound/nes_apu.cpp +++ b/src/devices/sound/nes_apu.cpp @@ -83,8 +83,8 @@ void nesapu_device::create_syncs(unsigned long sps) DEFINE_DEVICE_TYPE(NES_APU, nesapu_device, "nesapu", "N2A03 APU") -nesapu_device::nesapu_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) - : device_t(mconfig, NES_APU, tag, owner, clock) +nesapu_device::nesapu_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock) + : device_t(mconfig, type, tag, owner, clock) , device_sound_interface(mconfig, *this) , m_samps_per_sync(0) , m_buffer_size(0) @@ -108,6 +108,11 @@ nesapu_device::nesapu_device(const machine_config &mconfig, const char *tag, dev } } +nesapu_device::nesapu_device(const machine_config& mconfig, const char* tag, device_t* owner, u32 clock) + : nesapu_device(mconfig, NES_APU, tag, owner, clock) +{ +} + void nesapu_device::device_reset() { write(0x15, 0x00); @@ -134,7 +139,7 @@ void nesapu_device::calculate_rates() if (m_stream != nullptr) m_stream->set_sample_rate(rate); else - m_stream = stream_alloc_legacy(0, 1, rate); + m_stream = stream_alloc(0, 1, rate); } //------------------------------------------------- @@ -725,16 +730,15 @@ void nesapu_device::write(offs_t address, u8 value) //------------------------------------------------- -// sound_stream_update_legacy - handle a stream update +// sound_stream_update - handle a stream update //------------------------------------------------- -void nesapu_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) +void nesapu_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) { int accum; - stream_sample_t *output = outputs[0]; - memset( output, 0, samples*sizeof(*output) ); + auto &output = outputs[0]; - while (samples--) + for (int sampindex = 0; sampindex < output.samples(); sampindex++) { accum = apu_square(&m_APU.squ[0]); accum += apu_square(&m_APU.squ[1]); @@ -742,12 +746,6 @@ void nesapu_device::sound_stream_update_legacy(sound_stream &stream, stream_samp accum += apu_noise(&m_APU.noi); accum += apu_dpcm(&m_APU.dpcm); - /* 8-bit clamps */ - if (accum > 127) - accum = 127; - else if (accum < -128) - accum = -128; - - *output++=accum<<8; + output.put_int_clamp(sampindex, accum, 128); } } |