aboutsummaryrefslogtreecommitdiff
path: root/src/static/makefile
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-03-22 15:15:10 +0100
committerlonkaars <loek@pipeframe.xyz>2023-03-22 15:15:10 +0100
commit8495bc3169939d034622dcbf6fb84016a7430ef2 (patch)
tree0967c9e5fc88f49eadf95049d082fef7eae9fcb5 /src/static/makefile
parent7f51cd925883bbf958baa289d4d19231667c9eba (diff)
tilemap build system done
Diffstat (limited to 'src/static/makefile')
-rw-r--r--src/static/makefile34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/static/makefile b/src/static/makefile
new file mode 100644
index 0000000..a6a18db
--- /dev/null
+++ b/src/static/makefile
@@ -0,0 +1,34 @@
+XXD := xxd
+TILEPACK := ../../scripts/tilepack
+MANIFEST2HEADER := ../../scripts/manifest2header.awk
+
+INPUT += shop.hex \
+ slime.hex \
+ world.hex
+USER_META += world.h
+
+OUT_BIN := $(patsubst %.hex,%.bin, $(INPUT))
+OUT_META := $(patsubst %.hex,%.meta, $(INPUT))
+
+.PHONY: all clean
+
+all: tilemap.bin tilemap.h
+
+%.bin: %.hex
+ sed 's/;.*//g' $< | $(XXD) -r | $(TILEPACK) > $@
+
+%.meta: %.bin
+ wc -c $< | tr '.' ' ' | awk '1 { print $$2" "$$1 / 104 }' > $@
+
+manifest.txt: $(OUT_BIN) $(OUT_META)
+ cat $(OUT_META) | sort > $@
+
+tilemap.bin: manifest.txt $(OUT_BIN)
+ awk '1 { print $$1".bin" }' $< | xargs cat > $@
+
+tilemap.h: manifest.txt
+ $(MANIFEST2HEADER) $< > $@
+ cat $(USER_META) >> $@
+
+clean:
+ $(RM) $(OUT_BIN) $(OUT_META) manifest.txt tilemap.h tilemap.bin