boy-debug: Load multiple files at bootup, as a temporary workaround for not having a disablable bootrom slot
This commit is contained in:
parent
c971ff47cc
commit
054f9f49cb
@ -8,7 +8,7 @@ pub trait BusIOTools: BusIO {
|
|||||||
/// Prints all successful reads and writes
|
/// Prints all successful reads and writes
|
||||||
fn trace(&mut self) -> TracingBus<Self>;
|
fn trace(&mut self) -> TracingBus<Self>;
|
||||||
fn ascii(&mut self) -> AsciiSerial<Self>;
|
fn ascii(&mut self) -> AsciiSerial<Self>;
|
||||||
fn read_file(self, path: impl AsRef<Path>) -> IoResult<Self>
|
fn read_file(&mut self, path: impl AsRef<Path>) -> IoResult<&mut Self>
|
||||||
where
|
where
|
||||||
Self: Sized;
|
Self: Sized;
|
||||||
}
|
}
|
||||||
@ -24,7 +24,7 @@ impl<T: BusIO> BusIOTools for T {
|
|||||||
bus: self,
|
bus: self,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn read_file(mut self, path: impl AsRef<Path>) -> IoResult<Self> {
|
fn read_file(&mut self, path: impl AsRef<Path>) -> IoResult<&mut Self> {
|
||||||
let data = std::fs::read(path)?;
|
let data = std::fs::read(path)?;
|
||||||
eprintln!("Read {} bytes.", data.len());
|
eprintln!("Read {} bytes.", data.len());
|
||||||
for (addr, data) in data.into_iter().enumerate() {
|
for (addr, data) in data.into_iter().enumerate() {
|
||||||
|
@ -9,18 +9,17 @@ use boy_debug::{
|
|||||||
message::Response,
|
message::Response,
|
||||||
};
|
};
|
||||||
use rustyline::{config::Configurer, history::FileHistory, Editor};
|
use rustyline::{config::Configurer, history::FileHistory, Editor};
|
||||||
use std::error::Error;
|
use std::{env::args, error::Error};
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
// Set up the gameboy
|
// Set up the gameboy
|
||||||
// TODO: move off the main thread
|
// TODO: move off the main thread
|
||||||
let args: Vec<_> = std::env::args().collect();
|
let mut bus = vec![0; 0x10000];
|
||||||
let mut bus = match args.len() {
|
for arg in std::env::args().skip(1) {
|
||||||
2 => vec![0; 0x10000].read_file(&args[1])?,
|
bus.read_file(arg)?;
|
||||||
_ => return Err(format!("Usage: {} [rom.gb]", args[0]).into()),
|
}
|
||||||
};
|
|
||||||
// let mut bus = Bus::new(Cart::new(bus));
|
// let mut bus = Bus::new(Cart::new(bus));
|
||||||
let mut gb = Gameboy::new(bus.ascii());
|
let mut gb = Gameboy::new(bus);
|
||||||
|
|
||||||
// Set up and run the REPL
|
// Set up and run the REPL
|
||||||
let mut rl: Editor<(), FileHistory> = Editor::new()?;
|
let mut rl: Editor<(), FileHistory> = Editor::new()?;
|
||||||
|
Loading…
Reference in New Issue
Block a user