faster memory impl
This commit is contained in:
+34
-5
@@ -1,5 +1,8 @@
|
||||
use arc_swap::ArcSwap;
|
||||
use clap::Parser;
|
||||
use std::{
|
||||
fs,
|
||||
path::PathBuf,
|
||||
sync::{
|
||||
Arc,
|
||||
atomic::{AtomicBool, AtomicU8},
|
||||
@@ -8,13 +11,20 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use crate::processor::{processor::Emulator, state::SharedState};
|
||||
|
||||
mod memory;
|
||||
mod processor;
|
||||
use dsa::{Emulator, FastStore, MainStore, MemoryMap, SharedState};
|
||||
|
||||
fn main() {
|
||||
let mut emulator = Emulator::new();
|
||||
let args = DsaArgs::parse();
|
||||
|
||||
let mut emulator = Emulator::new(FastStore::new());
|
||||
|
||||
let mmap = match args.get_memory_map() {
|
||||
Some(m) => m,
|
||||
None => MemoryMap::default(),
|
||||
};
|
||||
|
||||
emulator.apply_memory_map(mmap);
|
||||
|
||||
let state = emulator.state_handle();
|
||||
let runner = thread::spawn(move || emulator.run());
|
||||
let observer = thread::spawn(|| observe(state));
|
||||
@@ -30,3 +40,22 @@ fn observe(state: Arc<SharedState>) {
|
||||
println!("GP Registers: {:?}", state.gp_registers);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
struct DsaArgs {
|
||||
/// Memory map to use on boot.
|
||||
/// Overrides default value.
|
||||
#[arg(long = "mmap")]
|
||||
memory_map: Option<PathBuf>,
|
||||
}
|
||||
|
||||
impl DsaArgs {
|
||||
pub fn get_memory_map(&self) -> Option<MemoryMap> {
|
||||
self.memory_map.as_ref().and_then(|m| {
|
||||
fs::read_to_string(m)
|
||||
.ok()
|
||||
.and_then(|map| ron::from_str(&map).ok())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user