From 48abc975052d5bb18abcbe64456e6b7a11b3de9f Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Sat, 8 May 2021 14:06:41 -0500 Subject: [PATCH] chore(ppu): add bytes() method to Pixels --- src/ppu.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/ppu.rs b/src/ppu.rs index 60f0dbd..c8bbd11 100644 --- a/src/ppu.rs +++ b/src/ppu.rs @@ -245,12 +245,12 @@ impl Ppu { ToFifoSleep => self.fetcher.obj.next(SendToFifoOne), SendToFifoOne => { // Load into Fifo - let maybe_low = self.fetcher.obj.tile.low; - let maybe_high = self.fetcher.obj.tile.high; - - let (low, high) = maybe_low - .zip(maybe_high) - .expect("Low & High Bytes in TileBuilder were unexpectedly missing."); + let (high, low) = self + .fetcher + .obj + .tile + .bytes() + .expect("Failed to unwrap Tile bytes"); let tbpp = Pixels::from_bytes(high, low); @@ -707,12 +707,7 @@ impl PixelFetcher { } fn send_to_fifo(&self, fifo: &mut FifoRenderer, palette: &BackgroundPalette) { - let maybe_low = self.bg.tile.low; - 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 (high, low) = self.bg.tile.bytes().expect("Failed to unwrap Tile bytes"); let tbpp = Pixels::from_bytes(high, low); @@ -936,6 +931,10 @@ impl TileBuilder { pub fn with_high_byte(&mut self, data: u8) { self.high = Some(data); } + + pub fn bytes(&self) -> Option<(u8, u8)> { + self.high.zip(self.low) + } } #[derive(Debug, Clone, Copy, Default)]