XSharp

MegaManX2Recomp overlap audit

Source inspection on 2026-11-07, prompted by the user’s request to check existing work before expanding the XSharp timing implementation.

Pinned inputs and validation scope

This audit inspected the tracked source and dependency revision. It did not build or run that project, import its native states, or replay Gap Jumps.bk2 there. The indexed repository searches for Gap Jumps, Aclanda and Scriver returned no matches; this is a bounded search finding, not a claim about every untracked generated file or private trial.

Existing work worth using

The project already contains a working original-code execution route. Its X2 runtime boots the real RESET vector and interprets uncovered ROM code. Generated/AOT coverage is layered over that route. It deliberately has no handwritten host task scheduler: the original game’s scheduler executes as game code.

Area Existing implementation Implication for XSharp
Player, enemies and RNG Original instructions execute through the shared CPU bridge. Useful as original-code execution evidence; it is not a collection of independent C# gameplay controllers.
CPU bus and internal clocks Interpreter tracks actual bus transfers and remaining internal cycles; paced AOT accessors do per-access accounting. Consult this implementation before growing another general CPU timing engine. Its current runtime must be distinguished from older approximate helper documentation.
NMI and IRQ Original vectors enter WRAM trampolines and the relocated driver; IRQ delivery checks the I flag. Confirms the same driver layout observed locally; useful for interpreting the real control flow and pending-update behavior.
DMA and refresh Shared runtime already charges both. Relevant reference, with the precision differences below; not a direct substitute for the measured compatibility models.
CX4 Instruction-level HG51B implementation, plus documented synthesized internal tables. Strong existing candidate for studying native OAM processing and coprocessor wait times. Avoid designing another CX4 emulator from scratch.
Diagnostics and replay MMX2REPLAY records checkpoints and checks WRAM/CGRAM/OAM/VRAM hashes. Useful comparison architecture and possible additional diagnostic runtime; its format is not a BizHawk BK2 native state.
Disassembly discovery DiztinGUIsh metadata includes instruction modes and boundaries; generated C stays outside Git. Useful for static discovery and intermediate C generation. The documented X2 import has only one semantic label, so entity naming/control-flow review remains necessary.

The current interpreter explicitly totals observed bus work plus six clocks for each remaining internal cycle. Therefore the older instr_master_cycles first-cut combiner in the Python recompiler is not, by itself, evidence that the current interpreter uses that approximation. The actual execution path was checked before drawing the following narrower conclusions.

Timing differences relevant to Gap Jumps

  1. X2 host frame budget. RunOneFrameOfGame uses 1364 * 262 clocks from the current CPU time and injects NMI at the next host-frame entry. The shared beam implementation also advances fixed 1364-clock lines. This differs from retaining the actual beam phase and the odd NTSC short scanline in the XSharp clock component.
  2. DMA setup/resumption. The general-DMA charge is a fixed 12-clock base plus eight clocks per enabled channel and eight per byte. It does not select setup/resume alignment from the live divider and the halted CPU-cycle length. As a formula comparison, a single 544-byte transfer charges 4,372 nominal clocks there; the locally measured native contexts need 4,376 or 4,384 before refresh. This comparison is a source-level inference, not a runtime failure reproduced in MegaManX2Recomp.
  3. Refresh placement. snes_refresh_charge accumulates work and adds 40 clocks per 1364-clock batch. It does not place refresh at the native revision-dependent horizontal position. XSharp’s separate component currently tests that physical placement against 11,999 original instruction intervals.

These are reasons to validate the proposed reference against the original BizHawk capture, especially around the lost update at 2185. They do not diminish its existing gameplay functionality or prove that its output diverges in this specific movie. No cross-project movie run has been performed by this audit.

Implementation direction

The pending acceptance remains autonomous Gap Jumps cadence. CPU/decompression/refresh and NMI work components still require engine-owned queue generation, task replacement/context handling and an independently derived task start phase. This repository is now part of that investigation’s reference set.