mirror of
https://github.com/dingusdev/dingusppc.git
synced 2026-10-22 12:02:34 +00:00
T2 readback wrapped after N+1 clocks, but its interrupt was scheduled for N+3. Mac OS Microseconds could see a wrapped counter with no pending interrupt, then clear the newly asserted interrupt by reading T2CL. The one-shot timer would never be serviced or rearmed. Abuse paces its intro text by repeatedly calling Microseconds until 150 ms have elapsed. This tight polling loop exposes the race. Once the interrupt is lost, the OS stops accumulating elapsed timer periods, while the hardware counter keeps wrapping. Microseconds then cycles within a roughly 84 ms window instead of advancing monotonically, so the 150 ms wait can no longer complete normally. The guest keeps running, but the text's pacing loop effectively stalls, accounting for the reported frozen or extremely slow scrolling. Use a shared time origin for counter readback and the N+1.5-clock interrupt, including the initial half-clock delay. Before reading T2 or IFR, also assert any overdue interrupt and cancel its queued callback, so realtime reads and acknowledgments don't depend on timer polling. Verified native Abuse intro and gameplay, native and Emscripten builds, and 84 timer checks covering rollover, acknowledgment and overdue reads. Co-Authored-By: joevt <950609+joevt@users.noreply.github.com> Co-Authored-By: Mihai Parparita <513813+mihaip@users.noreply.github.com>