Skip to content

Commit

Permalink
Added LD A, (a8) opcode (0xF0)
Browse files Browse the repository at this point in the history
  • Loading branch information
velllu committed Sep 6, 2023
1 parent d681161 commit f31ad33
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Cycles = u8;
// r -> one byte register
// rr -> two byte register
// ii -> the two bytes of immediate data
// ii -> the first byte of immediate data
// i -> the first byte of immediate data

// INC/DEC function
impl GameBoy {
Expand Down Expand Up @@ -69,6 +69,13 @@ impl GameBoy {
let register = *self.registers.get_r(register);
self.bus.write_byte((IO_START + self.next(1) as usize) as u16, register);
}

pub(crate) fn load_io_into_r(&mut self, register: OneByteRegister) {
let i = self.next(1);

let register = self.registers.get_r(register);
*register = self.bus.read((IO_START + i as usize) as u16)
}
}

// Bitwise operation functions (not all of them as of now)
Expand Down Expand Up @@ -230,6 +237,9 @@ impl GameBoy {
// Load R into IO (yes, only one of this)
0xE0 => { self.load_r_into_io(OneByteRegister::A); (2, 3) },

// Load IO into R (still only one of this)
0xF0 => { self.load_io_into_r(OneByteRegister::A); (2, 3) },

// Jump
// When we jump, we set 0 bytes, because if we returned the "correct" amount
// of bytes, the program will add them to PC after the jump
Expand Down

0 comments on commit f31ad33

Please sign in to comment.