saturnng/dist/saturn49g
Gwenhael Le Moine 5714377466
embed lua to load configuration file
- add --print-config option to output config to stdout
- config file name is config.lua and is look for under
  --state-dir (default: $XDG_CONFIG_DIR/saturnMODEL/)
- wrapper scripts will automatically create config file if needed
- lua version is configurable at build time by passing LUA_VERSION=XX
  to make. XX is lua by default but for example can be luajit
- command-line option have higher priority over config file
2024-10-09 15:24:23 +02:00

44 lines
1.2 KiB
Bash
Executable file

#!/bin/bash -eu
cd "$(dirname "$0")" || exit 1
BINNAME=$(basename "$0")
CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
CONFIGDIR=${CONFIGDIR:-$CONFIG_HOME/$BINNAME}
mkdir -p "$CONFIGDIR"
if [ ! -e "$CONFIGDIR"/rom ]; then
if [ -d ../share/saturn/ROMs/ ]; then
cp -R ../share/saturn/ROMs/ "$CONFIGDIR"/
elif [ -d ./ROMs/ ]; then
cp -R ./ROMs/ "$CONFIGDIR"/
fi
if [ ! -d "$CONFIGDIR"/ROMs ]; then
echo "Error: No ROMs/ dir found"
exit 1
fi
echo "The next step will download a ROM from https://hpcalc.org where \"HP graciously began allowing this to be downloaded in mid-2000.\""
echo "You can hit Ctrl-C now if you do not wish to download them."
read -r
make -C "$CONFIGDIR"/ROMs rom.49g
cp "$CONFIGDIR"/ROMs/rom.49g "$CONFIGDIR"/rom
fi
RESET=''
if [ ! -e "$CONFIGDIR"/ram ]; then
RESET=--reset
fi
if [ ! -e "$CONFIGDIR"/config.lua ]; then
./saturn --49g --state-dir "$CONFIGDIR" --print-config > "$CONFIGDIR"/config.lua
fi
if echo "$@" | grep -q "\--verbose"; then
./saturn --49g --state-dir "$CONFIGDIR" "$RESET" "$@"
else
./saturn --49g --state-dir "$CONFIGDIR" "$RESET" "$@" 2> /dev/null
fi