diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index 734d966781..3182d248f8 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -74,6 +74,7 @@ set(SRCS Src/ActionReplay.cpp Src/HW/DSPHLE/UCodes/UCode_AXWii.cpp Src/HW/DSPHLE/UCodes/UCode_CARD.cpp Src/HW/DSPHLE/UCodes/UCode_InitAudioSystem.cpp + Src/HW/DSPHLE/UCodes/UCode_NewAX.cpp Src/HW/DSPHLE/UCodes/UCode_ROM.cpp Src/HW/DSPHLE/UCodes/UCodes.cpp Src/HW/DSPHLE/UCodes/UCode_GBA.cpp diff --git a/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_NewAX.cpp b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_NewAX.cpp new file mode 100644 index 0000000000..28ef93a9bb --- /dev/null +++ b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_NewAX.cpp @@ -0,0 +1,106 @@ +// 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 Git repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#include "UCode_NewAX.h" +#include "../../DSP.h" + +CUCode_NewAX::CUCode_NewAX(DSPHLE* dsp_hle, u32 crc) + : IUCode(dsp_hle, crc) +{ + m_rMailHandler.PushMail(DSP_INIT); + DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP); +} + +CUCode_NewAX::~CUCode_NewAX() +{ + m_rMailHandler.Clear(); +} + +void CUCode_NewAX::HandleCommandList(u32 addr) +{ + // Signal end of processing + m_rMailHandler.PushMail(DSP_YIELD); + DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP); +} + +void CUCode_NewAX::HandleMail(u32 mail) +{ + // Indicates if the next message is a command list address. + static bool next_is_cmdlist = false; + bool set_next_is_cmdlist = false; + + if (next_is_cmdlist) + { + HandleCommandList(mail); + } + else if (m_UploadSetupInProgress) + { + PrepareBootUCode(mail); + } + else if (mail == MAIL_RESUME) + { + // Acknowledge the resume request + m_rMailHandler.PushMail(DSP_RESUME); + DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP); + } + else if (mail == MAIL_NEWUCODE) + { + soundStream->GetMixer()->SetHLEReady(false); + m_UploadSetupInProgress = true; + } + else if (mail == MAIL_RESET) + { + m_DSPHLE->SetUCode(UCODE_ROM); + } + else if (mail == MAIL_CONTINUE) + { + // We don't have to do anything here - the CPU does not wait for a ACK + // and sends a cmdlist mail just after. + } + else if ((mail & MAIL_CMDLIST_MASK) == MAIL_CMDLIST) + { + // A command list address is going to be sent next. + set_next_is_cmdlist = true; + } + else + { + ERROR_LOG(DSPHLE, "Unknown mail sent to AX::HandleMail: %08x", mail); + } + + next_is_cmdlist = set_next_is_cmdlist; +} + +void CUCode_NewAX::MixAdd(short* out_buffer, int nsamples) +{ + // nsamples * 2 for left and right audio channel + memset(out_buffer, 0, nsamples * 2 * sizeof (short)); +} + +void CUCode_NewAX::Update(int cycles) +{ + // Used for UCode switching. + if (NeedsResumeMail()) + { + m_rMailHandler.PushMail(DSP_RESUME); + DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP); + } +} + +void CUCode_NewAX::DoState(PointerWrap& p) +{ + DoStateShared(p); +} diff --git a/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_NewAX.h b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_NewAX.h new file mode 100644 index 0000000000..769f58d9d1 --- /dev/null +++ b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_NewAX.h @@ -0,0 +1,51 @@ +// 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 Git repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#ifndef _UCODE_NEWAX_H +#define _UCODE_NEWAX_H + +#include "UCodes.h" +#include "UCode_AXStructs.h" + +class CUCode_NewAX : public IUCode +{ +public: + CUCode_NewAX(DSPHLE* dsp_hle, u32 crc); + virtual ~CUCode_NewAX(); + + void HandleMail(u32 mail); + void MixAdd(short* out_buffer, int nsamples); + void Update(int cycles); + void DoState(PointerWrap& p); + +private: + enum MailType + { + MAIL_RESUME = 0xCDD10000, + MAIL_NEWUCODE = 0xCDD10001, + MAIL_RESET = 0xCDD10002, + MAIL_CONTINUE = 0xCDD10003, + + // CPU sends 0xBABE0000 | cmdlist_size to the DSP + MAIL_CMDLIST = 0xBABE0000, + MAIL_CMDLIST_MASK = 0xFFFF0000 + }; + + void HandleCommandList(u32 addr); +}; + +#endif // !_UCODE_NEWAX_H diff --git a/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCodes.cpp b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCodes.cpp index c04bf41403..58e6198205 100644 --- a/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCodes.cpp +++ b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCodes.cpp @@ -19,6 +19,7 @@ #include "UCode_AX.h" #include "UCode_AXWii.h" +#include "UCode_NewAX.h" #include "UCode_Zelda.h" #include "UCode_ROM.h" #include "UCode_CARD.h" @@ -57,7 +58,7 @@ IUCode* UCodeFactory(u32 _CRC, DSPHLE *dsp_hle, bool bWii) case 0xe2136399: // billy hatcher, dragonballz, mario party 5, TMNT, ava1080 case 0x3389a79e: // MP1/MP2 Wii (Metroid Prime Trilogy) INFO_LOG(DSPHLE, "CRC %08x: AX ucode chosen", _CRC); - return new CUCode_AX(dsp_hle, _CRC); + return new CUCode_NewAX(dsp_hle, _CRC); case 0x6ba3b3ea: // IPL - PAL case 0x24b22038: // IPL - NTSC/NTSC-JAP