2021-10-08 15:54:25 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-10-13 01:31:39 +00:00
|
|
|
# run from project root directory
|
|
|
|
|
|
|
|
# parameters
|
|
|
|
# 1 - input filename of text file containing list of effects (probably FX.CONF or DFX.CONF)
|
|
|
|
# 2 - output filename for index file
|
|
|
|
# 3 - output filename for merged-effects file
|
|
|
|
# 4 - input directory of (previously assembled) effects files
|
|
|
|
|
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
|
2021-10-13 01:31:39 +00:00
|
|
|
cat "$4/$key" >> "$3" # add effect code into merged-effects file
|
2021-10-08 16:20:42 +00:00
|
|
|
# (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"
|