#!/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. The user # navigates to the JOEYLIB volume in Finder and double-clicks the # example to run it. # # Unlike the other emulators, GS/OS does not auto-run on boot -- it # drops to Finder. The argument just prints a reminder of which # example to launch. # # scripts/run-iigs.sh # boots (Pattern hint) # scripts/run-iigs.sh hello # boots, hints HELLO # scripts/run-iigs.sh keys # boots, hints KEYS set -euo pipefail prog=${1:-pattern} 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 case $prog in hello|pattern|keys) ;; *) echo "usage: $0 [hello|pattern|keys]" >&2; exit 2 ;; esac 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) trap 'rm -rf "$work"' 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" target=$(echo "$prog" | tr '[:lower:]' '[:upper:]') 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