diff --git a/Source/Core/Core/HW/DSPHLE/DSPHLE.cpp b/Source/Core/Core/HW/DSPHLE/DSPHLE.cpp index 65e853ab62..7ba5d65508 100644 --- a/Source/Core/Core/HW/DSPHLE/DSPHLE.cpp +++ b/Source/Core/Core/HW/DSPHLE/DSPHLE.cpp @@ -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 { diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/AX.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/AX.cpp index 4e0af3c308..03cb955905 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/AX.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/AX.cpp @@ -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; diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/AX.h b/Source/Core/Core/HW/DSPHLE/UCodes/AX.h index 0f00fc9328..5d5387248b 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/AX.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/AX.h @@ -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; diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/CARD.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/CARD.cpp index 77bdc9a345..c490607c91 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/CARD.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/CARD.cpp @@ -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 diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/CARD.h b/Source/Core/Core/HW/DSPHLE/UCodes/CARD.h index 7dcc9779a6..5af43ce891 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/CARD.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/CARD.h @@ -12,6 +12,7 @@ public: CARDUCode(DSPHLE* dsphle, u32 crc); virtual ~CARDUCode(); + void Initialize() override; void HandleMail(u32 mail) override; void Update() override; }; diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/GBA.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/GBA.cpp index f23f8092fe..87f4c2e26e 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/GBA.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/GBA.cpp @@ -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 diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/GBA.h b/Source/Core/Core/HW/DSPHLE/UCodes/GBA.h index ac99afe006..f106761128 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/GBA.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/GBA.h @@ -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; }; diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/INIT.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/INIT.cpp index 3835abc459..de8fdb911f 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/INIT.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/INIT.cpp @@ -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() { } diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/INIT.h b/Source/Core/Core/HW/DSPHLE/UCodes/INIT.h index 2f53f91625..1bb4b21f0d 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/INIT.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/INIT.h @@ -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(); diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/ROM.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/ROM.cpp index f37ba78510..2df6bbce7d 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/ROM.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/ROM.cpp @@ -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() { } diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/ROM.h b/Source/Core/Core/HW/DSPHLE/UCodes/ROM.h index 9d1100f3aa..e2779a2e03 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/ROM.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/ROM.h @@ -12,6 +12,7 @@ public: ROMUCode(DSPHLE* dsphle, u32 crc); virtual ~ROMUCode(); + void Initialize() override; void HandleMail(u32 mail) override; void Update() override; diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.h b/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.h index 0cec95498c..b1fdd11dcf 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.h @@ -73,6 +73,7 @@ public: } virtual ~UCodeInterface() {} + virtual void Initialize() = 0; virtual void HandleMail(u32 mail) = 0; virtual void Update() = 0; diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp index 7418e86e3f..4b41b566a3 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp @@ -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()) diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.h b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.h index 86a0962f44..ae727a82a9 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.h @@ -188,6 +188,7 @@ public: ZeldaUCode(DSPHLE* dsphle, u32 crc); virtual ~ZeldaUCode(); + void Initialize() override; void HandleMail(u32 mail) override; void Update() override;