diff --git a/src/cpu.rs b/src/cpu.rs index 160d07bb6185fe5db0acc4d4993c67b375f08e68..ae088c047edab8c2c3722806fb85b00dc8ac1dfd 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -77,8 +77,8 @@ impl Cpu { println!("GOING TO PLAY BOOT SOUND"); } - if pc == 0x00e0 { - println!("GOING TO PLAY BOOT 0x00e0"); + if pc == 0x00e9 { + println!("GOING TO PLAY BOOT 0x00ef"); } // calls the current instruction and increments the number of diff --git a/src/inst.rs b/src/inst.rs index 1e72237747b2e763e5f16f2a44b663377e2868e1..49746b9044686fd9cb0949db948b4701c21d9688 100644 --- a/src/inst.rs +++ b/src/inst.rs @@ -129,12 +129,12 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [ (noimpl, 4, "! UNIMP !"), (noimpl, 4, "! UNIMP !"), (ld_mhl_a, 8, "LD [HL], A"), - (noimpl, 4, "! UNIMP !"), + (ld_a_b, 4, "LD A, B"), (noimpl, 4, "! UNIMP !"), (noimpl, 4, "! UNIMP !"), (ld_a_e, 4, "LD A, E"), (ld_a_h, 4, "LD A, H"), - (noimpl, 4, "! UNIMP !"), + (ld_a_l, 4, "LD A, L"), (noimpl, 4, "! UNIMP !"), (noimpl, 4, "! UNIMP !"), // 0x8 opcodes @@ -203,7 +203,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [ (noimpl, 4, "! UNIMP !"), (noimpl, 4, "! UNIMP !"), (noimpl, 4, "! UNIMP !"), - (noimpl, 4, "! UNIMP !"), + (cp_a_mhl, 8, "CP A, [HL]"), (noimpl, 4, "! UNIMP !"), // 0xc opcodes (ret_nz, 8, "RET NZ"), @@ -717,6 +717,10 @@ fn ld_mhl_a(cpu: &mut Cpu) { cpu.mmu.write(cpu.hl(), cpu.a); } +fn ld_a_b(cpu: &mut Cpu) { + cpu.a = cpu.b; +} + fn ld_a_e(cpu: &mut Cpu) { cpu.a = cpu.e; } @@ -725,6 +729,10 @@ fn ld_a_h(cpu: &mut Cpu) { cpu.a = cpu.h; } +fn ld_a_l(cpu: &mut Cpu) { + cpu.a = cpu.l; +} + fn sub_a_b(cpu: &mut Cpu) { cpu.a = sub_set_flags(cpu, cpu.a, cpu.b); } @@ -738,6 +746,11 @@ fn xor_a_a(cpu: &mut Cpu) { cpu.set_carry(false); } +fn cp_a_mhl(cpu: &mut Cpu) { + let byte = cpu.mmu.read(cpu.hl()); + sub_set_flags(cpu, cpu.a, byte); +} + fn ret_nz(cpu: &mut Cpu) { if cpu.get_zero() { return;