diff --git a/src/inst.rs b/src/inst.rs index eff4bf48c860c5e414acac65b72ad046ced4c017..f5b6cb94b9e1ea9e483c0537a27a6fcf6df41ba0 100644 --- a/src/inst.rs +++ b/src/inst.rs @@ -1473,7 +1473,7 @@ fn swap(cpu: &mut Cpu, value: u8) -> u8 { /// Helper function to shift an `u8` to the left and update CPU /// flags. -fn sla(cpu: &mut Cpu, value: u8) -> u8 { +fn sla(cpu: &mut Cpu, value: u8) -> u8 { let result = value << 1; cpu.set_sub(false); diff --git a/src/ppu.rs b/src/ppu.rs index 06598cb7002d4ce38fd210596ea3887cac0d358b..c3b7667a8687816f55deef48fdd24de92304e25d 100644 --- a/src/ppu.rs +++ b/src/ppu.rs @@ -16,6 +16,10 @@ pub const DISPLAY_HEIGHT: usize = 144; // The size of the RGB frame buffer in bytes. pub const FRAME_BUFFER_SIZE: usize = DISPLAY_WIDTH * DISPLAY_HEIGHT * RGB_SIZE; +// Defines the Game Boy pixel type as a buffer +// with the size of RGB (3 bytes). +pub type Pixel = [u8; RGB_SIZE]; + /// Represents the Game Boy PPU (Pixel Processing Unit) and controls /// all of the logic behind the graphics processing and presentation. /// Should store both the VRAM and HRAM together with the internal @@ -42,11 +46,11 @@ pub struct Ppu { tiles: [[[u8; 8]; 8]; TILE_COUNT], /// The palette of colors that is currently loaded in Game Boy /// and used for background (tiles). - palette: [[u8; RGB_SIZE]; PALETTE_SIZE], + palette: [Pixel; PALETTE_SIZE], // The palette that is going to be used for sprites/objects #0. - palette_obj_0: [[u8; RGB_SIZE]; PALETTE_SIZE], + palette_obj_0: [Pixel; PALETTE_SIZE], // The palette that is going to be used for sprites/objects #1. - palette_obj_1: [[u8; RGB_SIZE]; PALETTE_SIZE], + palette_obj_1: [Pixel; PALETTE_SIZE], /// The scroll Y register that controls the Y offset /// of the background. scy: u8, @@ -353,7 +357,7 @@ impl Ppu { } } - pub fn fill_frame_buffer(&mut self, color: [u8; RGB_SIZE]) { + pub fn fill_frame_buffer(&mut self, color: Pixel) { for index in (0..self.frame_buffer.len()).step_by(RGB_SIZE) { self.frame_buffer[index] = color[0]; self.frame_buffer[index + 1] = color[1];