From 8cdad9ce8c957b7c6166b0e6ecf77a7c32273e52 Mon Sep 17 00:00:00 2001 From: Pablo Stebler Date: Mon, 7 Aug 2023 00:26:01 +0200 Subject: [PATCH 1/2] DSPHLE: map memory based on console mode --- Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp | 3 ++- Source/Core/Core/HW/DSPHLE/UCodes/Zelda.h | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp index 4745d2b9b5..c6a3bdb344 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp @@ -11,6 +11,7 @@ #include "Common/CommonTypes.h" #include "Common/Logging/Log.h" #include "Common/Swap.h" +#include "Core/ConfigManager.h" #include "Core/HW/DSP.h" #include "Core/HW/DSPHLE/DSPHLE.h" #include "Core/HW/DSPHLE/MailHandler.h" @@ -1538,7 +1539,7 @@ void ZeldaAudioRenderer::Resample(VPB* vpb, const s16* src, MixingBuffer* dst) void* ZeldaAudioRenderer::GetARAMPtr() const { - if (m_aram_base_addr) + if (SConfig::GetInstance().bWii) return HLEMemory_Get_Pointer(m_aram_base_addr); else return Core::System::GetInstance().GetDSP().GetARAMPtr(); diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.h b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.h index 33963a8dd6..1023d6946c 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.h @@ -154,9 +154,7 @@ private: // Coefficients used for resampling. std::array m_resampling_coeffs{}; - // If non zero, base MRAM address for sound data transfers from ARAM. On - // the Wii, this points to some MRAM location since there is no ARAM to be - // used. If zero, use the top of ARAM. + // On the Wii, base address of the MRAM or ExRAM region replacing ARAM. u32 m_aram_base_addr = 0; void* GetARAMPtr() const; From cc403c1044a24e2226cb36b05aa6ffcf796a8628 Mon Sep 17 00:00:00 2001 From: Pablo Stebler Date: Mon, 7 Aug 2023 00:50:39 +0200 Subject: [PATCH 2/2] DSPHLE: handle offsets to a different memory region --- Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp | 10 +++++----- Source/Core/Core/HW/DSPHLE/UCodes/Zelda.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp index c6a3bdb344..ec5f4ef2c6 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp @@ -1537,12 +1537,12 @@ void ZeldaAudioRenderer::Resample(VPB* vpb, const s16* src, MixingBuffer* dst) vpb->current_pos_frac = pos & 0xFFF; } -void* ZeldaAudioRenderer::GetARAMPtr() const +void* ZeldaAudioRenderer::GetARAMPtr(u32 offset) const { if (SConfig::GetInstance().bWii) - return HLEMemory_Get_Pointer(m_aram_base_addr); + return HLEMemory_Get_Pointer(m_aram_base_addr + offset); else - return Core::System::GetInstance().GetDSP().GetARAMPtr(); + return reinterpret_cast(Core::System::GetInstance().GetDSP().GetARAMPtr()) + offset; } template @@ -1579,7 +1579,7 @@ void ZeldaAudioRenderer::DownloadPCMSamplesFromARAM(s16* dst, VPB* vpb, u16 requ vpb->SetCurrentARAMAddr(vpb->GetBaseAddress() + vpb->GetCurrentPosition() * sizeof(T)); } - T* src_ptr = (T*)((u8*)GetARAMPtr() + vpb->GetCurrentARAMAddr()); + T* src_ptr = (T*)GetARAMPtr(vpb->GetCurrentARAMAddr()); u16 samples_to_download = std::min(vpb->GetRemainingLength(), (u32)requested_samples_count); for (u16 i = 0; i < samples_to_download; ++i) @@ -1714,7 +1714,7 @@ void ZeldaAudioRenderer::DownloadAFCSamplesFromARAM(s16* dst, VPB* vpb, u16 requ void ZeldaAudioRenderer::DecodeAFC(VPB* vpb, s16* dst, size_t block_count) { u32 addr = vpb->GetCurrentARAMAddr(); - u8* src = (u8*)GetARAMPtr() + addr; + u8* src = (u8*)GetARAMPtr(addr); vpb->SetCurrentARAMAddr(addr + (u32)block_count * vpb->samples_source_type); for (size_t b = 0; b < block_count; ++b) diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.h b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.h index 1023d6946c..a0142dc957 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.h @@ -156,7 +156,7 @@ private: // On the Wii, base address of the MRAM or ExRAM region replacing ARAM. u32 m_aram_base_addr = 0; - void* GetARAMPtr() const; + void* GetARAMPtr(u32 offset) const; // Downloads PCM encoded samples from ARAM. Handles looping and other // parameters appropriately.