4cade/bin/buildhelp.sh

23 lines
898 B
Bash
Raw Normal View History

2021-10-06 02:20:15 +00:00
#!/bin/bash
# run from project root directory
2021-10-08 16:20:42 +00:00
# make in-memory array of game filenames
2021-10-06 04:40:16 +00:00
games=$(grep "," res/GAMES.CONF | grep -v "^#" | cut -d"," -f2 | cut -d"=" -f1 | sort)
2021-10-08 16:20:42 +00:00
# first help text is the 'TODO' placeholder screen
2021-10-06 04:40:16 +00:00
cp res/GAMEHELP/STANDARD "$1"
2021-10-06 02:20:15 +00:00
for c in {A..Z}; do
2021-10-08 16:20:42 +00:00
echo "group$c" # group games by first letter
2021-10-06 04:54:17 +00:00
for game in $(echo "$games" | grep "^$c"); do
2021-10-08 16:20:42 +00:00
echo "!byte ${#game}" # key length
echo "!text \"$game\"" # key (game filename)
2021-10-06 02:20:15 +00:00
if [ -f "res/GAMEHELP/$game" ]; then
2021-10-08 16:20:42 +00:00
echo "!be24 $(wc -c <"$1")" # value (3-byte big-endian offset into merged help file)
2021-10-06 02:20:15 +00:00
cat res/GAMEHELP/"$game" >> "$1"
else
2021-10-08 16:20:42 +00:00
echo "!be24 0" # if game has no help, reuse placeholder at offset 0
2021-10-06 02:20:15 +00:00
fi
done
done > "$2"