aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: e03833179c650c2f6196c0c259906aa5f5ea2ce9 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
GBASM=gbasm
MAKESELF=makeself

all: run

.PHONY: clean sclean

tileset.gbasm: ./scripts/generate-tiledata.py $(wildcard ./sprites/**/* ./sprites/*)
	@echo "; THIS FILE IS GENERATED AUTOMATICALLY, DO NOT CHANGE" > $@
	python ./scripts/generate-tiledata.py >> $@

%.gbasm: ./%.gbtxt ./scripts/generate_from_gbtxt.py
	@echo "; THIS FILE IS GENERATED AUTOMATICALLY, DO NOT CHANGE" > $@
	python ./scripts/generate_from_gbtxt.py $< >> $@

%.map.gbasm: ./%.ldtk ./scripts/parse-ldtkmap.py
	@echo "; THIS FILE IS GENERATED AUTOMATICALLY, DO NOT CHANGE" > $@
	python ./scripts/parse-ldtkmap.py $< >> $@

map/maps.gbasm: $(subst .ldtk,.map.gbasm,$(wildcard ./map/maps/*.ldtk))
	@echo "; THIS FILE IS GENERATED AUTOMATICALLY, DO NOT CHANGE" > $@
	ls ./map/maps/*.map.gbasm | sed 's/^\.\///' | awk '{print ".INCLUDE \""$$0"\"" }' >> $@

build/main.rom: build/main.rom.unsigned
	cp build/main.rom.unsigned build/main.rom
	python scripts/set_checksums.py build/main.rom
	python scripts/round-rom-size.py build/main.rom

build/main.rom.unsigned: main.gbasm tileset.gbasm text.gbasm dialogues/text.gbasm map/maps.gbasm $(wildcard ./*.gbasm) $(wildcard ./**/*.gbasm) $(wildcard ./**/**/*.gbasm) $(wildcard ./music/*.vgm)
	mkdir -p build
	$(GBASM) $< $@ > build/main.sym

build/tileset-dump.rom: scripts/tileset-dump.gbasm tileset.gbasm tiles.gbasm
	mkdir -p build
	$(GBASM) $< $@ > /dev/null

build/tileset-dump.rom.vram.dump: build/tileset-dump.rom
	gb --skip-bootrom --stop-dump-state --headless -s 100 -v errors $<

build/tileset.png: build/tileset-dump.rom.vram.dump scripts/extract-vram-tileset.py tileset.gbasm tiles.gbasm
	python scripts/extract-vram-tileset.py $< $@

build/makeself/gb_linux-x86_64:
	mkdir -p build/makeself
	wget https://github.com/AstatinChan/gameboy-emulator/releases/download/latest/gb_linux-x86_64 -O $@
	chmod +x $@

build/makeself/main.rom: build/main.rom
	mkdir -p build/makeself
	cp $< $@

build/makeself/start.sh: ./scripts/makeself-start.sh
	mkdir -p build/makeself
	cp $< $@
	chmod +x $@

build/game_linux_x86-64: build/makeself/start.sh build/makeself/main.rom build/makeself/gb_linux-x86_64
	$(MAKESELF) ./build/makeself $@ "Astatin's Bunny Game" ./start.sh

run: build/main.rom
	mkdir -p recordings
	gb $< --record-input "./recordings/$(shell date -Iseconds).record" -v infos,errors,debug #,halt_cycles

sameboy: build/main.rom
	sameboy build/main.rom

gearboy: build/main.rom
	gearboy build/main.rom build/main.sym

clean:
	rm -rf build

sclean: clean
	rm tileset.gbasm
	find . -name "*.gbtxt" | sed 's/\.gbtxt$$/.gbasm/' | xargs rm
	rm map/maps/*.map.gbasm map/maps.gbasm