XSharp

Continuous X2 movie comparison

Current validation: partial camera-request correction. Both complete Gap/Stag motion and camera diagnostics pass with explicit native cadence. Remaining autonomous timing first differs at Gap 2185 / Stag 216. The earlier verification preserves the now-corrected optional-camera regression.

The current Stag calibration records fourteen player-physics corrections, original executed-instruction/write evidence and separate complete autonomous/cadence-diagnostic runs. Reference cadence remains diagnostic assistance, never autonomous acceptance.

This Windows console host feeds an original BK2 input timeline through the production Direct3D 9 engine, player, world loader and scheduler. Its adapter supports an idle standing X2 USA player with released input history. With scene memory it selects the original stage/checkpoint/facing and effective initial camera limits, and initializes position/subpixels, health and zero velocity once. It then applies the original inputs without repositioning the player. The host explicitly selects UpdatePlayerWeaponsAfterPlayer, independently of the player movement profile. See the Stag/Gator baseline for the currently active verification; The later complete Gap/Stag verification preserves a Gap optional-camera regression on cb4a470; the later partial-request correction resolves it.

It is input-only playback with an explicit initial-state adapter, not conversion of BizHawk’s native state. The host aligns player/camera and, when captured, RNG once at frame zero. It compares player motion/observed acceleration, camera position/derived motion and RNG seed, and records both entity timelines. Scriver, Aclanda and native buster identities and active class-specific state have separate audits; other original actors/effects remain incompletely mapped. It still uses current player graphics/audio resources. A completed run is not a full-scene pass.

The current scene-wide analysis supersedes the historical milestones below. The autonomous run matches player/camera/RNG through 2184, then exposes a native graphics-loading stall. With explicit diagnostic native cadence, the later full run matches player motion/observed acceleration, camera motion, health and RNG throughout all 4,186 inputs, all 1,713 audited enemy states and all 412 audited weapon states. The report declares timing assistance and incomplete actor/visual coverage; complete scene fidelity remains pending.

The small-object audit additionally matches 5,304 states, including native draw requests, after the completed-camera phase and dust-facing fixes. The report’s unmappedObjectAudit inventories remaining non-player pool/dispatch types with observation counts, draw requests and first/last frames. A non-drawing controller is still an unverified controller. This inventory describes coverage, not parity. graphics-comparison.csv separately records native 1F18 and engine ObjectTile load-set selection, together with native task/job state. It does not drive timing or correct graphics state. Engine entity timelines now expose native slot address and visibility as well as their preceding class-specific state.

The initial-state adapter imports native 1F18 once. Checkpoint warmup otherwise leaves graphics set 4 while this movie starts in set 6; the initial position alignment alone does not fix that difference. The full cadence-assisted report docs/parity/gap-jumps-graphics-load-set-cadence-diagnostic.json matches load-set selection on all 4,187 observed states, including subsequent trigger changes. Its 20-update restoration from 2170 includes another load-set change, and snapshot verification now compares the engine’s load-set value as well as entity state. No load-set corrections occur during continuous playback.

Run

Capture an original reference with tools/parity/capture_bizhawk_movie.py, using the source movie, matching ROM and BizHawk 2.11/BSNESv115+. The capture must contain frame zero and all input frames. Launching the original emulator paused lets Lua sample frame zero before advancing. Its metadata.json must remain beside frames.csv.

Add --scene-memory --trace-rng --timeout 300 to that capture command for all known dispatcher slots, camera/RNG globals and the source RNG call/context log. The host validates the sibling memory file’s layout, length and SHA-256, then checks each decoded player/camera record against its frame CSV. Old CSV-only references remain usable but do not provide original actor/RNG coverage.

dotnet build tools/XSharp.MovieParity/XSharp.MovieParity.csproj
Push-Location tools/XSharp.MovieParity/bin/Debug/net9.0-windows7.0
try {
    .\XSharp.MovieParity.exe `
        'C:\Program Files\BizHawk\Movies\Gap Jumps.bk2' `
        'C:\path\to\Megaman X2 (USA).sfc' `
        'C:\path\to\original-capture\frames.csv' `
        "$env:TEMP\xsharp-gap-parity"
} finally {
    Pop-Location
}

Output must be absent or empty. The source movie, ROM and capture are read-only. ROM/movie/reference hashes and continuous frame indices are validated before initialization. There are no resets, input substitutions, trajectory corrections or per-frame synchronization during playback. Live controls are excluded by the engine input override. Sound channels are muted after warmup; native devices are still used by this full-engine host.

Append --frames 120 to stop at original movie frame 120. Omitting it runs through the movie’s last input. The reference always remains the full capture, preserving original frame numbering.

