Skip to content
Snippets Groups Projects
Verified Commit b1b7aaad authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

feat: more instructions

parent 96c51b90
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment