summaryrefslogtreecommitdiff
path: root/Makefile
blob: c7e15d827c20f7b95d482636429265a0e6aeb760 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
.PHONY: all compare clean

.SUFFIXES:
.SUFFIXES: .asm .o .gbc .png
.SECONDEXPANSION:

# Build Pokemon Pinball.
ROMS := pokepinball.gbc
OBJS := main.o wram.o

# If your default python is 3, you may want to change this to python27.
PYTHON := python
PRET := pokemon-reverse-engineering-tools/pokemontools

$(foreach obj, $(OBJS), \
	$(eval $(obj:.o=)_dep := $(shell $(PYTHON) $(PRET)/scan_includes.py $(obj:.o=.asm))) \
)

# Link objects together to build a rom.
all: $(ROMS) compare

# Assemble source files into objects.
# Use rgbasm -h to use halts without nops.
$(OBJS): $$*.asm $$($$*_dep)
	@$(PYTHON) $(PRET)/gfx.py 2bpp $(2bppq)
	@$(PYTHON) $(PRET)/gfx.py 1bpp $(1bppq)
	@$(PYTHON) $(PRET)/pcm.py pcm $(pcmq)
	rgbasm -h -o $@ $<

$(ROMS): $(OBJS)
	rgblink -n $(ROMS:.gbc=.sym) -m $(ROMS:.gbc=.map) -o $@ $^
	rgbfix -jsvc -k 01 -l 0x33 -m 0x1e -p 0 -r 02 -t "POKEPINBALL" -i VPHE $@

# The compare target is a shortcut to check that the build matches the original roms exactly.
# This is for contributors to make sure a change didn't affect the contents of the rom.
# More thorough comparison can be made by diffing the output of hexdump -C against both roms.
compare: $(ROMS) baserom.gbc
	cmp $^

# Remove files generated by the build process.
clean:
	rm -f $(ROMS) $(OBJS) $(ROMS:.gbc=.sym)
	find . \( -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pcm' \) -exec rm {} +

%.2bpp: %.png
	$(eval 2bppq += $<)
	@rm -f $@

%.1bpp: %.png
	$(eval 1bppq += $<)
	@rm -f $@

%.pcm: %.wav
	$(eval pcmq += $<)
	@rm -f $@