Append --start-frame 906 for an explicitly restricted clip, such as Gator Capsule after stage entry. The start must be idle standing normal gameplay with zero velocity and released controls; unsupported states are rejected before device creation. The source stage/checkpoint, effective camera top-left limits, facing and supported initial state come from that exact source memory record. The report declares its first/last compared frames and excluded prefix. Source input row 906 drives the update from state 906 to 907; the aligned start is not counted as an executed input or an RNG call. Derivatives restart at the clip boundary. Requested camera-limit interpolation and unsupported actor controllers are not converted. Movies whose scene begins with unsupported dust/actors may already have scene differences at the aligned start.

Append --verify-state-at 506 to save the pending ladder-top contact and, after continuous capture finishes, restore it and compare 20 subsequent updates. This includes player/camera motion, RNG and all recorded engine entities, including indices, lifetimes, counters and states. A failure writes state-replay-difference.json before exiting. This optional check requires 20 following frames and never rewinds or corrects the continuous comparison itself. Shader/audio resources are resolved relative to the executable.

comparison.csv stores the original and engine observables, signed differences, original state/substate, engine state, contacts and camera diagnostics. Frame n follows zero-based BK2 input row n-1; frame zero is the aligned state. Positions and speeds use 8 fractional bits, with original VY positive upward. Extra precision in the engine is retained in separate residue columns and also causes a mismatch. Original and engine animation/state IDs are diagnostic only and are not numerically equated.

scene-comparison.csv adds camera displacement/acceleration, player velocity differences, source/engine seed and the source game-update counter. Derivatives are observed per-frame differences, with undefined initial values left empty. original-entities.jsonl.gz preserves occupied source slots and raw class-specific bytes; xsharp-entities.jsonl.gz records allocated engine entities and motion/state diagnostics. Pool addresses/dispatch bytes are not assumed to be engine indices or original event IDs. Their semantic correspondence still needs implementation.

xsharp-rng-calls.csv records each actual generator step as frame, within-frame call number, previous seed and new seed. RNG.Advanced is an optional diagnostic notification after the seed commits; subscribing does not draw another random value. Current ushort-range helpers read the current value, so they do not report a step. Seed alignment/restoration does not report a draw either. The optional rewind is excluded from the continuous call log. With original --trace-rng metadata, the host validates the sibling call CSV’s hash/schema/revision and reports separate per-frame call counts and their first difference, alongside seed comparison. No source count drives the engine.

Run tools/parity/validate_movie_parity_inputs.py --host <built-exe> --capture <capture-directory> --movie <movie.bk2> --rom <X2-USA.sfc> --output <new-directory> for eight rejection-path checks: hash, schema, frame-zero calls, reversed/out-of-range frames, seed overflow, wrong RNG entry and non-sibling paths. The checks create private CSV/metadata copies and require rejection before device initialization or host-output creation.

Run tools/parity/validate_movie_clip_inputs.py with the same arguments for clip-bound, rewind-range, duplicate-option, non-standing-state and stage-entry rejection checks. Both tools preserve the source capture. The research register documents portable evidence exports and synchronized MegaEDX/HunterBaseStudio metadata.

report.json records separate player, camera, acceleration and RNG first differences, counts/errors, provenance and missing entity coverage. Exit code 2 means completed but divergent/incomplete; code 1 means invalid inputs, execution failure or failed restoration. Code 0 is reserved for eventual full-scene validation and is not emitted while entity correspondence is unmapped. Each input advances one host tick; the captured source game counter additionally exposes logic updates skipped by the original, including frame 2185 despite its zero joypad-lag flag. Modeling that behavior remains pending.

The report also records the first dying/non-alive frame. Playback continues through the engine’s normal death/respawn behavior, so downstream errors can become large. It never repairs the run by resetting X to the reference trajectory.

Initial baseline

The first complete execution is preserved in docs/parity/gap-jumps-baseline.json. It executed all 4,186 inputs. The first mismatch was stored horizontal velocity at movie frame 71, the walking-animation transition. The first position mismatch was frame 80, where ground-jump preparation incorrectly continued a dash’s horizontal displacement. The original remained stationary on that update; the engine advanced by 885/256 pixels. Later differences accumulate from these initial mismatches, so they cannot independently establish the cause of a later failed ladder-gap jump.

The BK2 reader, immutable movie data and input-session implementation were reused from the existing feature/demos work. They do not initialize devices. This does not import the complete recorder/controller/shortcut feature or imply that native SNES save states can be restored by XSharp.

Opening corrections and next divergence

docs/parity/gap-jumps-opening-fixes.json preserves a second full 4,186-input execution after correcting the X2 walking-transition stored speed and horizontal movement during ground-jump preparation. Frames 0 through 103 match X/Y/VX/VY exactly. The next mismatch is horizontal stored speed on frame 104, followed by position on frame 105: the engine treats the adjacent floor as a completed landing before the original resolves penetration. That changes the dash-inherited air speed and the fractional landing coordinate.

That full-movie run still fails parity. Later trajectory errors accumulate; XSharp enters its dying state at frame 1584 and becomes non-alive at 1615, while the original capture retains 18 health throughout. These later outcomes must not be described as faithful playback.

