XSharp

Imported map quadrant regression

The first standalone asset integration (1bb8a3c through ce8cdcc) included incorrect tile placement inside each 16x16 map. The reader accepted the files, but the exported graphics were visibly fragmented into an 8x8 checker pattern.

The original map record is four consecutive 16-bit tile descriptors in row-major order: top-left, top-right, bottom-left, bottom-right. The compatibility loader’s RefreshMapCache places those at (x,y) = (0,0), (8,0), (0,8), (8,8). ROMExporter.MapProperties.SetCell instead accepts (row, column); the exporter had passed the second and third descriptors as (1,0) and (0,1). That swapped the entire top-right and bottom-left descriptors, including their palette, flips and priority. Pixel decoding and renderer UVs were not the cause.

The exporter now uses (0,0), (0,1), (1,0), (1,1). This fixes newly imported foreground and background maps, including shared resource snapshots. All 41 sandbox packages and the embedded Penguin package must be regenerated, and the catalog package hashes/mirrored HunterBaseStudio catalog refreshed. Existing externally imported affected packages require reimport; do not transpose arbitrary authored packages or change the row-major schema to compensate.

Regression evidence

LevelExporterGraphicsTests feeds distinct synthetic native tile words and asymmetric pixel patterns through the actual RefreshMapCache and JSON serialization path for both foreground/background. It checks the position, palette, flip/mirror, priority and all 64 source pixels of each quadrant. The pre-fix exporter failed the top-right palette check (expected 2, actual 3). The synthetic fixture does not require a ROM or an engine/device.

The complete regenerated asset delta can be audited without a ROM as well:

python tools/verify_level_quadrant_repair.py --baseline ce8cdcc --output docs/levels/quadrant-repair-audit.json

This compares every base/shared graphics package to the affected Git revision, requiring exactly the quadrant permutation and unchanged source pixels, palettes, collision records, geometry, checkpoints, events and selector coverage. The checked-in audit result passed for all 42 packages / 1,722 logical resource states: 179 distinct graphics packages, 366,592 map records, of which 332,442 had different off-diagonal quadrants. The full CPU preparation of those assets and 55 focused tests also passed.

Earlier package/reader tests checked structural validity, atlas pixels and world creation from authored fixtures. They did not test the native descriptor order through the exporter, so their passing result did not detect this bug.

The DX9 smoke runner can now capture its real render target after the same 420 startup frames, before its resource-switch/state tests:

dotnet run --project tests/XSharp.LevelSmoke/XSharp.LevelSmoke.csproj -- --penguin 0 --capture=C:/Evidence/penguin.png

The captures below use the same startup, camera and host. They demonstrate the reported rendering regression and its repair; they are not a pixel-parity comparison with the original SNES renderer or validation of every stage.

Before:

Penguin with transposed tile quadrants

After:

Penguin with corrected tile quadrants