From f69184b88722cd65364937611a481860f7f7f3c0 Mon Sep 17 00:00:00 2001 From: ayuanx Date: Fri, 27 Nov 2009 17:39:37 +0000 Subject: [PATCH] This should fix the No Sound Problem in GC & Non-AX games. Besides, this should also fix the WAD game loading issue. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4617 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/HW/DSP.cpp | 21 +++++++++++++++---- .../Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp | 2 ++ .../Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp | 2 +- .../Src/UCodes/UCode_AX_Voice.h | 20 +++++++++++------- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Source/Core/Core/Src/HW/DSP.cpp b/Source/Core/Core/Src/HW/DSP.cpp index 46cff2980f..6a686c63bc 100644 --- a/Source/Core/Core/Src/HW/DSP.cpp +++ b/Source/Core/Core/Src/HW/DSP.cpp @@ -408,12 +408,20 @@ void Write16(const u16 _Value, const u32 _Address) break; case AUDIO_DMA_CONTROL_LEN: // called by AIStartDMA() + { + UAudioDMAControl old_control = g_audioDMA.AudioDMAControl; g_audioDMA.AudioDMAControl.Hex = _Value; - g_audioDMA.BlocksLeft = g_audioDMA.AudioDMAControl.NumBlocks; - g_audioDMA.ReadAddress = g_audioDMA.SourceAddress; - INFO_LOG(DSPINTERFACE, "AID DMA started - source address %08x, length %i blocks", g_audioDMA.SourceAddress, g_audioDMA.AudioDMAControl.NumBlocks); - break; + if (!old_control.Enabled && g_audioDMA.AudioDMAControl.Enabled) + { + // Enabled bit was flipped to true, let's latch address & length and call the interrupt. + g_audioDMA.BlocksLeft = g_audioDMA.AudioDMAControl.NumBlocks; + g_audioDMA.ReadAddress = g_audioDMA.SourceAddress; + GenerateDSPInterrupt(DSP::INT_AID); + INFO_LOG(DSPINTERFACE, "AID DMA started - source address %08x, length %i blocks", g_audioDMA.SourceAddress, g_audioDMA.AudioDMAControl.NumBlocks); + } + break; + } case AUDIO_DMA_BYTES_LEFT: _dbg_assert_(DSPINTERFACE,0); break; @@ -438,6 +446,11 @@ void UpdateAudioDMA() g_audioDMA.ReadAddress += 32; g_audioDMA.BlocksLeft--; if (!g_audioDMA.BlocksLeft) { + // No need to turn off the DMA - we can only get here if we had + // blocks left when we entered this function, and no longer have + // any. Latch new parameters + g_audioDMA.BlocksLeft = g_audioDMA.AudioDMAControl.NumBlocks; + g_audioDMA.ReadAddress = g_audioDMA.SourceAddress; // DEBUG_LOG(DSPLLE, "ADMA read addresses: %08x", g_audioDMA.ReadAddress); GenerateDSPInterrupt(DSP::INT_AID); } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp index d821e675f7..af88f933fb 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp @@ -115,6 +115,8 @@ bool CWII_IPC_HLE_Device_es::Open(u32 _CommandAddress, u32 _Mode) bool CWII_IPC_HLE_Device_es::Close(u32 _CommandAddress) { + // Leave deletion of the INANDContentLoader objects to CNANDContentManager, don't do it here! + m_NANDContent.clear(); INFO_LOG(WII_IPC_ES, "ES: Close"); Memory::Write_U32(0, _CommandAddress + 4); m_Active = false; 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 370edd8a04..c59ddec414 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AXWii.cpp @@ -184,7 +184,7 @@ void CUCode_AXWii::MixAdd_(short* _pBuffer, int _iSize, ParamBlockType &PB) if (!ReadOutPBWii(blockAddr, PB)) break; ProcessUpdates(PB); - MixAddVoice(PB, templbuffer, temprbuffer, _iSize, true); + MixAddVoice(PB, templbuffer, temprbuffer, _iSize, true, _CRC); if (!WriteBackPBWii(blockAddr, PB)) break; diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX_Voice.h b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX_Voice.h index e247f1db33..6d43b4d8e2 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX_Voice.h +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_AX_Voice.h @@ -82,7 +82,7 @@ inline bool WriteBackPBWii(u32 pb_address, ParamBlockType& PB) } template -inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer, int _iSize, bool Wii) +inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer, int _iSize, bool Wii, u32 CRC = 0) { ratioFactor = 32000.0f / (float)soundStream->GetMixer()->GetSampleRate(); @@ -249,12 +249,18 @@ inline void MixAddVoice(ParamBlockType &pb, int *templbuffer, int *temprbuffer, // New Super Mario Bros.Wii, Fatal Frame 4, // Resident Evil Darkside Chronicles, Muramasa The Demon Blade, etc. samplePos = newSamplePos - sampleEnd + loopPos; - - // AyuanX: DSP should not touch this running state - // even when a non-looping voice reaches the end of current sample - // because some game checks this flag and will turn it off when necessary - // - //pb.running = 0; + + if (Wii && (CRC == 0xfa450138)) + { + // Some Wii games check this flag and will turn it off when necessary + // If that is the case, DSP should not touch it + // + //pb.running = 0; + } + else + { + pb.running = 0; + } break; }