Skip to content

Preserve deterministic OAM scan state across first-frame restore - #9

Merged
deviankim merged 3 commits into
browser-environmentfrom
fix/multiplayer-oam-state
Oct 1, 2026
Merged

deviankim merged 3 commits into
browser-environmentfrom
fix/multiplayer-oam-state

Conversation

@deviankim

Copy link
Copy Markdown

Restoring the first LCD-off multiplayer bootstrap frame synthesized a pending OAM scan rather than restoring its actual state. On the GBC cartridge regression, the next frame then differed from uninterrupted execution at sprite-position-buffer offsets 1980 and 1982, despite matching pixels. Preserve the OAM reader's pending-change position and sprite-size source in the deterministic envelope instead.

Tracks https://github.com/ssk-play/chiptoy/issues/96 and the M2 correction review in ssk-play/romdev-browser#16. Stacked on #8; it keeps that observation hook and the LCD follow-up from #7. This is a separate core fix; no browser payload is patched in place.

Use the existing reserved envelope words at offsets 72 and 76. Deterministic schema becomes 0x47420103, and gambatte package becomes 0.15.0. Validate scan positions (0–80 or disabled 255) and Boolean size source before restoring. Ordinary savestate save/load remains unchanged when deterministic mode is off. Old deterministic schemas are rejected.

The build recipe resets both newly patched sprite mapper files, so repeat builds remain idempotent. Core-owned digests include the preserved fields; no state bytes are filtered by the consumer.

Self-review and validation:

  • Rebuilt through ROMDEV_BUILD_CWD=packages/romdevtools build-image/build-wasm.sh build-gambatte.sh, repeated successfully.
  • Patch checked against clean pinned upstream after its existing memory patch.
  • Native multiplayer core and world-observation suites: 29/29. Includes invalid envelope fields, causal digest mutations, legacy ordinary disk-state fixtures and new GB/GBC first-frame future checks (digest, CPU, audio and pixels).
  • Independent control with the previous b5306d03 payload reproduces the GBC two-byte mismatch; the new payload passes it.
  • Browser adapter suite on this core: 79/79, including partially executed three-console correction with identical final native state, first-frame audio and pixels.

Payload: https://github.com/ssk-play/romdev/releases/tag/browser-payloads-4be2b1a7777a, archive SHA-256 6a05620de4728392867eea07e87c2f6677cb0789197645c7b3559f9b0353c95d. Source b539ee652319aee4d136789eeb4b6aa6e5c99511 (payload built from patch commit 0ee02daa). Dev integration and external browser procedure are supplied in romdev-browser monteslu#16. Physical-phone performance acceptance is separate and pending. No merge or production deployment.

@deviankim
deviankim changed the base branch from feat/multiplayer-observation to browser-environment October 1, 2026 15:37
@deviankim

Copy link
Copy Markdown
Author

Reviewed. The OAM reader fields go into the reserved envelope words after saveState fills them and are restored before loadState, with range checks (0-80 or 255, a 0/1 size source). They are part of the core-owned digest; ordinary save states are unchanged; older deterministic schemas are refused. The build recipe resets the two newly patched files. Merging into browser-environment after #7 and #8.

# Conflicts:
#	packages/romdevtools/scripts/patches/gambatte-multiplayer-state.patch
@deviankim
deviankim merged commit 1df57e3 into browser-environment Oct 1, 2026
0 of 2 checks passed
@deviankim
deviankim deleted the fix/multiplayer-oam-state branch October 29, 2026 15:37
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