XSharp

X2 effective camera boundary transitions

The Stag USA replay has a camera-only discrepancy on frame 1272 while all four player motion values still match. This research isolates its native cause; the corresponding optional XSharp controller now resolves it. The full scene still diverges, and native execution cadence remains a declared diagnostic input.

Executed observation

Source: original Stag Final Climb.bk2, 3,487 unchanged inputs, BizHawk 2.11 / BSNESv115+, USA ROM SHA-1 637079014421563283CDED6AEAA0604597B2E33C. Metadata pins the movie, sync settings and hashes of instructions and writes. The full frame CSV retains SHA-256 4A064AC42BCF037AF03D0CC8962D24E50D3BF0DBD704B8D6F3FFD1EFCF88A007.

The camera uses direct page $1E58. On 1272, $00:DEBD..DEDB follows the player and writes Y 046A (1130). XSharp reaches that same candidate. Native $00:E0FB..E103 then clamps it against effective minimum Y $1E6A=046B, producing 1131. Later in that update, $00:E1E6..E229 copies requested minimum Y $1E78=0040 (64) into the effective field. The next frame can move above 1131.

Frame Camera Y after update Effective minimum Y after update Requested minimum Y
1269 1133 1131 64
1270 1133 1131 64
1271 1133 1131 64
1272 1131 64 64
1273 1125 64 64

This is neither a rounding correction nor a camera shake. The requested boundary was already 64 before the mismatch; making it immediately effective loses the old-bound clamp on the crossing update. Checkpoint bounds alone do not recreate this state. The current comparison adapter imports effective limits once but does not yet import/execute their pending transition.

Native state and static translation targets

The existing shared catalog distinguishes effective limits $1E66..1E6D from requests. Camera structure offsets are:

Offset Meaning observed in the native controller
+05, +08 Integer camera X/Y
+0A, +0C Boundary transition step / ordinary follow movement cap; Stag uses 2/8
+0E, +10, +12, +14 Effective minimum X, maximum X, minimum Y, maximum Y
+16, +18, +20, +26 Corresponding requested limits
+22, +24 Saved pre-follow camera X/Y
+28, +2A Upper/lower player screen Y targets, 96/128 in this replay
+2C, +2E Horizontal screen targets, both 128 in this replay

$00:E166..E26C updates effective limits after following/clamping. Its expansion paths consult the player integer position, the native previous-player words $09FA/$09FC, the appropriate screen target and boundary transition step. Translate the executed comparisons and carry semantics, rather than assuming a constant linear interpolation or replacing limits with recorded per-frame values. In particular, SBC target; ADC #0002; CMP #0004 retains carry from subtraction. The near-target interval needs a regression for each side before generalizing.

Optional implementation and validation

X2CameraBoundsControl is a device-free, serialized model in XSharp.Gameplay.X2. CameraBoundsController applies its effective world box before camera movement, clamps with the old limits after following, advances those limits, then commits newly generated level requests for the next update. The native request delay is independently visible at Stag 189. Applying the new request during that same update incorrectly changed effective minimum X from 1042 to 2558; the original retained 1042 until the following update.

The engine’s generic ICameraConstraintRequestObserver observes explicit level requests, including requests equal to the effective box which can cancel an older transition. Publishing an effective box is separate. Every observer gets the same request snapshot even when an earlier observer changes effective bounds. The X2 controller is registered only with EnableNativeCameraBounds = true; common/legacy/X1/X3 and ordinary X2 module selection retain existing behavior.

The isolated, hash-pinned stag-camera-bounds.json.gz fixture checks all 3,488 source states, including held logic updates. It supplies original player/camera positions and requested limits only as inputs to this boundary-model test. A second run restores its serialized state immediately before 1272. Separate tests check the asymmetric carry interval on all four edges, native record layout, request observation and module opt-in. The near-target interval is [-2, 0] relative to the screen target; +1 is outside because carry changes the addend.

The hosted comparison imports the pending native camera state once alongside its existing initial alignment. Every later request comes from XSharp level events. Its complete 3,487-input cadence diagnostic has:

Observable First difference
Player stored speed 1532
Player position 1579
Camera position / observed speed / observed acceleration 1608
Effective camera limits 2366
Requested camera limits 3191
RNG seed / call count 223

Thus the 1272 defect is resolved in continuous playback, not just by replaying recorded boundaries. These first camera differences occur after player-position divergence; they do not by themselves establish an independent camera cause. Their causes must be assessed after resolving that trajectory. A 20-update save-state replay from 1272 passes. Neither camera matching nor this component’s complete native-state test certifies autonomous pacing, enemy controllers, background/parallax/pixel rendering or the complete scene. The shared progress manifest pins the corresponding reports/builds and archives.

Reproduction

capture_bizhawk_movie.py --trace-camera 1269 1274 emits the camera-context instruction subset and pre-completion writes to $1E58..1E97. It uses private movie/configuration copies and only reads the original runtime. Write-time PCs may identify the following instruction; pre-instruction entries retain the executing PC and P/M/X context. Decode this camera path with M=16, X=8 where the recorded P register requires it. The evidence exporter validates and retains both camera CSV hashes alongside the original frame/WRAM/RNG capture.

The reproducible fixture generator verifies the original frame/scene hashes:

python tools/parity/extract_x2_camera_bounds_fixture.py `
  --capture 'C:\research\stag-original' `
  --output 'C:\research\stag-camera-bounds.json.gz' `
  --source 'C:\research\stag-camera-bounds-source.json'

It refuses existing outputs. The provenance record lists every projected WRAM word, fixture hash and generator. No ROM, native emulator state or per-frame correction is embedded in the hosted controller.

The subsequent shooting-pose and dash-admission corrections extend hosted diagnostic camera motion through 2408 and effective bounds through 3191; requests still match through 3190. The first camera/motion difference is now 2409. Earlier report values above retain their historical implementation-stage scope. The latest Stag calibration pins the new full reports and the explicit disabled held-Dash extension.

After correcting landing completion and first-slide kick initialization, all player positions, stored speeds and observed accelerations, camera coordinates/derivatives, and effective/requested limits match every state through 3487 in the full declared native-cadence diagnostic. Optional camera bounds remain disabled by default; the default held-Dash extension also remains enabled outside the explicit comparison configuration. Native RNG diverges from 223 and autonomous timing from 216; these component results do not certify the full scene. See current measured progress.

Partial level requests require preserving untouched requested destinations separately from published effective bounds. The partial-request correction records the Gap regression, explicit edge contract and headless coverage; the native boundary interpolation algorithm and its update phase are unchanged.