Merge pull request #12089 from stblr/gamecube-zelda-hle-in-wii-mode

GameCube Zelda HLE in Wii mode
This commit is contained in:
Admiral H. Curtiss 2023-10-04 06:57:01 +02:00 committed by GitHub
commit 68c9362449
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 10 deletions

View File

@ -11,6 +11,7 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Common/Swap.h" #include "Common/Swap.h"
#include "Core/ConfigManager.h"
#include "Core/HW/DSP.h" #include "Core/HW/DSP.h"
#include "Core/HW/DSPHLE/DSPHLE.h" #include "Core/HW/DSPHLE/DSPHLE.h"
#include "Core/HW/DSPHLE/MailHandler.h" #include "Core/HW/DSPHLE/MailHandler.h"
@ -1536,12 +1537,12 @@ void ZeldaAudioRenderer::Resample(VPB* vpb, const s16* src, MixingBuffer* dst)
vpb->current_pos_frac = pos & 0xFFF; vpb->current_pos_frac = pos & 0xFFF;
} }
void* ZeldaAudioRenderer::GetARAMPtr() const void* ZeldaAudioRenderer::GetARAMPtr(u32 offset) const
{ {
if (m_aram_base_addr) if (SConfig::GetInstance().bWii)
return HLEMemory_Get_Pointer(m_aram_base_addr); return HLEMemory_Get_Pointer(m_aram_base_addr + offset);
else else
return Core::System::GetInstance().GetDSP().GetARAMPtr(); return reinterpret_cast<u8*>(Core::System::GetInstance().GetDSP().GetARAMPtr()) + offset;
} }
template <typename T> template <typename T>
@ -1578,7 +1579,7 @@ void ZeldaAudioRenderer::DownloadPCMSamplesFromARAM(s16* dst, VPB* vpb, u16 requ
vpb->SetCurrentARAMAddr(vpb->GetBaseAddress() + vpb->GetCurrentPosition() * sizeof(T)); 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); u16 samples_to_download = std::min(vpb->GetRemainingLength(), (u32)requested_samples_count);
for (u16 i = 0; i < samples_to_download; ++i) for (u16 i = 0; i < samples_to_download; ++i)
@ -1713,7 +1714,7 @@ void ZeldaAudioRenderer::DownloadAFCSamplesFromARAM(s16* dst, VPB* vpb, u16 requ
void ZeldaAudioRenderer::DecodeAFC(VPB* vpb, s16* dst, size_t block_count) void ZeldaAudioRenderer::DecodeAFC(VPB* vpb, s16* dst, size_t block_count)
{ {
u32 addr = vpb->GetCurrentARAMAddr(); u32 addr = vpb->GetCurrentARAMAddr();
u8* src = (u8*)GetARAMPtr() + addr; u8* src = (u8*)GetARAMPtr(addr);
vpb->SetCurrentARAMAddr(addr + (u32)block_count * vpb->samples_source_type); vpb->SetCurrentARAMAddr(addr + (u32)block_count * vpb->samples_source_type);
for (size_t b = 0; b < block_count; ++b) for (size_t b = 0; b < block_count; ++b)

View File

@ -154,11 +154,9 @@ private:
// Coefficients used for resampling. // Coefficients used for resampling.
std::array<s16, 0x100> m_resampling_coeffs{}; std::array<s16, 0x100> m_resampling_coeffs{};
// If non zero, base MRAM address for sound data transfers from ARAM. On // On the Wii, base address of the MRAM or ExRAM region replacing ARAM.
// the Wii, this points to some MRAM location since there is no ARAM to be
// used. If zero, use the top of ARAM.
u32 m_aram_base_addr = 0; u32 m_aram_base_addr = 0;
void* GetARAMPtr() const; void* GetARAMPtr(u32 offset) const;
// Downloads PCM encoded samples from ARAM. Handles looping and other // Downloads PCM encoded samples from ARAM. Handles looping and other
// parameters appropriately. // parameters appropriately.