From 14bb53dcc693135ea44672b9683e0e6cbf1c9e88 Mon Sep 17 00:00:00 2001 From: "XTra.KrazzY" Date: Thu, 18 Mar 2010 06:20:52 +0000 Subject: [PATCH] DSPLLE: Run the threaded mode a bit differently and with respect to idle loops. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5212 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DSPCore/Src/DSPInterpreter.cpp | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/Source/Core/DSPCore/Src/DSPInterpreter.cpp b/Source/Core/DSPCore/Src/DSPInterpreter.cpp index 03ae912adc..5a892fc954 100644 --- a/Source/Core/DSPCore/Src/DSPInterpreter.cpp +++ b/Source/Core/DSPCore/Src/DSPInterpreter.cpp @@ -101,18 +101,23 @@ void Step() // Used by thread mode. void Run() { + int checkInterrupt = 0; gdsp_running = true; - while (!(g_dsp.cr & CR_HALT)) - { - // Are we running? - if (DSPHost_Running() && !DSPHost_OnThread()) - break; + while (!(g_dsp.cr & CR_HALT) && gdsp_running) + { + // Automatically let the other threads work if we're idle skipping + if(DSPAnalyzer::code_flags[g_dsp.pc] & DSPAnalyzer::CODE_IDLE_SKIP) + Common::YieldCPU(); - // This number (500) is completely arbitrary. TODO: tweak. - RunCycles(500); + Step(); - if (!gdsp_running) - break; + // Turns out the less you check for external interrupts, the more + // sound you hear, and it becomes slower + checkInterrupt++; + if(checkInterrupt == 500) { // <-- A completely arbitrary number. TODO: tweak + DSPCore_CheckExternalInterrupt(); + checkInterrupt = 0; + } } gdsp_running = false; } @@ -184,6 +189,8 @@ int RunCycles(int cycles) return 0; Step(); cycles--; + if (cycles < 0) + return 0; } DSPCore_CheckExternalInterrupt(); @@ -198,6 +205,8 @@ int RunCycles(int cycles) return 0; Step(); cycles--; + if (cycles < 0) + return 0; } // Now, run the rest of the block without idle skipping. It might trip into