From 6a6ab426a6d976be9575927f6a9eee63cc72fc23 Mon Sep 17 00:00:00 2001 From: transistor Date: Mon, 27 Nov 2023 19:19:40 -0800 Subject: [PATCH] Added option to moa-computie to select a rom file to boot --- .../frontends/console/src/bin/moa-computie.rs | 16 ++++++++++-- emulator/systems/computie/src/lib.rs | 2 +- emulator/systems/computie/src/system.rs | 26 +++++++++++++++---- .../systems/genesis/src/peripherals/ym7101.rs | 2 +- emulator/systems/genesis/src/system.rs | 15 ----------- 5 files changed, 37 insertions(+), 24 deletions(-) diff --git a/emulator/frontends/console/src/bin/moa-computie.rs b/emulator/frontends/console/src/bin/moa-computie.rs index fb5fb3f..1331894 100644 --- a/emulator/frontends/console/src/bin/moa-computie.rs +++ b/emulator/frontends/console/src/bin/moa-computie.rs @@ -1,14 +1,26 @@ +use clap::{Arg, ArgAction}; + use moa_console::ConsoleFrontend; -use moa_systems_computie::build_computie; +use moa_systems_computie::{build_computie, ComputieOptions}; fn main() { let matches = ConsoleFrontend::args("Computie68k Emulator") + .arg(Arg::new("ROM") + .short('r') + .long("rom") + .value_name("FILE") + .help("ROM file to load at the start of memory")) .get_matches(); + let mut options = ComputieOptions::default(); + if let Some(filename) = matches.get_one::("ROM") { + options.rom = filename.to_string(); + } + let mut frontend = ConsoleFrontend::new(); - let system = build_computie(&mut frontend).unwrap(); + let system = build_computie(&mut frontend, options).unwrap(); frontend.start(matches, system); } diff --git a/emulator/systems/computie/src/lib.rs b/emulator/systems/computie/src/lib.rs index 79d0906..20c10fc 100644 --- a/emulator/systems/computie/src/lib.rs +++ b/emulator/systems/computie/src/lib.rs @@ -1,4 +1,4 @@ mod system; -pub use crate::system::{build_computie, build_computie_k30, launch_terminal_emulator, launch_slip_connection}; +pub use crate::system::{build_computie, build_computie_k30, launch_terminal_emulator, launch_slip_connection, ComputieOptions}; diff --git a/emulator/systems/computie/src/system.rs b/emulator/systems/computie/src/system.rs index bfc9aee..bcd22b6 100644 --- a/emulator/systems/computie/src/system.rs +++ b/emulator/systems/computie/src/system.rs @@ -6,14 +6,30 @@ use moa_m68k::{M68k, M68kType}; use moa_peripherals_generic::AtaDevice; use moa_peripherals_motorola::MC68681; +pub struct ComputieOptions { + pub rom: String, + pub ram: usize, + pub frequency: Frequency, +} -pub fn build_computie(host: &H) -> Result { +impl Default for ComputieOptions { + fn default() -> Self { + Self { + rom: "binaries/computie/monitor.bin".to_string(), + ram: 0x10_0000, + frequency: Frequency::from_hz(10_000_000), + } + } +} + +pub fn build_computie(host: &H, options: ComputieOptions) -> Result { let mut system = System::default(); - let monitor = MemoryBlock::load("binaries/computie/monitor.bin")?; - system.add_addressable_device(0x00000000, Device::new(monitor))?; + let mut rom = MemoryBlock::new(vec![0; 0x10000]); + rom.load_at(0x0000, &options.rom)?; + system.add_addressable_device(0x00000000, Device::new(rom))?; - let mut ram = MemoryBlock::new(vec![0; 0x00100000]); + let mut ram = MemoryBlock::new(vec![0; options.ram]); ram.load_at(0, "binaries/computie/kernel.bin")?; system.add_addressable_device(0x00100000, Device::new(ram))?; @@ -27,7 +43,7 @@ pub fn build_computie(host: &H) -> Result { system.add_addressable_device(0x00700000, Device::new(serial))?; - let mut cpu = M68k::from_type(M68kType::MC68010, Frequency::from_hz(10_000_000), system.bus.clone(), 0); + let mut cpu = M68k::from_type(M68kType::MC68010, options.frequency, system.bus.clone(), 0); //cpu.enable_tracing(); //cpu.add_breakpoint(0x10781a); diff --git a/emulator/systems/genesis/src/peripherals/ym7101.rs b/emulator/systems/genesis/src/peripherals/ym7101.rs index b7405bb..54e35de 100644 --- a/emulator/systems/genesis/src/peripherals/ym7101.rs +++ b/emulator/systems/genesis/src/peripherals/ym7101.rs @@ -864,7 +864,7 @@ impl Addressable for Ym7101 { } }, - 0x11 | 0x12 => { + addr if (0x11..0x17).contains(&addr) => { self.sn_sound.borrow_mut().as_addressable().unwrap().write(clock, 0, data)?; }, diff --git a/emulator/systems/genesis/src/system.rs b/emulator/systems/genesis/src/system.rs index cd1ccca..1399b7d 100644 --- a/emulator/systems/genesis/src/system.rs +++ b/emulator/systems/genesis/src/system.rs @@ -41,21 +41,6 @@ pub fn build_genesis(host: &mut H, mut options: SegaGenesisOptions) -> }; let rom = MemoryBlock::new(rom_data); - //let mut rom = MemoryBlock::load("binaries/genesis/GenTestV3.0.bin").unwrap(); - //let mut rom = MemoryBlock::load("binaries/genesis/HDRV_Genesis_Test_v1_4.bin").unwrap(); - //let mut rom = MemoryBlock::load("binaries/genesis/ComradeOj's tiny demo.bin").unwrap(); - //let mut rom = MemoryBlock::load("binaries/genesis/Digital Rain demo.bin").unwrap(); - //let mut rom = MemoryBlock::load("binaries/genesis/Sonic The Hedgehog (W) (REV 00) [!].bin").unwrap(); - //let mut rom = MemoryBlock::load("binaries/genesis/Sonic The Hedgehog (W) (REV 01) [!].bin").unwrap(); - //let mut rom = MemoryBlock::load("binaries/genesis/Sonic the Hedgehog 2 (JUE) [!].bin").unwrap(); - //let mut rom = MemoryBlock::load("binaries/genesis/Sonic the Hedgehog 3 (U) [!].bin").unwrap(); - //let mut rom = MemoryBlock::load("binaries/genesis/Earthworm Jim (U) [h1].bin").unwrap(); - //let mut rom = MemoryBlock::load("binaries/genesis/Home Alone (beta).bin").unwrap(); - //let mut rom = MemoryBlock::load("binaries/genesis/F1 World Championship (JUE) [!].bin").unwrap(); - //let mut rom = MemoryBlock::load("binaries/genesis/Ren and Stimpy's Invention (U) [!].bin").unwrap(); - //let mut rom = MemoryBlock::load("binaries/genesis/Out of this World (U) [!].bin").unwrap(); - //let mut rom = MemoryBlock::load("binaries/genesis/Ghostbusters (REV 00) (JUE).bin").unwrap(); - //let mut rom = MemoryBlock::load("binaries/genesis/Teenage Mutant Ninja Turtles - The Hyperstone Heist (U) [!].bin").unwrap(); //rom.read_only(); let rom_end = rom.size(); system.add_addressable_device(0x00000000, Device::new(rom)).unwrap();