From 3dc28849c42245c468a58dddebf7427156db3602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tari=20Bal=C3=A1zs?= Date: Thu, 29 Jan 2026 23:21:00 +0100 Subject: [PATCH] #24 Assets Import-export fix --- Makefile | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 9fde949..383f4f4 100644 --- a/Makefile +++ b/Makefile @@ -58,25 +58,36 @@ watch: make build fswatch -o $(SRC_DIR) $(ORDER) assets | while read; do make build; done -import_assets: - @for t in $(ASSET_TYPES); do \ +import_assets: $(OUTPUT) + @TIC_CMD="load $(OUTPUT) &"; \ + for t in $(ASSET_TYPES); do \ for f in $(ASSETS_DIR)/$$t/*.png; do \ [ -e "$$f" ] || continue; \ echo "==> Importing $$f as $$t..."; \ - tic80 --cli --skip --fs=. --cmd="import $$t $$f & exit"; \ + TIC_CMD="$${TIC_CMD} & import $$t $$f"; \ done; \ - done + done; \ + TIC_CMD="$$TIC_CMD save & exit"; \ + echo $$TIC_CMD; \ + tic80 --cli --skip --fs=. --cmd="$$TIC_CMD" -export_assets: build +# export helper function +define f_export_asset_awk + cat $(2) | awk '/-- <$(1)>/,/<\/$(1)>/' >> $(3) +endef + +export_assets: +# $(OUTPUT) would be a circular dependency + @test -e $(OUTPUT) @echo "==> Exporting TIC-80 asset sections" @mkdir -p inc/meta - @sed -n '/^-- /,/^-- <\/PALETTE>/p;\ - /^-- /,/^-- <\/TILES>/p;\ - /^-- /,/^-- <\/SPRITES>/p;\ - /^-- /,/^-- <\/MAP>/p;\ - /^-- /,/^-- <\/SFX>/p;\ - /^-- /,/^-- <\/MUSIC>/p' \ - $(OUTPUT) > $(ASSETS_LUA) + @echo -n '' > $(ASSETS_LUA) + @$(call f_export_asset_awk,PALETTE,$(OUTPUT),$(ASSETS_LUA)) + @$(call f_export_asset_awk,TILES,$(OUTPUT),$(ASSETS_LUA)) + @$(call f_export_asset_awk,SPRITES,$(OUTPUT),$(ASSETS_LUA)) + @$(call f_export_asset_awk,MAP,$(OUTPUT),$(ASSETS_LUA)) + @$(call f_export_asset_awk,SFX,$(OUTPUT),$(ASSETS_LUA)) + @$(call f_export_asset_awk,WAVES,$(OUTPUT),$(ASSETS_LUA)) clean: @rm -f $(PROJECT)-*.tic $(PROJECT)-*.html.zip $(OUTPUT) @@ -115,3 +126,10 @@ ci-update: .PHONY: all build export watch import_assets export_assets clean ci-version ci-export ci-upload ci-update +#-- +#-- 000:224578acdeeeeddcba95434567653100 +#-- +# +#-- +#-- 000:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000 +#--