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

feat: finished implementing instructions :muscle:

Fixed some of the extended instructions
parent 3410eab7
No related branches found
No related tags found
No related merge requests found
Pipeline #920 passed
...@@ -91,15 +91,16 @@ fn main() { ...@@ -91,15 +91,16 @@ fn main() {
//game_boy.load_rom_file("../../res/roms/opus5.gb"); //game_boy.load_rom_file("../../res/roms/opus5.gb");
//game_boy.load_rom_file("../../res/roms/paradius/cpu/01-special.gb"); // PASSED //game_boy.load_rom_file("../../res/roms/paradius/cpu/01-special.gb"); // PASSED
//game_boy.load_rom_file("../../res/roms/paradius/cpu/02-interrupts.gb"); // FAILED #2 game_boy.load_rom_file("../../res/roms/paradius/cpu/02-interrupts.gb");
//game_boy.load_rom_file("../../res/roms/paradius/cpu/03-op sp,hl.gb"); // PASSED //game_boy.load_rom_file("../../res/roms/paradius/cpu/03-op sp,hl.gb"); // PASSED
//game_boy.load_rom_file("../../res/roms/paradius/cpu/04-op r,imm.gb"); // PASSED //game_boy.load_rom_file("../../res/roms/paradius/cpu/04-op r,imm.gb"); // PASSED
//game_boy.load_rom_file("../../res/roms/paradius/cpu/05-op rp.gb"); // PASSED //game_boy.load_rom_file("../../res/roms/paradius/cpu/05-op rp.gb"); // PASSED
//game_boy.load_rom_file("../../res/roms/paradius/cpu/06-ld r,r.gb"); // PASSED //game_boy.load_rom_file("../../res/roms/paradius/cpu/06-ld r,r.gb"); // PASSED
//game_boy.load_rom_file("../../res/roms/paradius/cpu/07-jr,jp,call,ret,rst.gb"); // PASSED //game_boy.load_rom_file("../../res/roms/paradius/cpu/07-jr,jp,call,ret,rst.gb"); // PASSED
//game_boy.load_rom_file("../../res/roms/paradius/cpu/08-misc instrs.gb"); // PASSED //game_boy.load_rom_file("../../res/roms/paradius/cpu/08-misc instrs.gb"); // PASSED
game_boy.load_rom_file("../../res/roms/paradius/cpu/09-op r,r.gb"); // NO FINISH //game_boy.load_rom_file("../../res/roms/paradius/cpu/09-op r,r.gb"); // PASSED
//game_boy.load_rom_file("../../res/roms/paradius/cpu/11-op a,(hl).gb"); // NO FINISH //game_boy.load_rom_file("../../res/roms/paradius/cpu/10-bit ops.gb"); //
//game_boy.load_rom_file("../../res/roms/paradius/cpu/11-op a,(hl).gb"); // PASSED
let mut counter = 0u32; let mut counter = 0u32;
......
...@@ -331,22 +331,22 @@ pub const EXTENDED: [(fn(&mut Cpu), u8, &'static str); 256] = [ ...@@ -331,22 +331,22 @@ pub const EXTENDED: [(fn(&mut Cpu), u8, &'static str); 256] = [
(sra_mhl, 16, "SRA [HL]"), (sra_mhl, 16, "SRA [HL]"),
(sra_a, 8, "SRA A"), (sra_a, 8, "SRA A"),
// 0x3 opcodes // 0x3 opcodes
(noimpl, 4, "! UNIMP !"), (swap_b, 8, "SWAP B"),
(noimpl, 4, "! UNIMP !"), (swap_c, 8, "SWAP C"),
(noimpl, 4, "! UNIMP !"), (swap_d, 8, "SWAP D"),
(noimpl, 4, "! UNIMP !"), (swap_e, 8, "SWAP E"),
(noimpl, 4, "! UNIMP !"), (swap_h, 8, "SWAP H"),
(noimpl, 4, "! UNIMP !"), (swap_l, 8, "SWAP L"),
(noimpl, 4, "! UNIMP !"), (swap_mhl, 16, "SWAP [HL]"),
(swap_a, 8, "SWAP A"), (swap_a, 8, "SWAP A"),
(srl_b, 8, "SRL B"), (srl_b, 8, "SRL B"),
(noimpl, 4, "! UNIMP !"), (srl_c, 8, "SRL B"),
(noimpl, 4, "! UNIMP !"), (srl_d, 8, "SRL D"),
(noimpl, 4, "! UNIMP !"), (srl_e, 8, "SRL E"),
(noimpl, 4, "! UNIMP !"), (srl_h, 8, "SRL H"),
(noimpl, 4, "! UNIMP !"), (srl_l, 8, "SRL L"),
(noimpl, 4, "! UNIMP !"), (srl_mhl, 16, "SRL [HL]"),
(noimpl, 4, "! UNIMP !"), (srl_a, 8, "SRL A"),
// 0x4 opcodes // 0x4 opcodes
(bit_0_b, 8, "BIT 0, B"), (bit_0_b, 8, "BIT 0, B"),
(bit_0_c, 8, "BIT 0, C"), (bit_0_c, 8, "BIT 0, C"),
...@@ -2110,7 +2110,7 @@ fn rrc_mhl(cpu: &mut Cpu) { ...@@ -2110,7 +2110,7 @@ fn rrc_mhl(cpu: &mut Cpu) {
} }
fn rrc_a(cpu: &mut Cpu) { fn rrc_a(cpu: &mut Cpu) {
cpu.l = rrc(cpu, cpu.a); cpu.a = rrc(cpu, cpu.a);
} }
fn rl_b(cpu: &mut Cpu) { fn rl_b(cpu: &mut Cpu) {
...@@ -2180,7 +2180,7 @@ fn rr_mhl(cpu: &mut Cpu) { ...@@ -2180,7 +2180,7 @@ fn rr_mhl(cpu: &mut Cpu) {
} }
fn rr_a(cpu: &mut Cpu) { fn rr_a(cpu: &mut Cpu) {
cpu.l = rr(cpu, cpu.a); cpu.a = rr(cpu, cpu.a);
} }
fn sla_b(cpu: &mut Cpu) { fn sla_b(cpu: &mut Cpu) {
...@@ -2253,6 +2253,37 @@ fn sra_a(cpu: &mut Cpu) { ...@@ -2253,6 +2253,37 @@ fn sra_a(cpu: &mut Cpu) {
cpu.a = sra(cpu, cpu.a); cpu.a = sra(cpu, cpu.a);
} }
fn swap_b(cpu: &mut Cpu) {
cpu.b = swap(cpu, cpu.b)
}
fn swap_c(cpu: &mut Cpu) {
cpu.c = swap(cpu, cpu.c)
}
fn swap_d(cpu: &mut Cpu) {
cpu.d = swap(cpu, cpu.d)
}
fn swap_e(cpu: &mut Cpu) {
cpu.e = swap(cpu, cpu.e)
}
fn swap_h(cpu: &mut Cpu) {
cpu.h = swap(cpu, cpu.h)
}
fn swap_l(cpu: &mut Cpu) {
cpu.l = swap(cpu, cpu.l)
}
fn swap_mhl(cpu: &mut Cpu) {
let hl = cpu.hl();
let byte = cpu.mmu.read(hl);
let result = swap(cpu, byte);
cpu.mmu.write(hl, result);
}
fn swap_a(cpu: &mut Cpu) { fn swap_a(cpu: &mut Cpu) {
cpu.a = swap(cpu, cpu.a) cpu.a = swap(cpu, cpu.a)
} }
...@@ -2261,6 +2292,37 @@ fn srl_b(cpu: &mut Cpu) { ...@@ -2261,6 +2292,37 @@ fn srl_b(cpu: &mut Cpu) {
cpu.b = srl(cpu, cpu.b); cpu.b = srl(cpu, cpu.b);
} }
fn srl_c(cpu: &mut Cpu) {
cpu.c = srl(cpu, cpu.c);
}
fn srl_d(cpu: &mut Cpu) {
cpu.d = srl(cpu, cpu.d);
}
fn srl_e(cpu: &mut Cpu) {
cpu.e = srl(cpu, cpu.e);
}
fn srl_h(cpu: &mut Cpu) {
cpu.h = srl(cpu, cpu.h);
}
fn srl_l(cpu: &mut Cpu) {
cpu.l = srl(cpu, cpu.l);
}
fn srl_mhl(cpu: &mut Cpu) {
let hl = cpu.hl();
let byte = cpu.mmu.read(hl);
let result = srl(cpu, byte);
cpu.mmu.write(hl, result);
}
fn srl_a(cpu: &mut Cpu) {
cpu.a = srl(cpu, cpu.a);
}
fn bit_0_b(cpu: &mut Cpu) { fn bit_0_b(cpu: &mut Cpu) {
bit_b(cpu, 0); bit_b(cpu, 0);
} }
...@@ -3193,7 +3255,7 @@ fn bit_l(cpu: &mut Cpu, bit: u8) { ...@@ -3193,7 +3255,7 @@ fn bit_l(cpu: &mut Cpu, bit: u8) {
} }
fn bit_mhl(cpu: &mut Cpu, bit: u8) { fn bit_mhl(cpu: &mut Cpu, bit: u8) {
let byte = cpu.read_u8(); let byte = cpu.mmu.read(cpu.hl());
cpu.set_sub(false); cpu.set_sub(false);
cpu.set_zero(bit_zero(byte, bit)); cpu.set_zero(bit_zero(byte, bit));
cpu.set_half_carry(true); cpu.set_half_carry(true);
......
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