76 lines
2.8 KiB
Bash
76 lines
2.8 KiB
Bash
# 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
|
|
#
|
|
# Human68k floppy staging shared by joey-run and the X68000 gates and tools.
|
|
# Every run boots a copy of the stock system disk (HUMAN302.XDF from the
|
|
# x68kFirmware component) trimmed to what it takes to boot and run one
|
|
# program; most also carry the program, its DATA tree and its log on an
|
|
# emptied second disk in drive B, so a run can never corrupt what boots it.
|
|
# Source after joeyEnv.sh and call `joeyNeed X68K_DIR x68kFirmware` first.
|
|
|
|
X68K_SYSTEM_DISK="${X68K_DIR:-}/HUMAN302.XDF"
|
|
|
|
|
|
# x68kAddTree DISK DIR PREFIX -- copy every file under DIR onto DISK as
|
|
# PREFIX/<path>, upper-cased the way Human68k shows names.
|
|
x68kAddTree() {
|
|
local disk="$1"
|
|
local dir="$2"
|
|
local prefix="$3"
|
|
local files
|
|
local f
|
|
local rel
|
|
files="$(find "$dir" -type f | sort)"
|
|
while IFS= read -r f; do
|
|
[ -n "$f" ] || continue
|
|
rel="${f#"$dir"/}"
|
|
x68kXdf add "$disk" "$f" "$prefix/${rel^^}" >/dev/null || return 1
|
|
done <<< "$files"
|
|
}
|
|
|
|
|
|
# x68kBootDisk OUT LINE... -- OUT becomes a boot disk whose AUTOEXEC.BAT runs
|
|
# the given command lines (pass them single-quoted: 'B:\UBER.X'). The stock
|
|
# disk's keyboard, beep and font drivers go, and so do its utility folders
|
|
# (~900 KB, in subdirectories only deltree can free): nothing a JoeyLib
|
|
# program needs -- except \SYS\RSDRV.SYS, Human68k's RS-232C driver, which
|
|
# comes back: the stock CONFIG.SYS loads it (DEVICE = \SYS\RSDRV.SYS), and
|
|
# the serial add-on requires it (src/x68000/serial.c).
|
|
x68kBootDisk() {
|
|
local out="$1"
|
|
local name
|
|
shift
|
|
cp "$X68K_SYSTEM_DISK" "$out" || return 1
|
|
for name in USKCG.SYS BEEP.SYS KEY.SYS STARTUP.ENV; do
|
|
x68kXdf delete "$out" "$name" >/dev/null 2>&1 || true
|
|
done
|
|
for name in SYS HIS BIN BASIC2 ASK ETC; do
|
|
x68kXdf deltree "$out" "$name" >/dev/null 2>&1 || true
|
|
done
|
|
if ! x68kXdf extract "$X68K_SYSTEM_DISK" SYS/RSDRV.SYS "$out.rsdrv" >/dev/null 2>&1; then
|
|
echo "x68kBootDisk: $X68K_SYSTEM_DISK has no SYS/RSDRV.SYS, which the serial add-on requires" >&2
|
|
return 1
|
|
fi
|
|
x68kXdf add "$out" "$out.rsdrv" SYS/RSDRV.SYS >/dev/null || return 1
|
|
rm -f "$out.rsdrv"
|
|
{ printf '%s\r\n' "$@"; printf '\x1a'; } > "$out.autoexec"
|
|
x68kXdf add "$out" "$out.autoexec" AUTOEXEC.BAT >/dev/null || return 1
|
|
rm -f "$out.autoexec"
|
|
}
|
|
|
|
|
|
# x68kDataDisk OUT -- OUT becomes an empty disk: the stock disk's BPB and
|
|
# boot sector with every file and folder freed (all 1221 clusters).
|
|
x68kDataDisk() {
|
|
cp "$X68K_SYSTEM_DISK" "$1" || return 1
|
|
x68kXdf empty "$1" >/dev/null
|
|
}
|
|
|
|
|
|
# x68kXdf ARGS... -- tools/xdftool.py (list, add, delete, deltree, empty,
|
|
# extract, free).
|
|
x68kXdf() {
|
|
python3 "$JOEY_REPO/tools/xdftool.py" "$@"
|
|
}
|