2021-10-08 15:54:25 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-10-08 16:20:42 +00:00
|
|
|
# create or truncate merged-effects file
|
2021-10-08 15:54:25 +00:00
|
|
|
:>| "$3"
|
2021-10-08 16:20:42 +00:00
|
|
|
|
|
|
|
# make temp file with list of effect names
|
2021-10-08 15:54:25 +00:00
|
|
|
records=$(mktemp)
|
|
|
|
grep -v "^$" < "$1" | grep -v "^#" | grep -v "^\[" > "$records"
|
2021-10-08 16:20:42 +00:00
|
|
|
|
|
|
|
# make temp assembly source file that represents the binary OKVS data structure
|
2021-10-08 15:54:25 +00:00
|
|
|
source=$(mktemp)
|
2021-10-08 16:20:42 +00:00
|
|
|
(echo "*=0" # dummy program counter for assembler
|
|
|
|
echo "!le16 $(wc -l <"$records"), 0" # OKVS header
|
2021-10-08 15:54:25 +00:00
|
|
|
while read -r key; do
|
2021-10-08 16:20:42 +00:00
|
|
|
echo "!byte ${#key}+5" # OKVS record length
|
|
|
|
echo "!byte ${#key}" # OKVS key length
|
|
|
|
echo "!text \"$key\"" # OKVS key (effect name)
|
|
|
|
echo "!be24 $(wc -c <"$3")" # offset into merged-effects file
|
|
|
|
cat "build/FX/$key" >> "$3" # add effect code into merged-effects file
|
|
|
|
# (all effects were previously assembled)
|
2021-10-08 15:54:25 +00:00
|
|
|
done < "$records") > "$source"
|
2021-10-08 16:20:42 +00:00
|
|
|
|
|
|
|
# assemble temp source file to create binary OKVS data structure
|
2021-10-08 15:54:25 +00:00
|
|
|
acme -o "$2" "$source"
|
2021-10-08 16:20:42 +00:00
|
|
|
|
|
|
|
# clean up
|
2021-10-08 15:54:25 +00:00
|
|
|
rm "$source"
|
|
|
|
rm "$records"
|