#!/bin/sh # SPDX-License-Identifier: MIT # The gate: build, then run every build headless on the family's fast 2600 board # (a2600-rust-fast, through tools/harness) and assert every frame's line count: # 1. a scripted console session (title, Game Select through all four games, # a two-player game played to game over with the difficulty switches # flipped, Game Reset from the title, Game Select out of a game, a new game); # 2. a paddle bot on two seeds (screen flips, clears, lost balls, game over). # NTSC and PAL60 must give 262 lines in every frame, PAL 312. Also fails if the # logic overruns a timer or a pixel probe disagrees with RAM. # Usage: scripts/check.sh [BOT_FRAMES] (default 18000 = five minutes per seed) set -eu cd "$(dirname "$0")/.." BOT_FRAMES="${1:-18000}" sh scripts/build.sh >/dev/null (cd tools/harness && nice cargo build --release --quiet) H=tools/harness/target/release/bigtop-harness mkdir -p target/check # Game Select x5 from the title (games 2,3,4,1,2), start game 2 (two players) # with the button; the paddle parked hard right so balls are lost; kicks now and # then; difficulty A/B flipped; game over by ~6500; Game Reset on the title; # Game Select during play (back to the title); start again with the button. SCRIPT="60:png=title.png,100:select,130:select,160:select,190:select,220:select,240:png=select.png" SCRIPT="$SCRIPT,300:pos=0.0,300:fire,330:png=serve.png,700:fire,900:diffA,1200:fire,2400:diffB,2500:fire" SCRIPT="$SCRIPT,7600:png=after-over.png,7700:reset,7720:png=reset.png,8200:select,8260:png=select-out.png" SCRIPT="$SCRIPT,8400:fire,8460:png=restart.png,8800:pos=0.2" FRAMES=9600 # The states session (game 1): each new state is reached by poking RAM and then # checked with expect= (RAM), the pixel probes (every 7th frame; the "net" probe # asserts no bat is drawn on an open floor) and a PNG. at() { f=$1; shift; for a in "$@"; do printf ',%s:%s' "$f" "$a"; done; } PLAY="poke=gameState=2 poke=vxH=0 poke=vxL=0 poke=cool=0" ST="60:fire,100:fire,150:expect=batW=24" # the top floor (no bat; its balloons popped here): the ball falls to the middle ST="$ST$(at 200 $PLAY poke=floor=2 poke=ballY=120 poke=ballX=80 poke=vyH=1 poke=vyL=128 poke=vxL=64 \ poke=balloons=0 poke=balloons+1=0 poke=balloons+2=0)" ST="$ST,212:png=open-top.png,212:expect=floor=2,245:png=fell-to-middle.png,245:expect=floor=1" # the emptied rows drift back in from the right, the top row first ST="$ST$(at 410 $PLAY poke=floor=2 poke=ballY=150 poke=ballX=30 poke=vyH=255 poke=vyL=0)" ST="$ST,425:png=refill.png,425:expect=balloons!=0,520:png=refill2.png,520:expect=balloons+1!=0" # the last drop target hit from below: 1000, the bat stays (2 = cleared bit 1), # and the targets come back after the wait, from the left ST="$ST$(at 600 $PLAY poke=floor=1 poke=ballY=70 poke=ballX=20 poke=vyH=253 poke=vyL=0 poke=drops=1 \ poke=dropT=0 poke=cleared=0 poke=msgT=0)" ST="$ST,616:expect=cleared=2,616:expect=drops=0,620:png=targets-cleared.png,700:expect=dropT!=0" ST="$ST,700:expect=drops=0$(at 760 $PLAY poke=floor=1 poke=ballY=110 poke=ballX=130 poke=vyH=0 poke=vyL=0)" ST="$ST,775:png=targets-back.png,800:expect=drops=255,800:expect=dropT=0" # the last balloon popped: multiplier 2x (multK 6) on the status line; a lost ball # puts it back to 1x ST="$ST$(at 900 $PLAY poke=floor=2 poke=ballY=40 poke=ballX=42 poke=vyH=253 poke=vyL=0 poke=rowX=40 \ poke=balloons=1 poke=balloons+1=0 poke=balloons+2=0 poke=cleared=2 poke=multK=0 poke=msgT=0)" ST="$ST,915:expect=multK=6,915:expect=balloons=0,925:png=multiplier.png" ST="$ST$(at 960 $PLAY poke=floor=0 poke=ballY=150 poke=ballX=20 poke=vyH=3 poke=vyL=0)" ST="$ST,1000:expect=gameState=3,1100:expect=gameState=1,1100:expect=multK=0" # Big Top: the bricks cleared, the drop targets' clear (cleared bit 1) already # made or made now: here the last target is hit from below with the bricks gone ST="$ST$(at 1150 $PLAY poke=floor=1 poke=ballY=70 poke=ballX=20 poke=vyH=253 poke=vyL=0 poke=drops=1 \ poke=dropT=0 poke=cleared=1 poke=bricks=0 poke=bricks+1=0 poke=bricks+2=0 poke=bricks+3=0 \ poke=bricks+4=0 poke=bricks+5=0 poke=msgT=0)" ST="$ST,1166:png=bigtop.png,1170:expect=level=1,1170:expect=cleared=0,1170:expect=drops=255" ST="$ST,1170:expect=balloons=63" # difficulty switches: the left one sets player 1's bat, the right one player 2's ST="$ST,1200:diffA,1210:expect=batW=16,1220:diffB,1220:diffRA,1230:expect=batW=24,1240:poke=curPlayer=1" ST="$ST,1250:expect=batW=16,1260:poke=curPlayer=0,1260:diffRB" # a ball falling in from the top floor passes in front of the clown (it would # have hit it on frames ~1281-1283 under the old rule) ST="$ST$(at 1270 $PLAY poke=floor=2 poke=ballY=150 poke=ballX=95 poke=vyH=2 poke=vyL=0 poke=clownX=84 \ poke=clownDir=1 poke=clownHit=0)" ST="$ST,1283:png=clown-pass.png,1295:expect=floor=1,1295:expect=clownHit=0" # punch-through: speed 7 going up at 15 degrees (the table's speed-7 class-0 # velocity, vx $006D, vy -$0330) through balloon 1 of each row (rows set moving # right, placed where the ball crosses them at level 1's row speeds): three pops # without a bounce, one speed step each, 7 -> 4; the ball and walls in the punch # colour ST="$ST$(at 1320 $PLAY poke=floor=2 poke=ballY=80 poke=ballX=56 poke=vxL=109 poke=vyH=252 poke=vyL=208 \ poke=speed=7 poke=rowDirs=0 poke=rowX=36 poke=rowX+1=40 poke=rowX+2=38 poke=balloons=63 poke=balloons+1=63 \ poke=balloons+2=63 poke=msgT=0)" ST="$ST,1326:png=punch.png,1343:expect=speed=4,1343:expect=balloons=55,1343:expect=balloons+1=55" ST="$ST,1343:expect=balloons+2=55" # a plain pop below the threshold bounces and still spends a step: speed 3 going up # (vx $004B, vy -$022C) pops balloon 1 of the lowest row, comes down at speed 2 # (class 0: vy $01EF, vyH 1) ST="$ST$(at 1400 $PLAY poke=floor=2 poke=ballY=80 poke=ballX=56 poke=vxL=75 poke=vyH=253 poke=vyL=212 \ poke=speed=3 poke=rowX+2=40 poke=balloons+2=63 poke=msgT=0)" ST="$ST,1415:expect=speed=2,1415:expect=vyH=1,1415:expect=balloons+2=55" # the cap: a kick (+2) at speed 7 stays at 7 (kick 0: the kick was taken) ST="$ST$(at 1450 $PLAY poke=floor=0 poke=ballY=150 poke=ballX=74 poke=vyH=2 poke=vyL=0 poke=speed=7 \ poke=kick=24)" ST="$ST,1462:expect=kick=0,1462:expect=speed=7,1462:expect=floor=0" STFRAMES=1500 fail=0 for v in ntsc pal60 pal; do case $v in ntsc) m=ntsc; l=262 ;; pal60) m=pal; l=262 ;; pal) m=pal; l=312 ;; esac echo "== $v (machine $m, $l lines)" out=$(timeout 600 nice "$H" run "build/bigtop-$v.bin" --machine $m --lines $l \ --frames $FRAMES --out "target/check/$v" --script "$SCRIPT") || { echo "$out"; fail=1; continue; } echo "$out" | grep -E "^frames|^timer|^states" | cut -c1-160 echo "$out" | grep -q "states seen {0, 1, 2, 3, 4}" || { echo "FAIL: not every state visited"; fail=1; } echo "$out" | grep -q "players {0, 1}" || { echo "FAIL: player 2 never played"; fail=1; } echo "$out" | grep -E "^probes|^stack|^FAIL" echo "-- states session (batless top, refill, targets back, multiplier, Big Top, switches, clown, power)" out=$(timeout 300 nice "$H" run "build/bigtop-$v.bin" --machine $m --lines $l \ --frames $STFRAMES --out "target/check/$v-states" --script "$ST") || { echo "$out"; fail=1; continue; } echo "$out" | grep -E "^frames|^probes|^expectations|^stack" | cut -c1-160 echo "$out" | grep -q "probes [0-9]* ([1-9][0-9]* open-net), failed 0" || { echo "FAIL: no open-net probe"; fail=1; } for s in 1 2; do log="target/check/$v-bot$s.log" timeout 900 nice "$H" bot "build/bigtop-$v.bin" --machine $m --lines $l \ --frames "$BOT_FRAMES" --seed $s --out "target/check/$v-bot$s" > "$log" 2>&1 \ || { echo "FAIL: bot seed $s ($log)"; fail=1; } grep -E "^summary|^line counts|^stack|^FAIL" "$log" | cut -c1-400 # the ball must fall from the batless top floor, and no ball may bounce off # the clown straight back to it. (Refills and drop-target clears are only # reported here: in 5 bot-minutes a full balloon clear is chance, about one # ball in five, and the NTSC seed 1 run of 2026-11-22 had none; the states # session checks both states deterministically.) grep -q "open falls [1-9]" "$log" || { echo "FAIL: no fall from the batless top floor (seed $s)"; fail=1; } grep -q "(clown 0)" "$log" || { echo "FAIL: clown bounce-back (seed $s)"; fail=1; } grep -E "^per ball" "$log" | cut -c1-200 done done [ $fail = 0 ] && echo "CHECK PASSED" || { echo "CHECK FAILED"; exit 1; }