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