Fixed branching comparisons not being signed.

Previously, it would cause infinite looping when iterating a value downwards, as the code relied on underflow logic to eventually return true in comparisons. With unsigned numbers, that would never occur.

Specifically, some ROMs iterate the TLB index down and used a BGEZ opcode.
Nabile Rahmani 2018-11-21 17:11:12 +01:00
parent 84f14de487
commit 18c8b8d041
1 changed files with 2 additions and 2 deletions

View File

@ -20,7 +20,7 @@ namespace DotN64.CPU
[0b11] = 3.0f
private delegate bool BranchCondition(ulong rs, ulong rt);
private delegate bool BranchCondition(long rs, long rt);
#region Properties
@ -290,7 +290,7 @@ namespace DotN64.CPU
private bool Branch(Instruction instruction, BranchCondition condition)
var result = condition(GPR[instruction.RS], GPR[instruction.RT]);
var result = condition((long)GPR[instruction.RS], (long)GPR[instruction.RT]);
if (result)
Jump(PC + ((ulong)(short)instruction.Immediate << 2));