gameboy-rust/crates/desktop/examples/write_rom_demo.rs
0xrsydn 109c1ffe81 feat(desktop): run ROM files in a window with keypad input
Add --rom PATH --window with optional bounded --frames execution. Capture from BIOS boot, pump native events between bounded machine slices, retain frames during STOP, and sample keypad input for wake-up. Share final machine reports with terminal mode.

Add an original file-exportable input ROM, controller and CLI regressions, and opt-in native window tests. Document controls, frame limits, STOP behavior, and compatibility limits. Verified on Darwin arm64: debug/release workspace and core tests, Clippy, rustdoc, native ROM diagnostics, all ten demo smoke tests, and a 60-frame release ROM run.
2026-10-05 19:22:13 +07:00

31 lines
922 B
Rust

//! Export original input-test instructions, never game or firmware content.
use std::{
error::Error,
fs::OpenOptions,
io::{self, Write},
};
fn main() -> Result<(), Box<dyn Error>> {
let mut args = std::env::args_os().skip(1);
let path = args.next().filter(|path| !path.is_empty()).ok_or_else(|| {
io::Error::new(
io::ErrorKind::InvalidInput,
"usage: write_rom_demo OUTPUT_PATH",
)
})?;
if args.next().is_some() {
return Err(io::Error::new(
io::ErrorKind::InvalidInput,
"usage: write_rom_demo OUTPUT_PATH",
)
.into());
}
let mut file = OpenOptions::new()
.write(true)
.create_new(true)
.open(&path)?;
file.write_all(&gba_demos::input_rom())?;
file.flush()?;
println!("Wrote original input-test ROM to {path:?}. Blue: idle; Z: red; Right: green.");
Ok(())
}