fn sub_and_set_flags(cpu: &mut Cpu, x: u8, y: u8) -> u8 {
    // Check for borrow using 32bit arithmetics
    let x = x as u32;
    let y = y as u32;

    let r = x.wrapping_sub(y);

    let rb = r as u8;

    cpu.set_zero(rb == 0);
    cpu.set_halfcarry((x ^ y ^ r) & 0x10 != 0);
    cpu.set_carry(r & 0x100 != 0);
    cpu.set_substract(true);

    rb
}
/// Helper function to substract two `u8`s and update the CPU flags
Helper function to substract two `u8`s and update the CPU flags
Helper function to substract two ` u8 ` s and update the CPU flags
fn sub_and_set_flags(cpu: &mut Cpu, x: u8, y: u8) -> u8 {
    // Check for borrow using 32bit arithmetics
    let x = x as u32;
    let y = y as u32;
    let r = x.wrapping_sub(y);
    let rb = r as u8;
    cpu.set_zero(rb == 0);
    cpu.set_halfcarry((x ^ y ^ r) & 0x10 != 0);
    cpu.set_carry(r & 0x100 != 0);
    cpu.set_substract(true);
    rb
}
fn sub_and_set_flags ( cpu : & mut Cpu , x : u8 , y : u8 ) -> u8 { // Check for borrow using 32bit arithmetics let x = x as u32 ; let y = y as u32 ; let r = x . wrapping_sub ( y ) ; let rb = r as u8 ; cpu . set_zero ( rb == 0 ) ; cpu . set_halfcarry ( ( x ^ y ^ r ) & 0x10 != 0 ) ; cpu . set_carry ( r & 0x100 != 0 ) ; cpu . set_substract ( true ) ; rb }
Helper function to substract two `u8`s and update the CPU flags
Helper function to substract two ` u8 ` s and update the CPU flags
cpu
&mut Cpu
x
u8
y
u8
cpu
&mut Cpu
x
u8
y
u8