#!/usr/bin/env bash # Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License. # See LICENSE.md for license information. # SPDX-License-Identifier: MIT # # verify-atarist-dirtymark.sh - the stage's dirty-band marker on a real 68000: # tests/host/dirtyMarkHost.c built for the Atari ST (make -f make/atarist.mk # atarist-dirtymark -> build/atarist/test/DIRTYMRK.PRG) and run under Hatari, # so the randomized marks and fills go through src/m68k/stageBands.s -- the asm # all three 68000 ports share -- and are held byte for byte to the plain # per-row widen. scripts/check-dirtymark.sh is the same harness on the host # against the C marker the x86 ports run. # # A wrong mark does not change the UBER hashes (they hash the surface, not the # bands); it shows as rows left stale on the screen, or copied for nothing. # # Usage: scripts/verify-atarist-dirtymark.sh # Env: TIMEOUT seconds to wait for the result (default 120) # Exit: 0 PASS, 1 FAIL, 2 SKIP (Hatari or EmuTOS not installed) set -uo pipefail repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) source "$repo/scripts/lib/joeyEnv.sh" timeout_s=${TIMEOUT:-120} prg=$repo/build/atarist/test/DIRTYMRK.PRG result=DIRTYMRK.TXT joeyNeed HATARI hatari joeyNeed EMUTOS_IMG emutos make -s -f "$repo/make/atarist.mk" atarist-dirtymark || { echo "verify-atarist-dirtymark: FAIL - building DIRTYMRK.PRG failed" >&2 exit 1 } work=$(mktemp -d -t joeylib-dirtymark.XXXXXX) cp "$prg" "$work/" display=:$((90 + RANDOM % 9)) Xvfb "$display" -screen 0 800x600x24 -nolisten tcp >/dev/null 2>&1 & xvfb_pid=$! hat_pid= cleanup() { [[ -n $hat_pid ]] && joeyStop "$hat_pid" kill "$xvfb_pid" 2>/dev/null || true wait 2>/dev/null || true rm -rf "$work" } trap cleanup EXIT sleep 0.4 DISPLAY=$display "$HATARI" \ --tos "$EMUTOS_IMG" \ --harddrive "$work" \ --gemdos-drive C \ --drive-a off --drive-b off \ --sound off \ --fast-forward on \ --frameskips 4 \ --auto "C:\\DIRTYMRK.PRG" >"$work/hatari.log" 2>&1 & hat_pid=$! waited=0 while (( waited < timeout_s )); do if [[ -s $work/$result ]]; then break fi sleep 1 (( waited++ )) || true done if [[ ! -s $work/$result ]]; then echo "verify-atarist-dirtymark: FAIL - no $result after ${timeout_s}s" >&2 exit 1 fi line=$(head -1 "$work/$result") echo "$line" if [[ $line =~ ^dirtyMark:\ ([0-9]+)\ passed,\ 0\ failed ]] && (( BASH_REMATCH[1] > 0 )); then echo "verify-atarist-dirtymark: PASS (${waited}s)" exit 0 fi echo "verify-atarist-dirtymark: FAIL" >&2 exit 1