Skip to content

Commit

Permalink
Forced an exception check after an interrupt is generated by the DSP.…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
skidau committed Apr 7, 2013
1 parent 5336882 commit 52053f5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
1 change: 1 addition & 0 deletions Source/Core/Core/Src/HW/DSP.cpp
Expand Up @@ -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
Expand Down
23 changes: 8 additions & 15 deletions Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.cpp
Expand Up @@ -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);
}
}

Expand Down
2 changes: 0 additions & 2 deletions Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_Zelda.h
Expand Up @@ -275,8 +275,6 @@ class CUCode_Zelda : public IUCode
u32 m_PBAddress; // The main param block array
u32 m_PBAddress2; // 4 smaller param blocks

u32 m_cycles;

void ExecuteList();

u8 *GetARAMPointer(u32 address);
Expand Down
15 changes: 12 additions & 3 deletions Source/Core/Core/Src/HW/SystemTimers.cpp
Expand Up @@ -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
Expand All @@ -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);
Expand Down

0 comments on commit 52053f5

Please sign in to comment.