Skip to content

Commit

Permalink
Added LD (a8), A opcode (0xE0)
Browse files Browse the repository at this point in the history
  • Loading branch information
velllu committed Sep 6, 2023
1 parent 0b464e6 commit edbbfb0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub(crate) mod bus {
pub(crate) const EOM_SIZE: usize = 160;
pub(crate) const HIGH_RAM_SIZE: usize = 127;
pub(crate) const IO_SIZE: usize = 128;
pub(crate) const IO_START: usize = 0xFF00;
pub(crate) const ROM_SIZE: usize = 32768;
pub(crate) const VIDEO_RAM_SIZE: usize = 8192;
pub(crate) const WORK_RAM_SIZE: usize = 8192;
Expand Down
9 changes: 9 additions & 0 deletions src/cpu.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::common::{merge_two_u8s_into_u16, Operator};
use crate::consts::bus::IO_START;
use crate::registers::OneByteRegister;
use crate::GameBoy;

Expand Down Expand Up @@ -63,6 +64,11 @@ impl GameBoy {
let register = self.registers.get_r(register);
*register = i;
}

pub(crate) fn load_i_into_io(&mut self, register: OneByteRegister) {
let register = *self.registers.get_r(register);
self.bus.write_byte((IO_START + self.next(1) as usize) as u16, register);
}
}

// Bitwise operation functions (not all of them as of now)
Expand Down Expand Up @@ -221,6 +227,9 @@ impl GameBoy {
(1, 2)
},

// Load R into IO (yes, only one of this)
0xE0 => { self.load_i_into_io(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 edbbfb0

Please sign in to comment.