From 2b38b9ba21181669982552975e99990289f91d4a Mon Sep 17 00:00:00 2001 From: yenatch Date: Mon, 9 Sep 2013 23:45:52 -0400 Subject: [PATCH 01/11] suppress .tx handling in Makefile there are too many .tx files for the commands to be meaningful better to just look at the makefile to see what's going on --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1fe1789ad..d3cbae3c5 100644 --- a/Makefile +++ b/Makefile @@ -12,10 +12,11 @@ all: baserom.gbc pokecrystal.gbc cmp baserom.gbc pokecrystal.gbc clean: rm -f pokecrystal.o pokecrystal.gbc - @echo 'rm -f $(TEXTFILES:.asm=.tx)' + @echo 'Removing preprocessed .tx files...' @rm -f $(TEXTFILES:.asm=.tx) pokecrystal.o: $(TEXTFILES:.asm=.tx) wram.asm constants.asm $(shell find constants/ -type f -name '*.asm') hram.asm gbhw.asm $(LZ_GFX) $(TWOBPP_GFX) - $(PYTHON) prequeue.py $(TEXTQUEUE) + @echo "Preprocessing .asm to .tx..." + @$(PYTHON) prequeue.py $(TEXTQUEUE) rgbasm -o pokecrystal.o pokecrystal.asm .asm.tx: $(eval TEXTQUEUE := $(TEXTQUEUE) $<) From 6e6514c2c9e08a263a9067998161eb4a1cb6bb48 Mon Sep 17 00:00:00 2001 From: yenatch Date: Tue, 10 Sep 2013 00:08:49 -0400 Subject: [PATCH 02/11] no need to use python if baserom.gbc doesn't exist this part is only reached if baserom.gbc doesn't exist, so it's pointless to check if it does --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d3cbae3c5..d480ceac1 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ pokecrystal.o: $(TEXTFILES:.asm=.tx) wram.asm constants.asm $(shell find constan $(eval TEXTQUEUE := $(TEXTQUEUE) $<) @rm -f $@ baserom.gbc: - $(PYTHON) -c "import os; assert 'baserom.gbc' in os.listdir('.'), 'Wait! Need baserom.gbc first. Check README and INSTALL for details.';" + @echo "Wait! Need baserom.gbc first. Check README and INSTALL for details." && false pokecrystal.gbc: pokecrystal.o rgblink -n pokecrystal.sym -m pokecrystal.map -o $@ $< From 3e9e7663ec0428a5f054e09efa704aea1d704c9a Mon Sep 17 00:00:00 2001 From: yenatch Date: Tue, 10 Sep 2013 02:03:40 -0400 Subject: [PATCH 03/11] preprocess everything it makes more sense this way --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index d480ceac1..6fc7ce2bf 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ PYTHON := python .SUFFIXES: .asm .tx .o .gbc .png .2bpp .lz -TEXTFILES := $(shell find ./ -type f -name '*.asm' | grep -v pokecrystal.asm | grep -v constants.asm | grep -v gbhw.asm | grep -v hram.asm | grep -v constants | grep -v wram.asm) +TEXTFILES := $(shell find ./ -type f -name '*.asm') TEXTQUEUE := PNG_GFX := $(shell find gfx/ -type f -name '*.png') @@ -14,10 +14,10 @@ clean: rm -f pokecrystal.o pokecrystal.gbc @echo 'Removing preprocessed .tx files...' @rm -f $(TEXTFILES:.asm=.tx) -pokecrystal.o: $(TEXTFILES:.asm=.tx) wram.asm constants.asm $(shell find constants/ -type f -name '*.asm') hram.asm gbhw.asm $(LZ_GFX) $(TWOBPP_GFX) +pokecrystal.o: $(TEXTFILES:.asm=.tx) $(LZ_GFX) $(TWOBPP_GFX) @echo "Preprocessing .asm to .tx..." @$(PYTHON) prequeue.py $(TEXTQUEUE) - rgbasm -o pokecrystal.o pokecrystal.asm + rgbasm -o pokecrystal.o pokecrystal.tx .asm.tx: $(eval TEXTQUEUE := $(TEXTQUEUE) $<) @rm -f $@ From 018cf26767647d233f939bc791a64d3b5d6e3bd1 Mon Sep 17 00:00:00 2001 From: yenatch Date: Tue, 10 Sep 2013 02:16:15 -0400 Subject: [PATCH 04/11] move gbhw.asm and hram.asm to constants.asm they're constants, so they have no business in pokecrystal.asm --- constants.asm | 3 +++ pokecrystal.asm | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/constants.asm b/constants.asm index 84d93f9dd..817268e9f 100644 --- a/constants.asm +++ b/constants.asm @@ -6,6 +6,9 @@ else VERSION EQU 1 endc +INCLUDE "gbhw.asm" +INCLUDE "hram.asm" + INCLUDE "constants/pokemon_constants.asm" INCLUDE "constants/move_constants.asm" INCLUDE "constants/battle_constants.asm" diff --git a/pokecrystal.asm b/pokecrystal.asm index 0155e0ca9..f64d44e76 100644 --- a/pokecrystal.asm +++ b/pokecrystal.asm @@ -1,5 +1,3 @@ INCLUDE "wram.asm" INCLUDE "constants.asm" -INCLUDE "gbhw.asm" -INCLUDE "hram.asm" -INCLUDE "main.tx" +INCLUDE "main.asm" From 4db0e3c18691b57bc8d00f02ea9fe7b116b97db1 Mon Sep 17 00:00:00 2001 From: yenatch Date: Tue, 10 Sep 2013 18:24:44 -0400 Subject: [PATCH 05/11] rewrite Makefile to handle multiple rgbasm objects for now, any new files to preprocess will trigger the targets for all objects. this isn't a problem yet since there's still only one object. --- Makefile | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 6fc7ce2bf..be357d323 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,8 @@ PYTHON := python TEXTFILES := $(shell find ./ -type f -name '*.asm') TEXTQUEUE := +OBJS := pokecrystal.o + PNG_GFX := $(shell find gfx/ -type f -name '*.png') LZ_GFX := $(shell find gfx/ -type f -name '*.lz') TWOBPP_GFX := $(shell find gfx/ -type f -name '*.2bpp') @@ -14,18 +16,21 @@ clean: rm -f pokecrystal.o pokecrystal.gbc @echo 'Removing preprocessed .tx files...' @rm -f $(TEXTFILES:.asm=.tx) -pokecrystal.o: $(TEXTFILES:.asm=.tx) $(LZ_GFX) $(TWOBPP_GFX) - @echo "Preprocessing .asm to .tx..." - @$(PYTHON) prequeue.py $(TEXTQUEUE) - rgbasm -o pokecrystal.o pokecrystal.tx -.asm.tx: - $(eval TEXTQUEUE := $(TEXTQUEUE) $<) - @rm -f $@ + baserom.gbc: @echo "Wait! Need baserom.gbc first. Check README and INSTALL for details." && false -pokecrystal.gbc: pokecrystal.o - rgblink -n pokecrystal.sym -m pokecrystal.map -o $@ $< +.asm.tx: + $(eval TEXTQUEUE := $(TEXTQUEUE) $<) + @rm -f $@ + +$(OBJS): $(TEXTFILES:.asm=.tx) $(LZ_GFX) $(TWOBPP_GFX) + @echo "Preprocessing .asm to .tx..." + @$(PYTHON) prequeue.py $(TEXTQUEUE) + rgbasm -o $@ $(@:.o=.tx) + +pokecrystal.gbc: $(OBJS) + rgblink -n pokecrystal.sym -m pokecrystal.map -o pokecrystal.gbc $< rgbfix -Cjv -i BYTE -k 01 -l 0x33 -m 0x10 -p 0 -r 3 -t PM_CRYSTAL $@ pngs: From e1c3fee92651a5b3550974e9fbd152840e796654 Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 11 Sep 2013 01:16:33 -0400 Subject: [PATCH 06/11] change old .tx includes to .asm these were forgotten about with the last preprocessor change. this is required for object dependencies to be handled by make. --- main.asm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/main.asm b/main.asm index 011e7d966..3961dcba0 100644 --- a/main.asm +++ b/main.asm @@ -86589,7 +86589,7 @@ SECTION "bank6C",ROMX,BANK[$6C] ; Common text I -INCLUDE "text/common.tx" +INCLUDE "text/common.asm" ; Map Scripts XXV @@ -86599,10 +86599,10 @@ INCLUDE "maps/Route10North.asm" SECTION "bank6D",ROMX,BANK[$6D] -INCLUDE "text/phone/mom.tx" -INCLUDE "text/phone/bill.tx" -INCLUDE "text/phone/elm.tx" -INCLUDE "text/phone/trainers1.tx" +INCLUDE "text/phone/mom.asm" +INCLUDE "text/phone/bill.asm" +INCLUDE "text/phone/elm.asm" +INCLUDE "text/phone/trainers1.asm" SECTION "bank6E",ROMX,BANK[$6E] @@ -86617,21 +86617,21 @@ SECTION "bank6F",ROMX,BANK[$6F] ; Common text II -INCLUDE "text/common_2.tx" +INCLUDE "text/common_2.asm" SECTION "bank70",ROMX,BANK[$70] ; Common text III -INCLUDE "text/common_3.tx" +INCLUDE "text/common_3.asm" SECTION "bank71",ROMX,BANK[$71] ; Common text IV -INCLUDE "text/common_4.tx" +INCLUDE "text/common_4.asm" SECTION "bank72",ROMX,BANK[$72] From 6a21963799575fa8a88ed55cde5408ef67c92d63 Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 11 Sep 2013 01:20:52 -0400 Subject: [PATCH 07/11] scan source files for Makefile dependencies preprocessing should work with multiple object files now --- Makefile | 11 +++++++++-- scan_includes.py | 27 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 scan_includes.py diff --git a/Makefile b/Makefile index be357d323..614462cf9 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ PYTHON := python .SUFFIXES: .asm .tx .o .gbc .png .2bpp .lz +.SECONDEXPANSION: TEXTFILES := $(shell find ./ -type f -name '*.asm') TEXTQUEUE := @@ -10,6 +11,8 @@ PNG_GFX := $(shell find gfx/ -type f -name '*.png') LZ_GFX := $(shell find gfx/ -type f -name '*.lz') TWOBPP_GFX := $(shell find gfx/ -type f -name '*.2bpp') +$(shell $(foreach obj, $(OBJS), $(eval OBJ_$(obj:.o=) := $(shell $(PYTHON) scan_includes.py $(obj:.o=.asm))))) + all: baserom.gbc pokecrystal.gbc cmp baserom.gbc pokecrystal.gbc clean: @@ -24,9 +27,10 @@ baserom.gbc: $(eval TEXTQUEUE := $(TEXTQUEUE) $<) @rm -f $@ -$(OBJS): $(TEXTFILES:.asm=.tx) $(LZ_GFX) $(TWOBPP_GFX) +$(OBJS): $$(patsubst %.o,%.tx,$$@) $$(patsubst %.asm,%.tx,$$(OBJ_$$(patsubst %.o,%,$$@))) @echo "Preprocessing .asm to .tx..." @$(PYTHON) prequeue.py $(TEXTQUEUE) + $(eval TEXTQUEUE := ) rgbasm -o $@ $(@:.o=.tx) pokecrystal.gbc: $(OBJS) @@ -52,4 +56,7 @@ gfx/trainers/%.lz: gfx/trainers/%.png $(PYTHON) extras/pokemontools/gfx.py png-to-lz $< .png.2bpp: $(PYTHON) extras/pokemontools/gfx.py png-to-lz $< - +%.2bpp: + @: +%.1bpp: + @: diff --git a/scan_includes.py b/scan_includes.py new file mode 100644 index 000000000..71b2e58a7 --- /dev/null +++ b/scan_includes.py @@ -0,0 +1,27 @@ +# coding: utf-8 + +# Recursively scan an asm file for rgbasm INCLUDEs and INCBINs. +# This is used to generate dependencies for each rgbasm object file. + +import sys + +def scan_for_includes(filename): + filenames = [] + for line in open(filename, 'r').readlines(): + if 'INCLUDE' in line or 'INCBIN' in line: + line = line.split(';')[0] + if 'INCLUDE' in line or 'INCBIN' in line: + filenames += [line.split('"')[1]] + return filenames + +def recursive_scan_for_includes(filename): + filenames = [] + if '.asm' in filename or '.tx' in filename: + for include in scan_for_includes(filename): + filenames += [include] + recursive_scan_for_includes(include) + return filenames + +if len(sys.argv) > 1: + for arg in sys.argv[1:]: + sys.stdout.write(' '.join(recursive_scan_for_includes(arg))) + From c195276073a9ae9b8ed5acc4de54600820992593 Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 11 Sep 2013 01:24:20 -0400 Subject: [PATCH 08/11] rename make variables for graphics files --- Makefile | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 614462cf9..4b47205a7 100644 --- a/Makefile +++ b/Makefile @@ -7,9 +7,10 @@ TEXTQUEUE := OBJS := pokecrystal.o -PNG_GFX := $(shell find gfx/ -type f -name '*.png') -LZ_GFX := $(shell find gfx/ -type f -name '*.lz') -TWOBPP_GFX := $(shell find gfx/ -type f -name '*.2bpp') +PNGS := $(shell find gfx/ -type f -name '*.png') +LZS := $(shell find gfx/ -type f -name '*.lz') +_2BPPS := $(shell find gfx/ -type f -name '*.2bpp') +_1BPPS := $(shell find gfx/ -type f -name '*.1bpp') $(shell $(foreach obj, $(OBJS), $(eval OBJ_$(obj:.o=) := $(shell $(PYTHON) scan_includes.py $(obj:.o=.asm))))) @@ -41,7 +42,7 @@ pngs: $(PYTHON) extras/pokemontools/gfx.py mass-decompress $(PYTHON) extras/pokemontools/gfx.py dump-pngs -lzs: $(LZ_GFX) $(TWOBPP_GFX) +lzs: $(LZS) $(_2BPPS) $(_1BPPS) @: gfx/pics/%/front.lz: gfx/pics/%/tiles.2bpp gfx/pics/%/front.png @@ -56,6 +57,8 @@ gfx/trainers/%.lz: gfx/trainers/%.png $(PYTHON) extras/pokemontools/gfx.py png-to-lz $< .png.2bpp: $(PYTHON) extras/pokemontools/gfx.py png-to-lz $< +.png.1bpp: + $(PYTHON) extras/pokemontools/gfx.py png-to-lz $< %.2bpp: @: %.1bpp: From 84ba0ffc31ec34fb4a626c4e33732ea8bc22ae38 Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 11 Sep 2013 01:25:39 -0400 Subject: [PATCH 09/11] rename lzs make target to gfx --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4b47205a7..7b1f84212 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ pngs: $(PYTHON) extras/pokemontools/gfx.py mass-decompress $(PYTHON) extras/pokemontools/gfx.py dump-pngs -lzs: $(LZS) $(_2BPPS) $(_1BPPS) +gfx: $(LZS) $(_2BPPS) $(_1BPPS) @: gfx/pics/%/front.lz: gfx/pics/%/tiles.2bpp gfx/pics/%/front.png From 74f8d746dba41e7fd864994ddc7a9019841829e1 Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 11 Sep 2013 01:26:51 -0400 Subject: [PATCH 10/11] abstract make targets are now phony --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 7b1f84212..7150b4849 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ PYTHON := python .SUFFIXES: .asm .tx .o .gbc .png .2bpp .lz +.PHONY: all clean pngs gfx .SECONDEXPANSION: TEXTFILES := $(shell find ./ -type f -name '*.asm') From e11a56a1f654de05043eeefac0061e6d2c1b67ba Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 11 Sep 2013 01:40:53 -0400 Subject: [PATCH 11/11] use a docstring instead of comments in scan_includes --- scan_includes.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scan_includes.py b/scan_includes.py index 71b2e58a7..3f006998c 100644 --- a/scan_includes.py +++ b/scan_includes.py @@ -1,7 +1,9 @@ # coding: utf-8 -# Recursively scan an asm file for rgbasm INCLUDEs and INCBINs. -# This is used to generate dependencies for each rgbasm object file. +""" +Recursively scan an asm file for rgbasm INCLUDEs and INCBINs. +This is used to generate dependencies for each rgbasm object file. +""" import sys