69 lines
3.2 KiB
Bash
Executable file
69 lines
3.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# make-iigs-boot-disk.sh - Build a GS/OS boot floppy that launches one
|
|
# JoeyLib example DIRECTLY, with no Finder in the way.
|
|
#
|
|
# WHY: the GS/OS Finder cannot be driven from a headless harness. Under
|
|
# gssquared, injected keystrokes reach the $C000 latch but never reach the
|
|
# Finder -- Open-Apple-A, Tab, arrow keys and plain letters all leave the
|
|
# desktop untouched (the single redraw seen after the first key of a run is
|
|
# the Finder's own settling: it was byte-identical for three different
|
|
# keys). Reaching the desktop also costs ~61s of boot per run. MAME's Lua
|
|
# harness drives the Finder by a different route, but that is one more
|
|
# moving part per probe.
|
|
#
|
|
# This replaces /System/Start (normally the Finder) with tools/iigsStart,
|
|
# whose whole job is a GS/OS QuitGS to the pathname baked in at build time.
|
|
# Boot the result as the FIRST drive and the example's own disk as the
|
|
# second; the example volume is mounted before Start runs.
|
|
#
|
|
# Usage: scripts/make-iigs-boot-disk.sh <out.po> <EXAMPLE> [volume]
|
|
# EXAMPLE uppercase binary name as it appears on the data disk
|
|
# volume data volume name, default JOEYLIB
|
|
# Requires: toolchains/env.sh sourced.
|
|
set -euo pipefail
|
|
|
|
out=${1:?usage: make-iigs-boot-disk.sh <out.po> <EXAMPLE> [volume]}
|
|
prog=${2:?usage: make-iigs-boot-disk.sh <out.po> <EXAMPLE> [volume]}
|
|
vol=${3:-JOEYLIB}
|
|
|
|
repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
|
: "${LLVM816_ROOT:?make-iigs-boot-disk.sh: source toolchains/env.sh first}"
|
|
CADIUS="${CADIUS:-$LLVM816_ROOT/tools/cadius/cadius}"
|
|
sysDisk="$repo/toolchains/emulators/support/gsos-system.po"
|
|
|
|
[ -x "$CADIUS" ] || { echo "make-iigs-boot-disk.sh: cadius not found at $CADIUS" >&2; exit 2; }
|
|
[ -f "$sysDisk" ] || { echo "make-iigs-boot-disk.sh: missing $sysDisk" >&2; exit 2; }
|
|
|
|
work=$(mktemp -d -t joeylib-boot.XXXXXX)
|
|
trap 'rm -rf "$work"' EXIT
|
|
|
|
# The GS/OS system disk's own volume name, which cadius paths are relative to.
|
|
# Match the volume line, which is a WHOLE line of the form "/NAME/". An
|
|
# unanchored match also hits the absolute image path in cadius's header
|
|
# (it yielded "home" from /home/scott/...).
|
|
sysVol=$("$CADIUS" CATALOG "$sysDisk" 2>/dev/null \
|
|
| grep -oE '^/[A-Za-z0-9._]+/$' | head -1 | tr -d '/')
|
|
[ -n "$sysVol" ] || { echo "make-iigs-boot-disk.sh: cannot read system volume name" >&2; exit 1; }
|
|
|
|
cp "$sysDisk" "$out"
|
|
|
|
# Out with the Finder (~200KB), in with the launcher. Deleting first is what
|
|
# makes room: the stock disk has under 50KB free.
|
|
"$CADIUS" DELETEFILE "$out" "/$sysVol/System/Start" >/dev/null
|
|
|
|
"$repo/toolchains/iigs/clang-build.sh" \
|
|
-DJOEY_START_PATH="\"/$vol/$prog\"" \
|
|
-o "$work/Start#B30000" \
|
|
"$repo/tools/iigsStart/iigsStart.c" \
|
|
"$repo/tools/iigsStart/iigsStartQuit.s" >/dev/null
|
|
|
|
"$CADIUS" ADDFILE "$out" "/$sysVol/System" "$work/Start#B30000" >/dev/null
|
|
|
|
# Never trust the exit code of a disk build here -- cadius reports success
|
|
# for a file it silently dropped when the volume was full.
|
|
if ! "$CADIUS" CATALOG "$out" 2>/dev/null | grep -qE '^ +Start +S16'; then
|
|
echo "make-iigs-boot-disk.sh: Start was not written (volume full?)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "iigs-boot-disk: $out (boots straight into /$vol/$prog)"
|