From 0893e7aab5a59fa90f3f43107e6d9966efa0adf9 Mon Sep 17 00:00:00 2001 From: alloncm Date: Sat, 13 Nov 2021 21:00:42 +0200 Subject: [PATCH 1/4] Add a feature to specify a bootrom path in the cmd --- README.md | 2 ++ gb/src/main.rs | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 08636e24..a42ec4a4 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,11 @@ magenboy [path_to_rom] [other_optional_flags] ``` ### Optional flags + * `--log` - Print logs in debug mode to a file * `--file-audio` - Saves the audio to a file * `--no-vsync` - Disable vsync +* `--bootrom [path to bootrom file]` - Specify the path for a bootrom ## GameBoy diff --git a/gb/src/main.rs b/gb/src/main.rs index 8d2b6a7f..5ad75a4f 100644 --- a/gb/src/main.rs +++ b/gb/src/main.rs @@ -118,7 +118,15 @@ fn emulation_thread_main(args: Vec, program_name: String, spsc_gfx_devic let audio_devices = MultiAudioDevice::new(devices); let mut mbc = initialize_mbc(&program_name); let joypad_provider = SdlJoypadProvider::new(buttons_mapper); - let mut gameboy = match fs::read("Dependencies/Init/dmg_boot.bin"){ + let bootrom_path = if check_for_terminal_feature_flag(&args, "--bootrom"){ + let index = args.iter().position(|v| *v == String::from("--bootrom")).expect("Error! you must specify a value for the --bootrom parameter"); + args[index + 1].clone() + }else{ + String::from("Dependencies/Init/dmg_boot.bin") + }; + + println!("{}", bootrom_path); + let mut gameboy = match fs::read(bootrom_path){ Result::Ok(file)=>{ info!("found bootrom!"); From e0821591eaad4a4c7af41d87786430cede2c5a78 Mon Sep 17 00:00:00 2001 From: alloncm Date: Sat, 13 Nov 2021 21:02:44 +0200 Subject: [PATCH 2/4] Update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a42ec4a4..0ae770b2 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ magenboy [path_to_rom] [other_optional_flags] * `--log` - Print logs in debug mode to a file * `--file-audio` - Saves the audio to a file * `--no-vsync` - Disable vsync -* `--bootrom [path to bootrom file]` - Specify the path for a bootrom +* `--bootrom [path to bootrom file]` - Specify the path for a bootrom (If not specified the emualtor will look at `Dependencies/Init/dmg_boot.bin`) ## GameBoy From 2cf67cd839d9cda495ab6bc0b9cd1fb6e93f4870 Mon Sep 17 00:00:00 2001 From: Alon Cohen-Magen Date: Fri, 19 Nov 2021 18:54:44 +0200 Subject: [PATCH 3/4] Remove print and crash instead of overflow --- gb/src/main.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gb/src/main.rs b/gb/src/main.rs index 5ad75a4f..528bced8 100644 --- a/gb/src/main.rs +++ b/gb/src/main.rs @@ -119,13 +119,12 @@ fn emulation_thread_main(args: Vec, program_name: String, spsc_gfx_devic let mut mbc = initialize_mbc(&program_name); let joypad_provider = SdlJoypadProvider::new(buttons_mapper); let bootrom_path = if check_for_terminal_feature_flag(&args, "--bootrom"){ - let index = args.iter().position(|v| *v == String::from("--bootrom")).expect("Error! you must specify a value for the --bootrom parameter"); - args[index + 1].clone() + let index = args.iter().position(|v| *v == String::from("--bootrom")).unwrap(); + args.get(index + 1).expect("Error! you must specify a value for the --bootrom parameter").clone() }else{ String::from("Dependencies/Init/dmg_boot.bin") }; - println!("{}", bootrom_path); let mut gameboy = match fs::read(bootrom_path){ Result::Ok(file)=>{ info!("found bootrom!"); From 9be6045ed5f17608f053c379f52c727a0bbbc258 Mon Sep 17 00:00:00 2001 From: alloncm Date: Sun, 21 Nov 2021 01:44:33 +0200 Subject: [PATCH 4/4] Remove the need for the Dependencies/Init If the flag is not use the system will look for dmg_boot.bin at the current working directory --- README.md | 2 +- gb/src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0ae770b2..e122942f 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ magenboy [path_to_rom] [other_optional_flags] * `--log` - Print logs in debug mode to a file * `--file-audio` - Saves the audio to a file * `--no-vsync` - Disable vsync -* `--bootrom [path to bootrom file]` - Specify the path for a bootrom (If not specified the emualtor will look at `Dependencies/Init/dmg_boot.bin`) +* `--bootrom [path to bootrom file]` - Specify the path for a bootrom (If not specified the emualtor will look for `dmg_boot.bin` at the cwd) ## GameBoy diff --git a/gb/src/main.rs b/gb/src/main.rs index 528bced8..23693b75 100644 --- a/gb/src/main.rs +++ b/gb/src/main.rs @@ -122,7 +122,7 @@ fn emulation_thread_main(args: Vec, program_name: String, spsc_gfx_devic let index = args.iter().position(|v| *v == String::from("--bootrom")).unwrap(); args.get(index + 1).expect("Error! you must specify a value for the --bootrom parameter").clone() }else{ - String::from("Dependencies/Init/dmg_boot.bin") + String::from("dmg_boot.bin") }; let mut gameboy = match fs::read(bootrom_path){