simplify some scripts

This commit is contained in:
4am 2021-10-23 01:36:04 -04:00
parent 1ed1755884
commit 23627f653e
3 changed files with 45 additions and 41 deletions

View File

@ -36,7 +36,7 @@ dsk: asm
#
# precompute binary data structure for mega-attract mode configuration file
#
bin/buildokvs.sh build/ATTRACT.IDX < res/ATTRACT.CONF
bin/buildokvs.sh < res/ATTRACT.CONF > build/ATTRACT.IDX
#
# precompute binary data structure and substitute special characters
# in game help and other all-text pages
@ -54,10 +54,10 @@ dsk: asm
# create search indexes
#
bin/builddisplaynames.py < build/GAMES.CONF > build/DISPLAY.CONF
grep "^00" < build/DISPLAY.CONF | cut -d"," -f2 | bin/buildokvs.sh build/SEARCH00.IDX
grep "^0" < build/DISPLAY.CONF | cut -d"," -f2 | bin/buildokvs.sh build/SEARCH01.IDX
grep "^.0" < build/DISPLAY.CONF | cut -d"," -f2 | bin/buildokvs.sh build/SEARCH10.IDX
cat build/DISPLAY.CONF | cut -d"," -f2 | bin/buildokvs.sh build/SEARCH11.IDX
grep "^00" < build/DISPLAY.CONF | cut -d"," -f2 | bin/buildokvs.sh > build/SEARCH00.IDX
grep "^0" < build/DISPLAY.CONF | cut -d"," -f2 | bin/buildokvs.sh > build/SEARCH01.IDX
grep "^.0" < build/DISPLAY.CONF | cut -d"," -f2 | bin/buildokvs.sh > build/SEARCH10.IDX
cat build/DISPLAY.CONF | cut -d"," -f2 | bin/buildokvs.sh > build/SEARCH11.IDX
#
# create a sorted list of game filenames, without metadata or display names
#
@ -67,44 +67,44 @@ dsk: asm
# note: prelaunch must be first in TOTAL.DATA due to a hack in LoadStandardPrelaunch
# note 2: these can not be padded because they are loaded at $0106 and padding would clobber the stack
#
bin/buildindexedfile.sh build/PRELAUNCH.IDX build/TOTAL.DATA build/PRELAUNCH.INDEXED < build/GAMES.SORTED
bin/buildindexedfile.sh build/TOTAL.DATA build/PRELAUNCH.INDEXED < build/GAMES.SORTED > build/PRELAUNCH.IDX
#
# precompute indexed files for game help
#
bin/buildindexedfile.sh -p -a build/GAMEHELP.IDX build/TOTAL.DATA build/GAMEHELP < build/GAMES.SORTED
bin/buildindexedfile.sh -p -a build/TOTAL.DATA build/GAMEHELP < build/GAMES.SORTED > build/GAMEHELP.IDX
#
# precompute indexed files for slideshows
#
(for f in res/SS/*; do \
bin/buildokvs.sh "build/SS/$$(basename $$f)" < "$$f"; \
bin/buildokvs.sh < "$$f" > "build/SS/$$(basename $$f)"; \
echo "$$(basename $$f)"; \
done) | bin/buildindexedfile.sh -p -a build/SLIDESHOW.IDX build/TOTAL.DATA build/SS
done) | bin/buildindexedfile.sh -p -a build/TOTAL.DATA build/SS > build/SLIDESHOW.IDX
(for f in res/ATTRACT/*; do \
bin/buildokvs.sh "build/ATTRACT/$$(basename $$f)" < "$$f"; \
bin/buildokvs.sh < "$$f" > "build/ATTRACT/$$(basename $$f)"; \
echo "$$(basename $$f)"; \
done) | bin/buildindexedfile.sh -p -a build/MINIATTRACT.IDX build/TOTAL.DATA build/ATTRACT
done) | bin/buildindexedfile.sh -p -a build/TOTAL.DATA build/ATTRACT > build/MINIATTRACT.IDX
#
# precompute indexed files for graphic effects
#
bin/buildindexedfile.sh -p -a build/FX.IDX build/TOTAL.DATA build/FX.INDEXED < res/FX.CONF
bin/buildindexedfile.sh -p -a build/DFX.IDX build/TOTAL.DATA build/FX.INDEXED < res/DFX.CONF
bin/buildindexedfile.sh -p -a build/TOTAL.DATA build/FX.INDEXED < res/FX.CONF > build/FX.IDX
bin/buildindexedfile.sh -p -a build/TOTAL.DATA build/FX.INDEXED < res/DFX.CONF > build/DFX.IDX
#
# precompute indexed files for HGR action screenshots
# note: these can not be padded because they are compressed and the decompressor needs the exact size
#
(for f in res/ACTION.HGR/[ABCD]*; do echo "$$(basename $$f)"; done) | bin/buildindexedfile.sh -a build/HGR0.IDX build/TOTAL.DATA res/ACTION.HGR
(for f in res/ACTION.HGR/[EFGH]*; do echo "$$(basename $$f)"; done) | bin/buildindexedfile.sh -a build/HGR1.IDX build/TOTAL.DATA res/ACTION.HGR
(for f in res/ACTION.HGR/[IJKL]*; do echo "$$(basename $$f)"; done) | bin/buildindexedfile.sh -a build/HGR2.IDX build/TOTAL.DATA res/ACTION.HGR
(for f in res/ACTION.HGR/[MNOP]*; do echo "$$(basename $$f)"; done) | bin/buildindexedfile.sh -a build/HGR3.IDX build/TOTAL.DATA res/ACTION.HGR
(for f in res/ACTION.HGR/[QRST]*; do echo "$$(basename $$f)"; done) | bin/buildindexedfile.sh -a build/HGR4.IDX build/TOTAL.DATA res/ACTION.HGR
(for f in res/ACTION.HGR/[UVWX]*; do echo "$$(basename $$f)"; done) | bin/buildindexedfile.sh -a build/HGR5.IDX build/TOTAL.DATA res/ACTION.HGR
(for f in res/ACTION.HGR/[YZ]*; do echo "$$(basename $$f)"; done) | bin/buildindexedfile.sh -a build/HGR6.IDX build/TOTAL.DATA res/ACTION.HGR
(for f in res/ACTION.HGR/[ABCD]*; do echo "$$(basename $$f)"; done) | bin/buildindexedfile.sh -a build/TOTAL.DATA res/ACTION.HGR > build/HGR0.IDX
(for f in res/ACTION.HGR/[EFGH]*; do echo "$$(basename $$f)"; done) | bin/buildindexedfile.sh -a build/TOTAL.DATA res/ACTION.HGR > build/HGR1.IDX
(for f in res/ACTION.HGR/[IJKL]*; do echo "$$(basename $$f)"; done) | bin/buildindexedfile.sh -a build/TOTAL.DATA res/ACTION.HGR > build/HGR2.IDX
(for f in res/ACTION.HGR/[MNOP]*; do echo "$$(basename $$f)"; done) | bin/buildindexedfile.sh -a build/TOTAL.DATA res/ACTION.HGR > build/HGR3.IDX
(for f in res/ACTION.HGR/[QRST]*; do echo "$$(basename $$f)"; done) | bin/buildindexedfile.sh -a build/TOTAL.DATA res/ACTION.HGR > build/HGR4.IDX
(for f in res/ACTION.HGR/[UVWX]*; do echo "$$(basename $$f)"; done) | bin/buildindexedfile.sh -a build/TOTAL.DATA res/ACTION.HGR > build/HGR5.IDX
(for f in res/ACTION.HGR/[YZ]*; do echo "$$(basename $$f)"; done) | bin/buildindexedfile.sh -a build/TOTAL.DATA res/ACTION.HGR > build/HGR6.IDX
# precompute indexed files for SHR artwork
# note: these can not be padded because they are compressed and the decompressor needs the exact size
#
(for f in res/ARTWORK.SHR/*; do \
echo "$$(basename $$f)"; \
done) | bin/buildindexedfile.sh -a build/ARTWORK.IDX build/TOTAL.DATA res/ARTWORK.SHR
done) | bin/buildindexedfile.sh -a build/TOTAL.DATA res/ARTWORK.SHR > build/ARTWORK.IDX
#
# create _FileInformation.txt files for subdirectories
#

View File

@ -6,9 +6,9 @@
# parameters
# stdin - input containing list of effects (probably FX.CONF or DFX.CONF)
# 1 - output filename for index file
# 2 - output filename for data file
# 3 - input directory of files to merge into data file
# stdout - binary OKVS data structure
# 1 - output filename for data file
# 2 - input directory of files to merge into data file
pad=false
append=false
@ -25,16 +25,16 @@ done
shift $((OPTIND-1))
if [ "$append" = false ]; then
rm -f "$2"
rm -f "$1"
fi
touch "$2"
touch "$1"
# if there is a file called "STANDARD" in the input directory, add it now
# because we will reuse it for any files that don't exist
if [ -f "$3"/STANDARD ]; then
standardoffset=$(wc -c < "$2")
standardsize=$(wc -c < "$3/STANDARD")
cat "$3"/STANDARD >> "$2"
if [ -f "$2"/STANDARD ]; then
standardoffset=$(wc -c < "$1")
standardsize=$(wc -c < "$2/STANDARD")
cat "$2"/STANDARD >> "$1"
fi
# make temp file with list of lines that contain keys
@ -49,11 +49,11 @@ source=$(mktemp)
echo "!byte ${#key}+7" # OKVS record length
echo "!byte ${#key}" # OKVS key length
echo "!text \"$key\"" # OKVS key
if [ -f "$3/$key" ]; then # if file exists, determine offset and size
offset=$(wc -c < "$2")
if [ -f "$2/$key" ]; then # if file exists, determine offset and size
offset=$(wc -c < "$1")
echo "!be24 $offset" # offset into merged data file
echo -n "!le16 "
size=$(wc -c < "$3/$key")
size=$(wc -c < "$2/$key")
if [ "$pad" = true ]; then
# If offset+size does not cross a block boundary, use file's true size.
# Otherwise, round up size to the next block boundary.
@ -68,16 +68,19 @@ source=$(mktemp)
# Caller said never pad, so always use file's true size.
echo "$size"
fi
cat "$3/$key" >> "$2" # append this file to the end of the merged data file
cat "$2/$key" >> "$1" # append this file to the end of the merged data file
else # if file does not exist, reuse STANDARD file
echo "!be24 $standardoffset"
echo "!le16 $standardsize"
fi
done < "$records") > "$source"
# assemble temp source file to create binary OKVS data structure
acme -o "$1" "$source"
# assemble temp source file into binary OKVS data structure, then output that
out=$(mktemp)
acme -o "$out" "$source"
cat "$out"
# clean up
rm "$out"
rm "$source"
rm "$records"

View File

@ -1,10 +1,8 @@
#!/bin/bash
# run from project root directory
# make temp file with just the key/value pairs (strip blank lines, comments, eof marker)
records=$(mktemp)
grep -v "^$" | grep -v "^#" | grep -v "^\[" > "$records"
awk '!/^$|^#|^\[/' > "$records"
# make temp assembly source file that represents the binary OKVS data structure
source=$(mktemp)
@ -18,9 +16,12 @@ source=$(mktemp)
echo "!text \"$value\"" # OKVS value
done < "$records") > "$source"
# assemble temp source file to create binary OKVS data structure
acme -o "$1" "$source"
# assemble temp source file into binary OKVS data structure, then output that
out=$(mktemp)
acme -o "$out" "$source"
cat "$out"
# clean up
rm "$out"
rm "$source"
rm "$records"