Skip to content

Observe completed logical worlds before view rendering - #8

Merged
deviankim merged 2 commits into
browser-environmentfrom
feat/multiplayer-observation
Oct 1, 2026
Merged

deviankim merged 2 commits into
browser-environmentfrom
feat/multiplayer-observation

Conversation

@deviankim

@deviankim deviankim commented Oct 1, 2026 •

Copy link
Copy Markdown

A player-view game can be deterministic across clients while its canonical consoles simulate different worlds. Comparing RAM at a display boundary is too late: rendering can already have changed it. This adds a bounded diagnostic publication hook that copies physical RAM when the engine writes its completed-world marker, before rendering.

Tracks https://github.com/ssk-play/chiptoy/issues/96. Stacked on #7 (base fix/multiplayer-lcd-state), without changing that PR. The consumer is ssk-play/romdev-browser#16; the engine publisher and trusted linked-symbol/world schema integration belong to M3.

The optional GB/GBC/NES exports observe a stable writable marker, unbanked LE32 tick and physical RAM fields. They never freeze CPU, advance clocks or modify emulated state. Eight publications, 32 spans and 1024 bytes are hard bounds. Drains return owned records and truncation metadata; restore/reset/media changes disarm and require rebinding. The diagnostic is outside savestates and causal hashes. Normal disk-state formats and deterministic schemas are unchanged. Boot RAM clearing cannot publish because the marker value must match 0xa5.

Core-host is 0.16.0, Gambatte 0.14.0 and fceumm 0.15.0. Exact dependent pins and workspace lockfile are updated. Recipes built both cores with the shared C observer; payload https://github.com/ssk-play/romdev/releases/tag/browser-payloads-da7751d556b4, archive SHA-256 e635d2f9feaf756ae20b0028193ca92df0be1bbf7912a03b991b4b590c77faa8. Source b5306d03d23a39b719b01cc7eea34d953baac56b.

Self-review checked physical-bank pointer handling, optional export detection, lifecycle cleanup, bounded copying, and state/hash exclusion. The selected core regression suite passed 75 tests with two existing skips and no failures. Five new tests compare raw snapshots, causal digests, CPU registers, pixels and audio against uninstrumented execution for 130 frames on GB/GBC/NES, prove pre-view bytes survive later view writes, and cover overflow, owned copies, invalid spans and C89 ABI behavior. ESLint and diff checks passed.

Consumer build/typecheck and all 65 tests pass, including logical tick comparison for one/two/four views, deliberately divergent worlds, and separate HTTP execution parity. Dev validation: Worker 714920f8-f18d-42ec-aa1d-f0043b409fa9, companion commit 3971450 (https://github.com/ssk-play/chiptoy/pull/104), library head a44b9cc. Served library /lib/romdev-browser/1.0.0-d14f76fad9/, worker build 8bbb01dac2bd21e3e8563c5b9660417a3ae64e5f2dfcaf396eb7de54c890e768. Chrome 152, Android 16 emulator Chrome 153 and iOS 26 Simulator Safari each passed nine logical-world cases and all 15 rollback smoke combinations; private dev reports were read back with this clean source/build and zero hidden interruptions. Browser console errors: zero.

External test:

  1. Open https://dev.chiptoy.com/lib/romdev-browser/1.0.0-d14f76fad9/benchmark/world-check.html, without login. Expect PASS for nine cases, seven matching pre-view worlds and two deliberately invalid slot-dependent worlds rejected at tick 1, score values 00/02 in canonical slots 0/2. Every native frame's raw snapshots and causal digests match uninstrumented execution; pixels agree.
  2. Reload and expect the same results/build. Confirm portrait width has no horizontal overflow.
  3. Open https://dev.chiptoy.com/benchmark?profile=smoke&device=Windows-test . A guest identity is created if needed for private report upload. Keep foreground; expect all 15 cases deterministic and Report saved on dev. Return report ID and browser/device. Hold the movement button at least 50ms (100–200ms recommended) while enabled.
  4. Compare the report build/core identities above. Emulator results prove functionality, not a physical-phone p95/p99 performance gate. Physical-phone performance remains a separate unpassed M2 gate; this hook is enabled only in correctness diagnostics, never in performance measurements.

@deviankim
deviankim marked this pull request as ready for review October 1, 2026 14:00
@deviankim
deviankim changed the base branch from fix/multiplayer-lcd-state to browser-environment October 1, 2026 15:37
@deviankim
deviankim merged commit 0da97b5 into browser-environment Oct 1, 2026
0 of 2 checks passed
deviankim added a commit that referenced this pull request Oct 1, 2026
# Conflicts:
#	packages/romdevtools/scripts/patches/gambatte-multiplayer-state.patch
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