mirror of
https://github.com/jkdansereau/goldeneye-pc-port.git
synced 2026-10-24 00:02:45 +02:00
Adds an env-gated (GE_DETERM=1, default OFF), test-only deterministic-clock mode to port/src/libultra.c per the design in docs/dev/findings.md section D117: osGetCount() returns a virtual clock advanced synchronously in osRecvMesg() when __scMain (the sole consumer of the scheduler's retrace queue) asks for the next message, instead of tracking real elapsed time. Goal: two runs of the same build take the same simulation path, for exact frame-diff regression testing and reproducible crash repro. Four passes this session, each is a real, verified result, not a guess: 1. Fixed the predicted pre-first-frame deadlock (a poll-driven fallback caused it in the first cut). 2. Replaced the poll-driven fallback with synchronous per-ask generation in osRecvMesg -- fixed the deadlock cleanly, but two-run divergence was still 33-38%. 3. Capped the pre-first-task tick backlog to a fixed constant -- divergence dropped to 17-20%, still not the ~0% target. 4. Added GE_DETERM_TRACE=1 instrumented tracing and diffed two runs' clock event logs directly. Proved the tick mechanism is now fully deterministic (byte-identical clock values through the first real task). Root-caused the actual remaining divergence: every synthesized retrace increments the scheduler's frameCount, which gates a half-rate client (the audio client) by parity -- since the pre-task spin count is still real-time-scheduling-dependent, that parity isn't guaranteed to match between runs. GE_DETERM is NOT achieving its determinism goal yet and is not meant to be used for anything today -- it ships here purely as a well-documented, zero-risk-when-off checkpoint (verify.sh bunker1 PASS, worst_cell unchanged, confirmed after every change this session) so the next attempt starts from proof instead of re-deriving four sessions of dead ends. Full trace numbers, exact line citations, and the mechanism: docs/dev/findings.md section D117 (four M-52 addenda). Claude-Session: https://claude.ai/code/session_01P3WrUHAFQZUuhrHhiJgTUr