-
Notifications
You must be signed in to change notification settings - Fork 2
/
makefile
149 lines (116 loc) · 3.66 KB
/
makefile
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/usr/bin/make -f
#
# Makefile for Libbet and the Magic Floor
# Copyright 2014-2020 Damian Yerrick
#
# Copying and distribution of this file, with or without
# modification, are permitted in any medium without royalty
# provided the copyright notice and this notice are preserved.
# This file is offered as-is, without any warranty.
#
# Used in the title of the zipfile and .gb executable
title:=libbet
version:=0.08
# Space-separated list of asm files without .z80 extension
# (use a backslash to continue on the next line)
objlist := header init localvars \
main floormodel \
rolling prevcombo \
instructions debrief achievements intro \
statusbar floorvram fade audio pitchtable \
ppuclear pads unpb16 rand bcd metasprite vwfdraw vwf7 \
popslide sgb
ifdef COMSPEC
ifndef GBEMU
GBEMU := start ""
endif
PY := py -3
else
ifndef GBEMU
# I now use a shell script in ~/.local/bin
GBEMU := bgb
endif
PY := python3
endif
# Support out-of-PATH RGBDS
RGBASM := $(RGBDS)rgbasm
RGBLINK := $(RGBDS)rgblink
RGBGFX := $(RGBDS)rgbgfx
RGBFIX := $(RGBDS)rgbfix
.SUFFIXES:
.PHONY: run all dist zip
run: $(title).gb
$(GBEMU) $<
all: $(title).gb
clean:
-rm obj/gb/*.z80 obj/gb/*.o obj/gb/*.2bpp obj/gb/*.pb16
-rm obj/gb/*.chr1
# Packaging
dist: zip
zip: $(title)-$(version).zip
# The zipfile depends on every file in zip.in, but as a shortcut,
# mention only files on which the ROM doesn't itself depend.
$(title)-$(version).zip: zip.in makefile $(title).gb \
README.md CHANGES.txt obj/gb/index.txt
$(PY) tools/zipup.py $< $(title)-$(version) -o $@
-advzip -z3 $@
# Build zip.in from the list of files in the Git tree
zip.in: makefile
git ls-files | grep -e "^[^.0]" | grep -v "^hopesup" > $@
echo 05-burndown/note_from_nocash.md >> $@
echo $(title).gb >> $@
echo zip.in >> $@
obj/gb/index.txt: makefile
echo "Files produced by build tools go here. (This file's existence forces the unzip tool to create this folder.)" > $@
# The ROM
objlisto = $(foreach o,$(objlist),obj/gb/$(o).o)
$(title).gb: $(objlisto)
$(RGBLINK) -p 0xFF -m$(title).map -n$(title).sym -o$@ $^
$(PY) tools/beforefix.py $@
$(RGBFIX) -jvsc -k "OK" -l 0x33 -m ROM -p 0xFF -t "LIBBET" -v $@
obj/gb/%.o: src/%.z80 src/hardware.inc src/global.inc
${RGBASM} -o $@ $<
obj/gb/%.o: obj/gb/%.z80
${RGBASM} -o $@ $<
# Files that will be included with incbin
obj/gb/intro.o: \
obj/gb/roll32-h.2bpp.pb16
obj/gb/floorvram.o: \
obj/gb/floorpieces-h.2bpp.pb16 \
obj/gb/floorborder-h.2bpp.pb16 obj/gb/floorborder-sgb-h.2bpp.pb16
obj/gb/statusbar.o: \
obj/gb/bigdigits-h.chr1
obj/gb/metasprite.o: \
obj/gb/Libbet.z80
obj/gb/main.o: \
obj/gb/Libbet.2bpp.pb16
obj/gb/sgb.o: \
obj/gb/sgbborder.border
# Local variable allocation
obj/gb/localvars.z80: tools/savescan.py $(sort $(wildcard src/*.z80))
$(PY) $^ -o $@
# Graphics conversion
# .2bpp (CHR data for Game Boy) denotes the 2-bit tile format
# used by Game Boy and Game Boy Color, as well as Super NES
# mode 0 (all planes), mode 1 (third plane), and modes 4 and 5
# (second plane).
obj/gb/%.2bpp: tilesets/%.png
${RGBGFX} -o $@ $<
obj/gb/%-h.2bpp: tilesets/%.png
${RGBGFX} -Z -o $@ $<
obj/gb/%-h.chr1: tilesets/%.png
${RGBGFX} -d1 -Z -o $@ $<
%.pb16: tools/pb16.py %
$(PY) $^ $@
obj/gb/vwf7.z80: tools/vwfbuild.py tilesets/vwf7_cp144p.png
$(PY) $^ $@
# One quirk of Make pre-4.3 that's annoying to work around is that
# recipes with multiple outputs may fall out of sync.
obj/gb/Libbet.2bpp: tools/extractcels.py tilesets/Libbet.ec tilesets/Libbet.png
$(PY) $^ $@ obj/gb/Libbet.z80
obj/gb/Libbet.z80: obj/gb/Libbet.2bpp
touch $@
obj/gb/pitchtable.z80: tools/pitchtable.py
$(PY) $< > $@
obj/gb/%.border: tools/makeborder.py tilesets/%.png
$(PY) $^ $@