#!/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-amiga-tilebank.sh - Tile-bank gate for the Amiga: proves that # assetbake's amiga encoder (plane-major: 8 rows of plane 0, then plane 1, ...) # writes exactly the layout the Amiga's native tile paste # (src/m68k/planarTile.h via src/amiga/amigaTile.h) reads, and that the Amiga # build refuses a bank baked for any other target. # # Boots an A500 (real Kickstart) in FS-UAE under Xvfb from a scratch directory # hard drive whose startup-sequence runs TileBank (examples/tilebank), with # the DATA/tilebank make/amiga.mk staged from the host gate's fixture beside # it. The program loads its own bake through jlTileBankLoadToSurface and # through jlTileBankLoad + jlTilePaste, checks every pixel of both against the # PNG, hashes both, and tries every other target's bake; its TILEBANK line in # joeylog.txt must say PASS with both hashes equal to the host gate's # (scripts/check-tilebank.sh, run here for the value) and every other target # refused. FS-UAE is stopped as soon as the line appears. # # Usage: scripts/verify-amiga-tilebank.sh # Env: TILEBANK_DATA_DIR stage this DATA/tilebank instead (negative controls) # Requires: fs-uae, the Kickstart, Xvfb, a host cc; build/amiga/bin/TileBank # and its DATA/tilebank (make amiga). set -uo pipefail repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) source "$repo/scripts/lib/joeyEnv.sh" source "$repo/scripts/lib/tileBankGate.sh" joeyNeed FSUAE fsuae source "$repo/scripts/lib/amigaGate.sh" amigaMachine binDir=$repo/build/amiga/bin dataDir=$(tileBankData "$binDir") wall=180 # hard cap on FS-UAE, whatever happens to this script lineSeconds=150 # a real-time boot plus the checks tileBankNeedBuild "$binDir/TileBank" "$dataDir" "make amiga" tileBankReference work=$(mktemp -d -t joeylib-amiga-tilebank.XXXXXX) guard="" fsuae="" xvfb="" # 2>/dev/null: bash reports the SIGKILLed timeout wrapper as "Killed". cleanup() { joeyStop "$fsuae" "$guard" "$xvfb" 2> /dev/null rm -rf "$work" } trap cleanup EXIT mkdir -p "$work/hd/s" "$work/hd/DATA" cp "$binDir/TileBank" "$work/hd/" cp -r "$dataDir" "$work/hd/DATA/tilebank" echo ":TileBank" > "$work/hd/s/startup-sequence" display=":$((RANDOM % 400 + 1300))" Xvfb "$display" -screen 0 800x600x24 -nolisten tcp > /dev/null 2>&1 & xvfb=$! sleep 1 # 2 MB of fast memory: a bare 512 KB A500 fails jlInit. DISPLAY="$display" timeout -s KILL "$wall" "$FSUAE" \ "${AMIGA_MACHINE_ARGS[@]}" \ --fast_memory=2048 \ --hard_drive_0="$work/hd" \ --hard_drive_0_label=JOEYLIB \ --automatic_input_grab=0 \ --fullscreen=0 \ --fade_out_duration=0 > "$work/fsuae.log" 2>&1 & guard=$! fsuae=$(joeyChild "$guard") log=$(tileBankAwaitLine "$work/hd" "$lineSeconds" "$guard") joeyStop "$fsuae" "$guard" 2> /dev/null fsuae="" guard="" if [ -z "$log" ]; then echo "verify-amiga-tilebank: FAIL - no TILEBANK line within ${lineSeconds}s" >&2 tail -5 "$work/fsuae.log" >&2 exit 1 fi tileBankJudge "$log"