From 52053f5d958d9c9c7467858be3d2e07ef4e2bf19 Mon Sep 17 00:00:00 2001 From: skidau Date: Sun, 7 Apr 2013 16:27:46 +1000 Subject: [PATCH] Forced an exception check after an interrupt is generated by the DSP. Changed the timing back to 3ms/5ms periods, fixing the slowdown and garbled AX audio. Fixed Accurate VBeam emulation when DSP HLE audio is being used. --- Source/Core/Core/Src/HW/DSP.cpp | 1 + .../Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp | 23 +++++++------------ .../Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.h | 2 -- Source/Core/Core/Src/HW/SystemTimers.cpp | 15 +++++++++--- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Source/Core/Core/Src/HW/DSP.cpp b/Source/Core/Core/Src/HW/DSP.cpp index a24c8920af..a0c597326f 100644 --- a/Source/Core/Core/Src/HW/DSP.cpp +++ b/Source/Core/Core/Src/HW/DSP.cpp @@ -647,6 +647,7 @@ void GenerateDSPInterruptFromDSPEmu(DSPInterruptType type, bool _bSet) { CoreTiming::ScheduleEvent_Threadsafe( 0, et_GenerateDSPInterrupt, type | (_bSet<<16)); + CoreTiming::ForceExceptionCheck(100); } // called whenever SystemTimers thinks the dsp deserves a few more cycles diff --git a/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp index ba9f4ec222..9d392cd6b0 100644 --- a/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp +++ b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp @@ -112,23 +112,16 @@ u8 *CUCode_Zelda::GetARAMPointer(u32 address) void CUCode_Zelda::Update(int cycles) { - m_cycles += cycles; - - if (m_cycles >= 243000) + if (!IsLightVersion()) { - m_cycles = 0; - - if (!IsLightVersion()) - { - if (m_rMailHandler.GetNextMail() == DSP_FRAME_END) - DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP); - } - - if (NeedsResumeMail()) - { - m_rMailHandler.PushMail(DSP_RESUME); + if (m_rMailHandler.GetNextMail() == DSP_FRAME_END) DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP); - } + } + + if (NeedsResumeMail()) + { + m_rMailHandler.PushMail(DSP_RESUME); + DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP); } } diff --git a/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.h b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.h index d105d3dea9..94a5bcea3f 100644 --- a/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.h +++ b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.h @@ -275,8 +275,6 @@ private: u32 m_PBAddress; // The main param block array u32 m_PBAddress2; // 4 smaller param blocks - u32 m_cycles; - void ExecuteList(); u8 *GetARAMPointer(u32 address); diff --git a/Source/Core/Core/Src/HW/SystemTimers.cpp b/Source/Core/Core/Src/HW/SystemTimers.cpp index 5854f728cb..749ab584a1 100644 --- a/Source/Core/Core/Src/HW/SystemTimers.cpp +++ b/Source/Core/Core/Src/HW/SystemTimers.cpp @@ -243,6 +243,8 @@ void PreInit() void Init() { + const int fields = SConfig::GetInstance().m_LocalCoreStartupParameter.bVBeam ? 2 : 1; + if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii) { // AyuanX: TO BE TWEAKED @@ -251,12 +253,19 @@ void Init() // FYI, WII_IPC_HLE_Interface::Update is also called in WII_IPCInterface::Write32 const int freq = 1500; - const int fields = SConfig::GetInstance().m_LocalCoreStartupParameter. - bVBeam ? 2 : 1; IPC_HLE_PERIOD = GetTicksPerSecond() / (freq * fields); } - DSP_PERIOD = 12500; // TO BE TWEAKED (> 15000 breaks Lost Kingdom II) + if (DSP::GetDSPEmulator()->IsLLE()) + { + DSP_PERIOD = 12000; // TO BE TWEAKED + } + else + { + // AX HLE uses 3ms (Wii) or 5ms (GC) timing period + int ms_to_process = SConfig::GetInstance().m_LocalCoreStartupParameter.bWii ? 3 : 5; + DSP_PERIOD = (int)(GetTicksPerSecond() / 1000) * ms_to_process / fields; + } // System internal sample rate is fixed at 32KHz * 4 (16bit Stereo) / 32 bytes DMA AUDIO_DMA_PERIOD = CPU_CORE_CLOCK / (AudioInterface::GetAIDSampleRate() * 4 / 32);