DSPHLE: Seperate HLE construction and initialization.

We must be able to construct the HLE without emulating the initialization
on loading a savestate.
This commit is contained in:
degasus 2016-12-26 12:25:57 +01:00
parent 4ebd369218
commit 8f9f2b1f76
14 changed files with 46 additions and 14 deletions

View File

@ -77,6 +77,7 @@ void DSPHLE::SetUCode(u32 _crc)
m_pUCode = nullptr;
m_MailHandler.Clear();
m_pUCode = UCodeFactory(_crc, this, m_wii);
m_pUCode->Initialize();
}
// TODO do it better?
@ -90,6 +91,7 @@ void DSPHLE::SwapUCode(u32 _crc)
{
m_lastUCode = m_pUCode;
m_pUCode = UCodeFactory(_crc, this, m_wii);
m_pUCode->Initialize();
}
else
{

View File

@ -18,10 +18,6 @@
AXUCode::AXUCode(DSPHLE* dsphle, u32 crc) : UCodeInterface(dsphle, crc), m_cmdlist_size(0)
{
INFO_LOG(DSPHLE, "Instantiating AXUCode: crc=%08x", crc);
m_mail_handler.PushMail(DSP_INIT);
DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
LoadResamplingCoefficients();
}
AXUCode::~AXUCode()
@ -29,6 +25,14 @@ AXUCode::~AXUCode()
m_mail_handler.Clear();
}
void AXUCode::Initialize()
{
m_mail_handler.PushMail(DSP_INIT);
DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
LoadResamplingCoefficients();
}
void AXUCode::LoadResamplingCoefficients()
{
m_coeffs_available = false;

View File

@ -55,6 +55,7 @@ public:
AXUCode(DSPHLE* dsphle, u32 crc);
virtual ~AXUCode();
void Initialize() override;
void HandleMail(u32 mail) override;
void Update() override;
void DoState(PointerWrap& p) override;

View File

@ -12,7 +12,6 @@
CARDUCode::CARDUCode(DSPHLE* dsphle, u32 crc) : UCodeInterface(dsphle, crc)
{
INFO_LOG(DSPHLE, "CARDUCode - initialized");
m_mail_handler.PushMail(DSP_INIT);
}
CARDUCode::~CARDUCode()
@ -20,6 +19,11 @@ CARDUCode::~CARDUCode()
m_mail_handler.Clear();
}
void CARDUCode::Initialize()
{
m_mail_handler.PushMail(DSP_INIT);
}
void CARDUCode::Update()
{
// check if we have to sent something

View File

@ -12,6 +12,7 @@ public:
CARDUCode(DSPHLE* dsphle, u32 crc);
virtual ~CARDUCode();
void Initialize() override;
void HandleMail(u32 mail) override;
void Update() override;
};

View File

@ -84,7 +84,6 @@ void ProcessGBACrypto(u32 address)
GBAUCode::GBAUCode(DSPHLE* dsphle, u32 crc) : UCodeInterface(dsphle, crc)
{
m_mail_handler.PushMail(DSP_INIT);
}
GBAUCode::~GBAUCode()
@ -92,6 +91,11 @@ GBAUCode::~GBAUCode()
m_mail_handler.Clear();
}
void GBAUCode::Initialize()
{
m_mail_handler.PushMail(DSP_INIT);
}
void GBAUCode::Update()
{
// check if we have to send something

View File

@ -16,6 +16,7 @@ struct GBAUCode : public UCodeInterface
GBAUCode(DSPHLE* dsphle, u32 crc);
virtual ~GBAUCode();
void Initialize() override;
void HandleMail(u32 mail) override;
void Update() override;
};

View File

@ -10,13 +10,17 @@
INITUCode::INITUCode(DSPHLE* dsphle, u32 crc) : UCodeInterface(dsphle, crc)
{
INFO_LOG(DSPHLE, "INITUCode - initialized");
m_mail_handler.PushMail(0x80544348);
}
INITUCode::~INITUCode()
{
}
void INITUCode::Initialize()
{
m_mail_handler.PushMail(0x80544348);
}
void INITUCode::Init()
{
}

View File

@ -12,6 +12,7 @@ public:
INITUCode(DSPHLE* dsphle, u32 crc);
virtual ~INITUCode();
void Initialize() override;
void HandleMail(u32 mail) override;
void Update() override;
void Init();

View File

@ -22,14 +22,18 @@ ROMUCode::ROMUCode(DSPHLE* dsphle, u32 crc)
: UCodeInterface(dsphle, crc), m_current_ucode(), m_boot_task_num_steps(0), m_next_parameter(0)
{
INFO_LOG(DSPHLE, "UCode_Rom - initialized");
m_mail_handler.Clear();
m_mail_handler.PushMail(0x8071FEED);
}
ROMUCode::~ROMUCode()
{
}
void ROMUCode::Initialize()
{
m_mail_handler.Clear();
m_mail_handler.PushMail(0x8071FEED);
}
void ROMUCode::Update()
{
}

View File

@ -12,6 +12,7 @@ public:
ROMUCode(DSPHLE* dsphle, u32 crc);
virtual ~ROMUCode();
void Initialize() override;
void HandleMail(u32 mail) override;
void Update() override;

View File

@ -73,6 +73,7 @@ public:
}
virtual ~UCodeInterface() {}
virtual void Initialize() = 0;
virtual void HandleMail(u32 mail) = 0;
virtual void Update() = 0;

View File

@ -118,7 +118,15 @@ ZeldaUCode::ZeldaUCode(DSPHLE* dsphle, u32 crc) : UCodeInterface(dsphle, crc)
m_renderer.SetFlags(m_flags);
INFO_LOG(DSPHLE, "Zelda UCode loaded, crc=%08x, flags=%08x", crc, m_flags);
}
ZeldaUCode::~ZeldaUCode()
{
m_mail_handler.Clear();
}
void ZeldaUCode::Initialize()
{
if (m_flags & LIGHT_PROTOCOL)
{
m_mail_handler.PushMail(0x88881111);
@ -130,11 +138,6 @@ ZeldaUCode::ZeldaUCode(DSPHLE* dsphle, u32 crc) : UCodeInterface(dsphle, crc)
}
}
ZeldaUCode::~ZeldaUCode()
{
m_mail_handler.Clear();
}
void ZeldaUCode::Update()
{
if (NeedsResumeMail())

View File

@ -188,6 +188,7 @@ public:
ZeldaUCode(DSPHLE* dsphle, u32 crc);
virtual ~ZeldaUCode();
void Initialize() override;
void HandleMail(u32 mail) override;
void Update() override;