diff --git a/Source/Core/DSPCore/Src/DSPCore.cpp b/Source/Core/DSPCore/Src/DSPCore.cpp index 308df2038b..f65996ac46 100644 --- a/Source/Core/DSPCore/Src/DSPCore.cpp +++ b/Source/Core/DSPCore/Src/DSPCore.cpp @@ -41,6 +41,7 @@ DSPCoreState core_state = DSPCORE_STOP; u16 cyclesLeft = 0; DSPEmitter *jit = NULL; Common::Event step_event; +Common::CriticalSection ExtIntCriticalSection; static bool LoadRom(const char *fname, int size_in_words, u16 *rom) { @@ -192,9 +193,11 @@ void DSPCore_SetException(u8 level) } // Notify that an external interrupt is pending (used by thread mode) -void DSPCore_SetExternalInterrupt() +void DSPCore_SetExternalInterrupt(bool val) { - g_dsp.external_interrupt_waiting = true; + ExtIntCriticalSection.Enter(); + g_dsp.external_interrupt_waiting = val; + ExtIntCriticalSection.Leave(); } // Coming from the CPU @@ -255,7 +258,7 @@ int DSPCore_RunCycles(int cycles) { DSPCore_CheckExternalInterrupt(); DSPCore_CheckExceptions(); - g_dsp.external_interrupt_waiting = false; + DSPCore_SetExternalInterrupt(false); } return cyclesLeft; diff --git a/Source/Core/DSPCore/Src/DSPCore.h b/Source/Core/DSPCore/Src/DSPCore.h index 20fcbc0ee2..9204237d35 100644 --- a/Source/Core/DSPCore/Src/DSPCore.h +++ b/Source/Core/DSPCore/Src/DSPCore.h @@ -278,7 +278,7 @@ void DSPCore_Shutdown(); // Frees all allocated memory. void DSPCore_CheckExternalInterrupt(); void DSPCore_CheckExceptions(); -void DSPCore_SetExternalInterrupt(); +void DSPCore_SetExternalInterrupt(bool val); // sets a flag in the pending exception register. void DSPCore_SetException(u8 level); diff --git a/Source/Core/DSPCore/Src/DSPInterpreter.cpp b/Source/Core/DSPCore/Src/DSPInterpreter.cpp index b64d54135f..56e1834b9f 100644 --- a/Source/Core/DSPCore/Src/DSPInterpreter.cpp +++ b/Source/Core/DSPCore/Src/DSPInterpreter.cpp @@ -156,7 +156,7 @@ int RunCyclesDebug(int cycles) { DSPCore_CheckExternalInterrupt(); DSPCore_CheckExceptions(); - g_dsp.external_interrupt_waiting = false; + DSPCore_SetExternalInterrupt(false); } while (true) @@ -220,7 +220,7 @@ int RunCycles(int cycles) { DSPCore_CheckExternalInterrupt(); DSPCore_CheckExceptions(); - g_dsp.external_interrupt_waiting = false; + DSPCore_SetExternalInterrupt(false); } while (true) diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp index e42d0dbb42..034fcead10 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp @@ -321,8 +321,16 @@ u16 DSP_WriteControlRegister(u16 _uFlag) // and immediately process it, if it has. if (_uFlag & 2) { - DSPCore_CheckExternalInterrupt(); - DSPCore_CheckExceptions(); + if (!g_dspInitialize.bOnThread) + { + DSPCore_CheckExternalInterrupt(); + DSPCore_CheckExceptions(); + } + else + { + DSPCore_SetExternalInterrupt(true); + } + } return DSPInterpreter::ReadCR();