; GENTEST and CASTEST (for 2nd port on 88-2SIO as cassette)
;
;    Entry at address zero writes the letter"U" (055h) over and over with a
;    1.5 character idle period in between each character. Entry at 0100h 
;    reads the tape and writes whatever it reads to the console (assumed to
;    be a 2SIO port at I/O address 10h/11h).
;
;    Adjust the volume output on the cassette player 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 to use with tapes recorded on this cassette recorder.

; GENTEST at 0000h - write the test pattern

	org	0		;load and run from address zero

	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

; CASTEST at 0100h - read the test pattern and display on console

	org	0100h		;load and run at address 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	013h		;read the character
	out	011h		;echo it to console

	jmp	loop

	end
