From a8f6904ec773a99f38aa170d8e29faeb6f07bb2a Mon Sep 17 00:00:00 2001 From: Marko Pusljar Date: Wed, 4 Aug 2010 16:50:52 +0000 Subject: [PATCH] dsphle - improved ax/axwii hle ucode switching (needed for Nintendo Puzzle Collection <-> GBA, ...) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6052 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp | 28 ++++++++------- .../Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp | 35 ++++++++++--------- 2 files changed, 34 insertions(+), 29 deletions(-) diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp index c4d5dd2fac..b56316c0a2 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX.cpp @@ -211,14 +211,10 @@ void CUCode_AX::MixAdd(short* _pBuffer, int _iSize) // Handle incoming mail void CUCode_AX::HandleMail(u32 _uMail) { - static s8 newucodemails = -1; - - if (newucodemails > -1) { - newucodemails++; - if (newucodemails == 10) { - newucodemails = -1; - m_rMailHandler.PushMail(DSP_RESUME); - } + if (m_UploadSetupInProgress) + { + PrepareBootUCode(_uMail); + return; } else { if ((_uMail & 0xFFFF0000) == MAIL_AX_ALIST) @@ -232,13 +228,16 @@ void CUCode_AX::HandleMail(u32 _uMail) } else if (_uMail == 0xCDD10001) // Action 1 - new ucode upload ( GC: BayBlade S.T.B,...) { - NOTICE_LOG(DSPHLE,"DSP IROM - New Ucode!"); - newucodemails = 0; + DEBUG_LOG(DSPHLE,"DSP IROM - New Ucode!"); + // TODO find a better way to protect from HLEMixer? + soundStream->GetMixer()->SetHLEReady(false); + m_UploadSetupInProgress = true; } else if (_uMail == 0xCDD10002) // Action 2 - IROM_Reset(); ( GC: NFS Carbon, FF Crystal Chronicles,...) { - NOTICE_LOG(DSPHLE,"DSP IROM - Reset!"); + DEBUG_LOG(DSPHLE,"DSP IROM - Reset!"); CDSPHandler::GetInstance().SetUCode(UCODE_ROM); + return; } else if (_uMail == 0xCDD10003) // Action 3 - AX_GetNextCmdBlock(); { @@ -256,8 +255,13 @@ void CUCode_AX::HandleMail(u32 _uMail) // Update with DSP Interrupt void CUCode_AX::Update(int cycles) { + if (NeedsResumeMail()) + { + m_rMailHandler.PushMail(DSP_RESUME); + g_dspInitialize.pGenerateDSPInterrupt(); + } // check if we have to send something - if (!m_rMailHandler.IsEmpty()) + else if (!m_rMailHandler.IsEmpty()) { g_dspInitialize.pGenerateDSPInterrupt(); } diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp index e08ad88d43..e74459c825 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp @@ -51,14 +51,10 @@ CUCode_AXWii::~CUCode_AXWii() void CUCode_AXWii::HandleMail(u32 _uMail) { - static s8 newucodemails = -1; - - if (newucodemails > -1) { - newucodemails++; - if (newucodemails == 10) { - newucodemails = -1; - m_rMailHandler.PushMail(DSP_RESUME); - } + if (m_UploadSetupInProgress) + { + PrepareBootUCode(_uMail); + return; } else if ((_uMail & 0xFFFF0000) == MAIL_AX_ALIST) { @@ -72,24 +68,24 @@ void CUCode_AXWii::HandleMail(u32 _uMail) break; case 0xCDD10001: // Action 1 - new ucode upload - NOTICE_LOG(DSPHLE,"DSP IROM - New Ucode!"); - newucodemails = 0; + DEBUG_LOG(DSPHLE,"DSP IROM - New Ucode!"); + // TODO find a better way to protect from HLEMixer? + soundStream->GetMixer()->SetHLEReady(false); + m_UploadSetupInProgress = true; break; case 0xCDD10002: // Action 2 - IROM_Reset(); ( WII: De Blob, Cursed Mountain,...) - NOTICE_LOG(DSPHLE,"DSP IROM - Reset!"); + DEBUG_LOG(DSPHLE,"DSP IROM - Reset!"); CDSPHandler::GetInstance().SetUCode(UCODE_ROM); - break; + return; case 0xCDD10003: // Action 3 - AX_GetNextCmdBlock() - //TODO: Implement?? break; default: - { DEBUG_LOG(DSPHLE, " >>>> u32 MAIL : AXTask Mail (%08x)", _uMail); AXTask(_uMail); - } + break; } } @@ -147,8 +143,13 @@ void CUCode_AXWii::MixAdd(short* _pBuffer, int _iSize) void CUCode_AXWii::Update(int cycles) { - // check if we have to sent something - if (!m_rMailHandler.IsEmpty()) + if (NeedsResumeMail()) + { + m_rMailHandler.PushMail(DSP_RESUME); + g_dspInitialize.pGenerateDSPInterrupt(); + } + // check if we have to send something + else if (!m_rMailHandler.IsEmpty()) { g_dspInitialize.pGenerateDSPInterrupt(); }