diff --git a/modflash/Makefile b/modflash/Makefile index bc758ff..5de6bc0 100644 --- a/modflash/Makefile +++ b/modflash/Makefile @@ -3,13 +3,13 @@ # SPDX-License-Identifier: GPL-3.0-or-later # # Supported environments: -# * GNU/Linux -# * Windows NT (using MinGW/MSYS/Cygwin/WSL) +# * GNU on Linux, FreeBSD etc. +# * GNU on Windows NT (using MinGW/MSYS/Cygwin/WSL) include ../sdk/common.mk .PHONY: all -all: | FLASHempty.ZX1 $(ADDITEM) ./addroms.sh ./addcores.sh roms.txt cores.txt +all: | FLASHempty.ZX1 ./addroms.sh ./addcores.sh roms.txt cores.txt cp FLASHempty.ZX1 FLASH.ZX1 ./addroms.sh ./addcores.sh diff --git a/modflash/addcores.sh b/modflash/addcores.sh index c498228..7470749 100755 --- a/modflash/addcores.sh +++ b/modflash/addcores.sh @@ -7,24 +7,26 @@ i=2 -Error() { - echo "ERROR: Exit status $1. Stopped." >&2 - exit $1 -} - AddCore() { local f=${3%.*}.tap echo "Adding core $i: \"$2\" ($3)..." - GenRom $1 "$2" $3 $f || Error $? - AddItem CORE$i $f || Error $? + GenRom $1 "$2" $3 $f + AddItem CORE$i $f rm -f $f let i+=1 } +OnError() { + local err=$? + echo "ERROR: Exit status $err. Stopped." >&2 + exit $err +} + OnExit() { rm -f addcores.tmp } +trap OnError ERR trap OnExit EXIT awk -F \; '/^[^#]+/{print "AddCore " $1 " " $2 " " gensub(/\\/, "/", "g", $3)}' cores.txt >addcores.tmp diff --git a/modflash/addroms.sh b/modflash/addroms.sh index 004e553..abf6873 100755 --- a/modflash/addroms.sh +++ b/modflash/addroms.sh @@ -7,26 +7,28 @@ i=0 -Error() { - echo "ERROR: Exit status $1. Stopped." >&2 - exit $1 -} - AddROM() { local n=`stat --printf "%s" $3` local i1=$((i+n/16384-1)) local f=${3%.*}.tap echo "Adding ROM in slots $i-$i1: \"$2\" ($3)..." - GenRom $1 "$2" $3 $f || Error $? - AddItem ROM $i $f || Error $? + GenRom $1 "$2" $3 $f + AddItem ROM $i $f rm -f $f let i=i1+1 } +OnError() { + local err=$? + echo "ERROR: Exit status $err. Stopped." >&2 + exit $err +} + OnExit() { rm -f addroms.tmp } +trap OnError ERR trap OnExit EXIT awk -F \; '/^[^#]+/{print "AddROM " $1 " " $2 " " gensub(/\\/, "/", "g", $3)}' roms.txt >addroms.tmp