fix: Set BG2/3 affine parametersr to default on bios skip

Former-commit-id: e6e3016f85230af3aa495b120a3d3abb385ba463
This commit is contained in:
Michel Heily 2020-01-16 19:47:05 +02:00
parent d97d07774f
commit 0e0f1764e8
3 changed files with 21 additions and 10 deletions

View file

@ -78,6 +78,11 @@ impl GameBoyAdvance {
None 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 { fn step_cpu(&mut self, io: &mut IoDevices) -> usize {
if io.intc.irq_pending() if io.intc.irq_pending()
&& self.cpu.last_executed.is_some() && self.cpu.last_executed.is_some()

View file

@ -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 /// 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 { pub fn read_pixel_index(&self, addr: u32, x: u32, y: u32, format: PixelFormat) -> usize {
let ofs = addr - VRAM_ADDR; let ofs = addr - VRAM_ADDR;

View file

@ -113,14 +113,8 @@ fn main() {
let mut rom_name = Path::new(&rom_path).file_name().unwrap().to_str().unwrap(); 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 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( let mut gba = GameBoyAdvance::new(
cpu, arm7tdmi::Core::new(),
bios_bin, bios_bin,
cart, cart,
video.clone(), video.clone(),
@ -128,6 +122,10 @@ fn main() {
input.clone(), input.clone(),
); );
if skip_bios {
gba.skip_bios();
}
if debug { if debug {
#[cfg(feature = "debugger")] #[cfg(feature = "debugger")]
{ {
@ -196,16 +194,15 @@ fn main() {
let bios_bin = read_bin_file(bios_path).unwrap(); let bios_bin = read_bin_file(bios_path).unwrap();
// create a new emulator - TODO, export to a function // create a new emulator - TODO, export to a function
let mut cpu = arm7tdmi::Core::new();
cpu.skip_bios();
gba = GameBoyAdvance::new( gba = GameBoyAdvance::new(
cpu, arm7tdmi::Core::new(),
bios_bin, bios_bin,
cart, cart,
video.clone(), video.clone(),
audio.clone(), audio.clone(),
input.clone(), input.clone(),
); );
gba.skip_bios();
} }
_ => {} _ => {}
} }