From 6dd48c6238b475d429975d1fbbe0fef8d557587e Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Sat, 6 Jul 2019 19:26:51 +0300 Subject: [PATCH] Add option to skip bios code so I can start checking out test roms Former-commit-id: b78c8d9807ba3097d641a57ec7fcd500b32b4d96 --- src/bin/cli.yml | 5 ++++- src/bin/main.rs | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/bin/cli.yml b/src/bin/cli.yml index 86245da..949460a 100644 --- a/src/bin/cli.yml +++ b/src/bin/cli.yml @@ -15,4 +15,7 @@ subcommands: long: game-rom takes_value: true help: Sets the game-rom file to use - required: true \ No newline at end of file + required: true + - skip_bios: + long: skip-bios + help: Skip running bios and start from the ROM instead. \ No newline at end of file diff --git a/src/bin/main.rs b/src/bin/main.rs index 61e2a6c..a1c14b2 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -12,6 +12,11 @@ use rustboyadvance_ng::util::read_bin_file; use rustboyadvance_ng::{GBAResult, GameBoyAdvance}; fn run_debug(matches: &ArgMatches) -> GBAResult<()> { + let skip_bios = match matches.occurrences_of("skip_bios") { + 0 => false, + _ => true + }; + let bios_bin = read_bin_file(matches.value_of("bios").unwrap_or_default())?; let rom_bin = read_bin_file(matches.value_of("game_rom").unwrap())?; @@ -21,6 +26,19 @@ fn run_debug(matches: &ArgMatches) -> GBAResult<()> { let mut core = Core::new(); core.reset(); core.set_verbose(true); + if skip_bios { + core.gpr[13] = 0x0300_7f00; + core.gpr_banked_r13[0] = 0x0300_7f00; // USR/SYS + core.gpr_banked_r13[0] = 0x0300_7f00; // FIQ + core.gpr_banked_r13[0] = 0x0300_7fa0; // IRQ + core.gpr_banked_r13[0] = 0x0300_7fe0; // SVC + core.gpr_banked_r13[0] = 0x0300_7f00; // ABT + core.gpr_banked_r13[0] = 0x0300_7f00; // UND + + core.pc = 0x0800_0000; + + core.cpsr.set(0x5f); + } let gba = GameBoyAdvance::new(core, bios_bin, gamepak);