
.SILENT:

all: docs/sam_cleanasm.s docs/sam_cish.c samtest.prg samtestnmi.prg samtest.exe 

docs/sam_cleanasm.s: sam.s sam_original.inc
	grep -v ';-' sam.s | grep -v ';:' > docs/sam_cleanasm.s

docs/sam_cish.c:	sam_original.inc sam.s
	echo "unsigned char X,Y,A;" > docs/sam_cish.c
	grep -e ";[:/]" sam_original.inc | sed -e 's/;://' | sed -e 's/;\/\//\/\//' >> docs/sam_cish.c
	grep -e ";[:/]" sam.s | sed -e 's/;://' | sed -e 's/;\/\//\/\//' >> docs/sam_cish.c

samtest.prg:	./test_asm/sam_test.s  sam.s
	cl65 --asm-include-dir . --asm-include-dir ./test_asm -t none -o samtest.prg ./test_asm/sam_test.s
test: samtest.prg
	x64 samtest.prg

samtestnmi.prg:	./test_asm/sam_testnmi.s  sam.s
	cl65 --asm-include-dir . --asm-include-dir ./test_asm -t none -o samtestnmi.prg ./test_asm/sam_testnmi.s
testnmi: samtestnmi.prg
	x64 samtestnmi.prg

samtest.exe:	./test_c/main.c docs/sam_cish.c
	gcc -w -I./docs/ -o samtest.exe ./test_c/main.c

.PHONY: clean zap

clean:
	@rm -f *~
	@rm -f *.o
	@rm -f *.prg
	@rm -f *.exe
	@rm -f test_asm/*~
	@rm -f test_asm/*.o
	@rm -f test_c/*~
	@rm -f test_c/*.o
	@rm -f docs/*~
	
zap: clean	
	@rm -f docs/sam_cish.c
	@rm -f docs/sam_cleanasm.s
