mirror of
https://github.com/a2-4am/4cade.git
synced 2024-11-26 17:49:43 +00:00
refactor support scripts [no functional changes]
This commit is contained in:
parent
857a7b960e
commit
a0a573cb8e
18
Makefile
18
Makefile
@ -41,9 +41,8 @@ dsk: asm
|
||||
# precompute FX and DFX indexes and merged data files containing multiple
|
||||
# graphic effects in a single file (loaded at runtime by LoadIndexedFile())
|
||||
#
|
||||
rm -f "build/FX.ALL"
|
||||
bin/buildfx.sh -p "res/FX.CONF" "build/FX.IDX" "build/FX.ALL" "build/FX.INDEXED" >>build/log
|
||||
bin/buildfx.sh -p "res/DFX.CONF" "build/DFX.IDX" "build/FX.ALL" "build/FX.INDEXED" >>build/log
|
||||
bin/buildindexedfile.sh -p "res/FX.CONF" "build/FX.IDX" "build/FX.ALL" "build/FX.INDEXED" >>build/log
|
||||
bin/buildindexedfile.sh -a -p "res/DFX.CONF" "build/DFX.IDX" "build/FX.ALL" "build/FX.INDEXED" >>build/log
|
||||
#
|
||||
# substitute special characters in help text and other pages that will be
|
||||
# drawn with DrawPage()
|
||||
@ -57,18 +56,19 @@ dsk: asm
|
||||
# precompute indexed files for game help, slideshow configuration,
|
||||
# mini-attract mode configuration, and prelaunch files
|
||||
#
|
||||
bin/buildhelp.sh "res/GAMES.CONF" "build/GAMEHELP.IDX" "build/GAMEHELP.ALL" "build/GAMEHELP" >>build/log
|
||||
awk -F "," '!/^#/ { print $$2 }' < res/GAMES.CONF | awk -F "=" '{ print $$1 }' | sort > build/GAMES.SORTED
|
||||
bin/buildindexedfile.sh -p "build/GAMES.SORTED" "build/GAMEHELP.IDX" "build/GAMEHELP.ALL" "build/GAMEHELP" >>build/log
|
||||
(for f in res/SS/*; do \
|
||||
bin/buildokvs.sh "$$f" "build/SS/$$(basename $$f)"; \
|
||||
echo "$$(basename $$f)"; \
|
||||
done) > build/SSDIR.CONF
|
||||
bin/buildfx.sh -p "build/SSDIR.CONF" "build/SLIDESHOW.IDX" "build/SLIDESHOW.ALL" "build/SS" >>build/log
|
||||
done) > build/SSDIR
|
||||
bin/buildindexedfile.sh -p "build/SSDIR" "build/SLIDESHOW.IDX" "build/SLIDESHOW.ALL" "build/SS" >>build/log
|
||||
(for f in res/ATTRACT/*; do \
|
||||
bin/buildokvs.sh "$$f" "build/ATTRACT/$$(basename $$f)"; \
|
||||
echo "$$(basename $$f)"; \
|
||||
done) > build/ATTRACTDIR.CONF
|
||||
bin/buildfx.sh -p "build/ATTRACTDIR.CONF" "build/MINIATTRACT.IDX" "build/MINIATTRACT.ALL" "build/ATTRACT" >>build/log
|
||||
bin/buildhelp.sh "res/GAMES.CONF" "build/PRELAUNCH.IDX" "build/PRELAUNCH.ALL" "build/PRELAUNCH.INDEXED" >>build/log
|
||||
done) > build/ATTRACTDIR
|
||||
bin/buildindexedfile.sh -p "build/ATTRACTDIR" "build/MINIATTRACT.IDX" "build/MINIATTRACT.ALL" "build/ATTRACT" >>build/log
|
||||
bin/buildindexedfile.sh "build/GAMES.SORTED" "build/PRELAUNCH.IDX" "build/PRELAUNCH.ALL" "build/PRELAUNCH.INDEXED" >>build/log
|
||||
#
|
||||
# create _FileInformation.txt files for subdirectories
|
||||
#
|
||||
|
@ -1,65 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# run from project root directory
|
||||
|
||||
# flags
|
||||
# -p pad merged file size to next block size (default off)
|
||||
|
||||
# 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
|
||||
|
||||
pad=false
|
||||
while getopts ":p:" opt; do
|
||||
case $opt in
|
||||
p) pad=true
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# create merged data file if it doesn't exist, but do not truncate it
|
||||
# (we may call this script more than once with the same data file)
|
||||
touch "$3"
|
||||
|
||||
# make temp file with list of effect names
|
||||
records=$(mktemp)
|
||||
awk '!/^$|^#|^\[/ { print }' < "$1" > "$records"
|
||||
|
||||
# make temp assembly source file that represents the binary OKVS data structure
|
||||
source=$(mktemp)
|
||||
(echo "*=0" # dummy program counter for assembler
|
||||
echo "!le16 $(wc -l <"$records"), 0" # OKVS header
|
||||
while read -r key; do
|
||||
echo "!byte ${#key}+7" # OKVS record length
|
||||
echo "!byte ${#key}" # OKVS key length
|
||||
echo "!text \"$key\"" # OKVS key (effect name)
|
||||
offset=$(wc -c < "$3")
|
||||
echo "!be24 $offset" # offset into merged-effects file
|
||||
echo -n "!le16 "
|
||||
# If offset+size does not cross a block boundary, use the size.
|
||||
# Otherwise, round up size to the next block boundary.
|
||||
# This padding does not get added to the file; it is just an
|
||||
# optimization to avoid a partial copy on the last block read.
|
||||
size=$(wc -c < "$4/$key")
|
||||
if [ "$pad" = true ]; then
|
||||
if [ $(($offset / 512)) -eq $((($offset + $size) / 512)) ]; then
|
||||
echo "$size"
|
||||
else
|
||||
echo "$(((($offset + $size + 511) & -512) - $offset))"
|
||||
fi
|
||||
else
|
||||
echo "$size"
|
||||
fi
|
||||
cat "$4/$key" >> "$3" # add effect code into merged-effects file
|
||||
# (all effects were previously assembled)
|
||||
done < "$records") > "$source"
|
||||
|
||||
# assemble temp source file to create binary OKVS data structure
|
||||
acme -o "$2" "$source"
|
||||
|
||||
# clean up
|
||||
rm "$source"
|
||||
rm "$records"
|
@ -1,42 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# run from project root directory
|
||||
|
||||
# parameters
|
||||
# 1 - input filename of text file containing list of games (probably GAMES.CONF)
|
||||
# 2 - output filename for index file
|
||||
# 3 - output filename for merged-gamehelp file
|
||||
# 4 - input directory of gamehelp files
|
||||
|
||||
# make temp file with list of game filenames
|
||||
records=$(mktemp)
|
||||
grep "," < "$1" | grep -v "^#" | cut -d"," -f2 | cut -d"=" -f1 | sort > "$records"
|
||||
|
||||
# first help text is the 'TODO' placeholder screen
|
||||
cp "$4"/STANDARD "$3"
|
||||
standardsize=$(wc -c < "$3")
|
||||
|
||||
# make temp assembly source file that represents the binary OKVS data structure
|
||||
source=$(mktemp)
|
||||
(echo "*=0" # dummy program counter for assembler
|
||||
echo "!le16 $(wc -l <"$records"), 0" # OKVS header
|
||||
while read -r key; do
|
||||
echo "!byte ${#key}+7" # OKVS record length
|
||||
echo "!byte ${#key}" # OKVS key length
|
||||
echo "!text \"$key\"" # OKVS key (effect name)
|
||||
if [ -f "$4/$key" ]; then
|
||||
echo "!be24 $(wc -c < "$3")" # offset into merged-gamehelp file (3-byte big-endian)
|
||||
echo "!le16 $(wc -c < "$4/$key")" # size
|
||||
cat "$4/$key" >> "$3" # add this gamehelp to the merged-gamehelp file
|
||||
else
|
||||
echo "!be24 0" # if game has no help, reuse placeholder at offset 0
|
||||
echo "!le16 $standardsize" # and the size of the placeholder text
|
||||
fi
|
||||
done < "$records") > "$source"
|
||||
|
||||
# assemble temp source file to create binary OKVS data structure
|
||||
acme -o "$2" "$source"
|
||||
|
||||
# clean up
|
||||
rm "$source"
|
||||
rm "$records"
|
77
bin/buildindexedfile.sh
Executable file
77
bin/buildindexedfile.sh
Executable file
@ -0,0 +1,77 @@
|
||||
#!/bin/bash
|
||||
|
||||
# flags
|
||||
# -a append to data file (default off = truncate)
|
||||
# -p pad sizes within data file to next block size (default off)
|
||||
|
||||
# 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 data file
|
||||
# 4 - input directory of files to merge into data file
|
||||
|
||||
pad=false
|
||||
append=false
|
||||
standardsize=0
|
||||
while getopts ":ap" opt; do
|
||||
case $opt in
|
||||
a) append=true
|
||||
;;
|
||||
p) pad=true
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
|
||||
if [ -f "$4"/STANDARD ]; then
|
||||
cp "$4"/STANDARD "$3"
|
||||
standardsize=$(wc -c < "$3")
|
||||
elif [ "$append" = false ]; then
|
||||
rm -f "$3"
|
||||
fi
|
||||
touch "$3"
|
||||
|
||||
# make temp file with list of lines that contain keys
|
||||
records=$(mktemp)
|
||||
awk '!/^$|^#|^\[/ { print }' < "$1" > "$records"
|
||||
|
||||
# make temp assembly source file that represents the binary OKVS data structure
|
||||
source=$(mktemp)
|
||||
(echo "*=0" # dummy program counter for assembler
|
||||
echo "!le16 $(wc -l <"$records"), 0" # OKVS header
|
||||
while IFS="=" read -r key value; do
|
||||
echo "!byte ${#key}+7" # OKVS record length
|
||||
echo "!byte ${#key}" # OKVS key length
|
||||
echo "!text \"$key\"" # OKVS key
|
||||
if [ -f "$4/$key" ]; then # if file exists, determine offset and size
|
||||
offset=$(wc -c < "$3")
|
||||
echo "!be24 $offset" # offset into merged data file
|
||||
echo -n "!le16 "
|
||||
size=$(wc -c < "$4/$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.
|
||||
# This padding does not get added to the file; it is just an
|
||||
# optimization to avoid a partial copy on the last block read.
|
||||
if [ $(($offset / 512)) -eq $((($offset + $size) / 512)) ]; then
|
||||
echo "$size"
|
||||
else
|
||||
echo "$(((($offset + $size + 511) & -512) - $offset))"
|
||||
fi
|
||||
else
|
||||
# Caller said never pad, so always use file's true size.
|
||||
echo "$size"
|
||||
fi
|
||||
cat "$4/$key" >> "$3" # append this file to the end of the merged data file
|
||||
else # if file does not exist, reuse placeholder at offset 0
|
||||
echo "!be24 0"
|
||||
echo "!le16 $standardsize"
|
||||
fi
|
||||
done < "$records") > "$source"
|
||||
|
||||
# assemble temp source file to create binary OKVS data structure
|
||||
acme -o "$2" "$source"
|
||||
|
||||
# clean up
|
||||
rm "$source"
|
||||
rm "$records"
|
Loading…
Reference in New Issue
Block a user