From bbe18ec20a6a22228acb8a5dac35495eb23df376 Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Wed, 26 Apr 2023 15:15:19 +1000 Subject: [PATCH] unify versions and bootrom options, update deps --- Cargo.lock | 35 +++++++++++++++++------------------ gb-emu/Cargo.toml | 2 +- gb-emu/src/main.rs | 14 +++++++------- gb-vst/Cargo.toml | 2 +- gb-vst/src/lib.rs | 6 +----- lib/src/connect/mod.rs | 25 ++++++------------------- lib/src/lib.rs | 18 +++++------------- lib/src/processor/mod.rs | 10 ++-------- vendored/nih-plug | 2 +- 9 files changed, 41 insertions(+), 73 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5f4956b..7037c97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,9 +70,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e579a7752471abc2a8268df8b20005e3eadd975f585398f17efcfd8d4927371" +checksum = "6342bd4f5a1205d7f41e94a41a901f5647c938cdfa96036338e8533c9d6c2450" dependencies = [ "anstyle", "anstyle-parse", @@ -109,9 +109,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcd8291a340dd8ac70e18878bc4501dd7b4ff970cfa21c207d36ece51ea88fd" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -162,9 +162,9 @@ checksum = "62af46d040ba9df09edc6528dae9d8e49f5f3e82f55b7d2ec31a733c38dbc49d" [[package]] name = "atomic_refcell" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "857253367827bd9d0fd973f0ef15506a96e79e41b0ad7aa691203a4e3214f6c8" +checksum = "79d6dc922a2792b006573f60b2648076355daeae5ce9cb59507e5908c9625d31" [[package]] name = "atty" @@ -382,8 +382,7 @@ dependencies = [ [[package]] name = "clap-sys" version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27f4e06657d33d5d194db1155cef359c359483a4170362bf4e105146dd0109e3" +source = "git+https://github.com/robbert-vdh/clap-sys.git?branch=feature/cstr-macro#523a5f8a8dd021ec99e7d6e0c0ebe7741a3da9d4" [[package]] name = "clap_builder" @@ -971,7 +970,7 @@ dependencies = [ [[package]] name = "gb-emu" -version = "0.2.0" +version = "0.3.0" dependencies = [ "clap", "cpal", @@ -1014,9 +1013,9 @@ dependencies = [ [[package]] name = "gilrs" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d0342acdc7b591d171212e17c9350ca02383b86d5f9af33c6e3598e03a6c57e" +checksum = "62fd19844d0eb919aca41d3e4ea0e0b6bf60e1e827558b101c269015b8f5f27a" dependencies = [ "fnv", "gilrs-core", @@ -1027,9 +1026,9 @@ dependencies = [ [[package]] name = "gilrs-core" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373b55d596e5a84fff61c559de54351a69f9ff481593ac78c35d9dc625df8d8f" +checksum = "fd745b0cb1a207756e8fabacf5623066ad6aa543ea0be4bab34e897e6bbe24f9" dependencies = [ "core-foundation", "io-kit-sys", @@ -1661,9 +1660,9 @@ dependencies = [ [[package]] name = "nih_log" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1d8a01d9663de15dbec9eaa9b7c261588e615ec204797b63039a2b0f30680fd" +checksum = "d0cdb52ef79af48ae110401c883bdb9c15e0306a99ab6ecf18bc52068b668e54" dependencies = [ "atty", "log", @@ -2281,9 +2280,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.37.14" +version = "0.37.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b864d3c18a5785a05953adeed93e2dca37ed30f18e69bba9f30079d51f363f" +checksum = "a0661814f891c57c930a610266415528da53c4933e6dea5fb350cbfe048a9ece" dependencies = [ "bitflags", "errno", @@ -2738,7 +2737,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "vst" -version = "0.1.0" +version = "0.3.0" dependencies = [ "async-ringbuf", "baseview", diff --git a/gb-emu/Cargo.toml b/gb-emu/Cargo.toml index 408defd..0b52bce 100644 --- a/gb-emu/Cargo.toml +++ b/gb-emu/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gb-emu" -version = "0.2.0" +version = "0.3.0" edition = "2021" [features] diff --git a/gb-emu/src/main.rs b/gb-emu/src/main.rs index c972b7b..2e795fc 100644 --- a/gb-emu/src/main.rs +++ b/gb-emu/src/main.rs @@ -55,16 +55,16 @@ struct Args { mute: bool, /// Run debug console - #[arg(short, long)] + #[arg(long)] debug: bool, - /// Force CGB mode + /// Prefer DMG mode #[arg(short, long)] - cgb: bool, + dmg: bool, - /// Skip BootROM + /// Show BootROM #[arg(long)] - skip: bool, + show_bootrom: bool, } fn main() { @@ -110,10 +110,10 @@ fn main() { } else { SerialTarget::None }) - .with_bootrom(args.bootrom.map(RomFile::Path), args.skip) + .with_bootrom(args.bootrom.map(RomFile::Path), args.show_bootrom) .with_no_save(args.no_save) .with_tile_window(tile_window) - .with_cgb_mode(args.cgb); + .with_cgb_mode(!args.dmg); let mut core = EmulatorCore::init(receiver, options); diff --git a/gb-vst/Cargo.toml b/gb-vst/Cargo.toml index d4f1070..07188d7 100644 --- a/gb-vst/Cargo.toml +++ b/gb-vst/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "vst" -version = "0.1.0" +version = "0.3.0" edition = "2021" [lib] diff --git a/gb-vst/src/lib.rs b/gb-vst/src/lib.rs index bce39fc..1d3ee0c 100644 --- a/gb-vst/src/lib.rs +++ b/gb-vst/src/lib.rs @@ -71,7 +71,6 @@ const FRAMES_TO_BUFFER: usize = 1; const DOWNSAMPLE_TYPE: DownsampleType = DownsampleType::ZeroOrderHold; const ROM: &[u8; 65536] = include_bytes!("../../test-roms/mGB.gb"); -const BOOTROM: Option<&[u8; 2304]> = Some(include_bytes!("../../sameboy-bootroms/cgb_boot.bin")); impl Plugin for GameboyEmu { const NAME: &'static str = "Gameboy"; @@ -203,7 +202,7 @@ impl Plugin for GameboyEmu { ProcessStatus::KeepAlive } - fn editor(&self, _: AsyncExecutor) -> Option> { + fn editor(&mut self, _: AsyncExecutor) -> Option> { Some(Box::new(Emulator::new( self.frame_receiver.clone(), self.key_handler.clone(), @@ -227,7 +226,6 @@ impl Plugin for GameboyEmu { vars.emulator_core.replace_output(output); vars.rx = rx; } else { - let bootrom = BOOTROM.map(|v| RomFile::Raw(v.to_vec())); let rom = RomFile::Raw(ROM.to_vec()); let (sender, receiver) = channel::(); @@ -257,7 +255,6 @@ impl Plugin for GameboyEmu { EmulatorCore::from_save_state(state, rom, receiver, window, output, serial_target) } else { let options = gb_emu_lib::Options::new(window, rom, output) - .with_bootrom(bootrom) .with_serial_target(serial_target) .force_no_save(); @@ -266,7 +263,6 @@ impl Plugin for GameboyEmu { #[cfg(not(feature = "savestate"))] let mut emulator_core = { let options = EmulatorOptions::new(window, rom, output) - .with_bootrom(bootrom, true) .with_serial_target(serial_target) .force_no_save(); diff --git a/lib/src/connect/mod.rs b/lib/src/connect/mod.rs index fc451d1..d68ceac 100644 --- a/lib/src/connect/mod.rs +++ b/lib/src/connect/mod.rs @@ -169,7 +169,7 @@ where pub(crate) camera: C, pub(crate) no_save: bool, pub(crate) bootrom: Option, - pub(crate) skip_bootrom: bool, + pub(crate) show_bootrom: bool, pub(crate) serial_target: SerialTarget, pub(crate) cgb_mode: bool, spooky: PhantomData, @@ -181,20 +181,7 @@ where R: Renderer, { pub fn new(window: R, rom: RomFile, output: AudioOutput) -> Self { - Self { - window, - tile_window: None, - rom, - output, - save_path: None, - camera: NoCamera::default(), - no_save: false, - bootrom: None, - skip_bootrom: false, - serial_target: SerialTarget::None, - cgb_mode: false, - spooky: PhantomData, - } + Self::new_with_camera(window, rom, output, NoCamera::default()) } } @@ -214,9 +201,9 @@ where camera, no_save: false, bootrom: None, - skip_bootrom: false, + show_bootrom: false, serial_target: SerialTarget::None, - cgb_mode: false, + cgb_mode: true, spooky: PhantomData, } } @@ -236,9 +223,9 @@ where self } - pub fn with_bootrom(mut self, bootrom: Option, skip_bootrom: bool) -> Self { + pub fn with_bootrom(mut self, bootrom: Option, show_bootrom: bool) -> Self { self.bootrom = bootrom; - self.skip_bootrom = skip_bootrom; + self.show_bootrom = show_bootrom; self } diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 428df99..e662403 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -10,7 +10,7 @@ use connect::{ }; use processor::{ memory::{mmio::gpu::Colour, rom::CgbRomType, OutputTargets, Rom}, - Cpu, CpuSaveState, RunBootrom, + Cpu, CpuSaveState, }; use std::{ fs::{self}, @@ -76,7 +76,7 @@ where RomFile::Raw(data) => Rom::load(data, None, camera.clone()), }; - let (bootrom_enabled, bootrom, cgb) = if let Some(b) = options.bootrom { + let (bootrom, cgb) = if let Some(b) = options.bootrom { let bootrom = match b { RomFile::Path(path) => match fs::read(path) { Ok(data) => data, @@ -89,15 +89,7 @@ where }; let cgb = rom.rom_type == CgbRomType::CgbOnly || options.cgb_mode || bootrom.len() > 256; - ( - if options.skip_bootrom { - RunBootrom::Skip - } else { - RunBootrom::Yes - }, - bootrom, - cgb, - ) + (bootrom, cgb) } else { let cgb = rom.rom_type == CgbRomType::CgbOnly || options.cgb_mode; let bootrom = if cgb { @@ -105,7 +97,7 @@ where } else { include_bytes!("../../sameboy-bootroms/dmg_boot.bin").to_vec() }; - (RunBootrom::Skip, bootrom, cgb) + (bootrom, cgb) }; options.window.prepare(WIDTH, HEIGHT); @@ -131,7 +123,7 @@ where camera, ), ), - bootrom_enabled, + options.show_bootrom, ), ) } diff --git a/lib/src/processor/mod.rs b/lib/src/processor/mod.rs index 0e46f2c..dff196e 100644 --- a/lib/src/processor/mod.rs +++ b/lib/src/processor/mod.rs @@ -20,12 +20,6 @@ pub(crate) enum Direction { Right, } -#[derive(Debug, Clone, Copy, PartialEq)] -pub(crate) enum RunBootrom { - Yes, - Skip, -} - pub struct Cpu where ColourFormat: From + Clone, @@ -81,7 +75,7 @@ where R: Renderer, C: PocketCamera + Send + 'static, { - pub(crate) fn new(memory: Memory, run_bootrom: RunBootrom) -> Self { + pub(crate) fn new(memory: Memory, run_bootrom: bool) -> Self { Self { memory, reg: Registers::init(), @@ -90,7 +84,7 @@ where halted: false, should_halt_bug: false, cycle_count: 0, - is_skipping: run_bootrom == RunBootrom::Skip, + is_skipping: !run_bootrom, } } diff --git a/vendored/nih-plug b/vendored/nih-plug index e6546c1..33c266b 160000 --- a/vendored/nih-plug +++ b/vendored/nih-plug @@ -1 +1 @@ -Subproject commit e6546c1aad139028253ddd4fb586f19463f5c881 +Subproject commit 33c266b496ec6a1cd87ef9fcc1ca541b5d34eb6e