Skip to content

Commit

Permalink
Start opcode tedium
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Nov 14, 2023
1 parent 4e07010 commit 38fb16b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 11 deletions.
30 changes: 30 additions & 0 deletions src/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,34 @@ impl CPU {
reg: Registers::new(mode)
}
}

pub fn call(&mut self, opcode: u8) {
match opcode {
0x06 => self.reg.b = 0,
0x0e => self.reg.c = 0,
0x16 => self.reg.d = 0,
0x1e => self.reg.e = 0,
0x26 => self.reg.h = 0,
0x2e => self.reg.l = 0,
0x36 => {},
0x3e => {},
0x02 => {},
0x12 => {},
0x0a => {},
0x1a => {},
0x22 => {},
0x32 => {},
0x2a => {},
0x3a => {},
0x40 => {},
0x41 => self.reg.b = self.reg.c,
0x42 => self.reg.b = self.reg.d,
0x43 => self.reg.b = self.reg.e,
0x44 => self.reg.b = self.reg.h,
0x45 => self.reg.b = self.reg.l,
0x46 => {},
0x47 => self.reg.b = self.reg.a,
_ => {},
}
}
}
26 changes: 15 additions & 11 deletions src/registers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,28 @@ use bitflags::{bitflags};
use crate::mode::GBMode;

pub struct Registers {
a: u8,
pub a: u8,
f: Flags,
b: u8,
c: u8,
d: u8,
e: u8,
h: u8,
l: u8,
pub b: u8,
pub c: u8,
pub d: u8,
pub e: u8,
pub h: u8,
pub l: u8,
pc: u16,
sp: u16,
}

bitflags! {
pub struct Flags: u8 {
const C = 0b00010000;
const H = 0b00100000;
const N = 0b01000000;
const Z = 0b10000000;
// Carry Flag
const C = 0b0001_0000;
// Half-Carry Flag
const H = 0b0010_0000;
// Subtract Flag
const N = 0b0100_0000;
// Zero Flag
const Z = 0b1000_0000;
}
}

Expand Down

0 comments on commit 38fb16b

Please sign in to comment.