Skip to content

Instantly share code, notes, and snippets.

@SBird1337
Created April 24, 2019 11:13
Show Gist options
  • Save SBird1337/e87bc691fc06620c1eb8a5cff8b37f19 to your computer and use it in GitHub Desktop.
Save SBird1337/e87bc691fc06620c1eb8a5cff8b37f19 to your computer and use it in GitHub Desktop.
grit wrapper for pokeemerald
#!/bin/sh
helpFunction()
{
echo ""
echo "Usage: $0 -i input -o output_directory"
echo "\t-i Input file to invoke grit with"
echo "\t-o Directory to write output files to"
exit 1 # Exit script after printing help
}
while getopts "i:o:g:" opt
do
case "$opt" in
i ) inputFile="$OPTARG" ;;
o ) outputDir="$OPTARG" ;;
g ) gritFile="$OPTARG" ;;
? ) helpFunction ;; # Print helpFunction in case parameter is non-existent
esac
done
# Print helpFunction in case parameters are empty
if [ -z "$inputFile" ] || [ -z "$outputDir" ]
then
echo "Some or all of the parameters are empty";
helpFunction
fi
outWithExt=$outputDir/$(basename $inputFile)
outBase=${outWithExt%.*}
if [ -z "$gritFile" ]
then
grit $inputFile -fh! -ftb -g -gt -gB4 -p -pn16 -m -mRtpf -pz! -gz! -mzl -o $outBase
else
grit $inputFile -fh! -ftb -g -gt -gB4 -p -pn16 -m -mRtpf -pz! -gz! -mzl -ff $gritfile -o $outBase
fi
mv "$outBase.img.bin" "$outBase.4bpp"
mv "$outBase.map.bin" "$outBase.bin"
mv "$outBase.pal.bin" "$outBase.gbapal"
tools/gbagfx/gbagfx "$outBase.4bpp" "$outBase.png"
tools/gbagfx/gbagfx "$outBase.gbapal" "$outBase.pal"
rm "$outBase.gbapal"
rm "$outBase.4bpp"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment