diff --git a/Source/Core/Core/Src/PowerPC/Jit64/Jit_SystemRegisters.cpp b/Source/Core/Core/Src/PowerPC/Jit64/Jit_SystemRegisters.cpp index defcf3d73d..d988d8c799 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/Jit_SystemRegisters.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/Jit_SystemRegisters.cpp @@ -28,6 +28,7 @@ #include "Jit.h" #include "JitRegCache.h" +#include "HW/ProcessorInterface.h" void Jit64::mtspr(UGeckoInstruction inst) { @@ -126,19 +127,23 @@ void Jit64::mtmsr(UGeckoInstruction inst) // If some exceptions are pending and EE are now enabled, force checking // external exceptions when going out of mtmsr in order to execute delayed // interrupts as soon as possible. - MOV(32, R(EAX), M(&MSR)); - TEST(32, R(EAX), Imm32(0x8000)); + TEST(32, M(&MSR), Imm32(0x8000)); FixupBranch eeDisabled = J_CC(CC_Z); - MOV(32, R(EAX), M((void*)&PowerPC::ppcState.Exceptions)); - TEST(32, R(EAX), Imm32(EXCEPTION_EXTERNAL_INT | EXCEPTION_PERFORMANCE_MONITOR | EXCEPTION_DECREMENTER)); + TEST(32, M((void*)&PowerPC::ppcState.Exceptions), Imm32(EXCEPTION_EXTERNAL_INT | EXCEPTION_PERFORMANCE_MONITOR | EXCEPTION_DECREMENTER)); FixupBranch noExceptionsPending = J_CC(CC_Z); + // Check if a CP interrupt is waiting and keep the GPU emulation in sync (issue 4336) + TEST(32, M((void *)&ProcessorInterface::m_InterruptCause), Imm32(ProcessorInterface::INT_CAUSE_CP)); + FixupBranch cpInt = J_CC(CC_NZ); + MOV(32, M(&PC), Imm32(js.compilerPC + 4)); WriteExternalExceptionExit(); - SetJumpTarget(eeDisabled); + SetJumpTarget(cpInt); SetJumpTarget(noExceptionsPending); + SetJumpTarget(eeDisabled); + WriteExit(js.compilerPC + 4, 0); js.firstFPInstructionFound = false;