ref: 18656332b7b4ca67461d4cd4b6b8282d3bc7ab0c
parent: 5f6ecb8d1ed1af55ba79e8db342c07368d7f6760
parent: e11a56a1f654de05043eeefac0061e6d2c1b67ba
author: Bryan Bishop <[email protected]>
date: Tue Sep 10 18:47:24 EDT 2013
Merge pull request #202 from yenatch/rgbasm-objects makefile: support multiple rgbasm objects
--- a/Makefile
+++ b/Makefile
@@ -1,30 +1,42 @@
PYTHON := python
.SUFFIXES: .asm .tx .o .gbc .png .2bpp .lz
+.PHONY: all clean pngs gfx
+.SECONDEXPANSION:
-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')
-LZ_GFX := $(shell find gfx/ -type f -name '*.lz')
-TWOBPP_GFX := $(shell find gfx/ -type f -name '*.2bpp')
+OBJS := pokecrystal.o
+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)))))
+
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)
- rgbasm -o pokecrystal.o pokecrystal.asm
+
+baserom.gbc:
+ @echo "Wait! Need baserom.gbc first. Check README and INSTALL for details." && false
+
.asm.tx:
$(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.';"
-pokecrystal.gbc: pokecrystal.o
- rgblink -n pokecrystal.sym -m pokecrystal.map -o $@ $<
+$(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)
+ 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:
@@ -31,7 +43,7 @@
$(PYTHON) extras/pokemontools/gfx.py mass-decompress
$(PYTHON) extras/pokemontools/gfx.py dump-pngs
-lzs: $(LZ_GFX) $(TWOBPP_GFX)
+gfx: $(LZS) $(_2BPPS) $(_1BPPS)
@:
gfx/pics/%/front.lz: gfx/pics/%/tiles.2bpp gfx/pics/%/front.png
@@ -46,4 +58,9 @@
$(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:
+ @:
--- a/constants.asm
+++ b/constants.asm
@@ -6,6 +6,9 @@
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"
--- a/main.asm
+++ b/main.asm
@@ -86589,7 +86589,7 @@
; Common text I
-INCLUDE "text/common.tx"
+INCLUDE "text/common.asm"
; Map Scripts XXV
@@ -86599,10 +86599,10 @@
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,7 +86617,7 @@
; Common text II
-INCLUDE "text/common_2.tx"
+INCLUDE "text/common_2.asm"
SECTION "bank70",ROMX,BANK[$70]
@@ -86624,7 +86624,7 @@
; Common text III
-INCLUDE "text/common_3.tx"
+INCLUDE "text/common_3.asm"
SECTION "bank71",ROMX,BANK[$71]
@@ -86631,7 +86631,7 @@
; Common text IV
-INCLUDE "text/common_4.tx"
+INCLUDE "text/common_4.asm"
SECTION "bank72",ROMX,BANK[$72]
--- 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"
--- /dev/null
+++ b/scan_includes.py
@@ -1,0 +1,29 @@
+# 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)))
+