Fixed exceptions not setting the correct branch delay value.

master
Nabile Rahmani 2018-06-09 18:10:39 +02:00
parent eb41337dce
commit c15c1d0b18
2 changed files with 4 additions and 2 deletions

View File

@ -32,7 +32,7 @@
if (!cpu.CP0.Status.EXL)
{
if (cpu.CP0.Cause.BD = cpu.DelaySlot.HasValue) // FIXME: Step() nullifies the delay slot before executing it.
if ((cpu.CP0.Cause.BD = cpu.branchDelay))
cpu.CP0.Registers[(int)SystemControlUnit.RegisterIndex.EPC] = cpu.PC - Instruction.Size;
else
cpu.CP0.Registers[(int)SystemControlUnit.RegisterIndex.EPC] = cpu.PC;

View File

@ -11,6 +11,7 @@ namespace DotN64.CPU
public partial class VR4300
{
#region Fields
private bool branchDelay;
private readonly IReadOnlyDictionary<Instruction, Action<Instruction>> operations;
private readonly IReadOnlyDictionary<byte, float> divModeMultipliers = new Dictionary<byte, float>
{
@ -253,8 +254,9 @@ namespace DotN64.CPU
private void Step()
{
Instruction instruction;
branchDelay = DelaySlot.HasValue;
if (!DelaySlot.HasValue)
if (!branchDelay)
{
instruction = ReadWord(PC);
PC += Instruction.Size;