bootrom as romfile + inline include_bytes
This commit is contained in:
parent
d041475ced
commit
79f9d70ff2
|
@ -79,7 +79,7 @@ fn main() {
|
||||||
rom: RomFile::Path(args.rom),
|
rom: RomFile::Path(args.rom),
|
||||||
save_path: args.save,
|
save_path: args.save,
|
||||||
no_save: args.no_save,
|
no_save: args.no_save,
|
||||||
bootrom_path: args.bootrom,
|
bootrom: args.bootrom.map(|v| RomFile::Path(v)),
|
||||||
connect_serial: args.connect_serial,
|
connect_serial: args.connect_serial,
|
||||||
verbose: args.verbose,
|
verbose: args.verbose,
|
||||||
cycle_count: args.cycle_count,
|
cycle_count: args.cycle_count,
|
||||||
|
|
|
@ -32,8 +32,6 @@ pub struct GameboyEmu {
|
||||||
type FrameReceiver = Mutex<Option<Receiver<Vec<[u8; 4]>>>>;
|
type FrameReceiver = Mutex<Option<Receiver<Vec<[u8; 4]>>>>;
|
||||||
type JoypadSender = Mutex<Option<Sender<(JoypadButtons, bool)>>>;
|
type JoypadSender = Mutex<Option<Sender<(JoypadButtons, bool)>>>;
|
||||||
|
|
||||||
const ROM: &[u8; 32768] = include_bytes!("../../test-roms/Tetris.gb");
|
|
||||||
|
|
||||||
impl Plugin for GameboyEmu {
|
impl Plugin for GameboyEmu {
|
||||||
const NAME: &'static str = "Gameboy";
|
const NAME: &'static str = "Gameboy";
|
||||||
|
|
||||||
|
@ -104,10 +102,16 @@ impl Plugin for GameboyEmu {
|
||||||
_context: &mut impl InitContext<Self>,
|
_context: &mut impl InitContext<Self>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let options = gb_emu_lib::Options {
|
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,
|
save_path: None,
|
||||||
no_save: true,
|
no_save: true,
|
||||||
bootrom_path: None,
|
bootrom: Some(RomFile::Raw(
|
||||||
|
include_bytes!("../../bootrom/dmg_boot.bin").to_vec(),
|
||||||
|
)),
|
||||||
connect_serial: false,
|
connect_serial: false,
|
||||||
verbose: false,
|
verbose: false,
|
||||||
cycle_count: false,
|
cycle_count: false,
|
||||||
|
|
|
@ -26,7 +26,7 @@ pub struct Options {
|
||||||
pub rom: RomFile,
|
pub rom: RomFile,
|
||||||
pub save_path: Option<String>,
|
pub save_path: Option<String>,
|
||||||
pub no_save: bool,
|
pub no_save: bool,
|
||||||
pub bootrom_path: Option<String>,
|
pub bootrom: Option<RomFile>,
|
||||||
pub connect_serial: bool,
|
pub connect_serial: bool,
|
||||||
pub verbose: bool,
|
pub verbose: bool,
|
||||||
pub cycle_count: bool,
|
pub cycle_count: bool,
|
||||||
|
@ -85,18 +85,17 @@ impl<ColourFormat: From<Colour> + Clone> EmulatorCore<ColourFormat> {
|
||||||
window.prepare(WIDTH, HEIGHT);
|
window.prepare(WIDTH, HEIGHT);
|
||||||
window.set_title(format!("{} on {}", rom.get_title(), rom.mbc_type()));
|
window.set_title(format!("{} on {}", rom.get_title(), rom.mbc_type()));
|
||||||
|
|
||||||
let bootrom_enabled = options.bootrom_path.is_some();
|
let bootrom_enabled = options.bootrom.is_some();
|
||||||
let bootrom: Option<Vec<u8>> = if let Some(path) = options.bootrom_path {
|
let bootrom: Option<Vec<u8>> = options.bootrom.map(|v| match v {
|
||||||
match fs::read(path) {
|
RomFile::Path(path) => match fs::read(path) {
|
||||||
Ok(data) => Some(data),
|
Ok(data) => data,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Error reading bootROM: {e}");
|
println!("Error reading bootROM: {e}");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
} else {
|
RomFile::Raw(data) => data,
|
||||||
None
|
});
|
||||||
};
|
|
||||||
|
|
||||||
Self::new(
|
Self::new(
|
||||||
receiver,
|
receiver,
|
||||||
|
|
Loading…
Reference in a new issue