summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/scsp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/sound/scsp.cpp')
-rw-r--r--src/devices/sound/scsp.cpp47
1 files changed, 13 insertions, 34 deletions
diff --git a/src/devices/sound/scsp.cpp b/src/devices/sound/scsp.cpp
index 143be37ca40..b340da3d237 100644
--- a/src/devices/sound/scsp.cpp
+++ b/src/devices/sound/scsp.cpp
@@ -36,9 +36,6 @@
#include <algorithm>
-static constexpr s32 clip16(int x) { return std::min(32767, std::max(-32768, x)); }
-static constexpr s32 clip18(int x) { return std::min(131071, std::max(-131072, x)); }
-
#define SHIFT 12
#define LFO_SHIFT 8
#define FIX(v) ((u32) ((float) (1 << SHIFT) * (v)))
@@ -165,11 +162,6 @@ scsp_device::scsp_device(const machine_config &mconfig, const char *tag, device_
m_timerC(nullptr),
m_mcieb(0),
m_mcipd(0),
- m_bufferl(nullptr),
- m_bufferr(nullptr),
- m_exts0(nullptr),
- m_exts1(nullptr),
- m_length(0),
m_RBUFDST(nullptr)
{
std::fill(std::begin(m_RINGBUF), std::end(m_RINGBUF), 0);
@@ -212,7 +204,7 @@ void scsp_device::device_start()
m_main_irq_cb.resolve_safe();
// Stereo output with EXTS0,1 Input (External digital audio output)
- m_stream = stream_alloc_legacy(2, 2, clock() / 512);
+ m_stream = stream_alloc(2, 2, clock() / 512);
for (int slot = 0; slot < 32; slot++)
{
@@ -317,17 +309,12 @@ void scsp_device::rom_bank_updated()
}
//-------------------------------------------------
-// sound_stream_update_legacy - handle a stream update
+// sound_stream_update - handle a stream update
//-------------------------------------------------
-void scsp_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples)
+void scsp_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- m_exts0 = inputs[0];
- m_exts1 = inputs[1];
- m_bufferl = outputs[0];
- m_bufferr = outputs[1];
- m_length = samples;
- DoMasterSamples(samples);
+ DoMasterSamples(inputs, outputs);
}
u8 scsp_device::DecodeSCI(u8 irq)
@@ -1276,17 +1263,12 @@ inline s32 scsp_device::UpdateSlot(SCSP_SLOT *slot)
return sample;
}
-void scsp_device::DoMasterSamples(int nsamples)
+void scsp_device::DoMasterSamples(std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
- stream_sample_t *bufr,*bufl;
- stream_sample_t const *exts[2];
-
- bufr = m_bufferr;
- bufl = m_bufferl;
- exts[0] = m_exts0;
- exts[1] = m_exts1;
+ auto &bufr = outputs[1];
+ auto &bufl = outputs[0];
- for (int s = 0; s < nsamples; ++s)
+ for (int s = 0; s < bufl.samples(); ++s)
{
s32 smpl = 0, smpr = 0;
@@ -1342,7 +1324,7 @@ void scsp_device::DoMasterSamples(int nsamples)
SCSP_SLOT *slot = m_Slots + i + 16; // 100217, 100237 EFSDL, EFPAN for EXTS0/1
if (EFSDL(slot))
{
- m_DSP.EXTS[i] = exts[i][s];
+ m_DSP.EXTS[i] = s32(inputs[i].get(s) * 32768.0);
u16 Enc = ((EFPAN(slot)) << 0x8) | ((EFSDL(slot)) << 0xd);
smpl += (m_DSP.EXTS[i] * m_LPANTABLE[Enc]) >> SHIFT;
smpr += (m_DSP.EXTS[i] * m_RPANTABLE[Enc]) >> SHIFT;
@@ -1351,17 +1333,14 @@ void scsp_device::DoMasterSamples(int nsamples)
if (DAC18B())
{
- smpl = clip18(smpl);
- smpr = clip18(smpr);
+ bufl.put_int_clamp(s, smpl, 131072);
+ bufr.put_int_clamp(s, smpr, 131072);
}
else
{
- smpl = clip16(smpl >> 2);
- smpr = clip16(smpr >> 2);
+ bufl.put_int_clamp(s, smpl >> 2, 32768);
+ bufr.put_int_clamp(s, smpr >> 2, 32768);
}
-
- *bufl++ = smpl;
- *bufr++ = smpr;
}
}