fix(ppu): add fifo delay when BG fifo is not empty

This commit is contained in:
Rekai Nyangadzayi Musuka 2021-07-14 21:11:31 -05:00
parent ab99e24f64
commit 1566d60fd4
1 changed files with 16 additions and 11 deletions

View File

@ -369,14 +369,15 @@ impl Ppu {
}
SendToFifoTwo => {
let palette = &self.monochrome.bg_palette;
self.fetch.send_to_fifo(&mut self.fifo, palette);
self.fetch.x_pos += 1;
if let Ok(()) = self.fetch.send_to_fifo(&mut self.fifo, palette) {
self.fetch.x_pos += 1;
self.fetch.back.next(TileNumber);
self.fetch.back.tile = Default::default();
}
}
}
}
if self.fifo.is_enabled() {
use RenderPriority::*;
@ -720,7 +721,11 @@ impl PixelFetcher {
tile_data_addr + (offset * 2)
}
fn send_to_fifo(&self, fifo: &mut FifoRenderer, palette: &BackgroundPalette) {
fn send_to_fifo(&self, fifo: &mut FifoRenderer, palette: &BackgroundPalette) -> Result<(), ()> {
if !fifo.back.is_empty() {
return Err(());
}
let (high, low) = self
.back
.tile
@ -729,14 +734,14 @@ impl PixelFetcher {
let tbpp = Pixels::from_bytes(high, low);
if fifo.back.is_empty() {
for x in 0..Pixels::PIXEL_COUNT {
let shade = palette.shade(tbpp.shade_id(x));
let fifo_info = BackgroundFifoInfo { shade };
fifo.back.push_back(fifo_info);
}
}
Ok(())
}
fn get_obj_addr(attr: &ObjectAttribute, pos: &ScreenPosition, size: ObjectSize) -> u16 {