libx48ng/dist/setup-x48ng-home.sh

41 lines
1.1 KiB
Bash
Raw Normal View History

2023-04-30 19:08:53 +02:00
#!/usr/bin/env sh
2023-04-30 18:50:24 +02:00
2024-08-29 11:17:22 +02:00
cd "$(dirname "$0")" || exit 1
2024-08-29 11:20:28 +02:00
CWD=$(pwd)
CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
DOTX48NG=${DOTX48NG:-$CONFIG_HOME/x48ng}
CONFIG=${CONFIG:-config.lua}
ROM=${ROM:-ROMs/gxrom-r}
RAM=${RAM:-ram}
STATE=${STATE:-state}
PORT1=${PORT1:-port1}
PORT2=${PORT2:-port2}
2023-04-30 18:50:24 +02:00
2024-08-11 13:51:35 +02:00
mkdir -p "${DOTX48NG}"
2023-04-30 19:08:53 +02:00
2024-08-29 11:20:28 +02:00
cp -r "$CWD"/ROMs/ "${DOTX48NG}"/
cd "${DOTX48NG}" || exit 1
echo "The next step will download all available HP 48 ROMs 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 ROMs get-roms
2023-04-30 18:50:24 +02:00
PORT1_SIZE=128
PORT2_SIZE=4096
if echo "$ROM" | grep -q "sxrom"; then
PORT2_SIZE=128
2023-05-14 16:20:09 +02:00
fi
[ -e ram ] && mv ram ram.orig
[ -e state ] && mv state state.orig
[ -e port1 ] && mv port1 port1.orig
[ -e port2 ] && mv port2 port2.orig
[ -e "${CONFIG}" ] && mv "${CONFIG}" "${CONFIG}".orig
dd if=/dev/zero of="$DOTX48NG"/"$PORT1" bs=1k count=$PORT1_SIZE
dd if=/dev/zero of="$DOTX48NG"/"$PORT2" bs=1k count=$PORT2_SIZE
x48ng --rom="$ROM" --ram="$RAM" --state="$STATE" --port1="$PORT1" --port2="$PORT2" --print-config > "${CONFIG}"