joeylib2/scripts/run-dos.sh

48 lines
1.5 KiB
Bash
Executable file

#!/usr/bin/env bash
# Launch the built DOS example in DOSBox. Defaults to PATTERN.
#
# scripts/run-dos.sh # runs PATTERN
# scripts/run-dos.sh hello # runs HELLO
# scripts/run-dos.sh draw # runs DRAW
#
# Argument is any built example name (case-insensitive); the script
# upper-cases it and appends .EXE, then checks the file exists.
set -euo pipefail
if [[ $# -gt 1 ]]; then
echo "usage: $0 [example-name]" >&2
exit 2
fi
prog=${1:-pattern}
repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
bin_dir=$repo/build/dos/bin
conf=$repo/scripts/dosbox-386sx16.conf
file=${prog^^}.EXE
if [[ ! -f "$bin_dir/$file" ]]; then
echo "$bin_dir/$file not built. Run 'make dos' first." >&2
if compgen -G "$bin_dir/*.EXE" > /dev/null; then
echo "available examples in $bin_dir:" >&2
ls "$bin_dir"/*.EXE | xargs -n1 basename >&2
fi
exit 1
fi
# mouse_capture=seamless is required for DOSBox-Staging when running
# inside a VM whose host already manages the pointer; without it the
# default capture-on-click behavior fights the VM's grab and mouse
# input is unusable. On plain DOSBox this -set flag is unknown and is
# logged once as a warning, then ignored -- harmless either way.
#
# -conf $conf locks the CPU to a simulated 386SX-16 (the slowest
# realistic 386 desktop). DOSBox layers configs: anything not set in
# our file falls back to the user's main dosbox.conf.
exec dosbox \
-conf "$conf" \
-set "mouse_capture=seamless" \
-c "C:" \
-c "$file" \
-c "pause" \
--exit "$bin_dir"