diff --git a/src/core/gpu.cpp b/src/core/gpu.cpp index 41c226598..b8bd9c5cd 100644 --- a/src/core/gpu.cpp +++ b/src/core/gpu.cpp @@ -814,7 +814,7 @@ void GPU::WriteGP1(u32 value) case 0x04: // DMA Direction { - Log_DebugPrintf("DMA direction <- 0x%02X", static_cast(m_GPUSTAT.dma_direction.GetValue())); + Log_DebugPrintf("DMA direction <- 0x%02X", static_cast(param)); if (m_GPUSTAT.dma_direction != static_cast(param)) { m_GPUSTAT.dma_direction = static_cast(param); diff --git a/src/core/save_state_version.h b/src/core/save_state_version.h index 3f891159c..6d4a2e25c 100644 --- a/src/core/save_state_version.h +++ b/src/core/save_state_version.h @@ -2,7 +2,7 @@ #include "types.h" static constexpr u32 SAVE_STATE_MAGIC = 0x43435544; -static constexpr u32 SAVE_STATE_VERSION = 27; +static constexpr u32 SAVE_STATE_VERSION = 28; #pragma pack(push, 4) struct SAVE_STATE_HEADER diff --git a/src/core/spu.cpp b/src/core/spu.cpp index ce20fbc24..7e21a88c1 100644 --- a/src/core/spu.cpp +++ b/src/core/spu.cpp @@ -1269,7 +1269,7 @@ void SPU::Voice::DecodeBlock(const ADPCMBlock& block) const u8 filter_index = block.GetFilter(); const s32 filter_pos = filter_table_pos[filter_index]; const s32 filter_neg = filter_table_neg[filter_index]; - s32 last_samples[2] = {adpcm_last_samples[0], adpcm_last_samples[1]}; + s16 last_samples[2] = {adpcm_last_samples[0], adpcm_last_samples[1]}; // samples for (u32 i = 0; i < NUM_SAMPLES_PER_ADPCM_BLOCK; i++) @@ -1279,9 +1279,8 @@ void SPU::Voice::DecodeBlock(const ADPCMBlock& block) sample += (last_samples[0] * filter_pos) >> 6; sample += (last_samples[1] * filter_neg) >> 6; - current_block_samples[i] = Clamp16(sample); last_samples[1] = last_samples[0]; - last_samples[0] = sample; + current_block_samples[i] = last_samples[0] = Clamp16(sample); } std::copy(last_samples, last_samples + countof(last_samples), adpcm_last_samples.begin()); @@ -1299,9 +1298,9 @@ s16 SPU::Voice::SampleBlock(s32 index) const return current_block_samples[index]; } -s16 SPU::Voice::Interpolate() const +s32 SPU::Voice::Interpolate() const { - static constexpr std::array gauss = {{ + static constexpr std::array gauss = {{ -0x001, -0x001, -0x001, -0x001, -0x001, -0x001, -0x001, -0x001, // -0x001, -0x001, -0x001, -0x001, -0x001, -0x001, -0x001, -0x001, // 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, // @@ -1371,11 +1370,11 @@ s16 SPU::Voice::Interpolate() const const u8 i = counter.interpolation_index; const s32 s = static_cast(ZeroExtend32(counter.sample_index.GetValue())); - s16 out = s16(gauss[0x0FF - i] * s32(SampleBlock(s - 3)) >> 15); - out += s16(gauss[0x1FF - i] * s32(SampleBlock(s - 2)) >> 15); - out += s16(gauss[0x100 + i] * s32(SampleBlock(s - 1)) >> 15); - out += s16(gauss[0x000 + i] * s32(SampleBlock(s - 0)) >> 15); - return out; + s32 out = s32(gauss[0x0FF - i]) * s32(SampleBlock(s - 3)); + out += s32(gauss[0x1FF - i]) * s32(SampleBlock(s - 2)); + out += s32(gauss[0x100 + i]) * s32(SampleBlock(s - 1)); + out += s32(gauss[0x000 + i]) * s32(SampleBlock(s - 0)); + return out >> 15; } void SPU::ReadADPCMBlock(u16 address, ADPCMBlock* block) @@ -1430,7 +1429,7 @@ std::tuple SPU::SampleVoice(u32 voice_index) if (voice.regs.adsr_volume != 0) { // interpolate/sample and apply ADSR volume - s16 sample; + s32 sample; if (IsVoiceNoiseEnabled(voice_index)) sample = GetVoiceNoiseLevel(); else @@ -1456,7 +1455,7 @@ std::tuple SPU::SampleVoice(u32 voice_index) const u16 old_step = step; step = Truncate16(static_cast((SignExtend32(step) * factor) >> 15)); } - step = std::min(step, 0x4000); + step = std::min(step, 0x3FFF); // Shouldn't ever overflow because if sample_index == 27, step == 0x4000 there won't be a carry out from the // interpolation index. If there is a carry out, bit 12 will never be 1, so it'll never add more than 4 to diff --git a/src/core/spu.h b/src/core/spu.h index 777b659fb..96016b15b 100644 --- a/src/core/spu.h +++ b/src/core/spu.h @@ -254,7 +254,7 @@ private: ADPCMFlags current_block_flags; std::array current_block_samples; std::array previous_block_last_samples; - std::array adpcm_last_samples; + std::array adpcm_last_samples; s32 last_volume; VolumeSweep left_volume; @@ -274,7 +274,7 @@ private: void DecodeBlock(const ADPCMBlock& block); s16 SampleBlock(s32 index) const; - s16 Interpolate() const; + s32 Interpolate() const; // Switches to the specified phase, filling in target. void SetADSRPhase(ADSRPhase phase);