Core/DSPHLE: Store reference to System in DSPHLE instances.
This commit is contained in:
parent
00fb709c74
commit
9be9cbda2f
|
@ -10,10 +10,10 @@
|
|||
|
||||
DSPEmulator::~DSPEmulator() = default;
|
||||
|
||||
std::unique_ptr<DSPEmulator> CreateDSPEmulator(bool hle)
|
||||
std::unique_ptr<DSPEmulator> CreateDSPEmulator(Core::System& system, bool hle)
|
||||
{
|
||||
if (hle)
|
||||
return std::make_unique<DSP::HLE::DSPHLE>();
|
||||
return std::make_unique<DSP::HLE::DSPHLE>(system);
|
||||
|
||||
return std::make_unique<DSP::LLE::DSPLLE>();
|
||||
}
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
#include <memory>
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
class PointerWrap;
|
||||
|
||||
class DSPEmulator
|
||||
|
@ -34,4 +38,4 @@ protected:
|
|||
bool m_wii = false;
|
||||
};
|
||||
|
||||
std::unique_ptr<DSPEmulator> CreateDSPEmulator(bool hle);
|
||||
std::unique_ptr<DSPEmulator> CreateDSPEmulator(Core::System& system, bool hle);
|
||||
|
|
|
@ -119,7 +119,7 @@ void DSPManager::Init(bool hle)
|
|||
|
||||
void DSPManager::Reinit(bool hle)
|
||||
{
|
||||
m_dsp_emulator = CreateDSPEmulator(hle);
|
||||
m_dsp_emulator = CreateDSPEmulator(m_system, hle);
|
||||
m_is_lle = m_dsp_emulator->IsLLE();
|
||||
|
||||
if (SConfig::GetInstance().bWii)
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
|
||||
namespace DSP::HLE
|
||||
{
|
||||
DSPHLE::DSPHLE() = default;
|
||||
DSPHLE::DSPHLE(Core::System& system) : m_system(system)
|
||||
{
|
||||
}
|
||||
|
||||
DSPHLE::~DSPHLE() = default;
|
||||
|
||||
|
@ -55,7 +57,7 @@ u32 DSPHLE::DSP_UpdateRate()
|
|||
{
|
||||
// AX HLE uses 3ms (Wii) or 5ms (GC) timing period
|
||||
// But to be sure, just update the HLE every ms.
|
||||
return Core::System::GetInstance().GetSystemTimers().GetTicksPerSecond() / 1000;
|
||||
return m_system.GetSystemTimers().GetTicksPerSecond() / 1000;
|
||||
}
|
||||
|
||||
void DSPHLE::SendMailToDSP(u32 mail)
|
||||
|
@ -221,8 +223,7 @@ u16 DSPHLE::DSP_WriteControlRegister(u16 value)
|
|||
SetUCode(UCODE_INIT_AUDIO_SYSTEM);
|
||||
temp.DSPInitCode = 1;
|
||||
// Number obtained from real hardware on a Wii, but it's not perfectly consistent
|
||||
m_control_reg_init_code_clear_time =
|
||||
Core::System::GetInstance().GetSystemTimers().GetFakeTimeBase() + 130;
|
||||
m_control_reg_init_code_clear_time = m_system.GetSystemTimers().GetFakeTimeBase() + 130;
|
||||
}
|
||||
|
||||
m_dsp_control.Hex = temp.Hex;
|
||||
|
@ -233,11 +234,10 @@ u16 DSPHLE::DSP_ReadControlRegister()
|
|||
{
|
||||
if (m_dsp_control.DSPInitCode != 0)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
if (system.GetSystemTimers().GetFakeTimeBase() >= m_control_reg_init_code_clear_time)
|
||||
if (m_system.GetSystemTimers().GetFakeTimeBase() >= m_control_reg_init_code_clear_time)
|
||||
m_dsp_control.DSPInitCode = 0;
|
||||
else
|
||||
system.GetCoreTiming().ForceExceptionCheck(50); // Keep checking
|
||||
m_system.GetCoreTiming().ForceExceptionCheck(50); // Keep checking
|
||||
}
|
||||
return m_dsp_control.Hex;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
#include "Core/HW/DSP.h"
|
||||
#include "Core/HW/DSPHLE/MailHandler.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
class PointerWrap;
|
||||
|
||||
namespace DSP::HLE
|
||||
|
@ -19,7 +23,11 @@ class UCodeInterface;
|
|||
class DSPHLE : public DSPEmulator
|
||||
{
|
||||
public:
|
||||
DSPHLE();
|
||||
explicit DSPHLE(Core::System& system);
|
||||
DSPHLE(const DSPHLE& other) = delete;
|
||||
DSPHLE(DSPHLE&& other) = delete;
|
||||
DSPHLE& operator=(const DSPHLE& other) = delete;
|
||||
DSPHLE& operator=(DSPHLE&& other) = delete;
|
||||
~DSPHLE();
|
||||
|
||||
bool Initialize(bool wii, bool dsp_thread) override;
|
||||
|
@ -42,6 +50,8 @@ public:
|
|||
void SetUCode(u32 crc);
|
||||
void SwapUCode(u32 crc);
|
||||
|
||||
Core::System& GetSystem() const { return m_system; }
|
||||
|
||||
private:
|
||||
void SendMailToDSP(u32 mail);
|
||||
|
||||
|
@ -67,5 +77,7 @@ private:
|
|||
DSP::UDSPControl m_dsp_control;
|
||||
u64 m_control_reg_init_code_clear_time = 0;
|
||||
CMailHandler m_mail_handler;
|
||||
|
||||
Core::System& m_system;
|
||||
};
|
||||
} // namespace DSP::HLE
|
||||
|
|
Loading…
Reference in New Issue