Skip to content

Say where in the frame the machine was touched, and stand on a scanline - #75

Merged
dimiro1 merged 2 commits into
masterfrom
dimiro1/-none
Sep 24, 2026
Merged

dimiro1 merged 2 commits into
masterfrom
dimiro1/-none

Conversation

@dimiro1

@dimiro1 dimiro1 commented Sep 24, 2026

Copy link
Copy Markdown
Owner

Three gaps in the headless debugger that a session of mid-screen raster work turned up. --log-events FILE (and events on|reads|off in the REPL) writes down every PPU, audio and mapper register write and both interrupts with the frame, scanline and dot each landed on — wiring up Debugger.setEventSink, which already produced all of it and had only the desktop's Events tab listening — so "where does this split land, on every frame, for two hundred frames" is one run rather than a stop and a state and a run per write; it arms nothing, and EventLogRunTests holds a logged run to the unlogged run's frame hash and cycle count. The REPL's state now reports v, t, fineX and writeLatch beside the beam position, spelled as the report has always spelled them — those four are what explains a background one tile out on exactly one scanline, where the scanline and dot are only the symptom. run-until-scanline N stands the machine part way down a frame: a sibling of run-until-change/-still rather than a beam term in break ... if, so a condition stays answerable from a CPU.State and a peek, and because the question raster work actually asks has no address in it. EventKind grew an id() beside its label so every record has seven whitespace-separated fields whatever happened, and --headless --help now opens with a map of its own sections.

mvn -B clean test is green across all eight modules.

🤖 Generated with Claude Code

dimiro1 and others added 2 commits September 24, 2026 19:51
Three gaps a session of mid-screen raster work found in the headless
debugger, easiest first.

The REPL's `state` reported the beam position and stopped there. For
raster work those are the symptom; loopy's v, t, fine-x and the write
latch are what explains them -- a coarse-X off by one tile on exactly one
scanline says so in `ppu.v` and nowhere else in the program. The report
has carried the same four all along, spelled the same way.

`--log-events FILE` is the second, and it is wiring rather than new
machinery: `Debugger.setEventSink` already hands out every PPU, audio and
mapper write and both interrupts with the beam position each landed on,
and nothing but the desktop's Events tab was listening. `EventTracer`
writes them down beside `Tracer`, one record a line with the frame,
scanline and dot, and `events on|reads|off` does it inside a session.

It stops nothing, which is the whole point: a watchpoint on $2006 in a
game whose NMI handler writes it forty times a frame is forty stops for
one frame's worth of answer, and a trace of the same run is a gigabyte.
This is the middle, and `EventLogRunTests` holds a logged run to the
unlogged run's frame hash and cycle count.

Seven whitespace separated fields on every line, which is why
`EventKind` grew an `id()` beside its label: five of the seven labels are
two words, so a reader cutting a line up would read the value of a PPU
write as the word "write".

`run-until-scanline N` is the third, and it is a sibling command rather
than a beam term in `break ... if`. A condition stays answerable from a
`CPU.State` and a `peek`, which is what its javadoc promises and what
keeps it testable without a machine -- and the question raster work
actually asks has no address in it at all.

And `--headless --help` opens with a map of its own sections, because it
is 250 lines and the half people miss is the half below the picture.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
SweepTests.aViewOnScreenIsSweptUntilItGoesAway showed a window, slept a
fixed 200ms and asserted a 5ms timer had ticked at least once. That whole
budget is one cold first-window creation on the event dispatch thread --
a native peer, a graphics pipeline, a font or two -- so on a loaded
Windows runner the thread can eat all of it with the timer started and
not yet run, which reads as a timer that never started. It failed that
way once on CI and passed on a re-run of the same commit.

It only surfaced now because the Windows and macOS runners arrived in the
commit before it: on Linux the test is skipped as headless, so this
assertion had barely run in CI at all.

So the positive half waits for the tick instead, up to ten seconds it
will never spend -- the cost of being wrong is asymmetric, a red build
nobody can reproduce against a few milliseconds on the one run where the
machine was busy. The negative half keeps its fixed pause, because an
absence has nothing to wait for and the timer is already stopped on the
dispatch thread before the pause begins.

Two smaller things fall out. isHeadless() is whether the JVM has a
display at all, which is weaker than whether the window just asked for
reached the screen, so the panel is asked directly and a machine that
cannot show one skips rather than fails. And the dispose moves into a
finally, so a failure leaves no window behind.

Checked by breaking Sweep so the timer never starts: the test still
fails, on the same assertion.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@dimiro1
dimiro1 merged commit 0871140 into master Sep 24, 2026
3 checks passed
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