pce_state_roundtrip/
pce-state-roundtrip.rs1use pcengine_rust::trace::{roundtrip, runahead, Setup};
9
10fn run() -> Result<String, String> {
11 let args: Vec<String> = std::env::args().skip(1).collect();
12 let setup = Setup::parse(&args)?;
13 let (mut at, mut to, mut extra, mut ahead, mut ahead_frames) = (300, 360, 777, 2, 120);
14 let mut rest = setup.rest.iter();
15 while let Some(arg) = rest.next() {
16 let value: i64 = rest
17 .next()
18 .and_then(|text| text.parse().ok())
19 .ok_or_else(|| format!("{arg} needs a number"))?;
20 match arg.as_str() {
21 "--at" => at = value,
22 "--to" => to = value,
23 "--extra" => extra = value,
24 "--ahead" => ahead = value,
25 "--ahead-frames" => ahead_frames = value,
26 _ => return Err(format!("unknown argument {arg}")),
27 }
28 }
29 let saved = roundtrip(&setup, at, to, extra)?;
30 let looked = runahead(&setup, ahead_frames, ahead)?;
31 Ok(format!("{saved}; run-ahead: {looked}"))
32}
33
34fn main() {
35 match run() {
36 Ok(what) => println!("ok: {what}"),
37 Err(error) => {
38 println!("FAIL: {error}");
39 std::process::exit(1);
40 }
41 }
42}