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
59 lines
3.3 KiB
Bash
Executable File
59 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# One paced ring-buffer run (STATUS item 4, FINDINGS 49.7.2).
|
|
#
|
|
# tools/bench/check.sh runs the ring pass FREE-RUNNING, which is right for what
|
|
# it gates -- wrap correctness at a fixed ring size, delivery removed as a
|
|
# variable by an unlimited pipe. It cannot answer the buffering question,
|
|
# because a free-running decoder never lets the ring back up.
|
|
#
|
|
# This runs the same rig with the decoder held to the container's frame rate,
|
|
# so the ring fills and FR_HEAD-FR_TAIL means "frames the decoder could still
|
|
# draw with the pipe dead". Every run is verified PIXEL-EXACT: a paced decode
|
|
# that drops a pixel is not a slack measurement, it is a bug.
|
|
#
|
|
# tools/bench/pace_run.sh <ring_kb> <kbps> [cut_at_tick] [cut_frames]
|
|
#
|
|
# kbps 0 = unlimited pipe. There is no default rate anywhere in this tree
|
|
# (FINDINGS 50) and there is none here either.
|
|
#
|
|
# DLX_PACE selects WHO KEEPS THE TIME: 1 (default) is the host writing the tick,
|
|
# 2 is the 68000 writing it off the CRTC's V-DISP (ROADMAP P3, FINDINGS 54).
|
|
# Everything else about the run is identical, which is the whole point -- the
|
|
# pace gate in src/player/stream.s cannot tell them apart, so a difference in
|
|
# the result is a difference in the CLOCK and not in the rig.
|
|
set -e
|
|
cd "$(dirname "$0")/../.."
|
|
RING=${1:?ring KB}; KBPS=${2:?pipe KB/s, or 0 for unlimited}
|
|
CUT_AT=$3; CUT_FR=${4:-1}
|
|
DLX=${DLX:-tmp/rc_fr_singe_scsi_span.dlx}
|
|
PACE=${DLX_PACE:-1}
|
|
TAG="r${RING}_k${KBPS}${CUT_AT:+_cut${CUT_AT}x${CUT_FR}}"
|
|
# The default tag is left ALONE when the host keeps the time: tools/bench/
|
|
# pace_sweep.sh reads tmp/pace_r<ring>_k<kbps>.log by name, and renaming the
|
|
# host-paced logs would break a sweep that has nothing to do with this option.
|
|
if [ "$PACE" != 1 ]; then TAG="${TAG}_p$PACE"; fi
|
|
|
|
tools/vasm/vasmm68k_mot -Fbin -o tmp/stream.bin src/player/stream.s > /dev/null
|
|
[ -f tmp/stream_disk.bin ] || python3 tools/bench/prep_stream.py "$DLX" > tmp/prep_stream.log
|
|
mkdir -p "tmp/snap_pace_$TAG"; rm -f "tmp/snap_pace_$TAG/x68000"/*.png
|
|
# `env` rather than an assignment prefix: an empty ${CUT_AT:+...} in the middle
|
|
# of a prefix is not an assignment token, so bash takes the next word as the
|
|
# command and the run dies with "SDL_VIDEODRIVER=dummy: command not found".
|
|
CUTENV=(); [ -n "$CUT_AT" ] && CUTENV=(DLX_CUT_AT="$CUT_AT" DLX_CUT_FR="$CUT_FR")
|
|
( cd tmp && env DLX_PACE=$PACE DLX_RING_KB=$RING DLX_STREAM_KBPS=$KBPS \
|
|
"${CUTENV[@]}" DLX_SLACK_CSV="slack_$TAG.csv" \
|
|
SDL_VIDEODRIVER=dummy stdbuf -oL timeout -k 5 900 \
|
|
mame x68000 -bios ipl10 -ramsize 2M -video soft -window -sound none \
|
|
-nothrottle -plugins -autoboot_script ../tools/bench/stream.lua \
|
|
-snapshot_directory "./snap_pace_$TAG" -snapview native -seconds_to_run 90 \
|
|
> "pace_$TAG.log" 2>&1 )
|
|
# The completion marker is not optional: a run killed mid-decode compares a
|
|
# half-drawn screen and reads as a wrap bug rather than as a truncated run.
|
|
grep -q "snapshot taken" "tmp/pace_$TAG.log" || {
|
|
echo "FAIL($TAG): no snapshot marker -- the pass did not complete."
|
|
tail -6 "tmp/pace_$TAG.log"; exit 1; }
|
|
echo "=== $TAG"
|
|
grep -aE "decoder (SELF-PACED|PACED|FREE)|FRAME CLOCK|ring: |UNDERRUNS|NO IDLE|SEEK SLACK|RING-BOUND|RATE-BOUND|BUILD TIME|PIPE CUT|DEADLINE|REQUIRED" \
|
|
"tmp/pace_$TAG.log" | sed "s/\[STR\] / /"
|
|
python3 tools/bench/verify_decode.py "$DLX" --snap "tmp/snap_pace_$TAG" | tail -2
|