Core/DSPHLE: Store reference to DSPManager in AESndAccelerator.

Avoids the use of the global System in ReadMemory() and WriteMemory().
This commit is contained in:
Admiral H. Curtiss 2024-01-08 04:15:44 +01:00
parent e9ab33b871
commit 3a9160100d
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
2 changed files with 26 additions and 3 deletions

View File

@ -81,7 +81,8 @@ bool AESndUCode::UseNewFlagMasks() const
m_crc == HASH_2022_PAD || m_crc == HASH_2023;
}
AESndUCode::AESndUCode(DSPHLE* dsphle, u32 crc) : UCodeInterface(dsphle, crc)
AESndUCode::AESndUCode(DSPHLE* dsphle, u32 crc)
: UCodeInterface(dsphle, crc), m_accelerator(dsphle->GetSystem().GetDSP())
{
}
@ -239,6 +240,12 @@ void AESndUCode::DMAOutParameterBlock()
HLEMemory_Write_U32(memory, m_parameter_block_addr + 40, m_parameter_block.flags);
}
AESndAccelerator::AESndAccelerator(DSP::DSPManager& dsp) : m_dsp(dsp)
{
}
AESndAccelerator::~AESndAccelerator() = default;
void AESndAccelerator::OnEndException()
{
// exception5 - this updates internal state
@ -249,12 +256,12 @@ void AESndAccelerator::OnEndException()
u8 AESndAccelerator::ReadMemory(u32 address)
{
return Core::System::GetInstance().GetDSP().ReadARAM(address);
return m_dsp.ReadARAM(address);
}
void AESndAccelerator::WriteMemory(u32 address, u8 value)
{
Core::System::GetInstance().GetDSP().WriteARAM(value, address);
m_dsp.WriteARAM(value, address);
}
static constexpr std::array<s16, 16> ACCELERATOR_COEFS = {}; // all zeros

View File

@ -10,16 +10,32 @@
#include "Core/DSP/DSPAccelerator.h"
#include "Core/HW/DSPHLE/UCodes/UCodes.h"
namespace DSP
{
class DSPManager;
}
namespace DSP::HLE
{
class DSPHLE;
class AESndAccelerator final : public Accelerator
{
public:
explicit AESndAccelerator(DSP::DSPManager& dsp);
AESndAccelerator(const AESndAccelerator&) = delete;
AESndAccelerator(AESndAccelerator&&) = delete;
AESndAccelerator& operator=(const AESndAccelerator&) = delete;
AESndAccelerator& operator=(AESndAccelerator&&) = delete;
~AESndAccelerator();
protected:
void OnEndException() override;
u8 ReadMemory(u32 address) override;
void WriteMemory(u32 address, u8 value) override;
private:
DSP::DSPManager& m_dsp;
};
class AESndUCode final : public UCodeInterface