diff --git a/README.md b/README.md index aa5c427..7fc135d 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ No issues so far Won't boot unless binary patched to remove a loop querying the flash chip ### Dragon Ball - Legacy of Goku 2 -crashes when entering in-game menu, other than that works fine. +~~crashes when entering in-game menu, other than that works fine.~~ ## Screenshots diff --git a/src/core/arm7tdmi/alu.rs b/src/core/arm7tdmi/alu.rs index 67d7e13..09677d8 100644 --- a/src/core/arm7tdmi/alu.rs +++ b/src/core/arm7tdmi/alu.rs @@ -47,7 +47,7 @@ impl AluOpCode { } } -#[derive(Debug, PartialEq, Primitive)] +#[derive(Debug, PartialEq, Primitive, Copy, Clone)] pub enum BarrelShiftOpCode { LSL = 0, LSR = 1, @@ -55,13 +55,13 @@ pub enum BarrelShiftOpCode { ROR = 3, } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Copy, Clone)] pub enum ShiftRegisterBy { ByAmount(u32), ByRegister(usize), } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Copy, Clone)] pub struct ShiftedRegister { pub reg: usize, pub shift_by: ShiftRegisterBy, @@ -69,7 +69,16 @@ pub struct ShiftedRegister { pub added: Option, } -#[derive(Debug, PartialEq)] +impl ShiftedRegister { + pub fn is_shifted_by_reg(&self) -> bool { + match self.shift_by { + ShiftRegisterBy::ByRegister(_) => true, + _ => false + } + } +} + +#[derive(Debug, PartialEq, Copy, Clone)] pub enum BarrelShifterValue { ImmediateValue(u32), RotatedImmediate(u32, u32), diff --git a/src/core/arm7tdmi/arm/exec.rs b/src/core/arm7tdmi/arm/exec.rs index baca483..729053d 100644 --- a/src/core/arm7tdmi/arm/exec.rs +++ b/src/core/arm7tdmi/arm/exec.rs @@ -183,8 +183,8 @@ impl Core { let op2 = insn.operand2()?; match op2 { - BarrelShifterValue::ShiftedRegister(_) => { - if insn.rn() == REG_PC { + BarrelShifterValue::ShiftedRegister(shifted_reg) => { + if insn.rn() == REG_PC && shifted_reg.is_shifted_by_reg() { op1 += 4; } }