AS      = /opt/vasm/vasmm68k_mot
ASFLAGS = -Ftos -quiet
TARGET  = CDLYBARS.PRG
SRC     = cdlybars.s

# Quarter-sine movement table (qsine.i), generated by genqsine.py.
# QN must equal NSIN in $(SRC) and stay a power of two; QTOP is the bar-top
# amplitude (CENTRE - top-most row = 88 - 10 = 78).
QSINE   = qsine.i
QN      = 32
QTOP    = 78

# Total file-size limit: 288 bytes (incl. the 32-byte header).  DEBUG +12.
LIMIT   = $(shell L=288; \
	grep -Eq '^DEBUG[[:space:]]+equ[[:space:]]+0*[1-9]' $(SRC) && L=`expr $$L + 12`; \
	echo $$L)

$(TARGET): $(SRC) $(QSINE)
	$(AS) $(ASFLAGS) -o $(TARGET) $(SRC)
	@python3 verify.py $(TARGET) $(LIMIT)

$(QSINE): genqsine.py Makefile
	python3 genqsine.py $(QN) $(QTOP) $(QSINE)

clean:
	rm -f $(TARGET) $(QSINE)

.PHONY: clean
