From aaa1da5abce29753d5352bf2dc16d13530e70a95 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 7 Oct 2016 08:55:54 -0400 Subject: [PATCH] DSPEmulator: Move common variable into base class --- Source/Core/Core/DSPEmulator.h | 5 ++++- Source/Core/Core/HW/DSPHLE/DSPHLE.cpp | 12 ++++++------ Source/Core/Core/HW/DSPHLE/DSPHLE.h | 5 +---- Source/Core/Core/HW/DSPLLE/DSPLLE.cpp | 14 +++++++------- Source/Core/Core/HW/DSPLLE/DSPLLE.h | 3 +-- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Source/Core/Core/DSPEmulator.h b/Source/Core/Core/DSPEmulator.h index b8cc8085d5..6778e67198 100644 --- a/Source/Core/Core/DSPEmulator.h +++ b/Source/Core/Core/DSPEmulator.h @@ -15,7 +15,7 @@ public: virtual ~DSPEmulator() {} virtual bool IsLLE() = 0; - virtual bool Initialize(bool bWii, bool bDSPThread) = 0; + virtual bool Initialize(bool wii, bool dsp_thread) = 0; virtual void Shutdown() = 0; virtual void DoState(PointerWrap& p) = 0; @@ -30,6 +30,9 @@ public: virtual void DSP_Update(int cycles) = 0; virtual void DSP_StopSoundStream() = 0; virtual u32 DSP_UpdateRate() = 0; + +protected: + bool m_wii = false; }; std::unique_ptr CreateDSPEmulator(bool hle); diff --git a/Source/Core/Core/HW/DSPHLE/DSPHLE.cpp b/Source/Core/Core/HW/DSPHLE/DSPHLE.cpp index 66254954b8..65e853ab62 100644 --- a/Source/Core/Core/HW/DSPHLE/DSPHLE.cpp +++ b/Source/Core/Core/HW/DSPHLE/DSPHLE.cpp @@ -16,9 +16,9 @@ DSPHLE::DSPHLE() { } -bool DSPHLE::Initialize(bool bWii, bool bDSPThread) +bool DSPHLE::Initialize(bool wii, bool dsp_thread) { - m_bWii = bWii; + m_wii = wii; m_pUCode = nullptr; m_lastUCode = nullptr; m_bHalt = false; @@ -76,7 +76,7 @@ void DSPHLE::SetUCode(u32 _crc) m_pUCode = nullptr; m_MailHandler.Clear(); - m_pUCode = UCodeFactory(_crc, this, m_bWii); + m_pUCode = UCodeFactory(_crc, this, m_wii); } // TODO do it better? @@ -89,7 +89,7 @@ void DSPHLE::SwapUCode(u32 _crc) if (m_lastUCode == nullptr) { m_lastUCode = m_pUCode; - m_pUCode = UCodeFactory(_crc, this, m_bWii); + m_pUCode = UCodeFactory(_crc, this, m_wii); } else { @@ -125,10 +125,10 @@ void DSPHLE::DoState(PointerWrap& p) // if a different type of ucode was being used when the savestate was created, // we have to reconstruct the old type of ucode so that we have a valid thing to call DoState on. UCodeInterface* ucode = - (ucode_crc == ucode_crc_beforeLoad) ? m_pUCode : UCodeFactory(ucode_crc, this, m_bWii); + (ucode_crc == ucode_crc_beforeLoad) ? m_pUCode : UCodeFactory(ucode_crc, this, m_wii); UCodeInterface* lastucode = (lastucode_crc != lastucode_crc_beforeLoad) ? m_lastUCode : - UCodeFactory(lastucode_crc, this, m_bWii); + UCodeFactory(lastucode_crc, this, m_wii); if (ucode) ucode->DoState(p); diff --git a/Source/Core/Core/HW/DSPHLE/DSPHLE.h b/Source/Core/Core/HW/DSPHLE/DSPHLE.h index 411440da7e..52284cfefd 100644 --- a/Source/Core/Core/HW/DSPHLE/DSPHLE.h +++ b/Source/Core/Core/HW/DSPHLE/DSPHLE.h @@ -17,7 +17,7 @@ class DSPHLE : public DSPEmulator public: DSPHLE(); - bool Initialize(bool bWii, bool bDSPThread) override; + bool Initialize(bool wii, bool dsp_thread) override; void Shutdown() override; bool IsLLE() override { return false; } void DoState(PointerWrap& p) override; @@ -42,9 +42,6 @@ public: private: void SendMailToDSP(u32 _uMail); - // Declarations and definitions - bool m_bWii; - // Fake mailbox utility struct DSPState { diff --git a/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp b/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp index dcd77db7d5..244d6cdfed 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPLLE.cpp @@ -29,8 +29,8 @@ #include "Core/NetPlayProto.h" DSPLLE::DSPLLE() - : m_hDSPThread(), m_csDSPThreadActive(), m_bWii(false), m_bDSPThread(false), - m_bIsRunning(false), m_cycle_count(0) + : m_hDSPThread(), m_csDSPThreadActive(), m_bDSPThread(false), m_bIsRunning(false), + m_cycle_count(0) { } @@ -155,7 +155,7 @@ static bool FillDSPInitOptions(DSPInitOptions* opts) return true; } -bool DSPLLE::Initialize(bool bWii, bool bDSPThread) +bool DSPLLE::Initialize(bool wii, bool dsp_thread) { requestDisableThread = false; @@ -167,10 +167,10 @@ bool DSPLLE::Initialize(bool bWii, bool bDSPThread) // needs to be after DSPCore_Init for the dspjit ptr if (Core::g_want_determinism || !g_dsp_jit) - bDSPThread = false; + dsp_thread = false; - m_bWii = bWii; - m_bDSPThread = bDSPThread; + m_wii = wii; + m_bDSPThread = dsp_thread; // DSPLLE directly accesses the fastmem arena. // TODO: The fastmem arena is only supposed to be used by the JIT: @@ -180,7 +180,7 @@ bool DSPLLE::Initialize(bool bWii, bool bDSPThread) InitInstructionTable(); - if (bDSPThread) + if (dsp_thread) { m_bIsRunning.Set(true); m_hDSPThread = std::thread(DSPThread, this); diff --git a/Source/Core/Core/HW/DSPLLE/DSPLLE.h b/Source/Core/Core/HW/DSPLLE/DSPLLE.h index 95c36a84dd..e7a80603a5 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPLLE.h +++ b/Source/Core/Core/HW/DSPLLE/DSPLLE.h @@ -18,7 +18,7 @@ class DSPLLE : public DSPEmulator public: DSPLLE(); - bool Initialize(bool bWii, bool bDSPThread) override; + bool Initialize(bool wii, bool dsp_thread) override; void Shutdown() override; bool IsLLE() override { return true; } void DoState(PointerWrap& p) override; @@ -39,7 +39,6 @@ private: std::thread m_hDSPThread; std::mutex m_csDSPThreadActive; - bool m_bWii; bool m_bDSPThread; Common::Flag m_bIsRunning; std::atomic m_cycle_count;