From 1ba8a15cf8db5166beb764edf0b0c8f24ad390d2 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Thu, 30 Nov 2023 09:29:01 -0500 Subject: [PATCH] Actually call CBs --- src/cpu.rs | 8 +++++++- src/registers.rs | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cpu.rs b/src/cpu.rs index 39fb31e..2dd720b 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -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 }, @@ -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), } } diff --git a/src/registers.rs b/src/registers.rs index b87e099..0a18ad6 100644 --- a/src/registers.rs +++ b/src/registers.rs @@ -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! {