.PHONY: all
all: image.hex common.hex bubble.hex

image.hex: firmware.hex jam3d.hex
	cat firmware.hex jam3d.hex > imageraw.hex
	./expand.py 0x8000 < imageraw.hex > image.hex
	rm imageraw.hex

common.hex: firmware.hex common_code.hex
	cat firmware.hex common_code.hex > commonraw.hex
	./expand.py 0x8000 < commonraw.hex > common.hex
	rm commonraw.hex

bubble.hex: firmware.hex bubble_code.hex
	cat firmware.hex bubble_code.hex > bubbleraw.hex
	./expand.py 0x8000 < bubbleraw.hex > bubble.hex

firmware.hex: firmware.asm defs.inc
	../genasm/genasm.py firmware.asm firmware.hex 0x7000

jam3d.hex: jam3d.asm
	../../assembler/assembler.pl jam3d.asm
	./csv2hex.py < jam3d.csv > jam3d.hex
	rm -f jam3d.count

common_code.hex: common_code.csv
	./csv2hex.py < common_code.csv > common_code.hex

bubble_code.hex: bubble_code.csv
	./csv2hex.py < bubble_code.csv > bubble_code.hex

.PHONY: clean
clean:
	rm -f jam3d.hex firmware.hex image.hex common.hex common_code.hex bubble_code.hex bubble.hex *~
