From 9736dc789584260e88179e5868a944b45d00ac6c Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 19 Sep 2020 21:21:29 +1000 Subject: [PATCH] CPU: Fix InterpretUncachedBlock() But this shouldn't be hit during normal execution. --- src/core/cpu_core.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/core/cpu_core.cpp b/src/core/cpu_core.cpp index cb92a8799..b4947af09 100644 --- a/src/core/cpu_core.cpp +++ b/src/core/cpu_core.cpp @@ -1461,7 +1461,8 @@ template void InterpretCachedBlock(const CodeBlock& block); void InterpretUncachedBlock() { - Panic("Fixme with regards to re-fetching PC"); + g_state.regs.npc = g_state.regs.pc; + FetchInstruction(); // At this point, pc contains the last address executed (in the previous block). The instruction has not been fetched // yet. pc shouldn't be updated until the fetch occurs, that way the exception occurs in the delay slot. @@ -1480,8 +1481,15 @@ void InterpretUncachedBlock() g_state.exception_raised = false; // Fetch the next instruction, except if we're in a branch delay slot. The "fetch" is done in the next block. - if (!FetchInstruction()) - break; + if (!g_state.current_instruction_in_branch_delay_slot) + { + if (!FetchInstruction()) + break; + } + else + { + g_state.regs.pc = g_state.regs.npc; + } // execute the instruction we previously fetched ExecuteInstruction();