Skip to content

Fix a batch of small correctness issues - #52

Merged
asterick merged 1 commit into
mainfrom
asterick/correctness-fixes
Jun 7, 2026
Merged

asterick merged 1 commit into
mainfrom
asterick/correctness-fixes

Conversation

@asterick

@asterick asterick commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Summary

Four small, independent correctness fixes (stacked on #51 — retarget to main after it merges):

  1. RTC prescaler (rtc.cc): prescale -= prescale zeroed the counter instead of subtracting the 0x8000 overflow threshold. Honest severity: latent, not symptomatic — osc1 reaches RTC::clock one tick at a time, so the remainder at crossing is always zero and both forms coincide today. Verified by A/B: zero divergence on baselines and on 3 commercial ROMs × 30 s. It would silently lose time the moment osc1 delivery was ever batched. The harness exercise now starts the RTC and the log line prints rtc=value+prescale, so the subsystem is regression-covered going forward (baselines regenerated for the new column).
  2. libretro savestates (libretro.cc): retro_unserialize() copied the state then returned false — every savestate load reported failure to the frontend. Now returns true.
  3. Breakpoints are a Set<number> instead of an array — the running loop did an indexOf per executed instruction.
  4. npm scripts chain with && instead of ; — a failed core build no longer lets vite build "succeed" with a stale wasm. (CI's stale comment about this updated too.)

Verification

  • RTC A/B (old vs fixed code): byte-identical exercise baselines and ROM runs — confirming both the fix's safety and its latent-only severity
  • Breakpoints driven in the browser: set/set/clear via disassembly clicks, counts correct; running with a breakpoint on the BIOS idle loop halts immediately
  • libretro .so builds; npm run check, wasm core build, and make -C core/test check all clean

🤖 Generated with Claude Code

Base automatically changed from asterick/regression-harness to main June 7, 2026 06:10
- RTC prescaler: `prescale -= prescale` zeroed the counter instead of
  subtracting the 0x8000 overflow threshold. Currently latent rather
  than symptomatic — osc1 reaches RTC::clock one tick at a time, so the
  remainder at crossing is always zero and the two forms coincide
  (verified by A/B: zero baseline/ROM divergence) — but it would lose
  time the moment osc1 ever arrived batched. The harness exercise now
  starts the RTC and the per-second log prints value+prescale so future
  regressions are visible.

- libretro savestates: retro_unserialize() copied the state and then
  returned false, so every savestate load reported failure to the
  frontend.

- Breakpoints are a Set instead of an array: the running loop checked
  indexOf per executed instruction.

- npm scripts chain with && instead of ;, so a failed step no longer
  lets the rest run (a failed core build used to still produce a
  "successful" vite build with a stale wasm).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@asterick
asterick force-pushed the asterick/correctness-fixes branch from 641c52f to 577d048 Compare June 7, 2026 06:10
@asterick
asterick merged commit 481850c into main Jun 7, 2026
3 checks passed
@asterick
asterick deleted the asterick/correctness-fixes branch June 7, 2026 06:11
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.

1 participant