#!/usr/bin/env bash # Launch the built Apple IIgs examples in GSplus. GSplus is booted from # a GS/OS 6.0.4 System disk (toolchains/emulators/support/gsos-system.po) # with joey.2mg mounted as the data disk on slot 5 drive 2. GS/OS drops # to Finder; the user navigates to the JOEYLIB volume and double-clicks # whichever example they want to run. # # No argument: GSplus has no way to dispatch a specific binary on boot # (Finder is interactive), so this script just stages the disk and # launches the emulator. set -euo pipefail if [[ $# -ne 0 ]]; then echo "usage: $0" >&2 echo " (no arguments -- launch GSplus, pick the demo in Finder)" >&2 exit 2 fi repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) gsplus=$repo/toolchains/emulators/gsplus/bin/gsplus rom=$repo/toolchains/emulators/support/apple-iigs.rom sys_disk=$repo/toolchains/emulators/support/gsos-system.po data_disk=$repo/build/iigs/bin/joey.2mg null_c600=$repo/toolchains/emulators/support/iigs-null-c600.rom for f in "$gsplus" "$rom" "$sys_disk" "$data_disk" "$null_c600"; do if [[ ! -f $f ]]; then echo "missing: $f" >&2 if [[ $f == "$data_disk" ]]; then echo "run 'make iigs-disk' to build it." >&2 else echo "run ./toolchains/install.sh (support files should have been staged)." >&2 fi exit 1 fi done # GSplus writes back to disk images during the session; stage writable # copies so repeated runs do not mutate the originals. work=$(mktemp -d -t joeylib-iigs.XXXXXX) cleanup() { # Stash the post-run disk image for manual inspection. if [[ -f $work/joey.2mg ]]; then cp "$work/joey.2mg" "$repo/build/iigs/bin/joey-after-run.2mg" echo "run-iigs: saved post-run disk -> $repo/build/iigs/bin/joey-after-run.2mg" >&2 fi rm -rf "$work" } trap cleanup EXIT cp "$sys_disk" "$work/boot.po" cp "$data_disk" "$work/joey.2mg" # Stage the null slot-6 PROM as c600.rom in the work dir. GSplus loads # any file named c600.rom in its search path (cwd first) as the slot 6 # ROM card, overriding the built-in Disk II firmware. The staged image # is 256 bytes with a leading RTS and no Pascal 1.1 firmware signature, # so the IIgs boot ROM's slot scan skips slot 6 and the two empty 5.25 # drives never get probed. Source: toolchains/install.sh's # install_support_iigs_null_c600. cp "$null_c600" "$work/c600.rom" cat < # ". g_limit_speed=2 caps emulation at the IIgs's native # 2.8 MHz; without this override GSplus boots at 8 MHz and our # performance characteristics don't match real hardware. The other # settings (0=unlimited, 1=1.024 MHz, 3=8 MHz) are reachable through # the in-emulator speed-cycle key if needed. # # No exec: let the bash EXIT trap fire so the scratch dir (and the # config.kegs GSplus auto-creates) gets cleaned up. "$gsplus" -rom "$rom" \ -s5d1 "$work/boot.po" \ -s5d2 "$work/joey.2mg" \ -g_limit_speed 2