chore(ppu): add bytes() method to Pixels
This commit is contained in:
parent
f7b2aa60a6
commit
48abc97505
23
src/ppu.rs
23
src/ppu.rs
|
@ -245,12 +245,12 @@ impl Ppu {
|
||||||
ToFifoSleep => self.fetcher.obj.next(SendToFifoOne),
|
ToFifoSleep => self.fetcher.obj.next(SendToFifoOne),
|
||||||
SendToFifoOne => {
|
SendToFifoOne => {
|
||||||
// Load into Fifo
|
// Load into Fifo
|
||||||
let maybe_low = self.fetcher.obj.tile.low;
|
let (high, low) = self
|
||||||
let maybe_high = self.fetcher.obj.tile.high;
|
.fetcher
|
||||||
|
.obj
|
||||||
let (low, high) = maybe_low
|
.tile
|
||||||
.zip(maybe_high)
|
.bytes()
|
||||||
.expect("Low & High Bytes in TileBuilder were unexpectedly missing.");
|
.expect("Failed to unwrap Tile bytes");
|
||||||
|
|
||||||
let tbpp = Pixels::from_bytes(high, low);
|
let tbpp = Pixels::from_bytes(high, low);
|
||||||
|
|
||||||
|
@ -707,12 +707,7 @@ impl PixelFetcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_to_fifo(&self, fifo: &mut FifoRenderer, palette: &BackgroundPalette) {
|
fn send_to_fifo(&self, fifo: &mut FifoRenderer, palette: &BackgroundPalette) {
|
||||||
let maybe_low = self.bg.tile.low;
|
let (high, low) = self.bg.tile.bytes().expect("Failed to unwrap Tile bytes");
|
||||||
let maybe_high = self.bg.tile.high;
|
|
||||||
|
|
||||||
let (low, high) = maybe_low
|
|
||||||
.zip(maybe_high)
|
|
||||||
.expect("Low & High Bytes in TileBuilder were unexpectedly missing.");
|
|
||||||
|
|
||||||
let tbpp = Pixels::from_bytes(high, low);
|
let tbpp = Pixels::from_bytes(high, low);
|
||||||
|
|
||||||
|
@ -936,6 +931,10 @@ impl TileBuilder {
|
||||||
pub fn with_high_byte(&mut self, data: u8) {
|
pub fn with_high_byte(&mut self, data: u8) {
|
||||||
self.high = Some(data);
|
self.high = Some(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn bytes(&self) -> Option<(u8, u8)> {
|
||||||
|
self.high.zip(self.low)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Default)]
|
#[derive(Debug, Clone, Copy, Default)]
|
||||||
|
|
Loading…
Reference in New Issue