; CASTEST (for 2nd port on 88-2SIO as cassette)
;
;    1) Run from address zero to write the letter "U" (55h) over and over with a
;       1.5 character idle period in between each character. Let it write to tape
;       for about 30 seconds to generate a test tape.
;
;    2) Run from address 100h to read the test tape and display the data on the
;       console (assumed to be an 88-2SIO port at I/O address 10h/11h). Adjust the
;       cassette volume upward until the "U" characters are displayed without error.
;       Give yourself some headroom and adjust the volume up another 25%-50% once
;       the "U"s start showing up. Mark this as the playback level for this tape
;       recorder.

; GENERATE test pattern: Run at 0000h

	org	0

	mvi	a,03h		;reset the cassette UART
	out	12h
	mvi	a,15h		;no RI, no XI, RTS Low, 8n1, /16
	out	12h

nxtChar	mvi	a,'U'		;send a "U" out the cassette port
	out	13h

; Delay 2.5 character times (at 300 baud) = 6917*12us = 83ms

	lxi	d,6917

delay	dcx	d		;5	
	mov	a,d		;5
	ora	e		;4
	jnz	delay		;10

	jmp	nxtChar


; READ test pattern: Run at 0100h

	org	0100h

	mvi	a,03h		;reset console UART
	out	10h
	mvi	a,15h		;no RI, no XI, RTS Low, 8n1, /16
	out	10h

loop	in	12h		;wait for character
	rrc
	jnc	loop		;nothing yet 

	in	13h		;read the character
	out	11h		;echo it to console
	jmp	loop

	end
