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

feat: more instructions

parent aa38e1ec
No related branches found
No related tags found
No related merge requests found
Pipeline #891 passed
......@@ -81,24 +81,24 @@ fn main() {
// creates a new Game Boy instance and loads both the boot ROM
// and the initial game ROM to "start the engine"
let mut game_boy = GameBoy::new();
game_boy.load_boot_mgb_bootix();
game_boy.load_boot_dmg_bootix();
//game_boy.load_rom_file("../../res/roms.prop/tetris.gb");
//game_boy.load_rom_file("../../res/roms.prop/alleyway.gb");
//game_boy.load_rom_file("../../res/roms/firstwhite.gb");
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/special.gb");
//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"); // NO FINISH
//game_boy.load_rom_file("../../res/roms/paradius/cpu/03-op sp,hl.gb"); // NO FINISH
//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/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/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/09-op r,r.gb"); // NO FINISH
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/11-op a,(hl).gb"); // NO FINISH
'main: loop {
......
......@@ -220,7 +220,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
(ret_z, 8, "RET Z"),
(ret, 16, "RET"),
(jp_z_u16, 12, "JP Z, u16"),
(noimpl, 4, "! UNIMP !"),
(illegal, 4, "ILLEGAL"),
(call_z_u16, 12, "CALL Z, u16"),
(call_u16, 24, "CALL u16"),
(adc_a_u8, 8, "ADC A, u8 "),
......@@ -268,7 +268,7 @@ pub const INSTRUCTIONS: [(fn(&mut Cpu), u8, &'static str); 256] = [
(push_af, 16, "PUSH AF"),
(or_a_u8, 8, "OR A, u8"),
(rst_30h, 16, "RST 30h"),
(noimpl, 4, "! UNIMP !"),
(ld_hl_spi8, 12, "LD HL, SP+i8"),
(ld_sp_hl, 8, "LD SP, HL"),
(ld_a_mu16, 16, "LD A [u16]"),
(ei, 4, "EI"),
......@@ -2005,6 +2005,21 @@ fn rst_30h(cpu: &mut Cpu) {
rst(cpu, 0x0030);
}
fn ld_hl_spi8(cpu: &mut Cpu) {
let sp = cpu.sp as i32;
let byte = cpu.read_u8() as i8;
let byte_i32 = byte as i32;
let result = sp.wrapping_add(byte_i32);
cpu.set_sub(false);
cpu.set_zero(false);
cpu.set_half_carry((sp ^ byte_i32 ^ result) & 0x10 == 0x10);
cpu.set_carry((sp ^ byte_i32 ^ result) & 0x100 == 0x100);
cpu.set_hl(result as u16);
}
fn ld_sp_hl(cpu: &mut Cpu) {
cpu.sp = cpu.hl();
}
......
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