From 2c6d3429b778eae1d619f428762ab5633140d7f8 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 26 Dec 2022 16:14:05 +1030 Subject: [PATCH] Core: Fix handling of BGEZAL ra in recompiler --- .../N64System/Recompiler/x86/x86RecompilerOps.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp index 6ac189099..1059e6296 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp @@ -759,6 +759,20 @@ void CX86RecompilerOps::Compile_Branch(RecompilerBranchCompare CompareType, bool ResetX86Protection(); m_Section->m_Cont.RegSet = m_RegWorkingSet; m_Section->m_Jump.RegSet = m_RegWorkingSet; + if (m_Section->m_Cont.LinkAddress != (uint32_t)-1) + { + m_Section->m_Cont.RegSet.UnMap_GPR(31, false); + m_Section->m_Cont.RegSet.SetMipsRegLo(31, m_Section->m_Cont.LinkAddress); + m_Section->m_Cont.RegSet.SetMipsRegState(31, CRegInfo::STATE_CONST_32_SIGN); + m_Section->m_Cont.LinkAddress = (uint32_t)-1; + } + if (m_Section->m_Jump.LinkAddress != (uint32_t)-1) + { + m_Section->m_Jump.RegSet.UnMap_GPR(31, false); + m_Section->m_Jump.RegSet.SetMipsRegLo(31, m_Section->m_Jump.LinkAddress); + m_Section->m_Jump.RegSet.SetMipsRegState(31, CRegInfo::STATE_CONST_32_SIGN); + m_Section->m_Jump.LinkAddress = (uint32_t)-1; + } } else { @@ -9305,7 +9319,6 @@ void CX86RecompilerOps::OverflowDelaySlot(bool TestTimer) } m_Assembler.MoveConstToVariable(&g_System->m_PipelineStage, "System->m_PipelineStage", PIPELINE_STAGE_JUMP); - if (TestTimer) { m_Assembler.MoveConstToVariable(&R4300iOp::m_TestTimer, "R4300iOp::m_TestTimer", TestTimer);