dsphle cleanup: Get rid of now-useless "DSPHandler" layer

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6948 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2011-01-28 19:31:46 +00:00
parent 419d6a244b
commit d61a79266a
23 changed files with 190 additions and 282 deletions

View File

@ -722,14 +722,6 @@
<Filter <Filter
Name="HLE" Name="HLE"
> >
<File
RelativePath=".\Src\HW\DSPHLE\DSPHandler.cpp"
>
</File>
<File
RelativePath=".\Src\HW\DSPHLE\DSPHandler.h"
>
</File>
<File <File
RelativePath=".\Src\HW\DSPHLE\DSPHLE.cpp" RelativePath=".\Src\HW\DSPHLE\DSPHLE.cpp"
> >

View File

@ -22,17 +22,17 @@
#include "ChunkFile.h" #include "ChunkFile.h"
#include "IniFile.h" #include "IniFile.h"
#include "HLEMixer.h" #include "HLEMixer.h"
#include "DSPHandler.h"
#include "Config.h" #include "Config.h"
#include "Setup.h" #include "Setup.h"
#include "StringUtil.h" #include "StringUtil.h"
#include "LogManager.h" #include "LogManager.h"
#include "IniFile.h" #include "IniFile.h"
#include "DSPHLE.h" #include "DSPHLE.h"
#include "UCodes/UCodes.h"
#include "../AudioInterface.h" #include "../AudioInterface.h"
DSPHLE::DSPHLE() { DSPHLE::DSPHLE() {
g_InitMixer = false; m_InitMixer = false;
soundStream = NULL; soundStream = NULL;
} }
@ -52,17 +52,23 @@ struct DSPState
Reset(); Reset();
} }
}; };
DSPState g_dspState; DSPState m_dspState;
void DSPHLE::Initialize(void *hWnd, bool bWii, bool bDSPThread) void DSPHLE::Initialize(void *hWnd, bool bWii, bool bDSPThread)
{ {
this->hWnd = hWnd; m_hWnd = hWnd;
this->bWii = bWii; m_bWii = bWii;
m_pUCode = NULL;
m_lastUCode = NULL;
m_bHalt = false;
m_bAssertInt = false;
g_InitMixer = false; SetUCode(UCODE_ROM);
g_dspState.Reset(); m_DSPControl.DSPHalt = 1;
m_DSPControl.DSPInit = 1;
CDSPHandler::CreateInstance(bWii); m_InitMixer = false;
m_dspState.Reset();
} }
void DSPHLE::DSP_StopSoundStream() void DSPHLE::DSP_StopSoundStream()
@ -72,15 +78,60 @@ void DSPHLE::DSP_StopSoundStream()
void DSPHLE::Shutdown() void DSPHLE::Shutdown()
{ {
AudioCommon::ShutdownSoundStream(); AudioCommon::ShutdownSoundStream();
}
// Delete the UCodes void DSPHLE::Update(int cycles)
CDSPHandler::Destroy(); {
if (m_pUCode != NULL)
m_pUCode->Update(cycles);
}
void DSPHLE::SendMailToDSP(u32 _uMail)
{
if (m_pUCode != NULL) {
DEBUG_LOG(DSP_MAIL, "CPU writes 0x%08x", _uMail);
m_pUCode->HandleMail(_uMail);
}
}
IUCode* DSPHLE::GetUCode()
{
return m_pUCode;
}
void DSPHLE::SetUCode(u32 _crc)
{
delete m_pUCode;
m_pUCode = NULL;
m_MailHandler.Clear();
m_pUCode = UCodeFactory(_crc, this, m_bWii);
}
// TODO do it better?
// Assumes that every odd call to this func is by the persistent ucode.
// Even callers are deleted.
void DSPHLE::SwapUCode(u32 _crc)
{
m_MailHandler.Clear();
if (m_lastUCode == NULL)
{
m_lastUCode = m_pUCode;
m_pUCode = UCodeFactory(_crc, this, m_bWii);
}
else
{
delete m_pUCode;
m_pUCode = m_lastUCode;
m_lastUCode = NULL;
}
} }
void DSPHLE::DoState(PointerWrap &p) void DSPHLE::DoState(PointerWrap &p)
{ {
p.Do(g_InitMixer); p.Do(m_InitMixer);
CDSPHandler::GetInstance().GetUCode()->DoState(p); GetUCode()->DoState(p);
} }
void DSPHLE::EmuStateChange(PLUGIN_EMUSTATE newState) void DSPHLE::EmuStateChange(PLUGIN_EMUSTATE newState)
@ -93,11 +144,11 @@ unsigned short DSPHLE::DSP_ReadMailBoxHigh(bool _CPUMailbox)
{ {
if (_CPUMailbox) if (_CPUMailbox)
{ {
return (g_dspState.CPUMailbox >> 16) & 0xFFFF; return (m_dspState.CPUMailbox >> 16) & 0xFFFF;
} }
else else
{ {
return CDSPHandler::GetInstance().AccessMailHandler().ReadDSPMailboxHigh(); return AccessMailHandler().ReadDSPMailboxHigh();
} }
} }
@ -105,11 +156,11 @@ unsigned short DSPHLE::DSP_ReadMailBoxLow(bool _CPUMailbox)
{ {
if (_CPUMailbox) if (_CPUMailbox)
{ {
return g_dspState.CPUMailbox & 0xFFFF; return m_dspState.CPUMailbox & 0xFFFF;
} }
else else
{ {
return CDSPHandler::GetInstance().AccessMailHandler().ReadDSPMailboxLow(); return AccessMailHandler().ReadDSPMailboxLow();
} }
} }
@ -117,7 +168,7 @@ void DSPHLE::DSP_WriteMailBoxHigh(bool _CPUMailbox, unsigned short _Value)
{ {
if (_CPUMailbox) if (_CPUMailbox)
{ {
g_dspState.CPUMailbox = (g_dspState.CPUMailbox & 0xFFFF) | (_Value << 16); m_dspState.CPUMailbox = (m_dspState.CPUMailbox & 0xFFFF) | (_Value << 16);
} }
else else
{ {
@ -129,10 +180,10 @@ void DSPHLE::DSP_WriteMailBoxLow(bool _CPUMailbox, unsigned short _Value)
{ {
if (_CPUMailbox) if (_CPUMailbox)
{ {
g_dspState.CPUMailbox = (g_dspState.CPUMailbox & 0xFFFF0000) | _Value; m_dspState.CPUMailbox = (m_dspState.CPUMailbox & 0xFFFF0000) | _Value;
CDSPHandler::GetInstance().SendMailToDSP(g_dspState.CPUMailbox); SendMailToDSP(m_dspState.CPUMailbox);
// Mail sent so clear MSB to show that it is progressed // Mail sent so clear MSB to show that it is progressed
g_dspState.CPUMailbox &= 0x7FFFFFFF; m_dspState.CPUMailbox &= 0x7FFFFFFF;
} }
else else
{ {
@ -140,12 +191,35 @@ void DSPHLE::DSP_WriteMailBoxLow(bool _CPUMailbox, unsigned short _Value)
} }
} }
u16 DSPHLE::WriteControlRegister(u16 _Value)
{
UDSPControl Temp(_Value);
if (Temp.DSPReset)
{
SetUCode(UCODE_ROM);
Temp.DSPReset = 0;
}
if (Temp.DSPInit == 0)
{
// copy 128 byte from ARAM 0x000000 to IMEM
SetUCode(UCODE_INIT_AUDIO_SYSTEM);
Temp.DSPInitCode = 0;
}
m_DSPControl.Hex = Temp.Hex;
return m_DSPControl.Hex;
}
u16 DSPHLE::ReadControlRegister()
{
return m_DSPControl.Hex;
}
// Other DSP fuctions // Other DSP fuctions
unsigned short DSPHLE::DSP_WriteControlRegister(unsigned short _Value) unsigned short DSPHLE::DSP_WriteControlRegister(unsigned short _Value)
{ {
UDSPControl Temp(_Value); UDSPControl Temp(_Value);
if (!g_InitMixer) if (!m_InitMixer)
{ {
if (!Temp.DSPHalt && Temp.DSPInit) if (!Temp.DSPHalt && Temp.DSPInit)
{ {
@ -158,25 +232,25 @@ unsigned short DSPHLE::DSP_WriteControlRegister(unsigned short _Value)
BackendSampleRate = 32000; BackendSampleRate = 32000;
soundStream = AudioCommon::InitSoundStream( soundStream = AudioCommon::InitSoundStream(
new HLEMixer(AISampleRate, DACSampleRate, BackendSampleRate), hWnd); new HLEMixer(this, AISampleRate, DACSampleRate, BackendSampleRate), m_hWnd);
if(!soundStream) PanicAlert("Error starting up sound stream"); if(!soundStream) PanicAlert("Error starting up sound stream");
// Mixer is initialized // Mixer is initialized
g_InitMixer = true; m_InitMixer = true;
} }
} }
return CDSPHandler::GetInstance().WriteControlRegister(_Value); return WriteControlRegister(_Value);
} }
unsigned short DSPHLE::DSP_ReadControlRegister() u16 DSPHLE::DSP_ReadControlRegister()
{ {
return CDSPHandler::GetInstance().ReadControlRegister(); return ReadControlRegister();
} }
void DSPHLE::DSP_Update(int cycles) void DSPHLE::DSP_Update(int cycles)
{ {
// This is called OFTEN - better not do anything expensive! // This is called OFTEN - better not do anything expensive!
// ~1/6th as many cycles as the period PPC-side. // ~1/6th as many cycles as the period PPC-side.
CDSPHandler::GetInstance().Update(cycles / 6); Update(cycles / 6);
} }
// The reason that we don't disable this entire // The reason that we don't disable this entire

View File

@ -18,10 +18,14 @@
#ifndef _DSPHLE_H #ifndef _DSPHLE_H
#define _DSPHLE_H #define _DSPHLE_H
#include "AudioCommon.h"
#include "SoundStream.h" #include "SoundStream.h"
#include "DSPHLEGlobals.h" // Local #include "DSPHLEGlobals.h" // Local
#include "MailHandler.h"
#include "../../PluginDSP.h" #include "../../PluginDSP.h"
class IUCode;
class DSPHLE : public PluginDSP { class DSPHLE : public PluginDSP {
public: public:
DSPHLE(); DSPHLE();
@ -52,15 +56,26 @@ public:
virtual void DSP_StopSoundStream(); virtual void DSP_StopSoundStream();
virtual void DSP_ClearAudioBuffer(bool mute); virtual void DSP_ClearAudioBuffer(bool mute);
// Formerly DSPHandler
void Update(int cycles);
u16 WriteControlRegister(u16 _Value);
u16 ReadControlRegister();
void SendMailToDSP(u32 _uMail);
IUCode *GetUCode();
void SetUCode(u32 _crc);
void SwapUCode(u32 _crc);
CMailHandler& AccessMailHandler() { return m_MailHandler; }
private: private:
// Declarations and definitions // Declarations and definitions
void *hWnd; void *m_hWnd;
bool bWii; bool m_bWii;
bool g_InitMixer; bool m_InitMixer;
SoundStream *soundStream; SoundStream *soundStream;
// Mailbox utility // Fake mailbox utility
struct DSPState struct DSPState
{ {
u32 CPUMailbox; u32 CPUMailbox;
@ -76,7 +91,16 @@ private:
Reset(); Reset();
} }
}; };
DSPState g_dspState; DSPState m_dspState;
IUCode* m_pUCode;
IUCode* m_lastUCode;
UDSPControl m_DSPControl;
CMailHandler m_MailHandler;
bool m_bHalt;
bool m_bAssertInt;
}; };
// Hack to be deleted. // Hack to be deleted.

View File

@ -1,110 +0,0 @@
// Copyright (C) 2003 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "DSPHandler.h"
CDSPHandler* CDSPHandler::m_pInstance = NULL;
CDSPHandler::CDSPHandler(bool bWii)
: m_pUCode(NULL),
m_lastUCode(NULL),
m_bHalt(false),
m_bAssertInt(false),
m_bWii(bWii)
{
SetUCode(UCODE_ROM);
m_DSPControl.DSPHalt = 1;
m_DSPControl.DSPInit = 1;
}
CDSPHandler::~CDSPHandler()
{
delete m_pUCode;
m_pUCode = NULL;
}
void CDSPHandler::Update(int cycles)
{
if (m_pUCode != NULL)
m_pUCode->Update(cycles);
}
unsigned short CDSPHandler::WriteControlRegister(unsigned short _Value)
{
UDSPControl Temp(_Value);
if (Temp.DSPReset)
{
SetUCode(UCODE_ROM);
Temp.DSPReset = 0;
}
if (Temp.DSPInit == 0)
{
// copy 128 byte from ARAM 0x000000 to IMEM
SetUCode(UCODE_INIT_AUDIO_SYSTEM);
Temp.DSPInitCode = 0;
}
m_DSPControl.Hex = Temp.Hex;
return m_DSPControl.Hex;
}
unsigned short CDSPHandler::ReadControlRegister()
{
return m_DSPControl.Hex;
}
void CDSPHandler::SendMailToDSP(u32 _uMail)
{
if (m_pUCode != NULL) {
DEBUG_LOG(DSP_MAIL, "CPU writes 0x%08x", _uMail);
m_pUCode->HandleMail(_uMail);
}
}
IUCode* CDSPHandler::GetUCode()
{
return m_pUCode;
}
void CDSPHandler::SetUCode(u32 _crc)
{
delete m_pUCode;
m_pUCode = NULL;
m_MailHandler.Clear();
m_pUCode = UCodeFactory(_crc, m_MailHandler, m_bWii);
}
// TODO do it better?
// Assumes that every odd call to this func is by the persistent ucode.
// Even callers are deleted.
void CDSPHandler::SwapUCode(u32 _crc)
{
m_MailHandler.Clear();
if (m_lastUCode == NULL)
{
m_lastUCode = m_pUCode;
m_pUCode = UCodeFactory(_crc, m_MailHandler, m_bWii);
}
else
{
delete m_pUCode;
m_pUCode = m_lastUCode;
m_lastUCode = NULL;
}
}

View File

@ -1,76 +0,0 @@
// Copyright (C) 2003 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef _DSPHANDLER_H
#define _DSPHANDLER_H
#include "Common.h"
#include "AudioCommon.h"
#include "MailHandler.h"
#include "UCodes/UCodes.h"
class CDSPHandler : NonCopyable
{
public:
void Update(int cycles);
unsigned short WriteControlRegister(unsigned short _Value);
unsigned short ReadControlRegister();
void SendMailToDSP(u32 _uMail);
IUCode* GetUCode();
void SetUCode(u32 _crc);
void SwapUCode(u32 _crc);
CMailHandler& AccessMailHandler() { return m_MailHandler; }
static CDSPHandler& GetInstance()
{
return *m_pInstance;
}
static void Destroy()
{
delete m_pInstance;
m_pInstance = NULL;
}
static CDSPHandler& CreateInstance(bool bWii)
{
if (!m_pInstance)
m_pInstance = new CDSPHandler(bWii);
return *m_pInstance;
}
private:
CDSPHandler(bool bWii);
~CDSPHandler();
// singleton instance
static CDSPHandler* m_pInstance;
IUCode* m_pUCode;
IUCode* m_lastUCode;
UDSPControl m_DSPControl;
CMailHandler m_MailHandler;
bool m_bHalt;
bool m_bAssertInt;
bool m_bWii;
};
#endif

View File

@ -17,15 +17,16 @@
#include "Config.h" // Local #include "Config.h" // Local
#include "DSPHLEGlobals.h" #include "DSPHLEGlobals.h"
#include "DSPHandler.h" #include "DSPHLE.h"
#include "HLEMixer.h" #include "HLEMixer.h"
#include "UCodes/UCodes.h"
void HLEMixer::Premix(short *samples, unsigned int numSamples) void HLEMixer::Premix(short *samples, unsigned int numSamples)
{ {
// if this was called directly from the HLE // if this was called directly from the HLE
if (IsHLEReady()) if (IsHLEReady())
{ {
IUCode *pUCode = CDSPHandler::GetInstance().GetUCode(); IUCode *pUCode = m_DSPHLE->GetUCode();
if (pUCode && samples) if (pUCode && samples)
pUCode->MixAdd(samples, numSamples); pUCode->MixAdd(samples, numSamples);
} }

View File

@ -3,13 +3,17 @@
#include "AudioCommon.h" #include "AudioCommon.h"
#include "Mixer.h" #include "Mixer.h"
class DSPHLE;
class HLEMixer : public CMixer class HLEMixer : public CMixer
{ {
public: public:
HLEMixer(unsigned int AISampleRate = 48000, unsigned int DACSampleRate = 48000, unsigned int BackendSampleRate = 32000) HLEMixer(DSPHLE *dsp_hle, unsigned int AISampleRate = 48000, unsigned int DACSampleRate = 48000, unsigned int BackendSampleRate = 32000)
: CMixer(AISampleRate, DACSampleRate, BackendSampleRate) {}; : CMixer(AISampleRate, DACSampleRate, BackendSampleRate), m_DSPHLE(dsp_hle) {};
virtual void Premix(short *samples, unsigned int numSamples); virtual void Premix(short *samples, unsigned int numSamples);
private:
DSPHLE *m_DSPHLE;
}; };
#endif // HLEMIXER_H #endif // HLEMIXER_H

View File

@ -22,15 +22,14 @@
#include "../DSPHLEGlobals.h" #include "../DSPHLEGlobals.h"
#include "Mixer.h" #include "Mixer.h"
#include "../MailHandler.h" #include "../MailHandler.h"
#include "../DSPHandler.h"
#include "../../DSP.h" #include "../../DSP.h"
#include "UCodes.h" #include "UCodes.h"
#include "UCode_AXStructs.h" #include "UCode_AXStructs.h"
#include "UCode_AX.h" #include "UCode_AX.h"
#include "UCode_AX_Voice.h" #include "UCode_AX_Voice.h"
CUCode_AX::CUCode_AX(CMailHandler& _rMailHandler) CUCode_AX::CUCode_AX(DSPHLE *dsp_hle)
: IUCode(_rMailHandler) : IUCode(dsp_hle)
, m_addressPBs(0xFFFFFFFF) , m_addressPBs(0xFFFFFFFF)
{ {
// we got loaded // we got loaded
@ -235,7 +234,7 @@ void CUCode_AX::HandleMail(u32 _uMail)
else if (_uMail == 0xCDD10002) // Action 2 - IROM_Reset(); ( GC: NFS Carbon, FF Crystal Chronicles,...) else if (_uMail == 0xCDD10002) // Action 2 - IROM_Reset(); ( GC: NFS Carbon, FF Crystal Chronicles,...)
{ {
DEBUG_LOG(DSPHLE,"DSP IROM - Reset!"); DEBUG_LOG(DSPHLE,"DSP IROM - Reset!");
CDSPHandler::GetInstance().SetUCode(UCODE_ROM); m_DSPHLE->SetUCode(UCODE_ROM);
return; return;
} }
else if (_uMail == 0xCDD10003) // Action 3 - AX_GetNextCmdBlock(); else if (_uMail == 0xCDD10003) // Action 3 - AX_GetNextCmdBlock();

View File

@ -29,7 +29,7 @@ enum
class CUCode_AX : public IUCode class CUCode_AX : public IUCode
{ {
public: public:
CUCode_AX(CMailHandler& _rMailHandler); CUCode_AX(DSPHLE *dsp_hle);
virtual ~CUCode_AX(); virtual ~CUCode_AX();
void HandleMail(u32 _uMail); void HandleMail(u32 _uMail);

View File

@ -19,7 +19,6 @@
#include "../MailHandler.h" #include "../MailHandler.h"
#include "Mixer.h" #include "Mixer.h"
#include "../DSPHandler.h"
#include "UCodes.h" #include "UCodes.h"
#include "UCode_AXStructs.h" #include "UCode_AXStructs.h"
@ -28,8 +27,8 @@
#include "UCode_AX_Voice.h" #include "UCode_AX_Voice.h"
CUCode_AXWii::CUCode_AXWii(CMailHandler& _rMailHandler, u32 l_CRC) CUCode_AXWii::CUCode_AXWii(DSPHLE *dsp_hle, u32 l_CRC)
: IUCode(_rMailHandler) : IUCode(dsp_hle)
, m_addressPBs(0xFFFFFFFF) , m_addressPBs(0xFFFFFFFF)
, _CRC(l_CRC) , _CRC(l_CRC)
{ {
@ -76,7 +75,7 @@ void CUCode_AXWii::HandleMail(u32 _uMail)
case 0xCDD10002: // Action 2 - IROM_Reset(); ( WII: De Blob, Cursed Mountain,...) case 0xCDD10002: // Action 2 - IROM_Reset(); ( WII: De Blob, Cursed Mountain,...)
DEBUG_LOG(DSPHLE,"DSP IROM - Reset!"); DEBUG_LOG(DSPHLE,"DSP IROM - Reset!");
CDSPHandler::GetInstance().SetUCode(UCODE_ROM); m_DSPHLE->SetUCode(UCODE_ROM);
return; return;
case 0xCDD10003: // Action 3 - AX_GetNextCmdBlock() case 0xCDD10003: // Action 3 - AX_GetNextCmdBlock()

View File

@ -25,7 +25,7 @@
class CUCode_AXWii : public IUCode class CUCode_AXWii : public IUCode
{ {
public: public:
CUCode_AXWii(CMailHandler& _rMailHandler, u32 _CRC); CUCode_AXWii(DSPHLE *dsp_hle, u32 _CRC);
virtual ~CUCode_AXWii(); virtual ~CUCode_AXWii();
void HandleMail(u32 _uMail); void HandleMail(u32 _uMail);

View File

@ -16,14 +16,14 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include "../DSPHLEGlobals.h" #include "../DSPHLEGlobals.h"
#include "../DSPHandler.h" #include "../DSPHLE.h"
#include "UCodes.h" #include "UCodes.h"
#include "UCode_CARD.h" #include "UCode_CARD.h"
#include "../../DSP.h" #include "../../DSP.h"
CUCode_CARD::CUCode_CARD(CMailHandler& _rMailHandler) CUCode_CARD::CUCode_CARD(DSPHLE *dsp_hle)
: IUCode(_rMailHandler) : IUCode(dsp_hle)
{ {
DEBUG_LOG(DSPHLE, "CUCode_CARD - initialized"); DEBUG_LOG(DSPHLE, "CUCode_CARD - initialized");
m_rMailHandler.PushMail(DSP_INIT); m_rMailHandler.PushMail(DSP_INIT);
@ -57,7 +57,7 @@ void CUCode_CARD::HandleMail(u32 _uMail)
} }
m_rMailHandler.PushMail(DSP_DONE); m_rMailHandler.PushMail(DSP_DONE);
CDSPHandler::GetInstance().SetUCode(UCODE_ROM); m_DSPHLE->SetUCode(UCODE_ROM);
} }

View File

@ -23,7 +23,7 @@
class CUCode_CARD : public IUCode class CUCode_CARD : public IUCode
{ {
public: public:
CUCode_CARD(CMailHandler& _rMailHandler); CUCode_CARD(DSPHLE *dsp_hle);
virtual ~CUCode_CARD(); virtual ~CUCode_CARD();
void HandleMail(u32 _uMail); void HandleMail(u32 _uMail);

View File

@ -16,14 +16,13 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include "../DSPHLEGlobals.h" #include "../DSPHLEGlobals.h"
#include "../DSPHandler.h"
#include "UCodes.h" #include "UCodes.h"
#include "UCode_GBA.h" #include "UCode_GBA.h"
#include "../../DSP.h" #include "../../DSP.h"
CUCode_GBA::CUCode_GBA(CMailHandler& _rMailHandler) CUCode_GBA::CUCode_GBA(DSPHLE *dsp_hle)
: IUCode(_rMailHandler) : IUCode(dsp_hle)
{ {
m_rMailHandler.PushMail(DSP_INIT); m_rMailHandler.PushMail(DSP_INIT);
} }
@ -142,7 +141,7 @@ void CUCode_GBA::HandleMail(u32 _uMail)
m_UploadSetupInProgress = true; m_UploadSetupInProgress = true;
break; break;
case 2: case 2:
CDSPHandler::GetInstance().SetUCode(UCODE_ROM); m_DSPHLE->SetUCode(UCODE_ROM);
break; break;
default: default:
DEBUG_LOG(DSPHLE, "CUCode_GBA - unknown 0xcdd1 cmd: %08x", _uMail); DEBUG_LOG(DSPHLE, "CUCode_GBA - unknown 0xcdd1 cmd: %08x", _uMail);

View File

@ -21,7 +21,7 @@
struct CUCode_GBA : public IUCode struct CUCode_GBA : public IUCode
{ {
CUCode_GBA(CMailHandler& _rMailHandler); CUCode_GBA(DSPHLE *dsp_hle);
virtual ~CUCode_GBA(); virtual ~CUCode_GBA();
void HandleMail(u32 _uMail); void HandleMail(u32 _uMail);

View File

@ -16,12 +16,11 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include "../DSPHLEGlobals.h" #include "../DSPHLEGlobals.h"
#include "../DSPHandler.h"
#include "UCodes.h" #include "UCodes.h"
#include "UCode_InitAudioSystem.h" #include "UCode_InitAudioSystem.h"
CUCode_InitAudioSystem::CUCode_InitAudioSystem(CMailHandler& _rMailHandler) CUCode_InitAudioSystem::CUCode_InitAudioSystem(DSPHLE *dsp_hle)
: IUCode(_rMailHandler) : IUCode(dsp_hle)
{ {
DEBUG_LOG(DSPHLE, "CUCode_InitAudioSystem - initialized"); DEBUG_LOG(DSPHLE, "CUCode_InitAudioSystem - initialized");
} }

View File

@ -23,7 +23,7 @@
class CUCode_InitAudioSystem : public IUCode class CUCode_InitAudioSystem : public IUCode
{ {
public: public:
CUCode_InitAudioSystem(CMailHandler& _rMailHandler); CUCode_InitAudioSystem(DSPHLE *dsp_hle);
virtual ~CUCode_InitAudioSystem(); virtual ~CUCode_InitAudioSystem();
void HandleMail(u32 _uMail); void HandleMail(u32 _uMail);

View File

@ -16,14 +16,13 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include "../DSPHLEGlobals.h" #include "../DSPHLEGlobals.h"
#include "../DSPHandler.h"
#include "UCodes.h" #include "UCodes.h"
#include "UCode_ROM.h" #include "UCode_ROM.h"
#include "Hash.h" #include "Hash.h"
#include "../../Memmap.h" #include "../../Memmap.h"
CUCode_Rom::CUCode_Rom(CMailHandler& _rMailHandler) CUCode_Rom::CUCode_Rom(DSPHLE *dsp_hle)
: IUCode(_rMailHandler) : IUCode(dsp_hle)
, m_CurrentUCode() , m_CurrentUCode()
, m_BootTask_numSteps(0) , m_BootTask_numSteps(0)
, m_NextParameter(0) , m_NextParameter(0)
@ -120,7 +119,7 @@ void CUCode_Rom::BootUCode()
DEBUG_LOG(DSPHLE, "CurrentUCode CRC: 0x%08x", ector_crc); DEBUG_LOG(DSPHLE, "CurrentUCode CRC: 0x%08x", ector_crc);
DEBUG_LOG(DSPHLE, "BootTask - done"); DEBUG_LOG(DSPHLE, "BootTask - done");
CDSPHandler::GetInstance().SetUCode(ector_crc); m_DSPHLE->SetUCode(ector_crc);
} }

View File

@ -23,7 +23,7 @@
class CUCode_Rom : public IUCode class CUCode_Rom : public IUCode
{ {
public: public:
CUCode_Rom(CMailHandler& _rMailHandler); CUCode_Rom(DSPHLE *dsp_hle);
virtual ~CUCode_Rom(); virtual ~CUCode_Rom();
void HandleMail(u32 _uMail); void HandleMail(u32 _uMail);

View File

@ -27,13 +27,12 @@
#include "Mixer.h" #include "Mixer.h"
#include "WaveFile.h" #include "WaveFile.h"
#include "../DSPHandler.h"
#include "../../DSP.h" #include "../../DSP.h"
CUCode_Zelda::CUCode_Zelda(CMailHandler& _rMailHandler, u32 _CRC) CUCode_Zelda::CUCode_Zelda(DSPHLE *dsp_hle, u32 _CRC)
: :
IUCode(_rMailHandler), IUCode(dsp_hle),
m_CRC(_CRC), m_CRC(_CRC),
m_bSyncInProgress(false), m_bSyncInProgress(false),
@ -413,7 +412,7 @@ void CUCode_Zelda::HandleMail_NormalVersion(u32 _uMail)
return; return;
case 0x0002: // Let IROM play us off case 0x0002: // Let IROM play us off
CDSPHandler::GetInstance().SetUCode(UCODE_ROM); m_DSPHLE->SetUCode(UCODE_ROM);
return; return;
case 0x0000: // Halt case 0x0000: // Halt

View File

@ -136,7 +136,7 @@ namespace {
class CUCode_Zelda : public IUCode class CUCode_Zelda : public IUCode
{ {
public: public:
CUCode_Zelda(CMailHandler& _rMailHandler, u32 _CRC); CUCode_Zelda(DSPHLE *dsp_hle, u32 _CRC);
virtual ~CUCode_Zelda(); virtual ~CUCode_Zelda();
void HandleMail(u32 _uMail); void HandleMail(u32 _uMail);

View File

@ -27,27 +27,26 @@
#include "UCode_InitAudioSystem.h" #include "UCode_InitAudioSystem.h"
#include "UCode_GBA.h" #include "UCode_GBA.h"
#include "Hash.h" #include "Hash.h"
#include "../DSPHandler.h"
IUCode* UCodeFactory(u32 _CRC, CMailHandler& _rMailHandler, bool bWii) IUCode* UCodeFactory(u32 _CRC, DSPHLE *dsp_hle, bool bWii)
{ {
switch (_CRC) switch (_CRC)
{ {
case UCODE_ROM: case UCODE_ROM:
INFO_LOG(DSPHLE, "Switching to ROM ucode"); INFO_LOG(DSPHLE, "Switching to ROM ucode");
return new CUCode_Rom(_rMailHandler); return new CUCode_Rom(dsp_hle);
case UCODE_INIT_AUDIO_SYSTEM: case UCODE_INIT_AUDIO_SYSTEM:
INFO_LOG(DSPHLE, "Switching to INIT ucode"); INFO_LOG(DSPHLE, "Switching to INIT ucode");
return new CUCode_InitAudioSystem(_rMailHandler); return new CUCode_InitAudioSystem(dsp_hle);
case 0x65d6cc6f: // CARD case 0x65d6cc6f: // CARD
INFO_LOG(DSPHLE, "Switching to CARD ucode"); INFO_LOG(DSPHLE, "Switching to CARD ucode");
return new CUCode_CARD(_rMailHandler); return new CUCode_CARD(dsp_hle);
case 0xdd7e72d5: case 0xdd7e72d5:
INFO_LOG(DSPHLE, "Switching to GBA ucode"); INFO_LOG(DSPHLE, "Switching to GBA ucode");
return new CUCode_GBA(_rMailHandler); return new CUCode_GBA(dsp_hle);
case 0x3ad3b7ac: // Naruto3, Paper Mario - The Thousand Year Door case 0x3ad3b7ac: // Naruto3, Paper Mario - The Thousand Year Door
case 0x3daf59b9: // Alien Hominid case 0x3daf59b9: // Alien Hominid
@ -59,14 +58,14 @@ IUCode* UCodeFactory(u32 _CRC, CMailHandler& _rMailHandler, bool bWii)
// Zelda:OOT, Tony hawk, viewtiful joe // Zelda:OOT, Tony hawk, viewtiful joe
case 0xe2136399: // billy hatcher, dragonballz, mario party 5, TMNT, ava1080 case 0xe2136399: // billy hatcher, dragonballz, mario party 5, TMNT, ava1080
INFO_LOG(DSPHLE, "CRC %08x: AX ucode chosen", _CRC); INFO_LOG(DSPHLE, "CRC %08x: AX ucode chosen", _CRC);
return new CUCode_AX(_rMailHandler); return new CUCode_AX(dsp_hle);
case 0x6ba3b3ea: // IPL - PAL case 0x6ba3b3ea: // IPL - PAL
case 0x24b22038: // IPL - NTSC/NTSC-JAP case 0x24b22038: // IPL - NTSC/NTSC-JAP
case 0x42f64ac4: // Luigi case 0x42f64ac4: // Luigi
case 0x4be6a5cb: // AC, Pikmin case 0x4be6a5cb: // AC, Pikmin
INFO_LOG(DSPHLE, "CRC %08x: JAC (early Zelda) ucode chosen", _CRC); INFO_LOG(DSPHLE, "CRC %08x: JAC (early Zelda) ucode chosen", _CRC);
return new CUCode_Zelda(_rMailHandler, _CRC); return new CUCode_Zelda(dsp_hle, _CRC);
case 0x6CA33A6D: // DK Jungle Beat case 0x6CA33A6D: // DK Jungle Beat
case 0x86840740: // Zelda WW - US case 0x86840740: // Zelda WW - US
@ -74,7 +73,7 @@ IUCode* UCodeFactory(u32 _CRC, CMailHandler& _rMailHandler, bool bWii)
case 0x2fcdf1ec: // Mario Kart, zelda 4 swords case 0x2fcdf1ec: // Mario Kart, zelda 4 swords
case 0x267fd05a: // Pikmin PAL case 0x267fd05a: // Pikmin PAL
INFO_LOG(DSPHLE, "CRC %08x: Zelda ucode chosen", _CRC); INFO_LOG(DSPHLE, "CRC %08x: Zelda ucode chosen", _CRC);
return new CUCode_Zelda(_rMailHandler, _CRC); return new CUCode_Zelda(dsp_hle, _CRC);
// WII CRCs // WII CRCs
case 0xb7eb9a9c: // Wii Pikmin - PAL case 0xb7eb9a9c: // Wii Pikmin - PAL
@ -82,7 +81,7 @@ IUCode* UCodeFactory(u32 _CRC, CMailHandler& _rMailHandler, bool bWii)
case 0x6c3f6f94: // Zelda TP - PAL case 0x6c3f6f94: // Zelda TP - PAL
case 0xd643001f: // Mario Galaxy - PAL / WII DK Jungle Beat - PAL case 0xd643001f: // Mario Galaxy - PAL / WII DK Jungle Beat - PAL
INFO_LOG(DSPHLE, "CRC %08x: Zelda Wii ucode chosen\n", _CRC); INFO_LOG(DSPHLE, "CRC %08x: Zelda Wii ucode chosen\n", _CRC);
return new CUCode_Zelda(_rMailHandler, _CRC); return new CUCode_Zelda(dsp_hle, _CRC);
case 0x2ea36ce6: // Some Wii demos case 0x2ea36ce6: // Some Wii demos
case 0x5ef56da3: // AX demo case 0x5ef56da3: // AX demo
@ -92,18 +91,18 @@ IUCode* UCodeFactory(u32 _CRC, CMailHandler& _rMailHandler, bool bWii)
case 0x4cc52064: // Bleach: Versus Crusade case 0x4cc52064: // Bleach: Versus Crusade
case 0xd9c4bf34: // WiiMenu case 0xd9c4bf34: // WiiMenu
INFO_LOG(DSPHLE, "CRC %08x: Wii - AXWii chosen", _CRC); INFO_LOG(DSPHLE, "CRC %08x: Wii - AXWii chosen", _CRC);
return new CUCode_AXWii(_rMailHandler, _CRC); return new CUCode_AXWii(dsp_hle, _CRC);
default: default:
if (bWii) if (bWii)
{ {
PanicAlert("DSPHLE: Unknown ucode (CRC = %08x) - forcing AXWii.\n\nTry LLE plugin if this is homebrew.", _CRC); PanicAlert("DSPHLE: Unknown ucode (CRC = %08x) - forcing AXWii.\n\nTry LLE plugin if this is homebrew.", _CRC);
return new CUCode_AXWii(_rMailHandler, _CRC); return new CUCode_AXWii(dsp_hle, _CRC);
} }
else else
{ {
PanicAlert("DSPHLE: Unknown ucode (CRC = %08x) - forcing AX.\n\nTry LLE plugin if this is homebrew.", _CRC); PanicAlert("DSPHLE: Unknown ucode (CRC = %08x) - forcing AX.\n\nTry LLE plugin if this is homebrew.", _CRC);
return new CUCode_AX(_rMailHandler); return new CUCode_AX(dsp_hle);
} }
} }
@ -181,6 +180,6 @@ void IUCode::PrepareBootUCode(u32 mail)
"Trying to boot new ucode with dram upload - not implemented"); "Trying to boot new ucode with dram upload - not implemented");
} }
CDSPHandler::GetInstance().SwapUCode(ector_crc); m_DSPHLE->SwapUCode(ector_crc);
} }
} }

View File

@ -22,6 +22,8 @@
#include "ChunkFile.h" #include "ChunkFile.h"
#include "Thread.h" #include "Thread.h"
#include "../DSPHLE.h"
#define UCODE_ROM 0x0000000 #define UCODE_ROM 0x0000000
#define UCODE_INIT_AUDIO_SYSTEM 0x0000001 #define UCODE_INIT_AUDIO_SYSTEM 0x0000001
@ -30,12 +32,13 @@ class CMailHandler;
class IUCode class IUCode
{ {
public: public:
IUCode(CMailHandler& _rMailHandler) IUCode(DSPHLE *dsphle)
: m_rMailHandler(_rMailHandler) : m_rMailHandler(dsphle->AccessMailHandler())
, m_UploadSetupInProgress(false) , m_UploadSetupInProgress(false)
, m_NextUCode() , m_NextUCode()
, m_NextUCode_steps(0) , m_NextUCode_steps(0)
, m_NeedsResumeMail(false) , m_NeedsResumeMail(false)
, m_DSPHLE(dsphle)
{} {}
virtual ~IUCode() virtual ~IUCode()
@ -74,6 +77,9 @@ protected:
// UCode only needs to set this to true, IUCode will set to false when done! // UCode only needs to set this to true, IUCode will set to false when done!
bool m_UploadSetupInProgress; bool m_UploadSetupInProgress;
// Need a pointer back to DSPHLE to switch ucodes.
DSPHLE *m_DSPHLE;
private: private:
struct SUCode struct SUCode
{ {
@ -94,6 +100,6 @@ private:
bool m_NeedsResumeMail; bool m_NeedsResumeMail;
}; };
extern IUCode* UCodeFactory(u32 _CRC, CMailHandler& _rMailHandler, bool bWii); extern IUCode* UCodeFactory(u32 _CRC, DSPHLE *dsp_hle, bool bWii);
#endif #endif