Repository navigation
v0.3.0 — 1:1 ROM Differential Verification Engine & Fygar Flap Timing
v0.3.0 — 1:1 ROM Differential Verification Engine & Fygar Flap Timing
A major milestone release introducing automated mathematical differential verification against original 1982 Namco arcade ROM bytes and MAME hardware microcode, alongside gameplay timing fixes uncovered by the new verification harness.
Highlights
1. Automated 1:1 ROM Differential Verification Harness
Rather than relying on subjective gameplay inspection, this release adds a reference verification system that executes original 1982 arcade ROM bytes in lockstep with the hand-decompiled Rust routines:
- Reference Z80 Interpreter (
src/z80_ref.rs): Ground-truth CPU emulator running original ROM machine code with precise Z80 flag calculation (SZ53P, DAA, 16-bit ALU, IX/IY index math, CB/ED/DD/FD opcode tables). - Step-by-Step State Verifier (
src/verify.rs&src/bin/verify_decomp.rs): Compares post-execution CPU and shared RAM states across each routine.- Dead-Stack Window Filtering: Eliminates false alarms from return address residue left below
SPin stack memory. - Onward Liveness Analysis: When scratch registers (
A,F,HL) differ at function exit, simulates 20,000 onward instructions from both states to prove whether the divergence propagates into memory/branches (REG-PROPAGATES) or is benign scratch state (REG-BENIGN).
- Dead-Stack Window Filtering: Eliminates false alarms from return address residue left below
- MAME Reference Alignment (
tools/mame/): Lua tracing harness verifying Namco51XXand53XXcustom I/O MCU commands, fire button edge detection, and bus timings against real chip microcode.
2. Bug Fix: Fygar Fire Breath Flap Animation (decomp_update_fygar_fire_2aa4)
Differential verification uncovered a real state divergence (STATE) during monster AI processing:
- Symptom: At frame 1,119, RAM
$857C(wing color) and$98A4..$98A9(fire sprite positions) diverged between Rust and the reference ROM. - Root Cause: In
decomp_update_fygar_fire_2aa4, the countdown timer was checked against5 | 8 | 12(FlapOrange) and7 | 10(FlapRed). In original Z80 ROM (cpu0_main.asmlines 6183–6219), the timer decrements every 2 frames: odd intervals5 | 9 | 13are FlapOrange ($0C) and7 | 11are FlapRed ($02). Even values caused frames 9, 11, and 13 to fall through toFireStep::None, skipping sprite clearances and desyncing wing colors. - Resolution: All 3 clearance branches now strictly follow the ROM cadence.
Verification Benchmarks
| Metric | Result |
|---|---|
| Total Frames Run | 2,000 |
| CPU Steps Verified | 119,999,998 (~120M) |
Real State Divergences (STATE) |
0 |
Register Propagations (REG-PROPAGATES) |
0 |
Benign Dead Scratch Registers (REG-BENIGN) |
25 (proven dead over 20,000 onward steps) |
Standard Unit Tests (cargo test) |
Passed |
Headless Verification (--headless-test) |
Passed |
Reproducing Verification
To verify the decompiled Rust routines against your own extracted ROM set:
cargo run --release --bin verify_decomp -- --frames 2000 --script tools/mame/inputscript.txtFull Changelog: v0.2.1...v0.3.0
Full Changelog: v0.2.1...v0.3.0
Full Changelog: v0.2.1...v0.3.0