Skip to content

denise: move the DIW comparator anchor to the hardware 2H-196 mapping#107

Merged
LinuxJedi merged 1 commit into
mainfrom
fix/diw-edge-anchor
Jul 4, 2026
Merged

denise: move the DIW comparator anchor to the hardware 2H-196 mapping#107
LinuxJedi merged 1 commit into
mainfrom
fix/diw-edge-anchor

Conversation

@LinuxJedi

Copy link
Copy Markdown
Owner

Summary

Move the Denise display-window comparator anchor one lores pixel left:
DIWSTRT/DIWSTOP hstart H now maps to framebuffer x = 2H - 196 (was 2H - 194).
Sprites follow (they share Denise's counter); bitplane fetch references move
+1 in lockstep so bitmap pixels keep their hardware-calibrated beam-anchored
positions. Net effect: every display window edge and sprite moves 2
framebuffer px left; bitmaps and colour writes stay.

This is the second half of the 1-lores-px divergence behind issues #68/#69
(the first half, early-DDF picture phase, landed as #10x). A standard lores
screen now shows its first bitmap sample flush at the window edge, as real
hardware does.

Hardware arbitration

vAmigaTS Agnus/Blitter/sblit/sblit0 (lores, DDF $38, standard DIW, image
flush to both window edges; real photo sblit0_A500_ECS.jpeg). In the
emulators, interior content positions agree exactly; the only difference is
the left window clip: vAmiga shows the leftmost partial swatch column 24 fb
px wide (= the right one), Copperline clipped it to 22. The photo (subpixel
edge detection, ~100 rows averaged per band, widths normalized by the
16-fb-px inter-swatch gap) measures the left partial column at 24.2 fb px
(lower band) / 24.5 (upper band) vs 24.9 for the right partial column -
full width, i.e. the window edge sits at 2H - 196 and exposes bitmap
sample 0. Copperline's 2H - 194 predicted 22 (2.8 photo px narrower than
measured, versus about 0.1 px scatter).

The old anchor also explains why the removed early-DDF "-1 sample"
correction existed: with the window edge 2px too far right, a standard DIW
overran the fetched row on early-DDF screens.

What changed

  • bitplane::DIW_HSTART_FB0 and bus::RENDER_DIW_HSTART_FB0 0x61 -> 0x62
    (window comparator + sprites/collisions).
  • Fetch references +1 (DIW_HSTART_FETCH_REFERENCE_LORES/HIRES, and the
    capture twins): bitmap sample positions are unchanged in the framebuffer.
  • Derived values move automatically: BITPLANE_CONTROL_PIPELINE_FB 34 -> 36,
    STANDARD_VISIBLE_X0 64 -> 62, TV cutout, presentation recentring 26 -> 24.
  • Colour/copper anchors (COLOR_WRITE_HPOS_FB0 etc.) untouched - they were
    verified against vAmiga (latch2 0.000%) and hardware.
  • Test expectations updated with hardware-verdict comments; sprite clxdat
    tests keep their overlap geometry by moving the programmed sprite hstart
    with the comparator.

Scores and checks

  • cargo test --release green (28 tests re-derived for the new anchor with
    hardware-verdict comments), cargo clippy and cargo fmt --check clean.
  • Calibrated-web checks (fetch-reference gates): KS1.3 boot (hires FMODE=0)
    and A1200 KS3.1 boot (hires FMODE=3) differ from the previous stage ONLY
    in the 2px border column at the window edge - the hires pictures did not
    move. Second Nature (lores composite) and the KS1.3 TV-mode presentation
    eyeballed clean; TV recentring follows the window (26 -> 24).
  • Demo screenshots vs the early-DDF stage: every difference is in the
    predicted classes - the newly exposed first bitmap column at standard
    window edges (Hamazing x 62-63), window-close clip at 702 (Inside the
    Machine), border column at x 14-15 (Gen-X, kicka1200, Zool), and sprite
    layers moving with the comparator (Zool cracktro text rows shift exactly
    -2 with zero residual; Gen-X gears shutter edge columns).
  • cargo test --release --test image_regression -- --ignored: 7 pass
    (ocs_bpu7_ham is the documented host-flaky perf test).
  • vAmigaTS full sweep (1929 cases vs vAmiga 4.4 refs), bucket means
    combined with the early-DDF PR against the pre-fix baseline:
    Agnus/DIW/OLDDIW 47.0% -> 4.3%, Denise/DIW 9.8% -> 0.9%, Denise/Sprites
    9.4% -> 5.1% (114 cases - the sprite anchor verified against vAmiga),
    Agnus/Copper 15.8% -> 9.7%, Agnus/DDF 9.7% -> 6.9%, Agnus/Blitter
    16.5% -> 14.4%. Standouts: Denise/Misc/Overscan/overscan2 90.8% ->
    0.004%, diw7/diw9/diw3/jumpbpu2 exactly 0.000%. The only score
    increases are CPU-timing buckets and coprace2; spot-checked MOVES8w
    (48.339%) and coprace2 (42.383%) regenerate to the same scores on
    clean main - pre-existing drift from the floating-bus work (vAmigaTS sweep fixes: 68000 floating bus + CIA-B POUT/CNT wiring #102),
    not this change.
  • Gen-X issue Demo issues #69 "endpart leftmost column missing": the end-text pages
    now show the previously clipped first lores column at the window edge
    (620s screenshot, content at framebuffer x 62-63).

A DIWSTRT/DIWSTOP hstart value H now opens/closes the display window at
framebuffer x = 2H - 196 (previously 2H - 194). Real hardware verdict from
the vAmigaTS Agnus/Blitter/sblit/sblit0 A500 photo: the leftmost partial
swatch column measures 24 fb px wide (gap-normalized, two independent
bands), equal to the right partial column, so the window edge exposes the
standard picture's first lo-res sample; Copperline clipped it to 22.

DIW_HSTART_FB0 and RENDER_DIW_HSTART_FB0 move 0x61 -> 0x62; sprites and
collisions follow automatically (SPRxPOS drives the same Denise counter
comparator). The bitplane fetch references move +1 in lockstep so bitmap
sample positions stay at their hardware-calibrated beam-anchored
framebuffer columns; colour/copper anchors are untouched. Derived values
shift with the window: BITPLANE_CONTROL_PIPELINE_FB 34 -> 36,
STANDARD_VISIBLE_X0 64 -> 62, TV cutout, presentation recentring 26 -> 24.

Combined with the linear early-DDF placement fix, vAmigaTS bucket means
move: Agnus/DIW/OLDDIW 47.0% -> 4.3%, Denise/DIW 9.8% -> 0.9%,
Denise/Sprites 9.4% -> 5.1%, Agnus/Copper 15.8% -> 9.7%,
Denise/Misc/Overscan/overscan2 90.8% -> 0.004%. KS1.3 (hires FMODE=0) and
A1200 KS3.1 (hires FMODE=3) boot pictures do not move; Gen-X's end-text
pages regain their previously clipped first column (issue #69).
Base automatically changed from fix/early-ddf-picture-phase to main July 4, 2026 10:09
@LinuxJedi LinuxJedi merged commit 5179b4b into main Jul 4, 2026
8 checks passed
@LinuxJedi LinuxJedi deleted the fix/diw-edge-anchor branch July 4, 2026 10:10
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