Put the frame clock on the 68000, and find that the 12 fps frame does not exist
ROADMAP P3 said "needs MFP timer or VBL" and neither can do it. The MFP's timer clock is 16 MHz/4, its prescalers stop at 200 and its data register is 8 bits, so the slowest tick any single timer can make is 78.125 Hz -- 6.5x faster than a frame -- and 4e6/12 is not an integer, so no setting reaches 12 Hz at all. The raster has no whole divide near 12 either: 4 refreshes is 13.86 fps and 5 is 11.09. tools/analysis/23_frame_clock.py walks all 7x256 timer settings rather than asserting it. src/player/clock.i takes the V-DISP falling edge on MFP GPIP4 -- the start of vertical blanking, which is when a player would present -- and adds fps*VTOTAL per edge to a 16-bit accumulator, emitting a tick at 31,500 and keeping the remainder. The long-run rate is fps*VTOTAL/VTOTAL = 12.000000 fps exactly, and both constants are read out of the CRTC at init, so the clock is derived from the registers that generate the raster it counts. Measured over 3,000 refreshes: 3,000 interrupts, 649 ticks where 649.1429 were due. It costs 181.35 clocks per V-DISP, 838 per frame, 0.1006% of the budget -- timed by the 68000 itself, because the host's granularity is 17.64 ms and the interrupt is microseconds. The loop's own cost was calibrated rather than looked up and landed on 38.000002 clocks, which both licenses the subtraction and confirms buscost.py's model; the 181.35 then decomposes exactly, leaving 43.99 clocks for the interrupt exception -- the textbook 44, measured. THE ONE THAT MOVES SOMETHING: 12 fps on a 55.4577 Hz raster is 4.6215 refreshes, so a frame is shown for 4 refreshes (72.13 ms) or 5 (90.16 ms), 37.9% of them short. The 833,333-clock budget every figure in this project is priced against is the MEAN slot, and the short one is 13.4% under it. The cadence was already in the tree unnamed: stream.lua's tick is sampled at frame boundaries, so its gaps were always 4 or 5, and every host-paced result in FINDINGS 49/51 carried it. P3 moved who produces it onto the machine and made it visible. It is not a dropped frame -- the pace gate lets an overrun eat the next frame's idle -- and on the gate container it costs 4 frames of 120 their idle against 1 for the nominal model, most of that the frame-0 transient at 111% of budget. stream.s counts it now, and the rig matches an offline model of the divider exactly. Also struck: MAME's raster runs 2.22% fast. refresh_mode() builds the frame period from scr.max_x*scr.max_y with scr.max_x = m_htotal - 8, one character cell short and an inclusive bound used as a count, so it runs at 56.6901 Hz where the registers say 55.4577 -- agreeing to six digits with the arithmetic. Every "1/55.46 s granularity" note in this tree was wrong and is 1/56.69 s, corrected in six files with the derivation put once in crtc_mode.lua. No conclusion changes and no 68000 cycle figure moves; the CPU clock is unrelated to the screen. But anything paced by the raster runs fast under MAME, so the rig reports both rates and prices the interrupt against the hardware's. decode.s and frame.i are unchanged; decode.bin is still 1,296 B at the same MD5. The pace gate's wait loop is byte-for-byte the one FINDINGS 51 measured and the free-running path executes none of the new code. check.sh gains two stages: the clock's own measurement, and 120 frames decoded pixel-exact with nothing outside the machine deciding when a frame may start. Claude-Session: https://claude.ai/code/session_01194oWYW8DQXK1SZ2DnChW6
This commit is contained in:
+45
-1
@@ -286,7 +286,7 @@ echo "--- session 21: the 68000 builds its own codebooks and palette (FINDINGS 5
|
||||
#
|
||||
# NOT gated on the cycle counts, and the reason is NOT the one blit.s has. These
|
||||
# are emulated time and reproduce exactly run to run; what they are not is
|
||||
# sharp, because MAME samples them on a 1/55.46 s clock and the job takes
|
||||
# sharp, because MAME samples them on a 1/56.69 s clock and the job takes
|
||||
# milliseconds. Nothing in the tree's cost models depends on them either. A
|
||||
# change in them is a re-derivation in FINDINGS 53, not a red light here.
|
||||
bash tools/bench/load_run.sh "$DLX" > tmp/load_gate.log 2>&1 || {
|
||||
@@ -294,4 +294,48 @@ bash tools/bench/load_run.sh "$DLX" > tmp/load_gate.log 2>&1 || {
|
||||
exit 1; }
|
||||
grep -aE "^ *OK|both CPU cores|SCENE CHANGE" tmp/load_gate.log | sed 's/^ *//;s/^/ /'
|
||||
|
||||
echo "--- session 22: the 68000 keeps its own frame clock (FINDINGS 54) ---"
|
||||
# ROADMAP P3. Until now the 12 fps tick came from tools/bench/stream.lua -- a
|
||||
# host writing a word into emulated RAM. A player has no host. src/player/
|
||||
# clock.i derives the tick from the CRTC's own V-DISP output through the MFP,
|
||||
# with a remainder-keeping divider whose two constants are READ OUT OF THE CRTC
|
||||
# at init, so the clock and the raster it counts cannot disagree.
|
||||
#
|
||||
# WHAT IS GATED, and it is deliberately structural rather than numeric:
|
||||
# * the interrupt count equals the raster frame count -- the tick IS the
|
||||
# raster, not something that merely resembles it;
|
||||
# * the divider does not accumulate drift, stated in TICKS (a remainder can
|
||||
# hold back at most one) rather than in ppm, which would let a longer
|
||||
# window advertise a tighter clock for free;
|
||||
# * every frame tick waits 4 or 5 refreshes and nothing else, which is what a
|
||||
# remainder-keeping divider can produce and a broken one cannot.
|
||||
# The interrupt COST is printed and not gated, for the same reason FINDINGS 53's
|
||||
# cycle counts are not: it is a measurement, and a change in it is a
|
||||
# re-derivation in FINDINGS 54 rather than a red light here.
|
||||
bash tools/bench/clock_run.sh 3000 12 > tmp/clock_gate.log 2>&1 || {
|
||||
echo "FAIL: the frame clock did not pass."; tail -12 tmp/clock_gate.log
|
||||
exit 1; }
|
||||
grep -aE "INTERRUPT:|PER FRAME:|DRIFT:|CADENCE:" tmp/clock_gate.log
|
||||
grep -q "V-DISP interrupts 3000" tmp/clock_gate.log || {
|
||||
echo "FAIL: the tick is not the raster -- the interrupt count and the frame"
|
||||
echo " count disagree. Everything else in FINDINGS 54 rests on that."
|
||||
exit 1; }
|
||||
|
||||
echo "--- session 22: 120 frames decoded on the machine's own clock (FINDINGS 54) ---"
|
||||
# The strongest form of the claim: the same pixel-exact 120-frame decode out of
|
||||
# the same 256 KB ring, with NOTHING outside the machine deciding when a frame
|
||||
# may start. The pace gate in src/player/stream.s is byte-for-byte the one
|
||||
# FINDINGS 51 measured -- it cannot tell a host-written tick from a machine-
|
||||
# written one, which is why this is a test of the clock and not of a new rig.
|
||||
DLX_PACE=2 bash tools/bench/pace_run.sh 256 0 > tmp/selfpace_check.log 2>&1 || {
|
||||
echo "FAIL: the self-paced pass did not complete."; tail -8 tmp/selfpace_check.log
|
||||
exit 1; }
|
||||
grep -aE "decoder SELF-PACED|FRAME CLOCK|UNDERRUNS|NO IDLE" tmp/selfpace_check.log
|
||||
grep -q "UNDERRUNS: 0/120" tmp/selfpace_check.log || {
|
||||
echo "FAIL: the self-paced decoder underran."; exit 1; }
|
||||
grep -q "^OK" tmp/selfpace_check.log || {
|
||||
echo "FAIL: the self-paced pass was not pixel-exact. The clock changed WHEN"
|
||||
echo " frames start; if it changed WHAT they draw, the interrupt is"
|
||||
echo " corrupting decoder state."; tail -4 tmp/selfpace_check.log; exit 1; }
|
||||
|
||||
echo "ALL GREEN"
|
||||
|
||||
Reference in New Issue
Block a user