diff --git a/src/cpu.rs b/src/cpu.rs index 6f84a97..e0f1351 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -125,7 +125,7 @@ impl CPU { fn alu_add(&mut self, x: u8) { let a = self.reg.a; let r = a.wrapping_add(x); - self.reg.set_flag(Flags::C, u16::from(a) + u16::from(x) > u16::from(u8::max)); + self.reg.set_flag(Flags::C, u16::from(a) + u16::from(x) > u16::from(u8::MAX)); self.reg.set_flag(Flags::H, (a & 0x0F) + (a & 0x0F) > 0x0F); self.reg.set_flag(Flags::N, false); self.reg.set_flag(Flags::Z, r == 0x00); @@ -136,7 +136,7 @@ impl CPU { let a = self.reg.a; let c = u8::from(self.reg.get_flag(Flags::C)); let r = a.wrapping_add(x).wrapping_add(c); - self.reg.set_flag(Flags::C, u16::from(a) + u16::from(x) + u16::from(c) > u16::from(u8::max)); + self.reg.set_flag(Flags::C, u16::from(a) + u16::from(x) + u16::from(c) > u16::from(u8::MAX)); self.reg.set_flag(Flags::H, (a & 0x0F) + (a & 0x0F) + (c & 0x0F) > 0x0F); self.reg.set_flag(Flags::N, false); self.reg.set_flag(Flags::Z, r == 0x00);