Add flag to just run the CPU
This commit is contained in:
parent
0b1a8e1398
commit
a9d79025cf
46
Cargo.lock
generated
46
Cargo.lock
generated
@ -108,13 +108,28 @@ checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"bitflags",
|
||||
"clap_derive",
|
||||
"clap_lex",
|
||||
"indexmap",
|
||||
"once_cell",
|
||||
"strsim",
|
||||
"termcolor",
|
||||
"textwrap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "3.2.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.2.4"
|
||||
@ -438,6 +453,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"bitflags",
|
||||
"bitvec",
|
||||
"clap",
|
||||
"derive-try-from-primitive",
|
||||
"elf",
|
||||
"human-repr",
|
||||
@ -555,6 +571,30 @@ dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
||||
dependencies = [
|
||||
"proc-macro-error-attr",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error-attr"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.47"
|
||||
@ -856,6 +896,12 @@ version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "936e4b492acfd135421d8dca4b1aa80a7bfc26e702ef3af710e0752684df5372"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||
|
||||
[[package]]
|
||||
name = "vte"
|
||||
version = "0.10.1"
|
||||
|
@ -9,6 +9,7 @@ edition = "2021"
|
||||
anyhow = "1.0.66"
|
||||
bitflags = "1.3.2"
|
||||
bitvec = "1.0.0"
|
||||
clap = { version = "3.2.23", features = ["clap_derive", "derive"] }
|
||||
derive-try-from-primitive = "1.0.0"
|
||||
elf = "0.7.0"
|
||||
human-repr = { version = "1.0.1", features = ["iec", "space"] }
|
||||
|
29
src/main.rs
29
src/main.rs
@ -20,6 +20,7 @@ use crate::{
|
||||
m68k::{BusError, M68K},
|
||||
};
|
||||
use anyhow::anyhow;
|
||||
use clap::Parser;
|
||||
use disas::DisassemblyError;
|
||||
use indexmap::IndexSet;
|
||||
use itertools::Itertools;
|
||||
@ -46,7 +47,18 @@ struct EmuState {
|
||||
address_breakpoints: IndexSet<u32>,
|
||||
}
|
||||
|
||||
/// 68K Backplane Computer Emulator
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(name = "68KEmu", author, version, about, long_about = None)]
|
||||
struct Args {
|
||||
/// Just run the CPU instad of starting a REPL
|
||||
#[clap(short, long)]
|
||||
run: bool,
|
||||
}
|
||||
|
||||
fn main() -> Result<(), anyhow::Error> {
|
||||
let args = Args::parse();
|
||||
|
||||
let config_str = fs::read_to_string("config.toml")
|
||||
.map_err(|e| anyhow!("Could not read config file ({})", e))?;
|
||||
let config: EmuConfig =
|
||||
@ -58,11 +70,24 @@ fn main() -> Result<(), anyhow::Error> {
|
||||
symbol_tables.load_table(path, true)?;
|
||||
}
|
||||
}
|
||||
Repl::<_, anyhow::Error>::new(EmuState {
|
||||
let mut state = EmuState {
|
||||
cpu: M68K::new(backplane),
|
||||
symbol_tables,
|
||||
address_breakpoints: IndexSet::new(),
|
||||
})
|
||||
};
|
||||
if args.run {
|
||||
let mut out = String::new();
|
||||
while !state.cpu.stopped {
|
||||
state.cpu.step();
|
||||
}
|
||||
out += &format!("{}\n", state.cpu);
|
||||
let pc = state.cpu.pc();
|
||||
out += &disas_fmt(&mut state.cpu, pc, &state.symbol_tables).0;
|
||||
out.pop(); // Remove trailing newline
|
||||
println!("{}", out);
|
||||
return Ok(());
|
||||
}
|
||||
Repl::<_, anyhow::Error>::new(state)
|
||||
.with_name("68KEmu")
|
||||
.with_version("0.1.0")
|
||||
.with_banner("68K Backplane Computer Emulator")
|
||||
|
Loading…
Reference in New Issue
Block a user