Skip to content

Commit

Permalink
Actually call CBs
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Nov 30, 2023
1 parent 76b6723 commit 1ba8a15
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ impl CPU {
}
}

pub fn read_byte(&mut self) -> u8 {
let byte = self.mem.read(self.reg.pc);
self.reg.pc += 1;
byte
}

pub fn call(&mut self, opcode: u8) -> u32 {
match opcode {
0x40 => { self.reg.b = self.reg.b; 1 },
Expand Down Expand Up @@ -104,7 +110,7 @@ impl CPU {
0x9D => { self.alu_sbc(self.reg.l); 1 },
0x9E => { self.alu_sbc(self.mem.read(self.reg.get_hl())); 2 },
0x9F => { self.alu_sbc(self.reg.a); 1 },
0xCB => { 0 }, // CB OPs
0xCB => { self.cb_call(self.read_byte()); 0 },
code => panic!("Instruction {:2X} is unknown!", code),
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/registers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ pub struct Registers {
pub e: u8,
pub h: u8,
pub l: u8,
pc: u16,
sp: u16,
pub pc: u16,
pub sp: u16,
}

bitflags! {
Expand Down

0 comments on commit 1ba8a15

Please sign in to comment.