From 06eea03d7dd35ade53ed2faffdc2e4d5e707c926 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 27 Jun 2024 16:34:19 +0930 Subject: [PATCH] RSP: DelaySlotAffectBranch should clamp PC --- .../Recompiler/RspRecompilerAnalysis.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Project64-rsp-core/Recompiler/RspRecompilerAnalysis.cpp b/Source/Project64-rsp-core/Recompiler/RspRecompilerAnalysis.cpp index c6302a6d8..2237b4260 100644 --- a/Source/Project64-rsp-core/Recompiler/RspRecompilerAnalysis.cpp +++ b/Source/Project64-rsp-core/Recompiler/RspRecompilerAnalysis.cpp @@ -1835,22 +1835,22 @@ Input: PC bool DelaySlotAffectBranch(uint32_t PC) { - RSPOpcode Branch, Delay; - OPCODE_INFO infoBranch, infoDelay; - - if (IsOpcodeNop(PC + 4) == true) + uint32_t DelayPC = (PC + 4) & 0xFFC; + if (IsOpcodeNop(DelayPC) == true) { return false; } - RSP_LW_IMEM(PC, &Branch.Value); - RSP_LW_IMEM(PC + 4, &Delay.Value); + RSPOpcode BranchOp, DelayOp; + RSP_LW_IMEM(PC, &BranchOp.Value); + RSP_LW_IMEM(DelayPC, &DelayOp.Value); + OPCODE_INFO infoBranch, infoDelay; memset(&infoDelay, 0, sizeof(infoDelay)); memset(&infoBranch, 0, sizeof(infoBranch)); - GetInstructionInfo(PC, &Branch, &infoBranch); - GetInstructionInfo(PC + 4, &Delay, &infoDelay); + GetInstructionInfo(PC, &BranchOp, &infoBranch); + GetInstructionInfo(DelayPC, &DelayOp, &infoDelay); if ((infoDelay.flags & COPO_MF_Instruction) == COPO_MF_Instruction) {