4cade/bin/generate-mini-attract-mode.sh

26 lines
1.3 KiB
Bash
Raw Normal View History

#!/bin/sh
# run from project root directory
cat res/games.conf | tr "\r" "\n" | grep "=" | grep -v "^#" | cut -d"," -f2 | cut -d"=" -f1 | \
while read game; do
# if I knew how to use awk, this could be O(N) instead of O(N^2)
name=`cat res/games.conf | tr "\r" "\n" | grep "$game=" | cut -d"=" -f2`
# initialize attract mode configuration file for this game
2019-06-26 02:44:39 +00:00
echo "#\n# Attract mode for $name\n#\n" > /tmp/g
# add title screenshot for DHGR games only
2019-06-26 02:44:39 +00:00
[ -f res/title.dhgr/"$game" ] && echo "TITLE.DHGR/$game=8" >> /tmp/g
# add box art, if any
2019-06-26 02:44:39 +00:00
[ -f res/artwork.shr/"$game" ] && echo "ARTWORK.SHR/$game=9" >> /tmp/g
# TODO add DHGR action screenshots, if any
cat res/ss/ACTDHGR*.CONF | tr "\r" "\n" | grep "$game""$" | cut -d"=" -f1 | sed -e "s/^/ACTION.DHGR\//g" | sed -e "s/$/=8/g" | sort | uniq >> /tmp/g
# add action screenshots, if any
cat res/ss/ACTION*.CONF | tr "\r" "\n" | grep "$game""$" | cut -d"=" -f1 | sed -e "s/^/ACTION.HGR\//g" | sed -e "s/$/=7/g" | sort | uniq >> /tmp/g
# add self-running demo, if any
2019-06-26 02:44:39 +00:00
cat res/attract.conf | tr "\r" "\n" | grep "^$game=0" >> /tmp/g
# add eof
2019-06-26 02:44:39 +00:00
echo "\n[eof]" >> /tmp/g
cat /tmp/g | tr "\n" "\r" > res/attract/"$game"
rm /tmp/g
done