# shellcheck shell=bash # Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License. # See LICENSE.md for license information. # SPDX-License-Identifier: MIT # # Shared by the Amiga gates (scripts/bench-amiga.sh, scripts/verify-amiga-*.sh) # and joey-run: which Amiga FS-UAE emulates. JOEY_AMIGA_MODEL picks it; the # A500 is the port's baseline, and the AGA machines prove the same programs # on a 68020 and a 68040 (their instruction caches, the 68040's copyback data # cache) and the AGA chipset's OCS modes: # # A500 68000, OCS: Kickstart 3.1 r40.63 (component kickstart) # A1200 68EC020, AGA: r40.68 (component kickstartA1200) # A4000 68040, AGA: r40.70 (component kickstartA4000), FS-UAE's A4000/040 # # Source after joeyEnv.sh. # # amigaMachine exit 2 unless the model's Kickstart is installed; sets # AMIGA_MACHINE_ARGS, FS-UAE's --amiga_model and # --kickstart_file # amigaShot DISPLAY KEY DIR OUT # a screenshot: press KEY (xdotool's name for the host key # FS-UAE has bound to action_screenshot), then move the # picture FS-UAE cropped to the Amiga's display from DIR # (its screenshots_output_dir) to OUT; 1 when none came AMIGA_MODEL="${JOEY_AMIGA_MODEL:-A500}" AMIGA_MACHINE_ARGS=() AMIGA_SHOT_SECONDS=5 # the screenshot key until FS-UAE has written the file amigaMachine() { case "$AMIGA_MODEL" in A500) joeyNeed KICKSTART_ROM kickstart AMIGA_MACHINE_ARGS=(--amiga_model=A500 --kickstart_file="$KICKSTART_ROM") ;; A1200) joeyNeed KICKSTART_A1200_ROM kickstartA1200 AMIGA_MACHINE_ARGS=(--amiga_model=A1200 --kickstart_file="$KICKSTART_A1200_ROM") ;; A4000) joeyNeed KICKSTART_A4000_ROM kickstartA4000 AMIGA_MACHINE_ARGS=(--amiga_model=A4000/040 --kickstart_file="$KICKSTART_A4000_ROM") ;; *) echo "JOEY_AMIGA_MODEL is A500, A1200 or A4000, not $AMIGA_MODEL" >&2 exit 2 ;; esac } # FS-UAE writes more than one picture of each screenshot; the one cropped # to the Amiga's display is the stage's. It makes the file before it writes # it: it is done when it has bytes and one more poll adds none. amigaShot() { local before local found local size="" local deadline before=$(find "$3" -name '*crop*.png' | wc -l) DISPLAY="$1" xdotool keydown "$2" sleep 0.3 DISPLAY="$1" xdotool keyup "$2" deadline=$((SECONDS + AMIGA_SHOT_SECONDS)) while [ "$SECONDS" -lt "$deadline" ]; do sleep 0.2 [ "$(find "$3" -name '*crop*.png' | wc -l)" -gt "$before" ] || continue found=$(ls -t "$3"/*crop*.png | head -1) [ -s "$found" ] || continue if [ "$(stat -c %s "$found")" = "$size" ]; then mv "$found" "$4" return 0 fi size=$(stat -c %s "$found") done return 1 }