summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2020-11-04 00:06:44 -0600
committerdannye <33dannye@gmail.com>2020-11-04 00:06:44 -0600
commit5647ca687b92954dcf37a6ea6bfbc9a341c32de4 (patch)
treedde1937a1bfdb3a835f4155e1c2eb8f1aaf86f63 /Makefile
parent53fcd05aa24693093d8af1dc8ec4fedd3957decc (diff)
Sync with pokered
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile85
1 files changed, 60 insertions, 25 deletions
diff --git a/Makefile b/Makefile
index 27363d87..a5366069 100644
--- a/Makefile
+++ b/Makefile
@@ -3,12 +3,25 @@ pcm := $(PYTHON) tools/pokemontools/pcm.py pcm
rom := pokeyellow.gbc
-objs := audio.o main.o text.o wram.o
+rom_obj := \
+audio.o \
+home.o \
+main.o \
+maps.o \
+text.o \
+wram.o \
+gfx/pics.o \
+gfx/sprites.o \
+gfx/tilesets.o
### Build tools
-MD5 := md5sum -c
+ifeq (,$(shell which sha1sum))
+SHA1 := shasum
+else
+SHA1 := sha1sum
+endif
RGBDS ?=
RGBASM ?= $(RGBDS)rgbasm
@@ -28,53 +41,75 @@ RGBLINK ?= $(RGBDS)rgblink
all: $(rom)
yellow: $(rom)
-# For contributors to make sure a change didn't affect the contents of the rom.
-compare: $(rom)
- @$(MD5) roms.md5
-
-clean:
- rm -f $(rom) $(objs) $(rom:.gbc=.sym)
- find . \( -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' -o -iname '*.pcm' \) -exec rm {} +
- $(MAKE) clean -C tools/
+clean: tidy
+ find . \( -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' -o -iname '*.pcm' \) -delete
tidy:
- rm -f $(rom) $(objs) $(rom:.gbc=.sym)
+ rm -f $(rom) $(rom_obj) $(rom:.gbc=.map) $(rom:.gbc=.sym) rgbdscheck.o
$(MAKE) clean -C tools/
+compare: $(rom)
+ @$(SHA1) -c roms.sha1
+
tools:
$(MAKE) -C tools/
+RGBASMFLAGS = -h -L -Weverything
+# Create a sym/map for debug purposes if `make` run with `DEBUG=1`
+ifeq ($(DEBUG),1)
+RGBASMFLAGS += -E
+endif
+
+rgbdscheck.o: rgbdscheck.asm
+ $(RGBASM) -o $@ $<
+
+# The dep rules have to be explicit or else missing files won't be reported.
+# As a side effect, they're evaluated immediately instead of when the rule is invoked.
+# It doesn't look like $(shell) can be deferred so there might not be a better way.
+define DEP
+$1: $2 $$(shell tools/scan_includes $2) | rgbdscheck.o
+ $$(RGBASM) $$(RGBASMFLAGS) -o $$@ $$<
+endef
+
# Build tools when building the rom.
# This has to happen before the rules are processed, since that's when scan_includes is run.
-ifeq (,$(filter clean tools,$(MAKECMDGOALS)))
+ifeq (,$(filter clean tidy tools,$(MAKECMDGOALS)))
+
$(info $(shell $(MAKE) -C tools))
+
+# Dependencies for objects
+$(foreach obj, $(rom_obj), $(eval $(call DEP,$(obj),$(obj:.o=.asm))))
+
endif
%.asm: ;
-%.o: dep = $(shell tools/scan_includes $(@D)/$*.asm)
-$(objs): %.o: %.asm $$(dep)
- $(RGBASM) -h -o $@ $*.asm
-
opts = -cjsv -k 01 -l 0x33 -m 0x1b -p 0 -r 03 -t "POKEMON YELLOW"
-$(rom): $(objs)
- $(RGBLINK) -n pokeyellow.sym -l pokeyellow.link -o $@ $^
+$(rom): $(rom_obj) layout.link
+ $(RGBLINK) -m $(rom:.gbc=.map) -n $(rom:.gbc=.sym) -l layout.link -o $@ $(filter %.o,$^)
$(RGBFIX) $(opts) $@
- sort $(rom:.gbc=.sym) -o $(rom:.gbc=.sym)
### Misc file-specific graphics rules
-gfx/game_boy.2bpp: tools/gfx += --remove-duplicates
-gfx/theend.2bpp: tools/gfx += --interleave --png=$<
+gfx/battle/attack_anim_1.2bpp: tools/gfx += --trim-whitespace
+gfx/battle/attack_anim_2.2bpp: tools/gfx += --trim-whitespace
+
+gfx/credits/the_end.2bpp: tools/gfx += --interleave --png=$<
+
+gfx/slots/slots_1.2bpp: tools/gfx += --trim-whitespace
+
gfx/tilesets/%.2bpp: tools/gfx += --trim-whitespace
-gfx/pokemon_yellow.2bpp: tools/gfx += --trim-whitespace
+gfx/tilesets/reds_house.2bpp: tools/gfx += --preserve=0x48
+
+gfx/trade/game_boy.2bpp: tools/gfx += --remove-duplicates
+
+gfx/sgb/border.2bpp: tools/gfx += --trim-whitespace
gfx/surfing_pikachu_1c.2bpp: tools/gfx += --trim-whitespace
gfx/surfing_pikachu_3.2bpp: tools/gfx += --trim-whitespace
-gfx/surfing_pikachu_1.2bpp: tools/gfx += --trim-whitespace
### Catch-all graphics rules
@@ -87,11 +122,11 @@ gfx/surfing_pikachu_1.2bpp: tools/gfx += --trim-whitespace
tools/gfx $(tools/gfx) -o $@ $@)
%.1bpp: %.png
- $(RGBGFX) -d1 $(rgbgfx) -o $@ $<
+ $(RGBGFX) $(rgbgfx) -d1 -o $@ $<
$(if $(tools/gfx),\
tools/gfx $(tools/gfx) -d1 -o $@ $@)
-%.pic: %.2bpp
+%.pic: %.2bpp
tools/pkmncompress $< $@