First landing correction

The first landing/contact transition is now corrected using original ROM write traces and controlled input experiments. The flat-floor analysis documents the executed instructions, fractional correction and delayed consumption of contact. docs/parity/gap-jumps-floor-fix.json preserves a further complete 4,186-input run: X/Y/VX/VY match through frame 121; the first speed difference is now 122 and the first position difference 123, at wall contact. The optional frame-105 save check passes 20 updates after restoration. Full parity and the later death remain unresolved.

For ordinary interactive Sponge testing in the existing demo, the user’s local ROM is selected through XSharpShared/Engine/Consts.cs:

public const string ROM_NAME = "BestGame.mmx";
public const int INITIAL_LEVEL = 2;

The existing local XSharp/Assets/ROMs/BestGame.mmx matches the documented X2 USA SHA-1. This comparison host selects the same ROM/stage through LoadInitialLevel, so it does not need a global constant change.

Wall-slide and airborne-input correction

The wall-slide analysis records the next milestone. docs/parity/gap-jumps-wall-slide.json is a 500-input diagnostic with an exact X/Y/VX/VY prefix through 158 and a passing 20-update replay from frame 123. The next mismatch is ceiling resolution on frame 159. The wall-slide entry frame retains its old speeds, the next eight updates hang with a one-pixel horizontal stored speed, and X2 airborne horizontal input takes effect without the ground delay or turn pause. Complete movie parity remains pending.

Diagnostic native cadence

--reference-cadence 1 is an explicit diagnostic mode. It reads only the captured native logic-counter increments to distinguish display frames from game updates. A held display frame executes no engine tick; it does not rewrite positions, speed, RNG or actor state. Input/display indices still advance, and snapshot verification follows the same clock. Counter jumps other than zero/one are rejected.

This mode isolates downstream physics/content differences from native resource-loading stalls. It is timing-assisted comparison, not proof that XSharp autonomously reproduces SNES scheduling. The report declares the assistance and held display frames, and whole-scene acceptance remains false. The default continues to execute one engine tick per input and exposes native pacing divergences.

Native buster audit

The host now compares each translated buster with its original $10D8..1317 slot: identity, lifetime, 24-bit position, active native velocity, routine/phase, gun pose, facing and active animation cursor. It excludes animation/velocity bytes that the full-charge initialization has not yet written, and declares that limit in the report. Enemy health and player-only matching cannot certify weapon behavior. The first independent 900-frame audit caught the nonlethal impact-state reset and charged impact position at 763/764; later full runs also exposed the initial dash gun pose at 1779 and firing direction at 2620.

Native small-object audit

nativeSmallObjectAudit separately checks the $1818..1D17 slots for Scriver fragments (2B), Aclanda fragments (37), static dust (10), rising dash smoke (31) and dash sparks (0B). It compares identity, lifetime, position, facing and animation; fragments additionally compare their active velocities and counter, and dash smoke compares its active velocity. Static dust retains unrelated old velocity and counter bytes, which are explicitly outside its semantic comparison. An unported dust variant still counts as missing, rather than being treated as covered by the one implemented wall-slide particle. The report records the first failure overall and per dispatch family. This expanded audit does not drive simulation or supply missing allocations from the reference.

The initial complete diagnostic in docs/parity/gap-jumps-small-objects-audit-initial.json exposes its first missing dust object at 126. It also exposes fragment allocation/initialization differences that the isolated flight tests and complete major-enemy audit cannot certify. Whole-scene acceptance remains false even when motion, RNG, mapped major enemies and weapons all pass.

After native dash smoke/spark integration, the full diagnostic in docs/parity/gap-jumps-dash-effects.json advances that first failure to 554. Unported death explosions and other producers still affect the shared slot addresses/fractions; isolated flight and emission tests do not resolve that audit.

The paired X2 host explicitly enables UseOriginalObjectSlots before level loading, independently of its X2 player physics selection. Ordinary engine content defaults to unrestricted allocations; native capacities and retained slot fractions are a compatibility option. Do not switch the option after pools have been created. The native cadence diagnostic remains a separate option and does not emulate the graphics loading scheduler.

Native player animation audit

The host explicitly enables the optional X2 player animation simulation. After one initial native animation/cache alignment, the controller generates its own commands from engine movement, successful shots and input/transition phases. scene.nativePlayerAnimationAudit compares the countdown, entry flags, pending image bit, script address and cached image. It does not feed reference animation commands into the controller. Other player sprite variants, pixels and native transfer timing remain outside this audit.

player-animation-control.csv records engine-generated typed control inputs and native assertion targets. Its logic_counter column declares original execution cadence for isolated fixture tests; that assistance cannot certify autonomous scheduling. The revision-pinned headless regression also compares generated VRAM transfers with the independently captured transfer fixture. See the graphics scheduler analysis for the complete hosted result and remaining timing/scene work.