From 316a3fcb5f19527a82457c4f4939fe7c67737af1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com>
Date: Sat, 22 Jul 2023 20:13:36 +0100
Subject: [PATCH] chore: new none boot ROM and no-boot flag

---
 frontends/sdl/src/main.rs | 11 +++++++++--
 src/data.rs               |  1 +
 src/gb.rs                 |  2 ++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/frontends/sdl/src/main.rs b/frontends/sdl/src/main.rs
index 017932bc..7938f0db 100644
--- a/frontends/sdl/src/main.rs
+++ b/frontends/sdl/src/main.rs
@@ -662,6 +662,13 @@ struct Args {
     #[arg(short, long, default_value_t = String::from("printer"), help = "Serial device to be used")]
     device: String,
 
+    #[arg(
+        long,
+        default_value_t = false,
+        help = "If set no boot ROM will be loaded"
+    )]
+    no_boot: bool,
+
     #[arg(long, default_value_t = false, help = "If set no PPU will be used")]
     no_ppu: bool,
 
@@ -740,7 +747,7 @@ fn main() {
     // parses the provided command line arguments and uses them to
     // obtain structured values
     let args = Args::parse();
-    let mode: GameBoyMode = if args.mode == "auto" {
+    let mode = if args.mode == "auto" {
         GameBoyMode::Dmg
     } else {
         GameBoyMode::from_string(&args.mode)
@@ -760,7 +767,7 @@ fn main() {
     game_boy.set_dma_enabled(!args.no_dma);
     game_boy.set_timer_enabled(!args.no_timer);
     game_boy.attach_serial(device);
-    game_boy.load(true);
+    game_boy.load(!args.no_boot);
 
     // prints the current version of the emulator (informational message)
     println!("========= Boytacean =========\n{}", game_boy);
diff --git a/src/data.rs b/src/data.rs
index 53c6dff7..dffe9542 100644
--- a/src/data.rs
+++ b/src/data.rs
@@ -8,6 +8,7 @@ pub enum BootRom {
     DmgBootix,
     MgbBootix,
     Cgb,
+    None,
 }
 
 pub const DMG_BOOT: [u8; 256] = [
diff --git a/src/gb.rs b/src/gb.rs
index fda32828..87b2379f 100644
--- a/src/gb.rs
+++ b/src/gb.rs
@@ -535,6 +535,7 @@ impl GameBoy {
             BootRom::DmgBootix => self.load_boot(&DMG_BOOTIX),
             BootRom::MgbBootix => self.load_boot(&MGB_BOOTIX),
             BootRom::Cgb => self.load_boot(&CGB_BOOT),
+            BootRom::None => (),
         }
     }
 
@@ -957,6 +958,7 @@ impl GameBoy {
             BootRom::DmgBootix => self.load_boot_path("./res/boot/dmg_bootix.bin"),
             BootRom::MgbBootix => self.load_boot_path("./res/boot/mgb_bootix.bin"),
             BootRom::Cgb => self.load_boot_path("./res/boot/cgb_boot.bin"),
+            BootRom::None => (),
         }
     }
 
-- 
GitLab