Skip to content

Apply due APU port writes without advancing past the guest clock - #258

Merged
mstan merged 1 commit into
mainfrom
fix/apu-guest-boundary-20261104
Nov 4, 2026
Merged

mstan merged 1 commit into
mainfrom
fix/apu-guest-boundary-20261104

Conversation

@mstan

@mstan mstan commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

When a CPU port write is queued exactly at the requested APU clock, apu_runToGuestCycle executes an extra SPC cycle just to drain the event. A second write at the same guest timestamp can then rebase the mapping. With an exact cycle budget, synchronization can instead return false with the boundary write still pending.

Drain writes due at the current clock before testing the target. Port updates at the boundary need no SPC instruction, timer or DSP advancement, and repeated synchronization stays at the same clock. This applies by default to both portable and native APU implementations. It does not claim full cycle parity or a hardware input-delay model.

Validation:

  • The added cases fail on engine main fb8cf15d and pass with the fix in both SNESRECOMP_APU_NATIVE=0 and =1.

  • Cover same-timestamp word bytes, unchanged clock/CPU-cycle residue, partial budgets, a write exactly at the budget limit, and idempotent zero-budget synchronization.

  • Combined automated regression passes on 40ddfb3e: 884 Python checks (two skips), nine PPU harnesses, three strict GLSL programs, 772 GPU comparisons, and supported MMX/ALttP/SMW/Super Metroid gameplay/current-build save-load/runtime checks. Super Metroid uses its compatible stable consumer for this stock-engine comparison; current title main requires a separate mod-runtime pin. The new owner visual/play check remains pending, so this stays draft.

Found while reviewing the new timing notes on #205 and #241. The same boundary repair is now on PR #241 at 3856deb1, retaining its access-exact hold/cleanup behavior and passing all four portable/native and instruction-start/access-exact combinations. This does not close #205 or supply the still-missing Secret of Evermore replay recipe. Tracking: beads-8wg.2.199.

@mstan
mstan marked this pull request as ready for review November 4, 2026 23:22
@mstan
mstan merged commit 2c73dfb into main Nov 4, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cycle parity between the compiled tier and the interpreter (measured on a HiROM title)

1 participant