all : sample0.xex \
	sample1.xex sample2.xex sample3.xex sample4.xex sample5.xex sample6.xex \
	fruit.xex mapclock.xex sailboat.xex sunset.xex train404.xex \
	potato.xex selfie.xex kitty.xex meme.xex

# sample5.s from sample5.jpg

# reminder: $< is input
#           $@ is output

%.s : %.jpg dither-image.js gif.sh mp4.sh
	node dither-image.js $< $@

chickens.s : chickens.wav pack-wav.js
	node pack-wav.js $< $@

dubstep.wav.s : dubstep.wav pack-wav.js
	node pack-wav.js $< $@

dubstep.wav : Dubstep_Loop_by_WinnieTheMoog.ogg
	ffmpeg -i "Dubstep_Loop_by_WinnieTheMoog.ogg" \
	  -t 2.0 \
	  -acodec pcm_u8 \
	  -ac 1 \
	  -ar 15704 \
	  -y $@

never-gonna-give-you-up.wav.s : never-gonna-give-you-up.wav pack-wav.js
	node pack-wav.js $< $@

never-gonna-give-you-up.wav : never-gonna-give-you-up.mp4
	ffmpeg -i "never-gonna-give-you-up.mp4" \
	  -vn \
	  -t 2.0 \
	  -acodec pcm_u8 \
	  -ac 1 \
	  -ar 15704 \
	  -y $@

%.o : %.s
	ca65 -v -t atari -o $@ $<

%.xex : %.o dither4.o never-gonna-give-you-up.wav.o atari-asm-xex.cfg
	ld65 -v -C ./atari-asm-xex.cfg -o $@ dither4.o never-gonna-give-you-up.wav.o $<

clean :
	rm -f *.o
	rm -f *.s.png
	rm -f sample[0-9].s
	rm -f fruit.s mapclock.s sailboat.s sunset.s train404.s
	rm -f potato.s selfie.s kitty.s meme.s
	rm -f *.xex
	rm -f chickens.s
	rm -f chickens.o
	rm -f dubstep.wav
	rm -f dubstep.wav.[so]
	rm -f never-gonna-give-you-up.wav
	rm -f never-gonna-give-you-up.wav.[so]

.dummy: sample0.s sample1.s sample2.s sample3.s sample4.s sample5.s sample6.s chickens.s