118 lines
4.4 KiB
Bash
Executable file
118 lines
4.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Launch the built Amiga example in FS-UAE. Defaults to PATTERN.
|
|
#
|
|
# Kickstart and Workbench:
|
|
# - If toolchains/emulators/support/kickstart.rom is present, it is
|
|
# used as the Kickstart ROM. Otherwise FS-UAE's built-in AROS ROM
|
|
# is used (less compatible with OCS Intuition but requires no
|
|
# licensed files).
|
|
# - If toolchains/emulators/support/workbench.adf is present, it is
|
|
# inserted into DF0: and the Amiga boots Workbench. The user
|
|
# launches the example from the JOEYLIB drawer on the desktop.
|
|
# - If Workbench is not present, AmigaDOS boots directly from DH0:,
|
|
# executes s/startup-sequence, and auto-runs the requested example.
|
|
#
|
|
# Always on A500 hardware (OCS chipset). Our HAL only uses OCS
|
|
# features so this matches real-hardware behavior.
|
|
#
|
|
# scripts/run-amiga.sh # runs Pattern
|
|
# scripts/run-amiga.sh hello # runs Hello
|
|
# scripts/run-amiga.sh keys # runs Keys
|
|
|
|
set -euo pipefail
|
|
|
|
prog=${1:-pattern}
|
|
repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
|
bin_dir=$repo/build/amiga/bin
|
|
support=$repo/toolchains/emulators/support
|
|
|
|
case $prog in
|
|
hello) file=Hello ;;
|
|
pattern) file=Pattern ;;
|
|
keys) file=Keys ;;
|
|
joy) file=Joy ;;
|
|
sprite) file=Sprite ;;
|
|
audio) file=Audio ;;
|
|
*) echo "usage: $0 [hello|pattern|keys|joy|sprite|audio]" >&2; exit 2 ;;
|
|
esac
|
|
|
|
if [[ ! -f "$bin_dir/$file" ]]; then
|
|
echo "$bin_dir/$file not built. Run 'make amiga' first." >&2
|
|
exit 1
|
|
fi
|
|
|
|
kickstart=$support/kickstart.rom
|
|
workbench=$support/workbench.adf
|
|
|
|
# Stage a fresh hard-drive directory containing both example binaries
|
|
# plus an s/startup-sequence that auto-invokes the chosen one. The
|
|
# startup-sequence only runs when booting directly from the hard
|
|
# drive (i.e. no Workbench floppy); Workbench takes over boot if
|
|
# present and the user launches manually.
|
|
work=$(mktemp -d -t joeylib-amiga.XXXXXX)
|
|
# Preserve any diagnostic dumps Pattern writes to the virtual HD
|
|
# (copper.txt, etc.) before the temp dir is removed on script exit.
|
|
dump_keep=/tmp/joeylib-amiga-dump
|
|
trap 'mkdir -p "$dump_keep"; cp "$work"/*.txt "$dump_keep"/ 2>/dev/null; rm -rf "$work"' EXIT
|
|
|
|
mkdir -p "$work/s"
|
|
cp "$bin_dir/Hello" "$work/" 2>/dev/null || true
|
|
cp "$bin_dir/Pattern" "$work/" 2>/dev/null || true
|
|
cp "$bin_dir/Keys" "$work/" 2>/dev/null || true
|
|
cp "$bin_dir/Joy" "$work/" 2>/dev/null || true
|
|
cp "$bin_dir/Sprite" "$work/" 2>/dev/null || true
|
|
cp "$bin_dir/Audio" "$work/" 2>/dev/null || true
|
|
# ':' prefix anchors to the root of the current volume; otherwise
|
|
# AmigaDOS looks in C: and the command is not found.
|
|
echo ":$file" > "$work/s/startup-sequence"
|
|
|
|
fsargs=(
|
|
--amiga_model=A500
|
|
--fast_memory=2048
|
|
--hard_drive_0="$work"
|
|
--hard_drive_0_label=JOEYLIB
|
|
# Mouse-handling overrides for VM hosts where FS-UAE's default
|
|
# relative-mode grab fights with the hypervisor's own pointer
|
|
# integration. automatic_input_grab=0 stops FS-UAE from grabbing
|
|
# the pointer on focus; middle_click_ungrab=1 is a fallback so a
|
|
# middle-click releases any grab that does occur; mouse_integration=1
|
|
# asks FS-UAE to track host pointer position directly instead of
|
|
# sampling relative deltas.
|
|
--automatic_input_grab=0
|
|
--middle_click_ungrab=1
|
|
--mouse_integration=1
|
|
# Speed overrides: floppy_drive_speed=800 runs the floppy at 8x so
|
|
# the Workbench boot finishes in a few seconds instead of a minute.
|
|
# accuracy=0 and fast_copper=1 are deliberately NOT set -- they
|
|
# compromise copper timing, which our per-scanline palette swaps
|
|
# depend on.
|
|
--floppy_drive_speed=800
|
|
)
|
|
|
|
if [[ -f $kickstart ]]; then
|
|
fsargs+=(--kickstart_file="$kickstart")
|
|
fi
|
|
|
|
if [[ -f $workbench ]]; then
|
|
fsargs+=(--floppy_drive_0="$workbench")
|
|
cat <<EOF
|
|
FS-UAE booting Workbench from DF0:. Once the desktop appears:
|
|
1. Double-click the JOEYLIB disk icon.
|
|
2. From the Window menu, pick "Show > All Files" (Workbench hides
|
|
files that have no .info icon by default).
|
|
3. Double-click $file to run it.
|
|
Alternatively open a Shell (Workbench > Tools > Shell), type 'cd
|
|
JOEYLIB:' then '$file'.
|
|
EOF
|
|
else
|
|
cat <<EOF
|
|
FS-UAE booting directly from the JOEYLIB hard drive. $file will
|
|
auto-run via s/startup-sequence. Drop a Workbench 3.1 ADF at
|
|
$workbench to boot the GUI instead.
|
|
EOF
|
|
fi
|
|
|
|
# Intentionally no exec: we need the bash EXIT trap to fire so the
|
|
# scratch dir gets cleaned up (and any diagnostic dumps preserved).
|
|
# exec would replace the shell and skip trap execution.
|
|
fs-uae "${fsargs[@]}"
|