fn add_sp_sn(cpu: &mut Cpu) {
    let sp = cpu.sp() as i32;
    let n  = next_byte(cpu) as i8;

    let nn = n as i32;

    let r = sp.wrapping_add(nn);

    // Carry and halfcarry are for the low byte
    cpu.set_carry((sp ^ nn ^ r) & 0x100 != 0);
    cpu.set_halfcarry((sp ^ nn ^ r) & 0x10 != 0);
    cpu.set_sp(r as u16);

    cpu.set_substract(false);
    cpu.set_zero(false);

    cpu.delay(2);
}
/// Add signed 8bit immediate value to `SP`
Add signed 8bit immediate value to `SP`
Add signed 8bit immediate value to ` SP `
fn add_sp_sn(cpu: &mut Cpu) {
    let sp = cpu.sp() as i32;
    let n  = next_byte(cpu) as i8;
    let nn = n as i32;
    let r = sp.wrapping_add(nn);
    // Carry and halfcarry are for the low byte
    cpu.set_carry((sp ^ nn ^ r) & 0x100 != 0);
    cpu.set_halfcarry((sp ^ nn ^ r) & 0x10 != 0);
    cpu.set_sp(r as u16);
    cpu.set_substract(false);
    cpu.set_zero(false);
    cpu.delay(2);
}
fn add_sp_sn ( cpu : & mut Cpu ) { let sp = cpu . sp ( ) as i32 ; let n = next_byte ( cpu ) as i8 ; let nn = n as i32 ; let r = sp . wrapping_add ( nn ) ; // Carry and halfcarry are for the low byte cpu . set_carry ( ( sp ^ nn ^ r ) & 0x100 != 0 ) ; cpu . set_halfcarry ( ( sp ^ nn ^ r ) & 0x10 != 0 ) ; cpu . set_sp ( r as u16 ) ; cpu . set_substract ( false ) ; cpu . set_zero ( false ) ; cpu . delay ( 2 ) ; }
Add signed 8bit immediate value to `SP`
Add signed 8bit immediate value to ` SP `
cpu
&mut Cpu
cpu
&mut Cpu