Merge pull request #202 from yenatch/rgbasm-objects

makefile: support multiple rgbasm objects
This commit is contained in:
Bryan Bishop 2013-09-10 22:47:24 -07:00
commit 18656332b7
5 changed files with 72 additions and 25 deletions

View File

@ -1,37 +1,49 @@
PYTHON := python PYTHON := python
.SUFFIXES: .asm .tx .o .gbc .png .2bpp .lz .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 := TEXTQUEUE :=
PNG_GFX := $(shell find gfx/ -type f -name '*.png') OBJS := pokecrystal.o
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)))))
all: baserom.gbc pokecrystal.gbc all: baserom.gbc pokecrystal.gbc
cmp baserom.gbc pokecrystal.gbc cmp baserom.gbc pokecrystal.gbc
clean: clean:
rm -f pokecrystal.o pokecrystal.gbc rm -f pokecrystal.o pokecrystal.gbc
@echo 'rm -f $(TEXTFILES:.asm=.tx)' @echo 'Removing preprocessed .tx files...'
@rm -f $(TEXTFILES:.asm=.tx) @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) baserom.gbc:
rgbasm -o pokecrystal.o pokecrystal.asm @echo "Wait! Need baserom.gbc first. Check README and INSTALL for details." && false
.asm.tx: .asm.tx:
$(eval TEXTQUEUE := $(TEXTQUEUE) $<) $(eval TEXTQUEUE := $(TEXTQUEUE) $<)
@rm -f $@ @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 $(OBJS): $$(patsubst %.o,%.tx,$$@) $$(patsubst %.asm,%.tx,$$(OBJ_$$(patsubst %.o,%,$$@)))
rgblink -n pokecrystal.sym -m pokecrystal.map -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 $@ rgbfix -Cjv -i BYTE -k 01 -l 0x33 -m 0x10 -p 0 -r 3 -t PM_CRYSTAL $@
pngs: pngs:
$(PYTHON) extras/pokemontools/gfx.py mass-decompress $(PYTHON) extras/pokemontools/gfx.py mass-decompress
$(PYTHON) extras/pokemontools/gfx.py dump-pngs $(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 gfx/pics/%/front.lz: gfx/pics/%/tiles.2bpp gfx/pics/%/front.png
@ -46,4 +58,9 @@ gfx/trainers/%.lz: gfx/trainers/%.png
$(PYTHON) extras/pokemontools/gfx.py png-to-lz $< $(PYTHON) extras/pokemontools/gfx.py png-to-lz $<
.png.2bpp: .png.2bpp:
$(PYTHON) extras/pokemontools/gfx.py png-to-lz $< $(PYTHON) extras/pokemontools/gfx.py png-to-lz $<
.png.1bpp:
$(PYTHON) extras/pokemontools/gfx.py png-to-lz $<
%.2bpp:
@:
%.1bpp:
@:

View File

@ -6,6 +6,9 @@ else
VERSION EQU 1 VERSION EQU 1
endc endc
INCLUDE "gbhw.asm"
INCLUDE "hram.asm"
INCLUDE "constants/pokemon_constants.asm" INCLUDE "constants/pokemon_constants.asm"
INCLUDE "constants/move_constants.asm" INCLUDE "constants/move_constants.asm"
INCLUDE "constants/battle_constants.asm" INCLUDE "constants/battle_constants.asm"

View File

@ -86589,7 +86589,7 @@ SECTION "bank6C",ROMX,BANK[$6C]
; Common text I ; Common text I
INCLUDE "text/common.tx" INCLUDE "text/common.asm"
; Map Scripts XXV ; Map Scripts XXV
@ -86599,10 +86599,10 @@ INCLUDE "maps/Route10North.asm"
SECTION "bank6D",ROMX,BANK[$6D] SECTION "bank6D",ROMX,BANK[$6D]
INCLUDE "text/phone/mom.tx" INCLUDE "text/phone/mom.asm"
INCLUDE "text/phone/bill.tx" INCLUDE "text/phone/bill.asm"
INCLUDE "text/phone/elm.tx" INCLUDE "text/phone/elm.asm"
INCLUDE "text/phone/trainers1.tx" INCLUDE "text/phone/trainers1.asm"
SECTION "bank6E",ROMX,BANK[$6E] SECTION "bank6E",ROMX,BANK[$6E]
@ -86617,21 +86617,21 @@ SECTION "bank6F",ROMX,BANK[$6F]
; Common text II ; Common text II
INCLUDE "text/common_2.tx" INCLUDE "text/common_2.asm"
SECTION "bank70",ROMX,BANK[$70] SECTION "bank70",ROMX,BANK[$70]
; Common text III ; Common text III
INCLUDE "text/common_3.tx" INCLUDE "text/common_3.asm"
SECTION "bank71",ROMX,BANK[$71] SECTION "bank71",ROMX,BANK[$71]
; Common text IV ; Common text IV
INCLUDE "text/common_4.tx" INCLUDE "text/common_4.asm"
SECTION "bank72",ROMX,BANK[$72] SECTION "bank72",ROMX,BANK[$72]

View File

@ -1,5 +1,3 @@
INCLUDE "wram.asm" INCLUDE "wram.asm"
INCLUDE "constants.asm" INCLUDE "constants.asm"
INCLUDE "gbhw.asm" INCLUDE "main.asm"
INCLUDE "hram.asm"
INCLUDE "main.tx"

29
scan_includes.py Normal file
View File

@ -0,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)))