diff --git a/src/gameboy/cpu.rs b/src/gameboy/cpu.rs index 212cf82..8cbf6a3 100644 --- a/src/gameboy/cpu.rs +++ b/src/gameboy/cpu.rs @@ -207,6 +207,13 @@ pub fn tick_cpu(state: &mut Gameboy) { 0x6d => load_store_move::ld_l_l, 0x6e => load_store_move::ld_l_deref_hl, 0x6f => load_store_move::ld_l_a, + 0x70 => load_store_move::ld_deref_hl_b, + 0x71 => load_store_move::ld_deref_hl_c, + 0x72 => load_store_move::ld_deref_hl_d, + 0x73 => load_store_move::ld_deref_hl_e, + 0x74 => load_store_move::ld_deref_hl_h, + 0x75 => load_store_move::ld_deref_hl_l, + 0x77 => load_store_move::ld_deref_hl_a, 0x78 => load_store_move::ld_a_b, 0x79 => load_store_move::ld_a_c, 0x7a => load_store_move::ld_a_d, diff --git a/src/gameboy/cpu/load_store_move.rs b/src/gameboy/cpu/load_store_move.rs index e2d3120..956f1cb 100644 --- a/src/gameboy/cpu/load_store_move.rs +++ b/src/gameboy/cpu/load_store_move.rs @@ -380,3 +380,29 @@ pub fn ld_deref_imm_u16_a(state: &mut Gameboy) -> CycleResult { _ => unreachable!(), } } + +macro_rules! define_ld_reg_imm_u8 { + ($lreg:ident) => { + paste::paste! { + pub fn [](state: &mut Gameboy) -> CycleResult { + match state.registers.cycle { + 0 => { + state.cpu_write_u8(state.registers.get_hl(), state.registers.$lreg); + state.registers.opcode_bytecount = Some(1); + CycleResult::NeedsMore + }, + 1 => CycleResult::Finished, + _ => unreachable!(), + } + } + } + }; +} + +define_ld_reg_imm_u8!(b); +define_ld_reg_imm_u8!(c); +define_ld_reg_imm_u8!(d); +define_ld_reg_imm_u8!(e); +define_ld_reg_imm_u8!(h); +define_ld_reg_imm_u8!(l); +define_ld_reg_imm_u8!(a);