Skip to content

Commit

Permalink
OPRI
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Feb 2, 2024
1 parent 0f398bd commit 7e2e645
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/components/ppu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub struct PPU {
vram: [u8; 0x4000],
vram_bank: usize,
oam: [u8; 0xA0],
opri: bool,
bgprio: [Priority; SCREEN_W],
pub interrupts: Interrupts,
pub frame_buffer: Vec<u8>,
Expand Down Expand Up @@ -155,6 +156,7 @@ impl PPU {
vram: [0; 0x4000],
vram_bank: 0,
oam: [0; 0xA0],
opri: true,
bgprio: [Priority::Normal; SCREEN_W],
interrupts: Interrupts::empty(),
frame_buffer: vec![0x00; 4 * SCREEN_W * SCREEN_H],
Expand Down Expand Up @@ -445,6 +447,7 @@ impl PPU {
continue;
}

// TODO: Respect OPRI
if previous_px == px {
if previous_address < sprite_address {
continue;
Expand Down Expand Up @@ -533,7 +536,7 @@ impl Memory for PPU {
match a {
0x8000..=0x9FFF => {
if self.ppu_mode != PPUMode::Draw {
self.vram[self.vram_bank * 0x2000 + a as usize - 0x8000]
self.vram[(self.vram_bank * 0x2000) + a as usize - 0x8000]
} else {
0xFF
}
Expand Down Expand Up @@ -588,8 +591,7 @@ impl Memory for PPU {
a | b
}
}
// TODO: Object Priority Mode
0xFF6C => 0x00,
0xFF6C => self.opri,
_ => panic!("Read to unsupported PPU address ({:#06x})!", a),
}
}
Expand All @@ -598,7 +600,7 @@ impl Memory for PPU {
match a {
0x8000..=0x9FFF => {
if self.ppu_mode != PPUMode::Draw {
self.vram[self.vram_bank * 0x2000 + a as usize - 0x8000] = v
self.vram[(self.vram_bank * 0x2000) + a as usize - 0x8000] = v
}
}
0xFE00..=0xFE9F => {
Expand Down Expand Up @@ -672,7 +674,7 @@ impl Memory for PPU {
}
}
// TODO: Object Priority Mode
0xFF6C => {}
0xFF6C => self.opri = v != 0,
_ => panic!("Write to unsupported PPU address ({:#06x})!", a),
}
}
Expand Down

0 comments on commit 7e2e645

Please sign in to comment.