ref: d72b2ec16796cba952499311e98ec3d8d654a55c
parent: bbbbd7b9ae6daf32d72ba67fed5ba54ff673480e
author: Jacob Moody <[email protected]>
date: Tue Feb 28 06:06:37 EST 2023
rewrite include scanner and move out of mkfile
--- a/mkfile
+++ b/mkfile
@@ -41,64 +41,8 @@
all:V: $TARG
-include:VE:
- {
- for(i in gfx/pokemon/*/front.png){
- which=`{echo $i | sed 's,gfx/pokemon/,,g;s,/front.png,,g'}
- echo 'gfx/pokemon/'^$which^'/front.animated.2bpp: gfx/pokemon/'^$which^'/front.2bpp gfx/pokemon/'^$which^'/front.dimensions'
- echo ' $TANIMG -o $target $prereq'
- echo 'gfx/pokemon/'^$which^'/front.animated.tilemap: gfx/pokemon/'^$which^'/front.2bpp gfx/pokemon/'^$which^'/front.dimensions'
- echo ' $TANIMG -t $target $prereq'
- echo 'gfx/pokemon/'^$which^'/bitmask.asm: gfx/pokemon/'^$which^'/front.animated.tilemap gfx/pokemon/'^$which^'/front.dimensions'
- echo ' $TANIM -b $prereq >$target'
- echo 'gfx/pokemon/'^$which^'/frames.asm: gfx/pokemon/'^$which^'/front.animated.tilemap gfx/pokemon/'^$which^'/front.dimensions'
- echo ' $TANIM -f $prereq >$target'
- echo 'gfx/pokemon/'^$which^'/back.2bpp: gfx/pokemon/'^$which^'/back.png'
- echo ' rgbgfx -h -o $target $prereq'
- }
- for(i in gfx/trainers/*.png){
- dst=`{echo $i | sed 's/\.png/\.2bpp/g'}
- echo $dst^': '^$i
- echo ' rgbgfx -h -o $target $prereq'
- }
- } >anim.mk
- {
- echo 'BMFILES=\'
- for(i in `{walk | grep asm}){
- sed -n 's/.*(INCLUDE|INCBIN) "(gfx.*bitmask\.asm)".*/\2/gp' $i | sed 's/^/ /g;s/$/\\/g' | grep -v 'unown/bitmask.asm'
- }
- echo
- echo 'FRFILES=\'
- for(i in `{walk | grep asm}){
- sed -n 's/.*(INCLUDE|INCBIN) "(gfx.*frames\.asm)".*/\2/gp' $i | sed 's/^/ /g;s/$/\\/g' | grep -v 'gfx/pokemon/unown/frames.asm|(kanto|johto)_frames.asm|gfx/pokemon/unown_frames.asm'
- }
- echo
- echo 'B2FILES=\'
- for(i in `{walk | grep asm}){
- sed -n 's/.*(INCLUDE|INCBIN) "(gfx.*\.2bpp)".*/\2/gp' $i | sed 's/^/ /g;s/$/\\/g'
- }
- echo
- echo 'B1FILES=\'
- for(i in `{walk | grep asm}){
- sed -n 's/.*(INCLUDE|INCBIN) "(gfx.*\.1bpp)".*/\2/gp' $i | sed 's/^/ /g;s/$/\\/g'
- }
- echo
- echo 'DIMFILES=\'
- for(i in `{walk | grep asm}){
- sed -n 's/.*(INCLUDE|INCBIN) "(gfx.*\.dimensions)".*/\2/gp' $i | sed 's/^/ /g;s/$/\\/g'
- }
- echo
- echo 'PALFILES=\'
- for(i in `{walk | grep asm}){
- sed -n 's/.*(INCLUDE|INCBIN) "(gfx.*\.gbcpal)".*/\2/gp' $i | sed 's/^/ /g;s/$/\\/g'
- }
- echo
- echo 'LZFILES=\'
- for(i in `{walk | grep asm}){
- sed -n 's/.*(INCLUDE|INCBIN) "(gfx.*\.lz)".*/\2/gp' $i | sed 's/^/ /g;s/$/\\/g'
- }
- echo
- } >inc.mk
+include:V:
+ ./tools/scan_includes.rc
check:V: $TARG
@{
--- /dev/null
+++ b/tools/scan_includes.rc
@@ -1,0 +1,57 @@
+#!/bin/rc
+{
+ for(i in gfx/pokemon/*/front.png){
+ which=`{echo $i | sed 's,gfx/pokemon/,,g;s,/front.png,,g'}
+ echo 'gfx/pokemon/'^$which^'/front.animated.2bpp: gfx/pokemon/'^$which^'/front.2bpp gfx/pokemon/'^$which^'/front.dimensions'
+ echo ' $TANIMG -o $target $prereq'
+ echo 'gfx/pokemon/'^$which^'/front.animated.tilemap: gfx/pokemon/'^$which^'/front.2bpp gfx/pokemon/'^$which^'/front.dimensions'
+ echo ' $TANIMG -t $target $prereq'
+ echo 'gfx/pokemon/'^$which^'/bitmask.asm: gfx/pokemon/'^$which^'/front.animated.tilemap gfx/pokemon/'^$which^'/front.dimensions'
+ echo ' $TANIM -b $prereq >$target'
+ echo 'gfx/pokemon/'^$which^'/frames.asm: gfx/pokemon/'^$which^'/front.animated.tilemap gfx/pokemon/'^$which^'/front.dimensions'
+ echo ' $TANIM -f $prereq >$target'
+ echo 'gfx/pokemon/'^$which^'/back.2bpp: gfx/pokemon/'^$which^'/back.png'
+ echo ' rgbgfx -h -o $target $prereq'
+ }
+ for(i in gfx/trainers/*.png){
+ dst=`{echo $i | sed 's/\.png/\.2bpp/g'}
+ echo $dst^': '^$i
+ echo ' rgbgfx -h -o $target $prereq'
+ }
+} >anim.mk
+{ for(i in `{walk | grep asm}) cat $i } | \
+sed -n 's/.*(INCLUDE|INCBIN) "(gfx.*((bitmask|frames)*\.(asm|2bpp|1bpp|dimensions|gbcpal|lz)))".*/\2/gp' | \
+awk '
+ function out(name, arr){
+ printf("%sFILES=\\\n", name);
+ for(i = 0; i < length(arr); i++)
+ printf(" %s\\\n", arr[i]);
+ print("");
+ }
+ /lz$/{ LZ[lzi++] = $0; }
+ /gbcpal$/{ PAL[pali++] = $0; }
+ /dimensions$/{ DIM[dimi++] = $0; }
+ /1bpp$/{ B1[b1i++] = $0; }
+ /2bpp$/{ B2[b2i++] = $0; }
+ /frames\.asm$/{
+ if(match($0, /(kanto|johto)_frames\.asm$/))
+ next;
+ if(match($0, /unown.frames.asm$/))
+ next;
+ FR[fri++] = $0;
+ }
+ /bitmask\.asm$/{
+ if(match($0, /unown.bitmask.asm/))
+ next;
+ BM[bmi++] = $0;
+ }
+ END{
+ out("BM", BM);
+ out("FR", FR);
+ out("B2", B2);
+ out("B1", B1);
+ out("DIM", DIM);
+ out("PAL", PAL);
+ out("LZ", LZ);
+ }
+'>inc.mk