diff --git a/src/inst.rs b/src/inst.rs index 2ddc841298f3fd1b8d3cc90fb7ada1fb02cb0680..05c7735bd51eb4eb24d443a29220d6af92163409 100644 --- a/src/inst.rs +++ b/src/inst.rs @@ -231,7 +231,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [ (push_de, 16, "PUSH DE"), (sub_a_u8, 8, "SUB A, u8"), (noimpl, 4, "! UNIMP !"), - (noimpl, 4, "! UNIMP !"), + (ret_c, 8, "RET C"), (reti, 16, "RETI"), (jp_c_u16, 12, "JP C, u16"), (illegal, 4, "ILLEGAL"), @@ -1450,6 +1450,15 @@ fn sub_a_u8(cpu: &mut Cpu) { cpu.a = sub_set_flags(cpu, cpu.a, byte); } +fn ret_c(cpu: &mut Cpu) { + if !cpu.get_carry() { + return; + } + + cpu.pc = cpu.pop_word(); + cpu.ticks = cpu.ticks.wrapping_add(12); +} + fn reti(cpu: &mut Cpu) { cpu.pc = cpu.pop_word(); cpu.enable_int();