diff --git a/gb-emu/src/main.rs b/gb-emu/src/main.rs index fa628a4..45f95fb 100644 --- a/gb-emu/src/main.rs +++ b/gb-emu/src/main.rs @@ -79,7 +79,7 @@ fn main() { rom: RomFile::Path(args.rom), save_path: args.save, no_save: args.no_save, - bootrom_path: args.bootrom, + bootrom: args.bootrom.map(|v| RomFile::Path(v)), connect_serial: args.connect_serial, verbose: args.verbose, cycle_count: args.cycle_count, diff --git a/gb-vst/src/lib.rs b/gb-vst/src/lib.rs index 143c7e1..f5a8171 100644 --- a/gb-vst/src/lib.rs +++ b/gb-vst/src/lib.rs @@ -32,8 +32,6 @@ pub struct GameboyEmu { type FrameReceiver = Mutex>>>; type JoypadSender = Mutex>>; -const ROM: &[u8; 32768] = include_bytes!("../../test-roms/Tetris.gb"); - impl Plugin for GameboyEmu { const NAME: &'static str = "Gameboy"; @@ -104,10 +102,16 @@ impl Plugin for GameboyEmu { _context: &mut impl InitContext, ) -> bool { let options = gb_emu_lib::Options { - rom: RomFile::Raw(ROM.to_vec()), + rom: RomFile::Raw( + include_bytes!("../../test-roms/TwinPeaksMeanwhile.gb") + .to_vec() + .to_vec(), + ), save_path: None, no_save: true, - bootrom_path: None, + bootrom: Some(RomFile::Raw( + include_bytes!("../../bootrom/dmg_boot.bin").to_vec(), + )), connect_serial: false, verbose: false, cycle_count: false, diff --git a/lib/src/lib.rs b/lib/src/lib.rs index ce21e06..10c9b1d 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -26,7 +26,7 @@ pub struct Options { pub rom: RomFile, pub save_path: Option, pub no_save: bool, - pub bootrom_path: Option, + pub bootrom: Option, pub connect_serial: bool, pub verbose: bool, pub cycle_count: bool, @@ -85,18 +85,17 @@ impl + Clone> EmulatorCore { window.prepare(WIDTH, HEIGHT); window.set_title(format!("{} on {}", rom.get_title(), rom.mbc_type())); - let bootrom_enabled = options.bootrom_path.is_some(); - let bootrom: Option> = if let Some(path) = options.bootrom_path { - match fs::read(path) { - Ok(data) => Some(data), + let bootrom_enabled = options.bootrom.is_some(); + let bootrom: Option> = options.bootrom.map(|v| match v { + RomFile::Path(path) => match fs::read(path) { + Ok(data) => data, Err(e) => { println!("Error reading bootROM: {e}"); exit(1); } - } - } else { - None - }; + }, + RomFile::Raw(data) => data, + }); Self::new( receiver,