name back to saturn; store data in ~/.config/..; guard before downloading rom

This commit is contained in:
Gwenhael Le Moine 2024-09-26 14:49:57 +02:00
parent becc8d8e7f
commit 6fa664257c
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
6 changed files with 127 additions and 69 deletions

View file

@ -1,4 +1,4 @@
# Simple Makefile to build saturn_bertolotti # Simple Makefile to build saturn
# #
# The cc-option function and the C{,PP}FLAGS logic were copied from the # The cc-option function and the C{,PP}FLAGS logic were copied from the
# fsverity-utils project. # fsverity-utils project.
@ -6,8 +6,10 @@
# The governing license can be found in the LICENSE file or at # The governing license can be found in the LICENSE file or at
# https://opensource.org/license/MIT. # https://opensource.org/license/MIT.
NAME = saturn
PREFIX = /usr PREFIX = /usr
DOCDIR = $(PREFIX)/doc/sb4xng DOCDIR = $(PREFIX)/doc/$(NAME)
VERSION_MAJOR = 0 VERSION_MAJOR = 0
VERSION_MINOR = 0 VERSION_MINOR = 0
@ -103,13 +105,13 @@ override CPPFLAGS := -I./src/ -D_GNU_SOURCE=1 \
.PHONY: all clean clean-all pretty-code install mrproper get-roms install .PHONY: all clean clean-all pretty-code install mrproper get-roms install
all: libChf/libChf.a dist/sb4xng docs all: libChf/libChf.a dist/$(NAME) docs
# Building # Building
libChf/libChf.a: libChf/libChf.a:
make -C libChf make -C libChf
dist/sb4xng: $(DOTOS) $(DOTOS_UI4x) libChf/libChf.a dist/$(NAME): $(DOTOS) $(DOTOS_UI4x) libChf/libChf.a
$(CC) $^ -o $@ $(CFLAGS) $(LIBS) $(SDLLIBS) $(NCURSESLIBS) $(CC) $^ -o $@ $(CFLAGS) $(LIBS) $(SDLLIBS) $(NCURSESLIBS)
dist/pack: src/pack.o src/disk_io.o src/debug.o libChf/libChf.a dist/pack: src/pack.o src/disk_io.o src/debug.o libChf/libChf.a
@ -127,7 +129,7 @@ clean:
make -C docs clean make -C docs clean
mrproper: clean mrproper: clean
rm -f dist/sb4xng dist/pack rm -f dist/$(NAME) dist/pack
make -C dist/ROMs mrproper make -C dist/ROMs mrproper
make -C libChf mrproper make -C libChf mrproper
make -C docs mrproper make -C docs mrproper
@ -144,17 +146,17 @@ get-roms:
make -C dist/ROMs get-roms make -C dist/ROMs get-roms
# Installation # Installation
install: dist/sb4xng doc install: dist/$(NAME) doc
install -m 755 -d -- $(DESTDIR)$(PREFIX)/bin install -m 755 -d -- $(DESTDIR)$(PREFIX)/bin
install -c -m 755 dist/sb4xng $(DESTDIR)$(PREFIX)/bin/sb4xng install -c -m 755 dist/$(NAME) $(DESTDIR)$(PREFIX)/bin/$(NAME)
install -c -m 755 dist/saturn48gx $(DESTDIR)$(PREFIX)/bin/saturn48gx install -c -m 755 dist/saturn48gx $(DESTDIR)$(PREFIX)/bin/saturn48gx
install -c -m 755 dist/saturn48sx $(DESTDIR)$(PREFIX)/bin/saturn48sx install -c -m 755 dist/saturn48sx $(DESTDIR)$(PREFIX)/bin/saturn48sx
install -c -m 755 dist/saturn40g $(DESTDIR)$(PREFIX)/bin/saturn40g install -c -m 755 dist/saturn40g $(DESTDIR)$(PREFIX)/bin/saturn40g
install -c -m 755 dist/saturn49g $(DESTDIR)$(PREFIX)/bin/saturn49g install -c -m 755 dist/saturn49g $(DESTDIR)$(PREFIX)/bin/saturn49g
install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/sb4xng install -m 755 -d -- $(DESTDIR)$(PREFIX)/share/$(NAME)
install -c -m 644 dist/hplogo.png $(DESTDIR)$(PREFIX)/share/sb4xng/hplogo.png install -c -m 644 dist/hplogo.png $(DESTDIR)$(PREFIX)/share/$(NAME)/hplogo.png
cp -R dist/ROMs/ $(DESTDIR)$(PREFIX)/share/sb4xng/ cp -R dist/ROMs/ $(DESTDIR)$(PREFIX)/share/$(NAME)/
install -m 755 -d -- $(DESTDIR)$(DOCDIR) install -m 755 -d -- $(DESTDIR)$(DOCDIR)
cp -R COPYING LICENSE README* docs-4.1.1.1 docs/*.{info,dvi,ps,pdf} libChf/docs/*.{info,dvi,ps,pdf} $(DESTDIR)$(DOCDIR) cp -R COPYING LICENSE README* docs-4.1.1.1 docs/*.{info,dvi,ps,pdf} libChf/docs/*.{info,dvi,ps,pdf} $(DESTDIR)$(DOCDIR)
@ -166,12 +168,12 @@ install: dist/sb4xng doc
sed "s|@PREFIX@|$(PREFIX)|g" dist/saturn40g.desktop > $(DESTDIR)$(PREFIX)/share/applications/saturn40g.desktop sed "s|@PREFIX@|$(PREFIX)|g" dist/saturn40g.desktop > $(DESTDIR)$(PREFIX)/share/applications/saturn40g.desktop
uninstall: uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/sb4xng rm -f $(DESTDIR)$(PREFIX)/bin/$(NAME)
rm -f $(DESTDIR)$(PREFIX)/bin/saturn48gx rm -f $(DESTDIR)$(PREFIX)/bin/saturn48gx
rm -f $(DESTDIR)$(PREFIX)/bin/saturn48sx rm -f $(DESTDIR)$(PREFIX)/bin/saturn48sx
rm -f $(DESTDIR)$(PREFIX)/bin/saturn40g rm -f $(DESTDIR)$(PREFIX)/bin/saturn40g
rm -f $(DESTDIR)$(PREFIX)/bin/saturn49g rm -f $(DESTDIR)$(PREFIX)/bin/saturn49g
rm -fr $(DESTDIR)$(PREFIX)/share/sb4xng rm -fr $(DESTDIR)$(PREFIX)/share/$(NAME)
rm -fr $(DESTDIR)$(DOCDIR) rm -fr $(DESTDIR)$(DOCDIR)
rm -f $(DESTDIR)$(PREFIX)/share/applications/saturn48gx.desktop rm -f $(DESTDIR)$(PREFIX)/share/applications/saturn48gx.desktop
rm -f $(DESTDIR)$(PREFIX)/share/applications/saturn48sx.desktop rm -f $(DESTDIR)$(PREFIX)/share/applications/saturn48sx.desktop

View file

@ -15,13 +15,37 @@ make install DESTDIR=/
### locally ### locally
``` shell ``` shell
./dist/run48.sh ./dist/saturn48gx
```
or
``` shell
./dist/saturn48sx
```
or
``` shell
./dist/saturn49g
```
or
``` shell
./dist/saturn40g
``` ```
### when installed ### when installed
``` shell ``` shell
saturn48gx saturn48gx
``` ```
or
``` shell
saturn48sx
```
or
``` shell
saturn49g
```
or
``` shell
saturn40g
```
## Post-fork changelog ## Post-fork changelog

34
dist/saturn40g vendored
View file

@ -1,28 +1,36 @@
#!/bin/bash -eu #!/bin/bash -eu
cd "$(dirname "$0")" || exit 1 cd "$(dirname "$0")" || exit 1
#CWD=$(pwd)
STATE_HOME=${XDG_STATE_HOME:-$HOME/.local/state} BINNAME=$(basename "$0")
STATEDIR=${STATEDIR:-$STATE_HOME/sb4xng/40g} CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
mkdir -p "$STATEDIR"
if [ ! -e "$STATEDIR"/rom ]; then CONFIGDIR=${CONFIGDIR:-$CONFIG_HOME/$BINNAME}
if [ ! -d ../share/sb4xng/ROMs/ ]; then 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" echo "Error: No ROMs/ dir found"
exit 1 exit 1
fi fi
if [ ! -d "$STATEDIR"/../ROMs ]; then
cp -R ../share/sb4xng/ROMs/ "$STATEDIR"/../ROMs echo "The next step will download a ROM from https://hpcalc.org where \"HP graciously began allowing this to be downloaded in mid-2000.\""
fi echo "You can hit Ctrl-C now if you do not wish to download them."
make -C "$STATEDIR"/../ROMs rom.39g read -r
cp "$STATEDIR"/../ROMs/rom.39g "$STATEDIR"/rom
make -C "$CONFIGDIR"/ROMs rom.39g
cp "$CONFIGDIR"/ROMs/rom.39g "$CONFIGDIR"/rom
fi fi
RESET='' RESET=''
if [ ! -e "$STATEDIR"/ram ]; then if [ ! -e "$CONFIGDIR"/ram ]; then
RESET=-reset RESET=-reset
fi fi
sb4xng --40g --state-dir "$STATEDIR" "$RESET" "$@" ./saturn --40g --state-dir "$CONFIGDIR" "$RESET" "$@"

38
dist/saturn48gx vendored
View file

@ -1,31 +1,39 @@
#!/bin/bash -eu #!/bin/bash -eu
cd "$(dirname "$0")" || exit 1 cd "$(dirname "$0")" || exit 1
#CWD=$(pwd)
STATE_HOME=${XDG_STATE_HOME:-$HOME/.local/state} BINNAME=$(basename "$0")
STATEDIR=${STATEDIR:-$STATE_HOME/sb4xng/48gx} CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
mkdir -p "$STATEDIR"
if [ ! -e "$STATEDIR"/rom ]; then CONFIGDIR=${CONFIGDIR:-$CONFIG_HOME/$BINNAME}
if [ ! -d ../share/sb4xng/ROMs/ ]; then 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" echo "Error: No ROMs/ dir found"
exit 1 exit 1
fi fi
if [ ! -d "$STATEDIR"/../ROMs ]; then
cp -R ../share/sb4xng/ROMs/ "$STATEDIR"/../ROMs echo "The next step will download a ROM from https://hpcalc.org where \"HP graciously began allowing this to be downloaded in mid-2000.\""
fi echo "You can hit Ctrl-C now if you do not wish to download them."
make -C "$STATEDIR"/../ROMs gxrom-r read -r
cp "$STATEDIR"/../ROMs/gxrom-r "$STATEDIR"/rom
make -C "$CONFIGDIR"/ROMs gxrom-r
cp "$CONFIGDIR"/ROMs/gxrom-r "$CONFIGDIR"/rom
fi fi
[ ! -e "$STATEDIR"/port1 ] && dd if=/dev/zero of="$STATEDIR"/port1 bs=1k count=128 [ ! -e "$CONFIGDIR"/port1 ] && dd if=/dev/zero of="$CONFIGDIR"/port1 bs=1k count=128
[ ! -e "$STATEDIR"/port2 ] && dd if=/dev/zero of="$STATEDIR"/port2 bs=1k count=4096 [ ! -e "$CONFIGDIR"/port2 ] && dd if=/dev/zero of="$CONFIGDIR"/port2 bs=1k count=4096
RESET='' RESET=''
if [ ! -e "$STATEDIR"/ram ]; then if [ ! -e "$CONFIGDIR"/ram ]; then
RESET=--reset RESET=--reset
fi fi
sb4xng --48gx --state-dir "$STATEDIR" "$RESET" "$@" ./saturn --48gx --state-dir "$CONFIGDIR" "$RESET" "$@"

38
dist/saturn48sx vendored
View file

@ -1,31 +1,39 @@
#!/bin/bash -eu #!/bin/bash -eu
cd "$(dirname "$0")" || exit 1 cd "$(dirname "$0")" || exit 1
#CWD=$(pwd)
STATE_HOME=${XDG_STATE_HOME:-$HOME/.local/state} BINNAME=$(basename "$0")
STATEDIR=${STATEDIR:-$STATE_HOME/sb4xng/48sx} CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
mkdir -p "$STATEDIR"
if [ ! -e "$STATEDIR"/rom ]; then CONFIGDIR=${CONFIGDIR:-$CONFIG_HOME/$BINNAME}
if [ ! -d ../share/sb4xng/ROMs/ ]; then 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" echo "Error: No ROMs/ dir found"
exit 1 exit 1
fi fi
if [ ! -d "$STATEDIR"/../ROMs ]; then
cp -R ../share/sb4xng/ROMs/ "$STATEDIR"/../ROMs echo "The next step will download a ROM from https://hpcalc.org where \"HP graciously began allowing this to be downloaded in mid-2000.\""
fi echo "You can hit Ctrl-C now if you do not wish to download them."
make -C "$STATEDIR"/../ROMs sxrom-j read -r
cp "$STATEDIR"/../ROMs/sxrom-j "$STATEDIR"/rom
make -C "$CONFIGDIR"/ROMs sxrom-j
cp "$CONFIGDIR"/ROMs/sxrom-j "$CONFIGDIR"/rom
fi fi
[ ! -e "$STATEDIR"/port1 ] && dd if=/dev/zero of="$STATEDIR"/port1 bs=1k count=128 [ ! -e "$CONFIGDIR"/port1 ] && dd if=/dev/zero of="$CONFIGDIR"/port1 bs=1k count=128
[ ! -e "$STATEDIR"/port2 ] && dd if=/dev/zero of="$STATEDIR"/port2 bs=1k count=128 [ ! -e "$CONFIGDIR"/port2 ] && dd if=/dev/zero of="$CONFIGDIR"/port2 bs=1k count=128
RESET='' RESET=''
if [ ! -e "$STATEDIR"/ram ]; then if [ ! -e "$CONFIGDIR"/ram ]; then
RESET=--reset RESET=--reset
fi fi
sb4xng --48sx --state-dir "$STATEDIR" "$RESET" "$@" ./saturn --48sx --state-dir "$CONFIGDIR" "$RESET" "$@"

34
dist/saturn49g vendored
View file

@ -1,28 +1,36 @@
#!/bin/bash -eu #!/bin/bash -eu
cd "$(dirname "$0")" || exit 1 cd "$(dirname "$0")" || exit 1
#CWD=$(pwd)
STATE_HOME=${XDG_STATE_HOME:-$HOME/.local/state} BINNAME=$(basename "$0")
STATEDIR=${STATEDIR:-$STATE_HOME/sb4xng/49g} CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
mkdir -p "$STATEDIR"
if [ ! -e "$STATEDIR"/rom ]; then CONFIGDIR=${CONFIGDIR:-$CONFIG_HOME/$BINNAME}
if [ ! -d ../share/sb4xng/ROMs/ ]; then 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" echo "Error: No ROMs/ dir found"
exit 1 exit 1
fi fi
if [ ! -d "$STATEDIR"/../ROMs ]; then
cp -R ../share/sb4xng/ROMs/ "$STATEDIR"/../ROMs echo "The next step will download a ROM from https://hpcalc.org where \"HP graciously began allowing this to be downloaded in mid-2000.\""
fi echo "You can hit Ctrl-C now if you do not wish to download them."
make -C "$STATEDIR"/../ROMs rom.49g read -r
cp "$STATEDIR"/../ROMs/rom.49g "$STATEDIR"/rom
make -C "$CONFIGDIR"/ROMs rom.49g
cp "$CONFIGDIR"/ROMs/rom.49g "$CONFIGDIR"/rom
fi fi
RESET='' RESET=''
if [ ! -e "$STATEDIR"/ram ]; then if [ ! -e "$CONFIGDIR"/ram ]; then
RESET=-reset RESET=-reset
fi fi
sb4xng --49g --state-dir "$STATEDIR" "$RESET" "$@" ./saturn --49g --state-dir "$CONFIGDIR" "$RESET" "$@"