DSPEmulator: Move common variable into base class

This commit is contained in:
Lioncash 2016-10-07 08:55:54 -04:00
parent 3c822f2c55
commit aaa1da5abc
5 changed files with 19 additions and 20 deletions

View File

@ -15,7 +15,7 @@ public:
virtual ~DSPEmulator() {} virtual ~DSPEmulator() {}
virtual bool IsLLE() = 0; 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 Shutdown() = 0;
virtual void DoState(PointerWrap& p) = 0; virtual void DoState(PointerWrap& p) = 0;
@ -30,6 +30,9 @@ public:
virtual void DSP_Update(int cycles) = 0; virtual void DSP_Update(int cycles) = 0;
virtual void DSP_StopSoundStream() = 0; virtual void DSP_StopSoundStream() = 0;
virtual u32 DSP_UpdateRate() = 0; virtual u32 DSP_UpdateRate() = 0;
protected:
bool m_wii = false;
}; };
std::unique_ptr<DSPEmulator> CreateDSPEmulator(bool hle); std::unique_ptr<DSPEmulator> CreateDSPEmulator(bool hle);

View File

@ -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_pUCode = nullptr;
m_lastUCode = nullptr; m_lastUCode = nullptr;
m_bHalt = false; m_bHalt = false;
@ -76,7 +76,7 @@ void DSPHLE::SetUCode(u32 _crc)
m_pUCode = nullptr; m_pUCode = nullptr;
m_MailHandler.Clear(); m_MailHandler.Clear();
m_pUCode = UCodeFactory(_crc, this, m_bWii); m_pUCode = UCodeFactory(_crc, this, m_wii);
} }
// TODO do it better? // TODO do it better?
@ -89,7 +89,7 @@ void DSPHLE::SwapUCode(u32 _crc)
if (m_lastUCode == nullptr) if (m_lastUCode == nullptr)
{ {
m_lastUCode = m_pUCode; m_lastUCode = m_pUCode;
m_pUCode = UCodeFactory(_crc, this, m_bWii); m_pUCode = UCodeFactory(_crc, this, m_wii);
} }
else else
{ {
@ -125,10 +125,10 @@ void DSPHLE::DoState(PointerWrap& p)
// if a different type of ucode was being used when the savestate was created, // 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. // we have to reconstruct the old type of ucode so that we have a valid thing to call DoState on.
UCodeInterface* ucode = 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) ? UCodeInterface* lastucode = (lastucode_crc != lastucode_crc_beforeLoad) ?
m_lastUCode : m_lastUCode :
UCodeFactory(lastucode_crc, this, m_bWii); UCodeFactory(lastucode_crc, this, m_wii);
if (ucode) if (ucode)
ucode->DoState(p); ucode->DoState(p);

View File

@ -17,7 +17,7 @@ class DSPHLE : public DSPEmulator
public: public:
DSPHLE(); DSPHLE();
bool Initialize(bool bWii, bool bDSPThread) override; bool Initialize(bool wii, bool dsp_thread) override;
void Shutdown() override; void Shutdown() override;
bool IsLLE() override { return false; } bool IsLLE() override { return false; }
void DoState(PointerWrap& p) override; void DoState(PointerWrap& p) override;
@ -42,9 +42,6 @@ public:
private: private:
void SendMailToDSP(u32 _uMail); void SendMailToDSP(u32 _uMail);
// Declarations and definitions
bool m_bWii;
// Fake mailbox utility // Fake mailbox utility
struct DSPState struct DSPState
{ {

View File

@ -29,8 +29,8 @@
#include "Core/NetPlayProto.h" #include "Core/NetPlayProto.h"
DSPLLE::DSPLLE() DSPLLE::DSPLLE()
: m_hDSPThread(), m_csDSPThreadActive(), m_bWii(false), m_bDSPThread(false), : m_hDSPThread(), m_csDSPThreadActive(), m_bDSPThread(false), m_bIsRunning(false),
m_bIsRunning(false), m_cycle_count(0) m_cycle_count(0)
{ {
} }
@ -155,7 +155,7 @@ static bool FillDSPInitOptions(DSPInitOptions* opts)
return true; return true;
} }
bool DSPLLE::Initialize(bool bWii, bool bDSPThread) bool DSPLLE::Initialize(bool wii, bool dsp_thread)
{ {
requestDisableThread = false; requestDisableThread = false;
@ -167,10 +167,10 @@ bool DSPLLE::Initialize(bool bWii, bool bDSPThread)
// needs to be after DSPCore_Init for the dspjit ptr // needs to be after DSPCore_Init for the dspjit ptr
if (Core::g_want_determinism || !g_dsp_jit) if (Core::g_want_determinism || !g_dsp_jit)
bDSPThread = false; dsp_thread = false;
m_bWii = bWii; m_wii = wii;
m_bDSPThread = bDSPThread; m_bDSPThread = dsp_thread;
// DSPLLE directly accesses the fastmem arena. // DSPLLE directly accesses the fastmem arena.
// TODO: The fastmem arena is only supposed to be used by the JIT: // 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(); InitInstructionTable();
if (bDSPThread) if (dsp_thread)
{ {
m_bIsRunning.Set(true); m_bIsRunning.Set(true);
m_hDSPThread = std::thread(DSPThread, this); m_hDSPThread = std::thread(DSPThread, this);

View File

@ -18,7 +18,7 @@ class DSPLLE : public DSPEmulator
public: public:
DSPLLE(); DSPLLE();
bool Initialize(bool bWii, bool bDSPThread) override; bool Initialize(bool wii, bool dsp_thread) override;
void Shutdown() override; void Shutdown() override;
bool IsLLE() override { return true; } bool IsLLE() override { return true; }
void DoState(PointerWrap& p) override; void DoState(PointerWrap& p) override;
@ -39,7 +39,6 @@ private:
std::thread m_hDSPThread; std::thread m_hDSPThread;
std::mutex m_csDSPThreadActive; std::mutex m_csDSPThreadActive;
bool m_bWii;
bool m_bDSPThread; bool m_bDSPThread;
Common::Flag m_bIsRunning; Common::Flag m_bIsRunning;
std::atomic<u32> m_cycle_count; std::atomic<u32> m_cycle_count;