diff --git a/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp b/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp index d7c585e5f1..0f4072c99d 100644 --- a/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp +++ b/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp @@ -14,18 +14,6 @@ #include #include -#if (defined(_MSC_VER) && (_MSC_VER < 1800)) -double trunc(double num) -{ - return (num < 0) ? ceil(num) : floor(num); -} - -float truncf(float num) -{ - return (num < 0) ? ceilf(num) : floorf(num); -} -#endif - bool R4300iOp::m_TestTimer = false; R4300iOpcode R4300iOp::m_Opcode; diff --git a/Source/Project64-core/N64System/Mips/Register.cpp b/Source/Project64-core/N64System/Mips/Register.cpp index 9ea6560445..c60e988d0f 100644 --- a/Source/Project64-core/N64System/Mips/Register.cpp +++ b/Source/Project64-core/N64System/Mips/Register.cpp @@ -709,7 +709,6 @@ void CRegisters::TriggerException(uint32_t ExceptionCode, uint32_t Coprocessor) CAUSE_REGISTER.BranchDelay = m_System->m_PipelineStage == PIPELINE_STAGE_JUMP; EPC_REGISTER = (int64_t)((int32_t)m_PROGRAM_COUNTER - (CAUSE_REGISTER.BranchDelay ? 4 : 0)); STATUS_REGISTER |= STATUS_EXL; - m_PROGRAM_COUNTER = 0x80000180; m_System->m_PipelineStage = PIPELINE_STAGE_JUMP; - m_System->m_JumpToLocation = (*_PROGRAM_COUNTER); + m_System->m_JumpToLocation = 0x80000180; } diff --git a/Source/Project64-core/N64System/Mips/SystemEvents.cpp b/Source/Project64-core/N64System/Mips/SystemEvents.cpp index 70b9ff1aa8..2161fbf369 100644 --- a/Source/Project64-core/N64System/Mips/SystemEvents.cpp +++ b/Source/Project64-core/N64System/Mips/SystemEvents.cpp @@ -114,7 +114,11 @@ void CSystemEvents::ExecuteEvents() m_System->Reset(true, true); break; case SysEvent_ExecuteInterrupt: - g_Reg->DoIntrException(); + if (g_Reg->DoIntrException()) + { + g_Reg->m_PROGRAM_COUNTER = m_System->JumpToLocation(); + m_System->m_PipelineStage = PIPELINE_STAGE_NORMAL; + } break; case SysEvent_Interrupt_SP: g_Reg->MI_INTR_REG |= MI_INTR_SP; diff --git a/Source/Project64-core/N64System/N64System.h b/Source/Project64-core/N64System/N64System.h index 62e7861e22..f4b5981d2a 100644 --- a/Source/Project64-core/N64System/N64System.h +++ b/Source/Project64-core/N64System/N64System.h @@ -146,6 +146,7 @@ class CN64System : friend class CInterpreterCPU; friend class R4300iOp32; friend class R4300iOp; + friend class CSystemEvents; friend class VideoInterfaceHandler; friend class PifRamHandler; diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp index 7fdcf83bf3..5fa749e69c 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp @@ -9476,6 +9476,9 @@ void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo m_Assembler.push(0); m_Assembler.PushImm32("EXC_SYSCALL", EXC_SYSCALL); m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::TriggerException), "CRegisters::TriggerException", 12); + m_Assembler.MoveVariableToX86reg(asmjit::x86::edx, &g_System->m_JumpToLocation, "System->m_JumpToLocation"); + m_Assembler.MoveX86regToVariable(&g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER", asmjit::x86::edx); + m_Assembler.MoveConstToVariable(&g_System->m_PipelineStage, "g_System->m_PipelineStage", PIPELINE_STAGE_NORMAL); ExitCodeBlock(); break; case ExitReason_Break: @@ -9483,6 +9486,9 @@ void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo m_Assembler.push(0); m_Assembler.PushImm32("EXC_BREAK", EXC_BREAK); m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::TriggerException), "CRegisters::TriggerException", 12); + m_Assembler.MoveVariableToX86reg(asmjit::x86::edx, &g_System->m_JumpToLocation, "System->m_JumpToLocation"); + m_Assembler.MoveX86regToVariable(&g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER", asmjit::x86::edx); + m_Assembler.MoveConstToVariable(&g_System->m_PipelineStage, "g_System->m_PipelineStage", PIPELINE_STAGE_NORMAL); ExitCodeBlock(); break; case ExitReason_COP1Unuseable: @@ -9490,6 +9496,9 @@ void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo m_Assembler.push(1); m_Assembler.PushImm32("EXC_CPU", EXC_CPU); m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::TriggerException), "CRegisters::TriggerException", 12); + m_Assembler.MoveVariableToX86reg(asmjit::x86::edx, &g_System->m_JumpToLocation, "System->m_JumpToLocation"); + m_Assembler.MoveX86regToVariable(&g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER", asmjit::x86::edx); + m_Assembler.MoveConstToVariable(&g_System->m_PipelineStage, "g_System->m_PipelineStage", PIPELINE_STAGE_NORMAL); ExitCodeBlock(); break; case ExitReason_ResetRecompCode: @@ -9512,6 +9521,9 @@ void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo m_Assembler.push(0); m_Assembler.PushImm32("EXC_OV", EXC_OV); m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::TriggerException), "CRegisters::TriggerException", 12); + m_Assembler.MoveVariableToX86reg(asmjit::x86::edx, &g_System->m_JumpToLocation, "System->m_JumpToLocation"); + m_Assembler.MoveX86regToVariable(&g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER", asmjit::x86::edx); + m_Assembler.MoveConstToVariable(&g_System->m_PipelineStage, "g_System->m_PipelineStage", PIPELINE_STAGE_NORMAL); ExitCodeBlock(); break; case ExitReason_AddressErrorExceptionRead32: @@ -9540,6 +9552,9 @@ void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo m_Assembler.push(0); m_Assembler.PushImm32("EXC_II", EXC_II); m_Assembler.CallThis((uint32_t)g_Reg, AddressOf(&CRegisters::TriggerException), "CRegisters::TriggerException", 12); + m_Assembler.MoveVariableToX86reg(asmjit::x86::edx, &g_System->m_JumpToLocation, "System->m_JumpToLocation"); + m_Assembler.MoveX86regToVariable(&g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER", asmjit::x86::edx); + m_Assembler.MoveConstToVariable(&g_System->m_PipelineStage, "g_System->m_PipelineStage", PIPELINE_STAGE_NORMAL); ExitCodeBlock(); break; default: