fix(ppu): DMA takes priority over OAM Scan

This commit is contained in:
Rekai Nyangadzayi Musuka 2021-06-12 13:40:55 -05:00
parent 0c22509d24
commit daeb02f7c9
1 changed files with 24 additions and 21 deletions

View File

@ -192,28 +192,31 @@ impl Ppu {
} }
fn scan_oam(&mut self) { fn scan_oam(&mut self) {
if self.scan_state.mode() == OamScanMode::Scan { match self.scan_state.mode() {
if !self.window_stat.coincidence() && self.scan_state.count() == 0 { OamScanMode::Scan if !self.dma.is_active() => {
// Determine whether we should draw the window next frame if !self.window_stat.coincidence() && self.scan_state.count() == 0 {
self.window_stat // Determine whether we should draw the window next frame
.set_coincidence(self.pos.line_y == self.pos.window_y); self.window_stat
.set_coincidence(self.pos.line_y == self.pos.window_y);
}
let sprite_height = self.ctrl.obj_size().as_u8();
let index = self.scan_state.count();
let attr = self.oam.attribute(index as usize);
let line_y = self.pos.line_y + 16;
if attr.x > 0
&& line_y >= attr.y
&& line_y < (attr.y + sprite_height)
&& !self.obj_buffer.is_full()
{
self.obj_buffer.add(attr);
}
self.scan_state.increase();
} }
_ => {}
let sprite_height = self.ctrl.obj_size().as_u8();
let index = self.scan_state.count();
let attr = self.oam.attribute(index as usize);
let line_y = self.pos.line_y + 16;
if attr.x > 0
&& line_y >= attr.y
&& line_y < (attr.y + sprite_height)
&& !self.obj_buffer.is_full()
{
self.obj_buffer.add(attr);
}
self.scan_state.increase();
} }
self.scan_state.next(); self.scan_state.next();