From 3aff585f328af7b036c9fad465a9e111287c5f61 Mon Sep 17 00:00:00 2001 From: RoadrunnerWMC Date: Mon, 3 Dec 2018 01:07:55 -0700 Subject: [PATCH 1/2] DSP: Add address mask for physical pointers to audio data buffers Hardware testing indicated that FFFFFFFC is the correct mask for all audio formats (mono and stereo PCM8, mono and stereo PCM16, and ADPCM). This fixes broken audio in Luigi's Mansion: Dark Moon and a few other games. --- src/audio_core/hle/source.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio_core/hle/source.cpp b/src/audio_core/hle/source.cpp index bc209571f..6d3c686af 100644 --- a/src/audio_core/hle/source.cpp +++ b/src/audio_core/hle/source.cpp @@ -284,7 +284,7 @@ bool Source::DequeueBuffer() { state.adpcm_state.yn2 = buf.adpcm_yn[1]; } - const u8* const memory = Memory::GetPhysicalPointer(buf.physical_address); + const u8* const memory = Memory::GetPhysicalPointer(buf.physical_address & 0xFFFFFFFC); if (memory) { const unsigned num_channels = buf.mono_or_stereo == MonoOrStereo::Stereo ? 2 : 1; switch (buf.format) { From 008ef1fd71965016126fa0cdd802cdfe1cc6765d Mon Sep 17 00:00:00 2001 From: RoadrunnerWMC Date: Mon, 3 Dec 2018 12:22:11 -0700 Subject: [PATCH 2/2] DSP: Add a comment about physical address masking See @wwylele's comment on PR 4483 for more details on what causes this behavior. --- src/audio_core/hle/source.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/audio_core/hle/source.cpp b/src/audio_core/hle/source.cpp index 6d3c686af..cbf99ec9d 100644 --- a/src/audio_core/hle/source.cpp +++ b/src/audio_core/hle/source.cpp @@ -284,6 +284,8 @@ bool Source::DequeueBuffer() { state.adpcm_state.yn2 = buf.adpcm_yn[1]; } + // This physical address masking occurs due to how the DSP DMA hardware is configured by the + // firmware. const u8* const memory = Memory::GetPhysicalPointer(buf.physical_address & 0xFFFFFFFC); if (memory) { const unsigned num_channels = buf.mono_or_stereo == MonoOrStereo::Stereo ? 2 : 1;