From 34341af17d8cd46812f07d4b82044ff07fd3225c Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sat, 20 Dec 2014 04:11:10 +0100 Subject: [PATCH] Zelda HLE: Implement saw wave generation (sample source 0001). Fixes issue 7961. --- Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp index a679f55149..5f99618a7d 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp @@ -476,8 +476,12 @@ struct ZeldaAudioRenderer::VPB enum SamplesSourceType { - // Simple square wave at 50% amplitude and 16KHz. + // Simple square wave at 50% amplitude and frequency controlled via the + // resampling ratio. SRC_SQUARE_WAVE = 0, + // Simple saw wave at 100% amplitude and frequency controlled via the + // resampling ratio. + SRC_SAW_WAVE = 1, // Samples stored in ARAM at a rate of 16 samples/9 bytes, AFC encoded, // at an arbitrary sample rate (resampling is applied). SRC_AFC_HQ_FROM_ARAM = 9, @@ -772,6 +776,18 @@ void ZeldaAudioRenderer::LoadInputSamples(MixingBuffer* buffer, VPB* vpb) break; } + case VPB::SRC_SAW_WAVE: + { + u32 pos = vpb->current_pos_frac; + for (size_t i = 0; i < buffer->size(); ++i) + { + (*buffer)[i] = pos & 0xFFFF; + pos += (vpb->resampling_ratio) >> 1; + } + vpb->current_pos_frac = pos & 0xFFFF; + break; + } + case VPB::SRC_AFC_HQ_FROM_ARAM: DownloadAFCSamplesFromARAM(raw_input_samples.data() + 4, vpb, NeededRawSamplesCount(*vpb));