Skip to content

Commit

Permalink
BGP, OP0, OP1
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Dec 11, 2023
1 parent 5e57fbb commit 2471618
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ pub struct GPU {
sy: u8,
sx: u8,
ly: u8,
lyc: u8,
lc: u8,
wy: u8,
wx: u8,
bgp: u8,
op0: u8,
op1: u8,
lcdc: LCDC,
lcds: LCDS,
ram: [u8; 0x4000],
Expand Down Expand Up @@ -60,12 +63,15 @@ impl GPU {
pub fn new(mode: GBMode) -> Self {
Self {
mode,
sy: 0,
sx: 0,
ly: 0,
lyc: 0,
wy: 0,
wx: 0,
sy: 0x00,
sx: 0x00,
ly: 0x00,
lc: 0x00,
wy: 0x00,
wx: 0x00,
bgp: 0x00,
op0: 0x00,
op1: 0x01,
lcdc: LCDC::empty(),
lcds: LCDS::empty(),
ram: [0; 0x4000],
Expand Down Expand Up @@ -124,7 +130,10 @@ impl GPU {
0xFF42 => self.sy,
0xFF43 => self.sx,
0xFF44 => self.ly,
0xFF45 => self.lyc,
0xFF45 => self.lc,
0xFF47 => self.bgp,
0xFF48 => self.op0,
0xFF49 => self.op1,
0xFF4A => self.wy,
0xFF4B => self.wx,
0xFF4F => 0xFE | self.ram_bank as u8,
Expand All @@ -142,7 +151,10 @@ impl GPU {
0xFF42 => self.sy = v,
0xFF43 => self.sx = v,
0xFF44 => print!("Attempted to write to LY!"),
0xFF45 => self.lyc = v,
0xFF45 => self.lc = v,
0xFF47 => self.bgp = v,
0xFF48 => self.op0 = v,
0xFF49 => self.op1 = v,
0xFF4A => self.wy = v,
0xFF4B => self.wx = v,
0xFF4F => self.ram_bank = (v & 0x01) as usize,
Expand Down

0 comments on commit 2471618

Please sign in to comment.