diff --git a/src/components/mmu.rs b/src/components/mmu.rs index ac9d5cc..86e641d 100644 --- a/src/components/mmu.rs +++ b/src/components/mmu.rs @@ -18,7 +18,7 @@ pub struct MMU { intf: Interrupts, inte: Interrupts, wram_bank: usize, - boot_rom: [u8; 0x900], + boot_rom: [u8; 0x900], boot_rom_enabled: bool, mode: GBMode } diff --git a/src/components/ppu.rs b/src/components/ppu.rs index 7816436..4ae3a42 100644 --- a/src/components/ppu.rs +++ b/src/components/ppu.rs @@ -3,6 +3,8 @@ use crate::config::{Color, Config, Palette}; use crate::Framebuffer; use bitflags::bitflags; +/// RGBA (4 bytes) per pixel +pub const FRAMEBUFFER_SIZE: usize = 4 * SCREEN_W * SCREEN_H; pub const SCREEN_W: usize = 160; pub const SCREEN_H: usize = 144; @@ -611,7 +613,7 @@ impl Memory for PPU { self.ppu_mode = PPUMode::HBlank; let mut framebuffer = self.framebuffer.write().unwrap(); - *framebuffer = vec![0x00; 4 * SCREEN_W * SCREEN_H]; + *framebuffer = [0; FRAMEBUFFER_SIZE]; } } 0xFF41 => { diff --git a/src/context.rs b/src/context.rs index 401a906..5b2a10f 100644 --- a/src/context.rs +++ b/src/context.rs @@ -374,7 +374,7 @@ impl Context { ] } - pub fn update(&mut self, rgba: &Vec) { + pub fn update(&mut self, rgba: &[u8]) { self.queue.write_texture( wgpu::ImageCopyTexture { aspect: wgpu::TextureAspect::All, diff --git a/src/main.rs b/src/main.rs index e1fbe01..e6086f6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,7 +22,7 @@ use winit::event_loop::EventLoop; use winit::application::ApplicationHandler; use winit::window::{Window, WindowId}; -type Framebuffer = Arc>>; +type Framebuffer = Arc>; mod config; mod context; @@ -162,7 +162,7 @@ fn main() { event_loop.set_control_flow(ControlFlow::Poll); let (input_tx, input_rx) = mpsc::channel::<(JoypadButton, bool)>(); - let framebuffer: Framebuffer = Arc::new(RwLock::new(vec![0; 4 * SCREEN_W * SCREEN_H])); + let framebuffer: Framebuffer = Arc::new(RwLock::new([0; FRAMEBUFFER_SIZE])); let mut app = App { game_name: String::from(game_name),