2014-09-26 06:10:36 +00:00
|
|
|
.POSIX:
|
2020-06-30 00:25:32 +00:00
|
|
|
.SUFFIXES:
|
2020-07-03 19:43:37 +00:00
|
|
|
.PRECIOUS: %.2bpp oam_%.2bpp
|
2023-12-08 19:39:27 +00:00
|
|
|
.PHONY: default build build-all test test-all all clean tidy
|
2014-09-26 06:10:36 +00:00
|
|
|
|
2024-08-01 00:38:36 +00:00
|
|
|
# Recursive `wildcard` function.
|
|
|
|
rwildcard = $(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
|
|
|
|
|
2020-06-25 19:51:58 +00:00
|
|
|
#
|
|
|
|
# Dev tools binaries and options
|
|
|
|
#
|
2022-10-12 22:35:40 +00:00
|
|
|
|
2023-12-06 17:39:06 +00:00
|
|
|
RGBDS :=
|
2022-10-12 22:37:12 +00:00
|
|
|
|
2023-12-06 17:39:06 +00:00
|
|
|
2BPP := $(RGBDS)rgbgfx
|
|
|
|
|
|
|
|
ASM := $(RGBDS)rgbasm
|
2023-12-08 04:13:52 +00:00
|
|
|
ASFLAGS := \
|
2024-07-26 05:10:34 +00:00
|
|
|
--export-all
|
2022-10-12 22:37:12 +00:00
|
|
|
|
2023-12-06 17:39:06 +00:00
|
|
|
LD := $(RGBDS)rgblink
|
2020-06-25 19:51:58 +00:00
|
|
|
LDFLAGS :=
|
|
|
|
|
2023-12-06 17:39:06 +00:00
|
|
|
FX := $(RGBDS)rgbfix
|
2020-06-25 19:51:58 +00:00
|
|
|
FXFLAGS := \
|
2020-06-21 13:43:44 +00:00
|
|
|
--color-compatible \
|
|
|
|
--sgb-compatible \
|
|
|
|
--ram-size 0x03 \
|
|
|
|
--old-licensee 0x33 \
|
|
|
|
--new-licensee "01" \
|
|
|
|
--mbc-type 0x1B \
|
|
|
|
--pad-value 0xFF \
|
|
|
|
--validate
|
2014-06-28 01:05:25 +00:00
|
|
|
|
2020-06-21 13:13:03 +00:00
|
|
|
# Default target: build and test only the US 1.0 revision.
|
2020-06-21 13:46:50 +00:00
|
|
|
# (Use `make all` to build and test all targets.)
|
2020-06-21 13:13:03 +00:00
|
|
|
default: build test
|
2014-06-28 01:05:25 +00:00
|
|
|
|
2020-06-29 23:04:13 +00:00
|
|
|
#
|
|
|
|
# Generic rules
|
|
|
|
#
|
|
|
|
|
2020-06-30 00:25:32 +00:00
|
|
|
# Dependencies for the base version (English 1.0)
|
2024-08-01 00:38:36 +00:00
|
|
|
asm_files := $(call rwildcard,src,*.asm)
|
2024-07-25 22:27:53 +00:00
|
|
|
# this is the only .inc file in the repo
|
|
|
|
asm_files += src/constants/hardware.inc
|
2024-08-01 00:38:36 +00:00
|
|
|
gfx_files := $(call rwildcard,src/gfx,*.png)
|
2024-07-25 22:27:53 +00:00
|
|
|
bin_files := $(wildcard src/data/backgrounds/*.tilemap.encoded)
|
|
|
|
bin_files += $(wildcard src/data/backgrounds/*.attrmap.encoded)
|
2020-06-30 00:25:32 +00:00
|
|
|
|
2020-07-03 19:43:37 +00:00
|
|
|
# Compile an PNG file for OAM memory to a 2BPP file
|
2020-08-31 09:10:07 +00:00
|
|
|
# (inverting the palette and de-interleaving the tiles).
|
2020-07-03 19:43:37 +00:00
|
|
|
oam_%.2bpp: oam_%.png
|
|
|
|
tools/gfx/gfx.py --invert --interleave --out $@ 2bpp $<
|
|
|
|
|
2020-08-31 09:10:07 +00:00
|
|
|
# Compile a PNG file to a 2BPP file, without any special conversion.
|
|
|
|
# (This typically uses `rgbgfx`, which is much faster than the
|
|
|
|
# Python-based `gfx.py`.)
|
2016-10-08 22:55:07 +00:00
|
|
|
%.2bpp: %.png
|
2018-03-27 13:15:31 +00:00
|
|
|
$(2BPP) -o $@ $<
|
2014-09-26 06:10:36 +00:00
|
|
|
|
2020-08-31 09:10:07 +00:00
|
|
|
# Compile all dependencies (ASM, 2BPP) into an single object file.
|
|
|
|
# (This means all the source code is always fully recompiled: for now,
|
|
|
|
# we don't compile the different ASM files separately.)
|
|
|
|
# Locale-specific rules below (e.g. `src/main.azlj.o`) will add their own
|
|
|
|
# pre-requisites to the ones defined by this rule.
|
2020-12-15 16:16:09 +00:00
|
|
|
src/main.%.o: src/main.asm $(asm_files) $(gfx_files:.png=.2bpp) $(bin_files)
|
2024-01-01 00:35:50 +00:00
|
|
|
$(ASM) $(ASFLAGS) $($*_ASFLAGS) -I src/ -o $@ $<
|
2020-06-30 00:25:32 +00:00
|
|
|
|
2020-08-31 14:13:22 +00:00
|
|
|
# Link object files into a GBC executable rom
|
2020-08-31 09:10:07 +00:00
|
|
|
# The arguments used are both the global options (e.g. `LDFLAGS`) and the
|
|
|
|
# locale-specific options (e.g. `azlg-r1_LDFLAGS`).
|
2020-06-29 23:04:13 +00:00
|
|
|
%.gbc: src/main.%.o
|
2020-06-30 00:51:26 +00:00
|
|
|
$(LD) $(LDFLAGS) $($*_LDFLAGS) -n $*.sym -o $@ $^
|
|
|
|
$(FX) $(FXFLAGS) $($*_FXFLAGS) $@
|
2014-06-28 01:05:25 +00:00
|
|
|
|
2020-06-30 00:13:40 +00:00
|
|
|
# Make may attempt to re-generate the Makefile; prevent this.
|
|
|
|
Makefile: ;
|
|
|
|
|
2020-06-01 17:41:37 +00:00
|
|
|
#
|
|
|
|
# Japanese
|
|
|
|
#
|
|
|
|
|
2024-08-01 00:38:36 +00:00
|
|
|
azlj_asm := $(call rwildcard,revisions/J0/src,*.asm)
|
|
|
|
azlj_gfx := $(call rwildcard,revisions/J0/src/gfx,*.png)
|
2024-07-25 22:27:53 +00:00
|
|
|
azlj_bin := $(wildcard revisions/J0/src/data/backgrounds/*.tilemap.encoded)
|
|
|
|
azlj_bin += $(wildcard revisions/J0/src/data/backgrounds/*.attrmap.encoded)
|
2020-06-29 23:15:45 +00:00
|
|
|
|
2020-06-01 17:41:37 +00:00
|
|
|
games += azlj.gbc
|
2020-12-15 16:16:09 +00:00
|
|
|
src/main.azlj.o: $(azlj_asm) $(azlj_gfx:.png=.2bpp) $(azlj_bin)
|
2024-01-01 00:35:50 +00:00
|
|
|
azlj_ASFLAGS = -DLANG=JP -DVERSION=0 -I revisions/J0/src/
|
2020-06-30 00:51:26 +00:00
|
|
|
azlj_FXFLAGS = --rom-version 0 --title "ZELDA"
|
2020-06-01 17:41:37 +00:00
|
|
|
|
|
|
|
games += azlj-r1.gbc
|
2020-12-15 16:16:09 +00:00
|
|
|
src/main.azlj-r1.o: $(azlj_asm) $(azlj_gfx:.png=.2bpp) $(azlj_bin)
|
2024-01-01 00:35:50 +00:00
|
|
|
azlj-r1_ASFLAGS = -DLANG=JP -DVERSION=1 -I revisions/J0/src/
|
2020-06-30 00:51:26 +00:00
|
|
|
azlj-r1_FXFLAGS = --rom-version 1 --title "ZELDA"
|
2020-06-29 23:04:13 +00:00
|
|
|
|
2020-06-01 17:41:37 +00:00
|
|
|
games += azlj-r2.gbc
|
2020-12-15 16:16:09 +00:00
|
|
|
src/main.azlj-r2.o: $(azlj_asm) $(azlj_gfx:.png=.2bpp) $(azlj_bin)
|
2024-01-01 00:35:50 +00:00
|
|
|
azlj-r2_ASFLAGS = -DLANG=JP -DVERSION=2 -I revisions/J0/src/
|
2020-06-30 00:51:26 +00:00
|
|
|
azlj-r2_FXFLAGS = --rom-version 2 --title "ZELDA" --game-id "AZLJ"
|
2020-06-01 17:41:37 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# German
|
|
|
|
#
|
|
|
|
|
2024-08-01 00:38:36 +00:00
|
|
|
azlg_asm := $(call rwildcard,revisions/G0/src,*.asm)
|
|
|
|
azlg_gfx := $(call rwildcard,revisions/G0/src/gfx,*.png)
|
2024-07-25 22:27:53 +00:00
|
|
|
azlg_bin := $(wildcard revisions/G0/src/data/backgrounds/*.tilemap.encoded)
|
|
|
|
azlg_bin += $(wildcard revisions/G0/src/data/backgrounds/*.attrmap.encoded)
|
2020-06-29 23:15:45 +00:00
|
|
|
|
2020-06-01 17:41:37 +00:00
|
|
|
games += azlg.gbc
|
2020-12-15 16:16:09 +00:00
|
|
|
src/main.azlg.o: $(azlg_asm) $(azlg_gfx:.png=.2bpp) $(azlg_bin)
|
2024-01-01 00:35:50 +00:00
|
|
|
azlg_ASFLAGS = -DLANG=DE -DVERSION=0 -I revisions/G0/src/
|
2020-06-30 00:51:26 +00:00
|
|
|
azlg_FXFLAGS = --rom-version 0 --non-japanese --title "ZELDA"
|
2020-06-01 17:41:37 +00:00
|
|
|
|
|
|
|
games += azlg-r1.gbc
|
2020-12-15 16:16:09 +00:00
|
|
|
src/main.azlg-r1.o: $(azlg_asm) $(azlg_gfx:.png=.2bpp) $(azlg_bin) azlj-r2.gbc
|
2024-01-01 00:35:50 +00:00
|
|
|
azlg-r1_ASFLAGS = -DLANG=DE -DVERSION=1 -I revisions/G0/src/
|
2020-06-30 00:51:26 +00:00
|
|
|
azlg-r1_LDFLAGS = -O azlj-r2.gbc
|
|
|
|
azlg-r1_FXFLAGS = --rom-version 1 --non-japanese --title "ZELDA" --game-id "AZLD"
|
2020-06-01 17:41:37 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# French
|
|
|
|
#
|
|
|
|
|
2024-08-01 00:38:36 +00:00
|
|
|
azlf_asm := $(call rwildcard,revisions/F0/src,*.asm)
|
|
|
|
azlf_gfx := $(call rwildcard,revisions/F0/src/gfx,*.png)
|
2024-07-25 22:27:53 +00:00
|
|
|
azlf_bin := $(wildcard revisions/F0/src/data/backgrounds/*.tilemap.encoded)
|
|
|
|
azlf_bin += $(wildcard revisions/F0/src/data/backgrounds/*.attrmap.encoded)
|
2020-06-29 23:15:45 +00:00
|
|
|
|
2020-06-01 17:41:37 +00:00
|
|
|
games += azlf.gbc
|
2020-12-15 16:16:09 +00:00
|
|
|
src/main.azlf.o: $(azlf_asm) $(azlf_gfx:.png=.2bpp) $(azlf_bin)
|
2024-01-01 00:35:50 +00:00
|
|
|
azlf_ASFLAGS = -DLANG=FR -DVERSION=0 -I revisions/F0/src/
|
2020-06-30 00:51:26 +00:00
|
|
|
azlf_FXFLAGS = --rom-version 0 --non-japanese --title "ZELDA"
|
2020-06-01 17:41:37 +00:00
|
|
|
|
|
|
|
games += azlf-r1.gbc
|
2020-12-15 16:16:09 +00:00
|
|
|
src/main.azlf-r1.o: $(azlf_asm) $(azlf_gfx:.png=.2bpp) $(azlf_bin) azlg-r1.gbc
|
2024-01-01 00:35:50 +00:00
|
|
|
azlf-r1_ASFLAGS = -DLANG=FR -DVERSION=1 -I revisions/F0/src/
|
2020-06-30 00:51:26 +00:00
|
|
|
azlf-r1_LDFLAGS = -O azlg-r1.gbc
|
|
|
|
azlf-r1_FXFLAGS = --rom-version 1 --non-japanese --title "ZELDA" --game-id "AZLF"
|
2020-06-01 17:41:37 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# English
|
|
|
|
#
|
|
|
|
|
|
|
|
games += azle.gbc
|
2020-06-30 00:25:32 +00:00
|
|
|
src/main.azle.o:
|
2020-06-30 00:51:26 +00:00
|
|
|
azle_ASFLAGS = -DLANG=EN -DVERSION=0
|
|
|
|
azle_FXFLAGS = --rom-version 0 --non-japanese --title "ZELDA"
|
2020-06-01 17:41:37 +00:00
|
|
|
|
|
|
|
games += azle-r1.gbc
|
2020-06-30 00:25:32 +00:00
|
|
|
src/main.azle-r1.o:
|
2020-06-30 00:51:26 +00:00
|
|
|
azle-r1_ASFLAGS = -DLANG=EN -DVERSION=1
|
|
|
|
azle-r1_FXFLAGS = --rom-version 1 --non-japanese --title "ZELDA"
|
2020-06-01 17:41:37 +00:00
|
|
|
|
|
|
|
games += azle-r2.gbc
|
2020-06-30 00:25:32 +00:00
|
|
|
src/main.azle-r2.o: azlf-r1.gbc
|
2020-06-30 00:51:26 +00:00
|
|
|
azle-r2_ASFLAGS = -DLANG=EN -DVERSION=2
|
|
|
|
azle-r2_LDFLAGS = -O azlf-r1.gbc
|
|
|
|
azle-r2_FXFLAGS = --rom-version 2 --non-japanese --title "ZELDA" --game-id "AZLE"
|
2020-06-01 17:41:37 +00:00
|
|
|
|
2020-06-21 13:13:03 +00:00
|
|
|
#
|
2020-06-29 23:04:13 +00:00
|
|
|
# Main targets
|
2020-06-21 13:13:03 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# By default, build the US 1.0 revision.
|
|
|
|
build: azle.gbc
|
|
|
|
|
|
|
|
# Build all revisions.
|
|
|
|
build-all: $(games)
|
|
|
|
|
|
|
|
# Test the default revision.
|
|
|
|
test: build
|
2020-06-29 22:34:24 +00:00
|
|
|
@tools/compare.sh ladx.md5 azle.gbc
|
2020-06-21 13:13:03 +00:00
|
|
|
|
|
|
|
# Test all revisions.
|
|
|
|
test-all: build-all
|
2020-06-29 22:34:24 +00:00
|
|
|
@tools/compare.sh ladx.md5 $(games)
|
2020-06-21 13:13:03 +00:00
|
|
|
|
|
|
|
all: build-all test-all
|
2020-06-21 13:11:06 +00:00
|
|
|
|
2023-12-08 19:39:27 +00:00
|
|
|
tidy:
|
2020-06-21 13:11:06 +00:00
|
|
|
rm -f $(games)
|
2020-06-29 23:49:22 +00:00
|
|
|
rm -f $(games:%.gbc=src/main.%.o)
|
2020-06-21 13:11:06 +00:00
|
|
|
rm -f $(games:.gbc=.map)
|
|
|
|
rm -f $(games:.gbc=.sym)
|
2023-12-08 19:39:27 +00:00
|
|
|
|
|
|
|
clean: tidy
|
2020-06-29 23:49:22 +00:00
|
|
|
rm -f $(gfx_files:.png=.2bpp)
|
|
|
|
rm -f $(azlj_gfx:.png=.2bpp)
|
|
|
|
rm -f $(azlg_gfx:.png=.2bpp)
|
|
|
|
rm -f $(azlf_gfx:.png=.2bpp)
|
2024-07-25 22:27:53 +00:00
|
|
|
|
|
|
|
### Debug Print ###
|
|
|
|
|
|
|
|
print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true
|