chore(ppu): rename select structs

This commit is contained in:
Rekai Nyangadzayi Musuka 2021-04-30 00:24:22 -05:00
parent 6ffdd92dbb
commit 51252db753
2 changed files with 12 additions and 14 deletions

View File

@ -6,7 +6,7 @@ use std::convert::TryInto;
use registers::{ use registers::{
BackgroundPalette, GrayShade, LCDControl, LCDStatus, ObjectFlags, ObjectPalette, BackgroundPalette, GrayShade, LCDControl, LCDStatus, ObjectFlags, ObjectPalette,
ObjectPaletteId, PpuMode, RenderPriority, TileDataAddress, TwoBitsPerPixel, ObjectPaletteId, Pixel, PpuMode, RenderPriority, TileDataAddress,
}; };
mod registers; mod registers;
@ -249,7 +249,7 @@ impl Ppu {
.zip(maybe_high) .zip(maybe_high)
.expect("Low & High Bytes in TileBuilder were unexpectedly missing."); .expect("Low & High Bytes in TileBuilder were unexpectedly missing.");
let tbpp = TwoBitsPerPixel::from_bytes(high, low); let tbpp = Pixel::from_bytes(high, low);
let palette = match attr.flags.palette() { let palette = match attr.flags.palette() {
ObjectPaletteId::Zero => self.monochrome.obj_palette_0, ObjectPaletteId::Zero => self.monochrome.obj_palette_0,
@ -267,7 +267,7 @@ impl Ppu {
let priority = attr.flags.priority(); let priority = attr.flags.priority();
let shade = palette.shade(tbpp.shade_id(x)); let shade = palette.shade(tbpp.shade_id(x));
let fifo_info = ObjectFifoPixel { let fifo_info = ObjectFifoInfo {
shade, shade,
palette, palette,
priority, priority,
@ -679,14 +679,14 @@ impl PixelFetcher {
.zip(maybe_high) .zip(maybe_high)
.expect("Low & High Bytes in TileBuilder were unexpectedly missing."); .expect("Low & High Bytes in TileBuilder were unexpectedly missing.");
let tbpp = TwoBitsPerPixel::from_bytes(high, low); let tbpp = Pixel::from_bytes(high, low);
if fifo.background.is_empty() { if fifo.background.is_empty() {
for x in 0..8 { for x in 0..8 {
let shade = palette.shade(tbpp.shade_id(x)); let shade = palette.shade(tbpp.shade_id(x));
let fifo_pixel = BackgroundFifoPixel { shade }; let fifo_info = BackgroundFifoInfo { shade };
fifo.background.push_back(fifo_pixel); fifo.background.push_back(fifo_info);
} }
} }
@ -762,7 +762,6 @@ impl Default for BackgroundFetcher {
struct ObjectFetcher { struct ObjectFetcher {
state: FetcherState, state: FetcherState,
tile: TileBuilder, tile: TileBuilder,
fifo_count: u8,
enabled: bool, enabled: bool,
} }
@ -772,7 +771,6 @@ impl Fetcher for ObjectFetcher {
} }
fn reset(&mut self) { fn reset(&mut self) {
self.fifo_count = 0;
self.state = FetcherState::TileNumber; self.state = FetcherState::TileNumber;
} }
@ -838,12 +836,12 @@ impl Default for FetcherState {
} }
#[derive(Debug, Clone, Copy, Default)] #[derive(Debug, Clone, Copy, Default)]
struct BackgroundFifoPixel { struct BackgroundFifoInfo {
shade: GrayShade, shade: GrayShade,
} }
#[derive(Debug, Clone, Copy, Default)] #[derive(Debug, Clone, Copy, Default)]
struct ObjectFifoPixel { struct ObjectFifoInfo {
shade: Option<GrayShade>, shade: Option<GrayShade>,
palette: ObjectPalette, palette: ObjectPalette,
priority: RenderPriority, priority: RenderPriority,
@ -853,8 +851,8 @@ struct ObjectFifoPixel {
// really necessary here? // really necessary here?
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
struct FifoRenderer { struct FifoRenderer {
background: VecDeque<BackgroundFifoPixel>, background: VecDeque<BackgroundFifoInfo>,
object: VecDeque<ObjectFifoPixel>, object: VecDeque<ObjectFifoInfo>,
enabled: bool, enabled: bool,
} }

View File

@ -303,9 +303,9 @@ impl From<ObjectPalette> for u8 {
} }
} }
pub struct TwoBitsPerPixel(u8, u8); pub struct Pixel(u8, u8);
impl TwoBitsPerPixel { impl Pixel {
pub fn from_bytes(higher: u8, lower: u8) -> Self { pub fn from_bytes(higher: u8, lower: u8) -> Self {
Self(higher, lower) Self(higher, lower)
} }