diff --git a/src/core/gba.rs b/src/core/gba.rs index 5da5a89..8e0a4f2 100644 --- a/src/core/gba.rs +++ b/src/core/gba.rs @@ -78,6 +78,11 @@ impl GameBoyAdvance { None } + pub fn skip_bios(&mut self) { + self.cpu.skip_bios(); + self.sysbus.io.gpu.skip_bios(); + } + fn step_cpu(&mut self, io: &mut IoDevices) -> usize { if io.intc.irq_pending() && self.cpu.last_executed.is_some() diff --git a/src/core/gpu/mod.rs b/src/core/gpu/mod.rs index bc47c88..9a80cc0 100644 --- a/src/core/gpu/mod.rs +++ b/src/core/gpu/mod.rs @@ -248,6 +248,15 @@ impl Gpu { } } + pub fn skip_bios(&mut self) { + for i in 0..2 { + self.bg_aff[i].pa = 0x100; + self.bg_aff[i].pb = 0; + self.bg_aff[i].pc = 0; + self.bg_aff[i].pd = 0x100; + } + } + /// helper method that reads the palette index from a base address and x + y pub fn read_pixel_index(&self, addr: u32, x: u32, y: u32, format: PixelFormat) -> usize { let ofs = addr - VRAM_ADDR; diff --git a/src/plat/sdl2/main.rs b/src/plat/sdl2/main.rs index a848f64..65b4341 100644 --- a/src/plat/sdl2/main.rs +++ b/src/plat/sdl2/main.rs @@ -113,14 +113,8 @@ fn main() { let mut rom_name = Path::new(&rom_path).file_name().unwrap().to_str().unwrap(); let cart = Cartridge::from_path(Path::new(&rom_path)).unwrap(); - let mut cpu = arm7tdmi::Core::new(); - if skip_bios { - cpu.skip_bios(); - } - let cpu = cpu; - let mut gba = GameBoyAdvance::new( - cpu, + arm7tdmi::Core::new(), bios_bin, cart, video.clone(), @@ -128,6 +122,10 @@ fn main() { input.clone(), ); + if skip_bios { + gba.skip_bios(); + } + if debug { #[cfg(feature = "debugger")] { @@ -196,16 +194,15 @@ fn main() { let bios_bin = read_bin_file(bios_path).unwrap(); // create a new emulator - TODO, export to a function - let mut cpu = arm7tdmi::Core::new(); - cpu.skip_bios(); gba = GameBoyAdvance::new( - cpu, + arm7tdmi::Core::new(), bios_bin, cart, video.clone(), audio.clone(), input.clone(), ); + gba.skip_bios(); } _ => {} }