
; Test Program to interact with the SUPER IO Board
; John Monahan San Ramon CA 94583.    11/13/2021
;==============================================================================
;
;==============================================================================
;
;	V1.0	6/13/2022			;Initial Code for V1.0 Board
;	V1.1	6/29/2022			;Initial Code for V0.3 Board
;
;

						;Equates for display on SD Systems Video Board (Used In CPM Debugging mode only)
SCROLL		EQU	01H			;Set scrool direction UP.
LF		EQU	0AH
CR		EQU	0DH
BS		EQU	08H			;Back space (required for sector display)
BELL		EQU	07H
FF		EQU	0CH
SPACE		EQU	20H
QUIT		EQU	11H			;Turns off any screen enhancements (flashing, underline etc).
NO$ENHANCEMENT	EQU	17H			;Turns off whatever is on
FAST		EQU	10H			;High speed scrool
TAB		EQU	09H			;TAB ACROSS (8 SPACES FOR SD-BOARD)
ESC		EQU	1BH
CLEAR		EQU	1CH			;SD Systems Video Board, Clear to EOL. (Use 80 spaces if EOL not available
						;on other video cards)
FALSE		EQU	0
TRUE		EQU	NOT FALSE

CPM		EQU	FALSE			;TRUE if output via CPM, FALSE if direct to hardware
DEBUG		EQU	FALSE



;       ------- S100 SERIAL PORTS ---------------
	
ACTL			EQU	089H		;CHANNEL A CONTROL (For RS232 Port) (#1 UART)	
ADTA			EQU	08BH		;CHANNEL A DATA (MODEM_DATA_PORT)
BCTL			EQU	088H		;CHANNEL B CONTROL PORT ASSIGNMENTS OF THE ZILOG (For Speech Synthesizer) (#2 UART)
BDTA			EQU	08AH		;CHANNEL B DATA (For Speech Synthesizer)

;ACTL			EQU	0A1H		;CHANNEL A CONTROL (For RS232 Port) ,serial board	
;ADTA			EQU	0A3H		;CHANNEL A DATA (MODEM_DATA_PORT)
;BCTL			EQU	0A0H		;CHANNEL B CONTROL PORT ASSIGNMENTS OF THE ZILOG (For Speech Synthesizer ,serial board)
;BDTA			EQU	0A2H		;CHANNEL B DATA (For Speech Synthesizer)


FX$SOUND$STATUS$PORT	EQU	09DH		;AdaFruit FX Sound card (#1 UART)
FX$SOUND$DATA$PORT	EQU	09FH		;AdaFruit FX Sound card  
DFP$SOUND$STATUS$PORT	EQU	09CH		;DFP Sound card          (#2 UART)
DFP$SOUND$DATA$PORT	EQU	09EH		;DFP Sound card  



WIFI$STATUS$PORT	EQU	8DH		;WiFi Status Port (#1 UART Port)
WIFI$DATA$PORT		EQU	8FH		;WiFi Data Port 
 
USB$STATUS$PORT		EQU	8CH		;USB Status Port (#2 UART port)
USB$DATA$PORT		EQU	8EH		;USB Data Port    


;       ------- 8255A PORTS ---------------	

PARALLEL$A		EQU	5CH		;8255A Port A  (U9)
PARALLEL$B		EQU	5DH		;8255A Port B
PARALLEL$C		EQU	5EH		;8255A Port C
PARALLEL$D		EQU	5FH		;8255A Port D (Control Port).

PARALLEL$E		EQU	3CH		;8255A Port A  (U13)
PARALLEL$F		EQU	3DH		;8255A Port B  (IOBYTE Switches)
PARALLEL$G		EQU	3EH		;8255A Port C
PARALLEL$H		EQU	3FH		;8255A Port D (Control Port).

WRITECFG8255		EQU	10000000b	;89H, Set all three 8255 ports to output mode
READCFG8255		EQU	10011011b	;9BH, Set  all three 8255 ports- to input mode
READ$WRITECFG8255	EQU	10001010b	;9AH, Set  A as output, B input, Bits 0-3 of C as output, bits 7-4 of C as input


		MACLIB	Z80				;For the Z80 DJNZ opcode



;--------------------------------------------------------------------------------------------

	ORG	100H			;<--- For CPM

START:	LXI	SP,STACK
        IF CPM
	LXI     D,SIGN$ON$CPM		;print a welcome message via CPM IO
        ELSE
 	LXI     D,SIGN$ON$Z80		;print a welcome message via Z80 monitor IO
        ENDIF	

	CALL	PSTRING
	
	CALL	INIT$Z8530		;<<< Setup the three Zilog Z8530's UARTS to their default values >>>
	
	MVI	A,WRITEcfg8255		;10000000b (Set all three 8255_SELECT_A ports to output mode)
	OUT	PARALLEL$D		;4BH	(8255A #1 Port D (Control Port).

	MVI	A,READ$WRITECFG8255	;10001010b (Set A output, B input, C bits 0-3 output, C bits 7-4 as input)
	OUT	PARALLEL$H		;4BH	(8255A #2 Port D (Control Port).
	
					;--------------- Actual start of menu commands ------------------------------
BEGIN:	CALL	ZCRLF
	JMP	MAINLOOP
	

ABORT:	
        IF CPM
	JMP	0H			;Reboot CPM	
        ELSE
 	JMP	0F000H			;Monitor
        ENDIF	


TBL$LIST:
	DW  ERROR			; "A"  
	DW  ERROR			; "B"  
	DW  ERROR			; "C"  
	DW  DFP$SOUND$TEST		; "D"  DFP Sound card test (Not currently working)
	DW  ERROR			; "E"  
	DW  ADAFRUIT$FX			; "F"  AdaFruit Sound card test
	DW  GET$PARALLEL		; "G"  Input 8255A Ports
	DW  SEND$PARALLEL		; "H"  Send data to 8255A ports
	DW  READ$IOBYTE			; "I"  Read IOBYTE switches
	DW  ERROR			; "J"  
	DW  ERROR			; "K"  
	DW  TEST$LEDS			; "L"  Test the LEDs for 8255(A);
	DW  ERROR			; "M"  
	DW  ERROR			; "N"  
	DW  ERROR			; "O"  
	DW  PRINTER$TEST		; "P"  Send a string to the printer
	DW  ERROR			; "Q"  
	DW  SERIAL$PORT$TEST		; "R"  Test RS232 port
	DW  TEST$SPEECH			; "S"  Test Speech synthesizer
	DW  USB$PORT$TEST		; "T"  Test the USB port adaptor
	DW  ERROR			; "U" 
	DW  ERROR			; "V"  
	DW  WIFI$TEST			; "W"  
	DW  ERROR			; "X" 
	DW  ERROR			; "Y" 
	DW  ERROR			; "Z"  

ERROR:	LXI     D, MSGERR		;CMD error msg
	CALL	PSTRING
	JMP	MAINLOOP
	
					;COMMAND BRANCH TABLE

;-------------------------- MAIN LOOP ------------------------------------------------------------

MAINLOOP:				;print main menu
	LXI	D,MENU$STRING$
	CALL	PSTRING


MAINLOOP1:
	LXI	D,Prompt		;Please Enter a CMD >
	CALL	PSTRING
	
	CALL	ZCI
	CPI	ESC			;Abort if ESC
	JZ	ABORT

	
	CALL	upper
	CPI	'A'			;Must be >= 'A" (Otherwise it jumps off table)
	JC	ERROR
	CPI	'Z'+1			;Must be <= 'Z'
	JNC	ERROR
	MOV	C,A
	CALL	ZCO
	
	CALL	ZCRLF
	
	SBI	'@'			;Adjust to 0,1AH
	
	LXI	H,TBL$LIST		;Get IDE Menu selection
	ADD	A			;X2
	ADD	L
	MOV	L,A
	MOV	A,M
	INX	H
	MOV	H,M
	MOV	L,A			;Jump to table pointer
	PCHL				;JMP (HL)


;------------------------------ USB PORT Test --------------------------------------------------
USB$PORT$TEST:
XXX:
;	MVI	C,33H			;Quick test
;	CALL	ZCO
;	CALL	USB$OUT			;Also send to S100 terminal
;	JMP	XXX
	
	
	LXI	D,TEST$USB$MSG1		;Test the USB Serial Port Adaptor. (P4)
	CALL	PSTRING
	
	LXI	D,TEST$USB$MSG2		;Please enter keyboard characters from THIS RS232 Terminal
	CALL	USB$STRING
	
USB$LOOP:
	CALL	ZCSTS			;Check Z80 Keyboard Char for ESC
	JZ	USB$LOOP0
	CALL	ZCI			;Get S100 keyboard chatracter
	CPI	ESC
	JNZ	USB$LOOP0
	LXI	D,DONE$USB$MSG
	CALL	USB$STRING
	JMP	MAINLOOP

USB$LOOP0:
	CALL	USB$IN			;Get character from Serial terminal
	CPI	ESC
	JNZ	USB$LOOP2
	LXI	D,DONE$USB$MSG
	CALL	USB$STRING
	JMP	MAINLOOP		;Abort if ESC
	
USB$LOOP2:	
	MOV	C,A
	CALL	ZCO			;Also send to S100 terminal
	CALL	USB$OUT			;Send character in [C] to RS232 Port
	JMP	USB$LOOP0



;-------------------------------------------------------------------------------------------

USB$OUT:				;From MASTER.Z80 monitor code
	XRA	A			;Will try 256 times, then timeout
USBXXX:	PUSH	PSW
	IN	USB$STATUS$PORT		;MODEM/SERIAL OUT
	ANI	04H			;Are we ready for a character
	JNZ	USB$SENDM		;NZ if ready to recieve character
	POP	PSW
	DCR	A
	JNZ	USBXXX
	RET
USB$SENDM:
	POP	PSW
	MOV	A,C
	OUT	USB$DATA$PORT		;Send it
	RET



				;From MASTER.Z80 monitor code
;	IN	USB$STATUS$PORT		;U10 B status port
;	ANI	01H
;	JZ	USB$IN
;	IN	USB$DATA$PORT
;	RET

;					Note I cannot get the AdaFruit or Sparkfun USB
;					adaptors to recognise a keyboard input without
;					;jumpering the CTS to RTS on the adaptor pins
;					;jumper P40 pin 2 to pin 6. (pin 2 must be ground)
USB$IN:		
	XRA	A			;Will try 256 times, then timeout
USB$INX:	
	PUSH	PSW	
	CALL	USB$STAT		;MODEN/SERIAL IN
	JNZ	USB$GETMOD
	POP	PSW
	DCR	A
	JNZ	USB$INX
	RET
USB$GETMOD:
	POP	PSW	
	IN	USB$DATA$PORT
	RET


USB$STAT:				;Get Serial Input port Status
	IN	USB$STATUS$PORT		;U12 B status port
	ANI	01H
	RZ				;Ret NZ if nothing
	XRA	A
	DCR	A
	RET				;Ret FF/NZ if something




;------------------------------ RS232 SERIAL PORT Test --------------------------------------------------

SERIAL$PORT$TEST:
	LXI	D,TEST$RS232$MSG1	;Please enter keyboard characters from the RS232 Terminal'
	CALL	PSTRING
	
	LXI	D,TEST$RS232$MSG2	;Please enter keyboard characters from THIS RS232 Terminal
	CALL	SERIAL$STRING
	
SERIAL$LOOP:
	CALL	ZCSTS	
	JZ	SERIAL$LOOP0
	CALL	ZCI			;Get S100 keyboard chatracter
	CPI	ESC
	JNZ	SERIAL$LOOP0
	LXI	D,DONE$SERIAL$MSG
	CALL	SERIAL$STRING
	JMP	MAINLOOP

SERIAL$LOOP0:
	CALL	SERIAL$IN		;Get character from Serial terminal
	CPI	ESC
	JNZ	SERIAL$LOOP2
	LXI	D,DONE$SERIAL$MSG
	CALL	SERIAL$STRING
	JMP	MAINLOOP		;Abort if ESC
	
SERIAL$LOOP2:	
	MOV	C,A
	CALL	SERIAL$OUT		;Send character in [C] to RS232 Port
	CALL	ZCO			;Also send to S100 terminal
	JMP	SERIAL$LOOP


;-------------------------------------------------------------------------------------------

SERIAL$OUT:				;From MASTER.Z80 monitor code
	XRA	A			;Will try 256 times, then timeout
MODXXX:	PUSH	PSW
	IN	ACTL			;MODEM/SERIAL OUT
	ANI	04H			;Are we ready for a character
	JNZ	SENDM			;NZ if ready to recieve character
	POP	PSW
	DCR	A
	JNZ	MODXXX
	RET
SENDM:	POP	PSW
	MOV	A,C
	OUT	ADTA			;Send it
	RET


SERIAL$IN:				;From MASTER.Z80 monitor code
	XRA	A			;Will try 256 times, then timeout
SERIAL$INX:	
	PUSH	PSW	
	CALL	SERIAL$STAT		;MODEN/SERIAL IN
	JNZ	GETMOD
	POP	PSW
	DCR	A
	JNZ	SERIAL$INX
	RET
GETMOD:	POP	PSW	
	IN	ADTA
	RET


SERIAL$STAT:				;Get Serial Input port Status
	IN	ACTL			;U7 A status port
	ANI	01H
	RZ				;Ret NZ if nothing
	XRA	A
	DCR	A
	RET				;Ret FF/NZ if something
	





;------------------------------ SPEECH TEST --------------------------------------------------------------	

TEST$SPEECH:
	LXI	D,TEST$SPEECH$MSG	;'Send test string to speaker$'
	CALL	PSTRING
	CALL	ZCI
	MVI	C,CR
	CALL	SPEAK$OUT
	CALL	SPEAK$OUT
	CALL	SPEAK$OUT
		
	LXI	H,SPEECH$STRING
	CALL	SPEAK$MSG
	CALL	ZCRLF
	JMP	MAINLOOP

					
SPEAK$MSG:				;THIS IS A ROUTINE TO SEND A STRING TO TALKER [HL] AT STRING (Up to $)
	MOV	A,M
	CPI	'$'
	JZ	SPEAK1
	MOV	C,A
	CALL	ZCO
	CALL	SPEAKOUT
	INX	H
	JMP	SPEAK$MSG
SPEAK1:	MVI	C,CR			;MUST END WITH A CR
	CALL	SPEAK$OUT
	RET


SPEAK$OUT:
	IN	BCTL			;Check Status
	ANI	04H
	JZ	SPEAK$OUT		;NZ if ready to recieve character
	MOV	A,C
	OUT	BDTA			;(Port 8AH), Send it
	RET

	

;------------------------------ READ IOBYTE SWITCHES --------------------------------------------------------------	

READ$IOBYTE:
	LXI	D,RD$IOBYTE$MSG		;I cmd, Read IOBYTE Port Switches$'
	CALL	PSTRING
	IN	PARALLEL$F		;Port 39H
	CALL	ZBITS
	CALL	ZCRLF
	JMP	MAINLOOP


;------------------------------ PRINTER TEST --------------------------------------------------------------	
	

PRINTER$TEST:					
	LXI	D,TEST$PRN$MSG		;P cmd, Send test string to printer$'
	CALL	PSTRING

	LXI	D,PRINTER$STRING
	CALL	PSTRING
	CALL	ZCRLF
	
	LXI	H,PRINTER$STRING
PRN$LOOP:
	MOV	A,M
	ORA	A
	JZ	FLUSH$PRINTER
	MOV	C,A
	CALL	LO			;Send character to printer
	INX	H			;Next character
	JMP	PRN$LOOP

FLUSH$PRINTER:
	CALL	FLUSH			;Send page/form feed when string is printed
	JMP	MAINLOOP


;------------------------------------- LED BAR TEST --------------------------------------------------

TEST$LEDS:	
	LXI	D,L$MENU$STRING		;L cmd, Will pulse the 8 LED's
	CALL	PSTRING
	
	MVI	A,0FEH
ROTATE1:
	OUT	PARALLEL$C		;8255 (A) Port C
	PUSH	PSW
	CALL	ZBITS
	CALL	ZCRLF
	CALL	ZCI
	CPI	ESC
	JZ	MAINLOOP
	POP	PSW
	RLC
	JMP	ROTATE1
	


;------------------------------------- FX Sound Board Test --------------------------------------------------

ADAFRUIT$FX:				;Initilise the Adafruit FX Sound Board

;LOOP$TEST:
;	MVI	C,33H
;	CALL	FX$CO
;	CALL	FX$CI
;	MOV	C,A
;	CALL	ZCO
;	JMP	LOOP$TEST
	
FX$MENU$LOOP:
	LXI	D,ADAFRUIT$FX$MENU
	CALL	PSTRING
	MVI	C,'>'
	CALL	ZCO			;Send a character
	
	CALL	ZCI
	CPI	ESC
	JZ	MAINLOOP
	CPI	'1'
	JZ	FX$GET$FILES
	CPI	'2'
	JZ	FX$PLAY$FILE
	CPI	'3'
	JZ	FX$PLAY$LOUDER
	CPI	'4'
	JZ	FX$PLAY$LOWER
	CPI	'5'
	JZ	FX$PAUSE
	CPI	'6'
	JZ	FX$RESUME
	CPI	'7'
	JZ	FX$STOP
	CPI	'8'
	JZ	GET$FILE$NAME

	LXI	D,BAD$CMD		;Invalid CMD option
	CALL	PSTRING
	JMP	FX$MENU$LOOP
	
	
;---------------------------------------------------

FX$GET$FILES:
	MVI	C,'1'
	CALL	ZCO
	CALL	ZCRLF
	
	MVI	C,'L'			;Get files 'L'
	CALL	FX$CO
	MVI	C,0DH
	CALL	FX$CO
	MVI	C,0AH
	CALL	FX$CO
	
FX$LOOP2:
	LXI	H,0 
	SHLD	STATUS$COUNT		;Status check 64K times else abort
FX$LOOP1:
	LHLD	STATUS$COUNT
	DCX	H
	SHLD	STATUS$COUNT
	MOV	A,L
	ORA	H
	JZ	FX$MENU$LOOP
	
	CALL	FX$STATUS
	JZ	FX$LOOP1
	CALL	FX$CI
	MOV	C,A
	CALL	ZCO
	JMP	FX$LOOP2
	
	
FX$PLAY$FILE:
	MVI	C,'2'
	CALL	ZCO
	
	CALL	ZCRLF
	
	LXI	D,ENTER$FILE$NO
	CALL	PSTRING
	CALL	GETHEX			;Note must be 2 characters
	STA	FX$FILE$NO

	CALL	ZCRLF
	MVI	C,'#'			;Get file '#'
	CALL	FX$CO
	
	LDA	FX$FILE$NO		;Two characters,  send high digit first
	RRC
	RRC
	RRC
	RRC
	ANI	0FH
	ADI	30H			;Convert to ASCII
	MOV	C,A
	CALL	FX$CO
	CALL	ZCO
	
	LDA	FX$FILE$NO		;Get low digit
	ANI	0FH
	ADI	30H			;Convert to ASCII
	MOV	C,A
	CALL	FX$CO
	CALL	ZCO
	
	MVI	C,0DH
	CALL	FX$CO
	MVI	C,0AH
	CALL	FX$CO
	
FX$FILE$NUMBER:
	LXI	H,8000H
	SHLD	STATUS$COUNT		;Status check 100 times, if nothing, we aee done return to menu
FX$FILE$NUMBER2:
	LHLD	STATUS$COUNT
	DCX	H
	SHLD	STATUS$COUNT
	MOV	A,L
	ORA	H
	JZ	FX$MENU$LOOP
	
	CALL	FX$STATUS
	JZ	FX$FILE$NUMBER2
	CALL	FX$CI
	MOV	C,A
	CALL	ZCO
	JMP	FX$FILE$NUMBER
	

FX$PLAY$LOUDER:
	MVI	C,'3'
	CALL	ZCO
	LXI	D,FX$UP$VOLUME
	CALL	PSTRING
	CALl	ZCRLF
	
	MVI	C,'+'			;Set vol up
	CALL	FX$CO
	MVI	C,0DH
	CALL	FX$CO
	MVI	C,0AH
	CALL	FX$CO
	
FX$LOUDER1:
	LXI	H,8000H
	SHLD	STATUS$COUNT		;Status check 100 times else abort
FX$LOUDER2:
	LHLD	STATUS$COUNT
	DCX	H
	SHLD	STATUS$COUNT
	MOV	A,L
	ORA	H
	JZ	FX$MENU$LOOP
	
	CALL	FX$STATUS
	JZ	FX$LOUDER2
	CALL	FX$CI
	MOV	C,A
	CALL	ZCO
	JMP	FX$LOUDER1



FX$PLAY$LOWER:
	MVI	C,'4'
	CALL	ZCO
	LXI	D,FX$DOWN$VOLUME
	CALL	PSTRING
	CALl	ZCRLF

	MVI	C,'-'			;Set vol downn
	CALL	FX$CO
	MVI	C,0DH
	CALL	FX$CO
	MVI	C,0AH
	CALL	FX$CO

FX$LOWER1:
	LXI	H,8000H
	SHLD	STATUS$COUNT		;Status check 100 times else abort
FX$LOWER2:
	LHLD	STATUS$COUNT
	DCX	H
	SHLD	STATUS$COUNT
	MOV	A,L
	ORA	H
	JZ	FX$MENU$LOOP
	
	CALL	FX$STATUS
	JZ	FX$LOWER2
	CALL	FX$CI
	MOV	C,A
	CALL	ZCO
	JMP	FX$LOWER1


FX$PAUSE:
	MVI	C,'5'
	CALL	ZCO
	LXI	D,FX$PAUSE$MSG
	CALL	PSTRING

	MVI	C,'='			;Pause signal
	CALL	FX$CO
	MVI	C,0DH
	CALL	FX$CO
	MVI	C,0AH
	CALL	FX$CO
	JZ	FX$MENU$LOOP


FX$RESUME:
	MVI	C,'6'
	CALL	ZCO
	LXI	D,FX$RESUME$MSG
	CALL	PSTRING

	MVI	C,'>'			;Resume signal
	CALL	FX$CO
	MVI	C,0DH
	CALL	FX$CO
	MVI	C,0AH
	CALL	FX$CO
	JZ	FX$MENU$LOOP

FX$STOP:
	MVI	C,'7'
	CALL	ZCO
	LXI	D,FX$STOP$MSG
	CALL	PSTRING

	MVI	C,'q'			;Stop playback
	CALL	FX$CO
	MVI	C,0DH
	CALL	FX$CO
	MVI	C,0AH
	CALL	FX$CO
	JZ	FX$MENU$LOOP


GET$FILE$NAME:				;Get a file
	MVI	C,'8'
	CALL	ZCO
	CALL	ZCRLF
	CALL	ZCRLF
	
	LXI	D,FX$ENTER$NAME
	CALL	PSTRING

	CALL	FILE$NAME		;Name in [HL]

	LXI	D,FX$GOT$NAME
	CALL	PSTRING
	LXI	D,FX$BUFFER
	CALL	PSTRING
	
	MVI	C,'P'			;Get File
	CALL	FX$CO
	MVI	B,12			;File name is XXXDXXXXX,XXX
	LXI	H,FX$BUFFER
MORE$NAME:
	CALL	DELAY$SHORT		;Seems to be needed.
	MOV	C,M
	INX	H
	CALL	FX$CO
	DJNZ	MORE$NAME

	MVI	C,0DH
	CALL	FX$CO
	MVI	C,0AH
	CALL	FX$CO
	
MORE$NAME2:
	LXI	H,0 
	SHLD	STATUS$COUNT		;Status check 100 times else abort
MORE$NAME3:
	LHLD	STATUS$COUNT
	DCX	H
	SHLD	STATUS$COUNT
	MOV	A,L
	ORA	H
	JZ	FX$MENU$LOOP
	
	CALL	FX$STATUS
	JZ	MORE$NAME3
	CALL	FX$CI
	MOV	C,A
	CALL	ZCO
	JMP	MORE$NAME2

;
;
;
;
FILE$NAME:				;Get a 11 character file name
	LXI	H,FX$BUFFER
	MVI	B,13
	MVI	A,20H			;Clear Spaces
MORE$NAME5:
	MOV	M,A
	INX	H
	DJNZ	MORE$NAME5

	LXI	H,FX$BUFFER
	MVI	B,9			;8 characters max
MORE$NAME6:
	CALL	ZCI
	CALL	UPPER			;Must be upper case
	MOV	C,A
	CPI	'.'
	JZ	EXT$NAME		;Get extension			
	CALL	ZCO
	MOV	M,A
	INX	H
	DJNZ	MORE$NAME6
EXT$NAME:
	CALL	ZCO	
	LXI	H,FX$BUFFER$EXT
	
	MVI	B,3			;3 characters max
MORE$NAME7:
	CALL	ZCI
	CALL	UPPER			;Must be upper case
	MOV	C,A
	CALL	ZCO
	MOV	M,A
	INX	H
	DJNZ	MORE$NAME7
	MVI	A,'$'
	MOV	M,A
	RET

;
;--------------------------------- FX Sound card Support Routines ------------------------------

FX$STATUS:
	IN	FX$SOUND$STATUS$PORT	
	ANI	01H
	RET				;Ret Z if nothing
	
FX$CI:	IN	FX$SOUND$STATUS$PORT	
	ANI	01H
	JZ	FX$CI
	IN 	FX$SOUND$DATA$PORT	;Get data from the FX Sound Port
	RET
	

FX$CO:	IN	FX$SOUND$STATUS$PORT	;Print Character, (in [C]), on USB Port
	ANI	00000010B		;Wait until ready
	JNZ	FX$CO	
	MOV	A,C
	OUT	FX$SOUND$DATA$PORT
	RET



DELAY$SHORT:
	PUSH	PSW
	PUSH	B
	MVI	A,40			;DELAY ~100 MS (DOES NOT SEEM TO BE CRITICAL)
DELAY3:	MVI	B,0
M11:	DCR	B
	JNZ	M11
	DCR     A
	JNZ     DELAY3
	POP	B
	POP	PSW
	RET


;------------------------------------- WIFI BOARD TEST ---------------------------------------

WIFI$TEST:				;Initilise the WiFi Board
WIFI$MENU$LOOP:
	LXI	D,WIFI$MENU
	CALL	PSTRING
	
	CALL	ZCI
	CPI	ESC
	JZ	MAINLOOP

	CPI	'1'
	JZ	ECHO$TEST$WIFI

	CPI	'2'
	JZ	AT$CMD$CWMODE$WIFI

	CPI	'3'
	JZ	AT$CMD$GMR$WIFI
					
	CPI	'4'
	JZ	AT$CMD$SET$WIFI

	CPI	'5'
	JZ	AT$CMD$NETWORK$WIFI	;Show networks
	
	CPI	'6'
	JZ	AT$CMD$IP$WIFI		;Show IP address

	LXI	D,BAD$CMD
	CALL	PSTRING
	JMP	WIFI$MENU$LOOP
	
	
;---------------------------------------------------

ECHO$TEST$WIFI:	
	LXI	D,ECHO$WIFI$MSG		;Menu #1, Echo test of serial port without WIFI card.$'
	CALL	PSTRING
	CALL	ZCRLF

	MVI	C,'>'
	CALL	ZCO

WIFI$LOOP:
	CALL	ZCSTS			;Anything at keyboard
	JZ	WIFI$LOOP1		;No, go back and try WIFI port
	CALL	ZCI
	CPI	ESC
	JZ	WIFI$MENU$LOOP
	MOV	C,A
	CALL	WIFI$CO			;Send character in [C]
	JMP	WIFI$LOOP
	
WIFI$LOOP1:
	CALL	WIFI$CSTS		;Anything at WIFI Port
	JZ	WIFI$LOOP		;No, try console
	CALL	WIFI$CI			;Yes, get the character
	MOV	C,A
	CALL	ZCO			;Show the recieved character
	JMP	WIFI$LOOP		;Go back and try Console port


;---------------------------------------------------

AT$CMD$CWMODE$WIFI:			;Menu #2
	CALL	ZCRLF
	LXI	D,OK$WIFI$MSG0		;'Will send AT+CWMODE=?'
	CALL	PSTRING

	LXI	H,AT$WIFI$MSG2		;AT+CWMODE=?
AT$WIFI2:	
	MOV	A,M
	CPI	'$'
	JZ	WIFI$RD$LOOP
	CALL	SEND$WIFI
	INX	H
	JMP	AT$WIFI2

;---------------------------------------------------

AT$CMD$GMR$WIFI:
	CALL	ZCRLF			;Menu #3
	LXI	D,OK$WIFI$MSG1		;'Will send AT+GMR'
	CALL	PSTRING

	LXI	H,AT$WIFI$MSG3		;AT+GMR
AT$WIFI3:	
	MOV	A,M
	CPI	'$'
	JZ	WIFI$RD$LOOP
	CALL	SEND$WIFI
	INX	H
	JMP	AT$WIFI3


;---------------------------------------------------
;
AT$CMD$SET$WIFI:
	CALL	ZCRLF			;Menu #4
	LXI	D,OK$WIFI$MSG2		;'Will send AT+CWMODE=1'
	CALL	PSTRING

	LXI	H,AT$WIFI$MSG4		;AT+CWMODE=1
AT$WIFI4:	
	MOV	A,M
	CPI	'$'
	JZ	WIFI$RD$LOOP
	CALL	SEND$WIFI
	INX	H
	JMP	AT$WIFI4


;---------------------------------------------------
;
AT$CMD$NETWORK$WIFI:
	CALL	ZCRLF			;Menu #5
	LXI	D,OK$WIFI$MSG3		;'Will send AT+CWLAP'
	CALL	PSTRING

	LXI	H,AT$WIFI$MSG5		;AT+CWLAP
AT$WIFI5:	
	MOV	A,M
	CPI	'$'
	JZ	WIFI$RD$LOOP
	CALL	SEND$WIFI
	INX	H
	JMP	AT$WIFI5


;---------------------------------------------------
;

AT$CMD$IP$WIFI:
	CALL	ZCRLF			;Menu #6
	LXI	D,OK$WIFI$MSG4		;'Will send AT+CIFSR'
	CALL	PSTRING

	LXI	H,AT$WIFI$MSG5		;AT+CIFSR
AT$WIFI6:	
	MOV	A,M
	CPI	'$'
	JZ	WIFI$RD$LOOP
	CALL	SEND$WIFI
	INX	H
	JMP	AT$WIFI6


;----------------------------------------------------

SEND$WIFI:
	MOV	C,A
	CALL	WIFI$CO
	CALL	WIFI$CI
	MOV	C,A
	CALL	ZCO
	RET

WIFI$RD$LOOP:
	CALL	ZCSTS			;Anything at keyboard
	JNZ	WIFI$LOOP2		;No, go back and try WIFI port
	CALL	WIFI$CSTS		;Anything returned
	JZ	WIFI$RD$LOOP
	CALL	WIFI$CI			;Get character
	MOV	C,A
	CALL	ZCO
	JMP	WIFI$RD$LOOP
	
WIFI$LOOP2:	
	CALL	ZCI
	CPI	ESC
	JNZ	WIFI$RD$LOOP
	JMP	WIFI$MENU$LOOP
	
	
;-------------------------------------------
;   WIFI SERIAL PORT STATUS ROUTINE
;----------------------------------------------------
	
WIFI$CSTS:
	IN	WIFI$STATUS$PORT	
	ANI	01H
	RET				;Ret Z if nothing										

;----------------------------------------------------
;   WIFI SERIAL PORT GET CHARACTER ROUTINE
;----------------------------------------------------

WIFI$CI:	
	IN 	WIFI$STATUS$PORT	;Get a character from the Serial Port
	ANI	01H
	JZ	WIFI$CI			;Wait until something is there
	IN	WIFI$DATA$PORT
	RET


;----------------------------------------------------
;  WIFI PORT SEND CHARACTER ROUTINE
;----------------------------------------------------

WIFI$CO:
	IN	WIFI$STATUS$PORT	;Print Character, (in [C]), on Serial Port
	ANI	00000010B		;Wait until ready
	JNZ	WIFI$CO	
	MOV	A,C				
	OUT	WIFI$DATA$PORT
	RET


;------------------------------------- DFP SOUND TEST ---------------------------------------

DFP$SOUND$TEST:				;Initilise the DFP Sound Board
DFP$LOOP$TEST:
;	IN	PARALLEL$F
;	MOV	C,A
;	CALL	DFP$CO
;	CALL	DFP$CI
;	MOV	A,C
;	CALL	HEXOUT
;	JMP	MAINLOOP
;	JMP	DFP$LOOP$TEST

DFP$MENU$LOOP:
	LXI	D,DFP$SOUND$MENU
	CALL	PSTRING
	MVI	C,'>'
	CALL	ZCO			;Send a character
	
	CALL	ZCI
	CPI	ESC
	JZ	MAINLOOP
	MOV	C,A
	CALL	ZCO

	CPI	'0'
	JZ	DFP$PLAY$FILE

	CPI	'1'
	JZ	DFP$SET$VOLUME

	CPI	'2'
	JZ	DFP$REPEAT$PLAY

	CPI	'3'
	JZ	DFP$PAUSE

	CPI	'4'
	JZ	DFP$PLAY

	CPI	'5'
	JZ	DFP$ALL

	CPI	'6'
	JZ	DFP$RESET

	CPI	'7'
	JZ	DFP$BYTE$OUT

	CPI	'8'
	JZ	DFP$QUERY		;This routine is not working correctly
					;returning wrong values
	LXI	D,BAD$CMD
	CALL	PSTRING
	JMP	DFP$MENU$LOOP
	
	
;---------------------------------------------------
		
DFP$PLAY$FILE:				;<<<<<<<< Play a file >>>>>>>>>>
	LXI	D,ENTER$FILE$NO
	CALL	PSTRING
	CALL	GETHEX			;Note must be 2 characters
	STA	DFP$VARIABLE		;Add to CMD paramater
	STA	DFP$CURRENT$TRACK	;Store Current track number (for repeat command below)
	LXI	D,SENDING$CMD
	CALL	PSTRING
	
	LXI	H,FILE$NUMBER$CMD
	CALL	SEND$CMD
	CALL	ZCRLF
	CALL	ZCRLF
	JZ	DFP$MENU$LOOP

	
DFP$SET$VOLUME:				;<<<<<<<< Set Volume >>>>>>>>
	LXI	D,DFP$ENTER$VOLUME
	CALL	PSTRING
	CALL	GETHEX			;Note must be 2 characters
	STA	DFP$VARIABLE		;Add to CMD paramater
	LXI	D,SENDING$CMD
	CALL	PSTRING
					
	LXI	H,DFP$VOLUME$CMD
	CALL	SEND$CMD
	CALL	ZCRLF
	CALL	ZCRLF
	JZ	DFP$MENU$LOOP


DFP$REPEAT$PLAY:			;<<<<<<<< Repeat Play current tarck >>>>>>>>
	LXI	D,DFP$REPEAT$MSG
	CALL	PSTRING
	XRA	A
	STA	DFP$VARIABLE		;No paramater needed
	LXI	D,SENDING$CMD
	CALL	PSTRING
					
	LDA	DFP$CURRENT$TRACK	;Get Current #
	STA	DFP$VARIABLE		;Set current #
	LXI	H,DFP$REPEAT$CMD
	CALL	SEND$CMD
	CALL	ZCRLF
	CALL	ZCRLF
	JZ	DFP$MENU$LOOP


DFP$PAUSE:				;<<<<<<<< Pause Play current tarck >>>>>>>>
	LXI	D,DFP$PAUSE$MSG
	CALL	PSTRING
	XRA	A
	STA	DFP$VARIABLE		;No paramater needed
	LXI	D,SENDING$CMD
	CALL	PSTRING
					
	LXI	H,DFP$PAUSE$CMD
	CALL	SEND$CMD
	CALL	ZCRLF
	CALL	ZCRLF
	JZ	DFP$MENU$LOOP


DFP$PLAY:				;<<<<<<<< Play current tarck >>>>>>>>
	LXI	D,DFP$PLAY$MSG
	CALL	PSTRING
	XRA	A
	STA	DFP$VARIABLE		;No paramater needed
	LXI	D,SENDING$CMD
	CALL	PSTRING
					
	LXI	H,DFP$PLAY$CMD
	CALL	SEND$CMD
	CALL	ZCRLF
	CALL	ZCRLF
	JZ	DFP$MENU$LOOP


DFP$ALL:				;<<<<<<<< Repeat play all tracks >>>>>>>>
	LXI	D,DFP$PLAY$ALL$MSG
	CALL	PSTRING
	MVI	A,01
	STA	DFP$VARIABLE		;No paramater needed
	LXI	D,SENDING$CMD
	CALL	PSTRING
					
	LXI	H,DFP$ALL$PLAY$CMD
	CALL	SEND$CMD
	CALL	ZCRLF
	CALL	ZCRLF
	JZ	DFP$MENU$LOOP



DFP$RESET:				;<<<<<<<< Reset Player >>>>>>>>
	LXI	D,DFP$RESET$MSG
	CALL	PSTRING
	XRA	A
	STA	DFP$VARIABLE		;No paramater needed
	LXI	D,SENDING$CMD
	CALL	PSTRING
					
	LXI	H,DFP$RESET$CMD
	CALL	SEND$CMD
	CALL	ZCRLF
	CALL	ZCRLF
	JZ	DFP$MENU$LOOP


DFP$QUERY:				;<<<<<<<< Query the Player with CMD 42 >>>>>>>>
	LXI	D,DFP$QUERY$MSG
	CALL	PSTRING

	MVI	A,0FEH
	STA	DFP$VARIABLE$HIGH	;Two paramaters needed, HIGH
	MVI	A,0BCH
	STA	DFP$VARIABLE		;LOW, paramater needed
	
	LXI	D,SENDING$CMD
	CALL	PSTRING
					
	LXI	H,DFP$QUERY$VOL$CMD
	CALL	SEND$QUERY$CMD
	
	LXI	D,GOT$BACK
	CALL	PSTRING
	
	MVI	B,10
MORE$QUERY:
	CALL	DFP$CI
	CALL	HEXOUT
	DJNZ	MORE$QUERY
	
	CALL	ZCRLF
	CALL	ZCRLF
	JZ	DFP$MENU$LOOP


DFP$BYTE$OUT:				;;<<<<<<<< Send a Byte (nibble) to port 2AH  >>>>>>>>
	LXI	D,DFP$BYTE$VALUE	;Please enter a value to send to port 2AH (XX+CR):$'
	CALL	PSTRING

	CALL	GETHEX			;Note up to characters
	OUT	DFP$SOUND$STATUS$PORT	;Send nibble
	CALL	ZCRLF
	CALL	ZCRLF
	JMP	DFP$MENU$LOOP
	
	
	
	
;--------------------------------- DFP Sound card Support Routines ------------------------------

SEND$CMD				;Send a command
	MOV	C,M			;1. Send 7E FF 06 03 00 00 XX EF
	CALL	DFP$CO
	CALL	HEXOUT
	CALL	DELAY$SHORT

	INX	H
	MOV	C,M			;2. FF (Version Number)
	CALL	DFP$CO
	CALL	HEXOUT
	CALL	DELAY$SHORT

	INX	H
	MOV	C,M			;3. 06 Length
	CALL	DFP$CO
	CALL	HEXOUT
	CALL	DELAY$SHORT

	INX	H
	MOV	C,M			;4. XX CMD
	CALL	DFP$CO
	CALL	HEXOUT
	CALL	DELAY$SHORT

	INX	H
	MOV	C,M			;5. 00  No feedback required
	CALL	DFP$CO
	CALL	HEXOUT
	CALL	DELAY$SHORT

	INX	H
	MOV	C,M
	CALL	DFP$CO
	CALL	HEXOUT
	CALL	DELAY$SHORT

	LDA	DFP$VARIABLE		;7. Get veriable (paramater low)
	MOV	C,A
	CALL	DFP$CO
	CALL	HEXOUT
	CALL	DELAY$SHORT

	MVI	C,0EFH			;8. EF (Terminator)
	CALL	DFP$CO
	CALL	HEXOUT
	CALL	DELAY$SHORT
	RET
	

SEND$QUERY$CMD				;Send a query command 
	MOV	C,M			;1. Send 7E FF 06 03 00 XX XX EF
	CALL	DFP$CO
	CALL	HEXOUT
	CALL	DELAY$SHORT

	INX	H
	MOV	C,M			;2. FF (Version Number)
	CALL	DFP$CO
	CALL	HEXOUT
	CALL	DELAY$SHORT

	INX	H
	MOV	C,M			;3. 06 Length
	CALL	DFP$CO
	CALL	HEXOUT
	CALL	DELAY$SHORT

	INX	H
	MOV	C,M			;4. XX CMD
	CALL	DFP$CO
	CALL	HEXOUT
	CALL	DELAY$SHORT

	INX	H
	MOV	C,M			;5. 00  No feedback required
	CALL	DFP$CO
	CALL	HEXOUT
	CALL	DELAY$SHORT
	
	MVI	C,0			;6.  always 00
	CALL	DFP$CO
	CALL	HEXOUT
	CALL	DELAY$SHORT

	MVI	C,0			;7. always 00
	CALL	DFP$CO
	CALL	HEXOUT
	CALL	DELAY$SHORT

	LDA	DFP$VARIABLE$HIGH 
	MOV	C,A
	CALL	DFP$CO
	CALL	HEXOUT
	CALL	DELAY$SHORT

	LDA	DFP$VARIABLE
	MOV	C,A
	CALL	DFP$CO
	CALL	HEXOUT
	CALL	DELAY$SHORT

	MVI	C,0EFH			;8. EF (Terminator)
	CALL	DFP$CO
	CALL	HEXOUT
	CALL	DELAY$SHORT
	RET
	

DFP$STATUS:				;Get USB Input port Status
	IN	DFP$SOUND$STATUS$PORT	
	ANI	01H
	RET				;Ret Z if nothing
	
DFP$CI:	IN	DFP$SOUND$STATUS$PORT	
	ANI	01H
	JZ	DFP$CI
	IN 	DFP$SOUND$DATA$PORT	;Get data from the DFP Sound Port
	RET
	

DFP$CO:	IN	DFP$SOUND$STATUS$PORT	;Print Character, (in [C]), on USB Port
	ANI	00000010B		;Wait until ready
	JNZ	DFP$CO	
	MOV	A,C
	OUT	DFP$SOUND$DATA$PORT
	RET


;------------------------------------- SEND 8255A PORT DATA ---------------------------------------
	
SEND$PARALLEL:				; "H"  Send data to 8255A ports
	LXI	D,P$SEND$MSG
	CALL	PSTRING
	
	MVI	A,WRITECFG8255
	OUT	PARALLEL$D

	LXI	D,P$SENDA$MSG		;Enter 8255A Port A (XXH):$'
	CALL	PSTRING
	CALL	GETHEX
	STA	PORT$A$STORE		;Store it in RAM
	OUT	PARALLEL$A

	LXI	D,P$SENDB$MSG		;Enter 8255A Port B (XXH):$'
	CALL	PSTRING
	CALL	GETHEX
	STA	PORT$B$STORE		;Store it in RAM
	OUT	PARALLEL$B

	LXI	D,P$SENDC$MSG		;Enter 8255A Port C (XXH):$'
	CALL	PSTRING
	CALL	GETHEX
	STA	PORT$C$STORE		;Store it in RAM
	OUT	PARALLEL$C

	LXI	D,OUT$RESULT$MSG	;'8255A Ports    A           B              C$'
	CALL	PSTRING

	LXI	D,OUT$RESULT1$MSG	;CR,LF,'             $'
	CALL	PSTRING
	LDA	PORT$A$STORE
	CALL	ZBITS

	LXI	D,OUT$RESULT2$MSG	;'          $'
	CALL	PSTRING
	LDA	PORT$B$STORE
	CALL	ZBITS
	
	LXI	D,OUT$RESULT3$MSG	;'          $'
	CALL	PSTRING
	LDA	PORT$C$STORE
	CALL	ZBITS
	CALL	ZCRLF
	CALl	ZCRLF
	JMP	MAINLOOP		;Done



;------------------------------------- GET 8255A PORT DATA ---------------------------------------

GET$PARALLEL:				; "G"  Input 8255A Ports
	LXI	D,P$GET$MSG
	CALL	PSTRING

	MVI	A,READCFG8255
	OUT	PARALLEL$D

	IN	PARALLEL$A
	STA	PORT$A$STORE		;Store it in RAM
	IN	PARALLEL$B
	STA	PORT$B$STORE		;Store it in RAM
	IN	PARALLEL$C
	STA	PORT$C$STORE		;Store it in RAM

	LXI	D,OUT$RESULT$MSG	;'8255A Ports    A           B              C$'
	CALL	PSTRING

	LXI	D,OUT$RESULT1$MSG	;CR,LF,'             $'
	CALL	PSTRING
	LDA	PORT$A$STORE
	CALL	ZBITS

	LXI	D,OUT$RESULT2$MSG	;'          $'
	CALL	PSTRING
	LDA	PORT$B$STORE
	CALL	ZBITS
	
	LXI	D,OUT$RESULT3$MSG	;'          $'
	CALL	PSTRING
	LDA	PORT$C$STORE
	CALL	ZBITS
	
	CALL	ZCRLF
	CALl	ZCRLF
	JMP	MAINLOOP		;Done





;---------------------------------------- SUBROUTINES ---------------------------------------------------

ZCRLF:
	PUSH	PSW
	PUSH	B
	MVI	C,CR
	CALL	ZCO
	MVI	C,LF
	CALL	ZCO
	POP	B
	POP	PSW
	RET

ZEOL:				;CR and clear current line
	MVI	C,CR
	CALL	ZCO
	MVI	C,CLEAR		;Note hardware dependent, (Use 80 spaces if necessary)
	CALL	ZCO
	RET


;	Print a string in [DE] up to '$'

PSTRING:
 IF CPM
	MVI	C,PRINT
	JMP	BDOS		;PRINT MESSAGE, 
 ELSE
	PUSH	B
	PUSH	D
	PUSH	H
	XCHG
PSTRX:	MOV	A,M
	CPI	'$'
	JZ	DONEP
	MOV	C,A
	CALL	ZCO
	INX	H
	JMP	PSTRX
DONEP:	POP	H
	POP	D
	POP	B
	RET
  ENDIF



;	Print a string in [DE] up to '$' on USB Port

USB$STRING:
	PUSH	B
	PUSH	D
USB$PSTRX:
	LDAX	D
	CPI	'$'
	JZ	DONE$USB
	MOV	C,A
	CALL	USB$out			;Send character in [C]
	INX	D
	JMP	USB$PSTRX
DONE$USB:
	POP	D
	POP	B
	RET


;	Print a string in [DE] up to '$' on RS232 Serial Port

SERIAL$STRING:
	PUSH	B
	PUSH	D
SERIAL$PSTRX:
	LDAX	D
	CPI	'$'
	JZ	DONE$SERIAL
	MOV	C,A
	CALL	SERIAL$OUT		;Send character in [C]
;	CALL	ZCO
	INX	D
	JMP	SERIAL$PSTRX
DONE$SERIAL:
	POP	D
	POP	B
	RET


;------------------------------------------------------------------
; Print a 16 bit number in RAM located @ [HL] 
; (Note Special Low Byte First. Used only for Drive ID)

printparm:
	INX	H		;Index to high byte first
	MOV	a,M
	CALL	HEXOUT
	DCX	H		;Now low byte
	MOV	a,M
	CALL	HEXOUT
	RET

HHEXOUT:				;No registers altered
	CALL	HEXOUT
	PUSH	PSW
	PUSH	B
	MVI	C,'H'
	CALL	ZCO
	POP	B
	POP	PSW
	RET
	
; Print an 8 bit number, located in [A]
HEXOUT:	PUSH	PSW			;No registers altered
	PUSH	B
	PUSH	PSW
	RRC
	RRC
	RRC
	RRC
	CALL	ZCONV
	POP	PSW
	CALL	ZCONV
	POP	B
	POP	PSW
	RET

ZCONV:	ANI	0FH		;HEX to ASCII and print it
	ADI	90H
	DAA
	ACI	40H
	DAA
	MOV	C,A
	CALL	ZCO
	RET

;DISPLAY BIT PATTERN IN [A]
ZBITS:	PUSH	PSW
	PUSH	B
	PUSH	D
	MOV	E,A		
	MVI	B,8
BBBQ2:	
	DB	0CBH,23H	;Z80 Op code for SLA A,E
	MVI	A,18H
	ADC	A
	MOV	C,A
	CALL	ZCO
	DJNZ	BBBQ2
	POP	D
	POP	B
	POP	PSW
	RET

GETCMD:	CALL	ZCI		;GET A CHARACTER, convert to UC, ECHO it
	CPI	ESC
	RZ			;Don't echo an ESC
	CALL	UPPER
  IF NOT CPM
	PUSH	PSW		;Save it
	PUSH	B
 	MOV	C,A
	CALL	ZCO		;Echo it
	POP	B
	POP	PSW		;get it back
 ENDIF
	RET

				;Convert LC to UC
UPPER:	CPI	'a'		;must be >= lowercase a
	RC			; else go back...
	CPI	'z'+1		;must be <= lowercase z
	RNC			; else go back...
	SUI	'a'-'A'		;subtract lowercase bias
	RET

				;ASCII TO BINARY CONVERSION ROUTINE
ASBIN:	SUI	30H 
	CPI	0AH 
	RM
	SUI	07H 
	RET


GETHEX:
	call	ZCI			;GET A CHARACTER, convert to UC, ECHO it
	call	UPPER
	cpI	ESC
	jz	HEXABORT$NO$ECHO
	cpi	'/'			;check 0-9, A-F
	jc	HEXABORT$NO$ECHO
	cpi	'F'+1
	jnc	HEXABORT$NO$ECHO

IF CPM 
ELSE
	PUSH	B
	PUSH	PSW
	MOV	C,A
	CALL	ZCO
	POP	PSW
	POP	B
ENDIF
	call	ASBIN			;Convert to binary
	rlc				;Shift to high nibble
	rlc
	rlc
	rlc
	MOV	b,A			;Store it
	
	call	ZCI			;GET second CHARACTER, convert to UC, ECHO it
	call	UPPER	
	cpi	ESC
	jz	HEXABORT$NO$ECHO
	CPI	CR
	JZ	ONE$DIGIT
	
	cpi	'/'			;check 0-9, A-F
	jc	HEXABORT$NO$ECHO
	cpi	'F'+1
	jnc	HEXABORT$NO$ECHO
IF CPM 
ELSE
	PUSH	B
	PUSH	PSW
	MOV	C,A
	CALL	ZCO
	POP	PSW
	POP	B
ENDIF
	call	ASBIN			;Convert to binary
	ora	B			;add in the first digit
	ora	A			;To return NC
	ret
HEXABORT$NO$ECHO:
	scf				;Set Carry flag
	ret
;
ONE$DIGIT:				;A CR wase ntered after only 1 digit
	MOV	A,B
	RAR				;Shift to high nibble back down
	RAR
	RAR
	RAR
	ANI	0FH
	ORA	A
	RET


;>>>>>>>>>>>>>>>>>>>> MAIN CONSOLE ROUTINES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
ZCO:				;Write character that is in [C]
  IF  CPM
	PUSH	PSW
	PUSH	B
	PUSH	D
	PUSH	H
	MOV	E,C
	MVI	C,WRCON
	CALL	BDOS
	POP	H
	POP	D
	POP	B
	POP	PSW
	RET
  ELSE	
	PUSH	PSW	
ZCO1:	IN   	0H		;Show Character
	ANI	04H
	JZ	ZCO1
	MOV	A,C
	OUT	1H
	POP	PSW
	RET
  ENDIF

ZCI:				;Return keyboard character in [A]
  IF CPM
	PUSH	B
	PUSH	D
	PUSH	H
	MVI	C,RDCON
	CALL	BDOS
	POP	H
	POP	D
	POP	B
	RET
  ELSE
ZCI1:	IN	0H		;Get Character in [A]
	ANI	02H
	JZ	ZCI1
	IN	01H
	RET
  ENDIF


ZCSTS:
  IF  CPM
	PUSH	B
	PUSH	D
	PUSH	H
	MVI	C,CONST
	CALL	BDOS		;Returns with 1 in [A] if character at keyboard
	POP	H
	POP	D
	POP	B
	CPI	1
	RET
  ELSE	
	IN	0H		;Get Status in [A]
	ANI	02H
	RZ
	MVI	A,01H
	ORA	A
	RET
  ENDIF


;>>>>>>>>>>>>>>>>>>>> MAIN PRINTER OUTPUT ROUTINE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
	
LO:	IN	PARALLEL$G		;Is the printer busy
	ANI	01000000B    		;Remember bits 7-4 are inputs for 8255 port C, (bits 0-3 are outputs)
	CPI	01000000B 
	JNZ	LO			;If so wait
	MOV	A,C
	OUT	PARALLEL$E		;38H, Send Data to printer
	MVI	A,01H			;3AH, Setup strobe High -> Low -> High
	OUT	PARALLEL$G
	MVI	A,0	 		;Send STROBE FOR CENTRONICS
	OUT	PARALLEL$G
	MVI	A,01H			;Raise strobe again
	OUT	PARALLEL$G
	RET	

LSTAT:	PUSH	B
	MVI	B,0FFH
LSTAT1:	IN	PARALLEL$G		;3AH 
	ANI	11000000B
	JZ	LSTAT2
	DJNZ	LSTAT1			;Keep trying
	POP	B
	XRA	A
	DCR	A			;BUSY = HIGH, or ACK = HIGH,  NON-ZERO FLAG, PRINTER BUSY
	RET	
LSTAT2:	POP	B
	XRA	A	     		;BUSY = LOW, ACK = LOW,  ZERO FLAG, PRINTER READY
	RET	
	

FLUSH:	MVI	A,FF			;Send a Form Feed to LaserJet Printer
	OUT	PARALLEL$E		;38H, Send Data
	
	MVI	A,01H			;3AH, Setup strobe High -> Low -> High
	OUT	PARALLEL$G
	MVI	A,0	 		;Send STROBE FOR CENTRONICS
	OUT	PARALLEL$G
	MVI	A,01H			;Raise strobe again
	OUT	PARALLEL$G
	RET	



;----------------------------INITILIZAE ZILOG Z8530 UARTS ------------------------------------------------------------------

INIT$Z8530:				;Setup the three Z8530's
	CALL	INIT$SCC$A$A		;Initilize UART A  (RS232 + SPEECH)
	CALL	INIT$SCC$A$B
	CALL	INIT$SCC$B$A		;Initilize UART B  (FX + DFP Audio)
	CALL	INIT$SCC$B$B
	CALL	INIT$SCC$C$A		;Initilize UART C  (WiFi + USB Port)
	CALL	INIT$SCC$C$B
	RET
	
INIT$SCC$A$A:				
	MVI	A,ACTL			;Program Channel A of UART_A 
	MOV	C,A
	MVI	B,0EH			;Byte count for OTIR below
	LXI	H,SCCINIT$A$A
	OUTIR
	RET
	
INIT$SCC$A$B:
	MVI	A,BCTL			;Program Channel B of UART_A
	MOV	C,A
	MVI	B,0EH			;Byte count for OTIR below
	LXI	H,SCCINIT$A$B
	OUTIR
	RET

INIT$SCC$B$A:				
	MVI	A,FX$SOUND$STATUS$PORT	;Program Channel A of UART_B
	MOV	C,A
	MVI	B,0EH			;Byte count for OTIR below
	LXI	H,SCCINIT$B$A
	OUTIR
	RET
	
INIT$SCC$B$B:
	MVI	A,DFP$SOUND$STATUS$PORT	;Program Channel B of UART_B
	MOV	C,A
	MVI	B,0EH			;Byte count for OTIR below
	LXI	H,SCCINIT$B$B
	OUTIR
	RET

INIT$SCC$C$A:				
	MVI	A,WIFI$STATUS$PORT	;Program Channel A  of UART_C
	MOV	C,A
	MVI	B,0EH			;Byte count for OTIR below
	LXI	H,SCCINIT$C$A
	OUTIR
	RET
	
INIT$SCC$C$B:
	MVI	A,USB$STATUS$PORT	;Program Channel B of UART_C
	MOV	C,A
	MVI	B,0EH			;Byte count for OTIR below
	LXI	H,SCCINIT$C$B
	OUTIR
	RET

SCCINIT$A$A:
	DB	04H			;Point to WR4     >>>>>>>>>>>>>>>>>>>>> (RS232 UART)
	DB	44H			;X16 clock,1 Stop,NP
;	DB	04H			;X1 clock,1 Stop,NP
	DB	03H			;Point to WR3
	DB	0C1H			;Enable reciever, Auto Enable, Recieve 8 bits	
;	DB	0E1H			;Enable reciever, No Auto Enable, Recieve 8 bits (for CTS bit)	
	DB	05H			;Point to WR5
	DB	0EAH			;Enable, Transmit 8 bits
	DB	0BH			;Set RTS,DTR, Enable. Point to WR11
	DB	56H			;Recieve/transmit clock = BRG

	DB	0CH			;Point to WR12
;	DB	40H			;Low Byte 2400 Baud 
;	DB	1EH			;Low Byte 4800 Baud 
;	DB	0EH			;Low Byte 9600 Baud 
;	DB	06H			;Low byte 19,200 Baud 
	DB	02H			;Low byte 38,400 Baud <<<<<<<<<<< XModem I/O
;	DB	13H			;low byte 115,200 Baud (With 1X clk)  
;	DB	00H			;Low byte 76,800 Baud  
;	DB	06H			;Try for 460800
	DB	0DH			;Point to WR13
	DB	00H			;High byte for Baud
	DB	0EH			;Point to WR14
	DB	01H			;Use 4.9152 MHz Clock. Note SD Systems uses a 2.4576 MHz clock, enable BRG
	DB	0FH			;Point to WR15
	DB	00H			;Generate Int with CTS going high

SCCINIT$A$B:
	DB	04H			;Point to WR4    >>>>>>>>>>>>>>>>>>>>>>>>> (Speech)
	DB	44H			;X16 clock,1 Stop,NP
	DB	03H			;Point to WR3
	DB	0C1H			;Enable reciever, Auto Enable, Recieve 8 bits	
	DB	05H			;Point to WR5
	DB	0EAH			;Enable, Transmit 8 bits
	DB	0BH			;Set RTS,DTR, Enable. Point to WR11
	DB	56H			;Recieve/transmit clock = BRG

	DB	0CH			;Point to WR12
	DB	06H			;Low byte 19,200 Baud <<<<<<<<<<< Note Speech synthizer defaults to this value
	DB	0DH			;Point to WR13
	DB	00H			;High byte for Baud
	DB	0EH			;Point to WR14
	DB	01H			;Use 4.9152 MHz Clock. Note SD Systems uses a 2.4576 MHz clock, enable BRG
	DB	0FH			;Point to WR15
	DB	00H			;Generate Int with CTS going high


SCCINIT$B$A:
	DB	04H			;Point to WR4 >>>>>>>>>>>>>>>>>>>>> (FX AUDIO)
	DB	44H			;X16 clock,1 Stop,NP
	DB	03H			;Point to WR3
	DB	0C1H			;Enable reciever, Auto Enable, Recieve 8 bits	
	DB	05H			;Point to WR5
	DB	0EAH			;Enable, Transmit 8 bits
	DB	0BH			;Set RTS,DTR, Enable. Point to WR11
	DB	56H			;Recieve/transmit clock = BRG

	DB	0CH			;Point to WR12
	DB	0EH			;Low Byte 9600 Baud 
	DB	0DH			;Point to WR13
	DB	00H			;High byte for Baud
	DB	0EH			;Point to WR14
	DB	01H			;Use 4.9152 MHz Clock. Note SD Systems uses a 2.4576 MHz clock, enable BRG
	DB	0FH			;Point to WR15
	DB	00H			;Generate Int with CTS going high

SCCINIT$B$B:
	DB	04H			;Point to WR4     >>>>>>>>>>>>>>>> (DFP Audio)
	DB	44H			;X16 clock,1 Stop,NP
	DB	03H			;Point to WR3
	DB	0C1H			;Enable reciever, Auto Enable, Recieve 8 bits	
	DB	05H			;Point to WR5
	DB	0EAH			;Enable, Transmit 8 bits
	DB	0BH			;Set RTS,DTR, Enable. Point to WR11
	DB	56H			;Recieve/transmit clock = BRG

	DB	0CH			;Point to WR12
	DB	0EH			;Low Byte 9600 Baud 
	DB	0DH			;Point to WR13
	DB	00H			;High byte for Baud
	DB	0EH			;Point to WR14
	DB	01H			;Use 4.9152 MHz Clock. Note SD Systems uses a 2.4576 MHz clock, enable BRG
	DB	0FH			;Point to WR15
	DB	00H			;Generate Int with CTS going high

SCCINIT$C$A:
	DB	04H			;Point to WR4 >>>>>>>>>>>>>>>>>>>>>>>>>> (WiFi UART)
	DB	44H			;X16 clock,1 Stop,NP
	DB	03H			;Point to WR3
	DB	0C1H			;Enable reciever, Auto Enable, Recieve 8 bits	
	DB	05H			;Point to WR5
	DB	0EAH			;Enable, Transmit 8 bits
	DB	0BH			;Set RTS,DTR, Enable. Point to WR11
	DB	56H			;Recieve/transmit clock = BRG

	DB	0CH			;Point to WR12
	DB	0EH			;Low Byte 9600 Baud  <<<<<<<<<<<<<<< (For ESP8266 WiFI Module)
	DB	0DH			;Point to WR13
	DB	00H			;High byte for Baud
	DB	0EH			;Point to WR14
	DB	01H			;Use 4.9152 MHz Clock. Note SD Systems uses a 2.4576 MHz clock, enable BRG
	DB	0FH			;Point to WR15
	DB	00H			;Generate Int with CTS going high

SCCINIT$C$B:
	DB	04H			;Point to WR4 >>>>>>>>>>>>>>>>>>>>>> (USB Port)
	DB	44H			;X16 clock,1 Stop,NP
	DB	03H			;Point to WR3
	DB	0C1H			;Enable reciever, Auto Enable, Recieve 8 bits	
	DB	05H			;Point to WR5
	DB	0EAH			;Enable, Transmit 8 bits
	DB	0BH			;Set RTS,DTR, Enable. Point to WR11
	DB	56H			;Recieve/transmit clock = BRG

	DB	0CH			;Point to WR12
;	DB	0EH			;Low Byte 9600 Baud 
;	DB	06H			;Low byte 19,200 Baud 
	DB	02H			;Low byte 38,400 Baud 
	DB	0DH			;Point to WR13
	DB	00H			;High byte for Baud
	DB	0EH			;Point to WR14
	DB	01H			;Use 4.9152 MHz Clock. Note SD Systems uses a 2.4576 MHz clock, enable BRG
	DB	0FH			;Point to WR15
	DB	00H			;Generate Int with CTS going high
	
	
	


;--------------------------------------------------------------------------------------------------------

SIGN$ON$CPM:	DB	CR,LF,LF,'Super IO Board II Test Program (V1.1) '
		DB	'using CPM3 Console BIOS Routines'
		DB	CR,LF,'Baud rates for RS232 and USB port = 38,400, Speech = 19200.'
		DB	CR,LF,'FX Audio, DFP audio and WiFi = 9600.',CR,LF,'$'
SIGN$ON$Z80:	DB	CR,LF,LF,'Super IO Board II Test Program (V1.1) '
		DB	'using the Z80 Monitor for IO'
		DB	CR,LF,'Baud rates for RS232 and USB port = 38,400, Speech = 19200.'
		DB	CR,LF,'FX Audio, DFP audio and WiFi = 9600.',CR,LF,'$'
		

MENU$STRING$:	DB  CR,LF
		DB '(D) DFP Sound Card Test    (F) FX Sound Card Test(R)',CR,LF
		DB '(G) Get 8255A Ports        (H) Set 8255A ports',CR,LF
		DB '(I) Read IOBYTE Switches   (L) Test LEDs',CR,LF
		DB '(P) Printer Test           (Q) ',CR,LF
		DB '(R) RS232 Serial Port Test (S) Speech test ',CR,LF
		DB '(T) USB Port Test          (U) Set Date & Time ',CR,LF
		DB '(W) WiFi Card Test         (ESC) Quit',CR,LF,'$'

MSGERR		DB	CR,LF,'Sorry that was not a valid menu option!',CR,LF,LF,'$'
Prompt:		db	CR,LF,LF,'Please enter command > $'
L$MENU$STRING	DB	CR,LF,'Test LEDs with 8255A Port C.'
		DB	CR,LF,'Enter keyboard character for each LED.  ESC to abort',CR,LF,'$'

TEST$PRN$MSG	DB	CR,LF,'Send the following test string to the Printer port:-',CR,LF,'$'
PRINTER$STRING	DB	CR,LF,'This is a test string being sent to the printer '
		DB	      'port on the Super IO II Board'
		DB	CR,LF,'Second line, 0123456789,  ABCDEF,  abcdef'
		DB	CR,LF,'Third line,  terminating string$',0H
		
RD$IOBYTE$MSG	DB	CR,LF,'IOBYTE Port Switches = $'

TEST$SPEECH$MSG	DB	CR,LF,'Sending the following string to '
		DB	'the speaker V-STAMP module.'
		DB	CR,LF,'This is a test. 12345678'
		DB	CR,LF,'Enter CR to start test.$'
SPEECH$STRING	DB	'This is a test. 12345678$'

TEST$RS232$MSG1	DB	CR,LF,'Test the RS232 Port. (P17, J1)'
		DB	CR,LF,'Please enter keyboard characters from the RS232 Terminal'
		DB	CR,LF,'They will be sent to the S100 Bus U7 RS232 Port Rx pin. '
		DB	CR,LF,'The loop around U7 RS232 Port Tx pin will return the character'
		DB	CR,LF,'to the RS232 Terminal (and display it here).'
		DB	CR,LF,'Enter ESC to abort.',CR,LF,LF,'$'
		
TEST$RS232$MSG2	DB	CR,LF,'Test the RS232 Port. (P17, J1)'
		DB	CR,LF,'Please enter keyboard characters from THIS RS232 Terminal'
		DB	CR,LF,'They will be sent to the S100 Bus U7 RS232 Port Rx pin.'
		DB	CR,LF,'The loop around U7 RS232 Port Tx pin will return the character '
		DB	CR,LF,'here (and on the S100 Console).'
		DB	CR,LF,'Enter ESC to abort.',CR,LF,LF,'$'


DONE$SERIAL$MSG	DB	CR,LF,'Test of the RS232 Serial Port finished.',CR,LF,'$'

TEST$USB$MSG1	DB	CR,LF,'Test the USB Serial Port Adaptor. (P4)'
		DB	CR,LF,'Please enter keyboard characters from the USB Terminal'
		DB	CR,LF,'They will be sent to the S100 Bus U10 RS232 Port Rx pin. '
		DB	CR,LF,'The loop around U10 Port Tx pin will return the character'
		DB	CR,LF,'to the USB Terminal (and display it here).'
		DB	CR,LF,'Enter ESC to abort.',CR,LF,LF,'$'

TEST$USB$MSG2	DB	CR,LF,'Test the USB Serial Port Adaptor. (P4)'
		DB	CR,LF,'Please enter keyboard characters from THIS USB Terminal'
		DB	CR,LF,'They will be sent to the S100 Bus U10 RS232 Port Rx pin. '
		DB	CR,LF,'The loop around U10 Port Tx pin will return the character'
		DB	CR,LF,'here (and on the S100 Console).'
		DB	CR,LF,'Enter ESC to abort.',CR,LF,LF,'$'

DONE$USB$MSG	DB	CR,LF,'Test of the USB Serial Port Adaptor finished.',CR,LF,'$'


ADAFRUIT$FX$MENU
		DB	CR,LF,LF,'AdaFruit FX Sound card Menu.',CR,LF,LF
		DB	'(1) List All Files',CR,LF
		DB	'(2) Play File #',CR,LF
		DB	'(3) Increase Volume',CR,LF
		DB	'(4) Decrease Volume',CR,LF
		DB	'(5) Pause Playing',CR,LF
		DB	'(6) Resume Playing',CR,LF
		DB	'(7) Stop Playing',CR,LF
		DB	'(8) Play Filename',CR,LF
		DB	CR,LF,'Enter a menu option. ESC to abort to main Menu.',CR,LF,LF,'$'

NO$ADAFRUIT$FX$CARD DB	CR,LF,BELL,'No AdaFruit FX card detected. (Or RST pin in low).',CR,LF,'$'
BAD$CMD		DB	CR,LF,BELL,'Invalid menu option.$'
ENTER$FILE$NO	DB	CR,LF,'Please enter the Track Number (XX+CR):$'

FX$UP$VOLUME	DB	CR,LF,'Volume Increased$'
FX$DOWN$VOLUME	DB	CR,LF,'Volume Decreased$'
FX$PAUSE$MSG	DB	CR,LF,'Pause Playback$'
FX$RESUME$MSG	DB	CR,LF,'Resume Playback$'
FX$STOP$MSG	DB	CR,LF,'Stop Playback$'
FX$ENTER$NAME	DB	CR,LF,'Enter File name (In XXXXXXXX.XXX Format):$'
FX$GOT$NAME	DB	CR,LF,'Will play the following file: $'


WIFI$MENU	DB	CR,LF,LF,'WiFi ESP8266 Card Menu.',CR,LF,LF
		DB	'(1) Simple WiFi port Echo Test',CR,LF
		DB	'(2) Send AT+CWMODE=? Command, (View Options Mode)',CR,LF
		DB	'(3) Send AT+GMR Command, (Get Firmware Version)',CR,LF
		DB	'(4) Send AT+CWMODE=1 Command, (Set Mode)',CR,LF
		DB	'(5) Send AT+CWLAP Command, (Get Networks)',CR,LF
		DB	'(6) Send AT+CIFSR Command, (Get IP Address)',CR,LF
		DB	CR,LF,'Enter a menu option. ESC to abort to main Menu.',CR,LF,LF,'$'

ECHO$WIFI$MSG	DB	CR,LF,'0.  Echo test of serial port on the WIFI card.'
		DB	CR,LF,'Please enter keyboard characters. (ESC to abort).$'

OK$WIFI$MSG0	DB	'2.  Will send AT+CWMODE=? Command (View Options). '
		DB	CR,LF,'Enter ESC to return to WiFi Menu.',CR,LF,LF,'$'
OK$WIFI$MSG1	DB	'3.  Will send AT+GMR Command (Get Firmware Version).  '
		DB	CR,LF,'Enter ESC to return to WiFi Menu',CR,LF,LF,'$'
OK$WIFI$MSG2	DB	'4.  Will send AT+CWMODE=1 Command (Set Mode).  '
		DB	CR,LF,'Enter ESC to return to WiFi Menu',CR,LF,LF,'$'
OK$WIFI$MSG3	DB	'5.  Will send AT+CWLAP Command (Get Networks). '
		DB	CR,LF,'Enter ESC to return to WiFi Menu',CR,LF,LF,'$'
OK$WIFI$MSG4	DB	'6.  Will send AT+CIFSR Command (Get IP Add.). '
		DB	CR,LF,'Enter ESC to return to WiFi Menu',CR,LF,LF,'$'

AT$WIFI$MSG2	DB	'AT+CWMODE=?',CR,LF,'$'
AT$WIFI$MSG3	DB	'AT+GMR',CR,LF,'$'
AT$WIFI$MSG4	DB	'AT+CWMODE=1',CR,LF,'$'
AT$WIFI$MSG5	DB	'AT+CWLAP',CR,LF,'$'

DFP$SOUND$MENU
		DB	CR,LF,LF,'DFP SD Card Sound Menu.',CR,LF
		DB	'Read SD card on a PC to display the sound files present',CR,LF,LF
		DB	'(0) Play File #',CR,LF
		DB	'(1) Set Sound Volume',CR,LF
		DB	'(2) Continously play current track',CR,LF
		DB	'(3) Pause Playing',CR,LF
		DB	'(4) Play or Resume playing current track',CR,LF
		DB	'(5) Continously play all tracks',CR,LF
		DB	'(6) Stop Playing',CR,LF
		DB	'(7) Send Byte to Port 8AH',CR,LF
		DB	CR,LF,'Enter a menu option. ESC to abort to main Menu.',CR,LF,LF,'$'

NO$DFP$CARD	DB	CR,LF,BELL,'No DFP Sound Card detected',CR,LF,'$'

DFP$FILE$NUMBER DB	CR,LF,'Please enter the File Number (XX+CR):$'
SENDING$CMD	DB	CR,LF,'Sending the following Command:- $'
GOT$BACK	DB	CR,LF,'The DFP Player returned:- $'
DFP$BYTE$VALUE	DB	CR,LF,'Please enter a value to send to port 8AH (XX+CR):$'

DFP$ENTER$VOLUME DB	CR,LF,'Please enter the desired Volume Number (00-30+CR):$'
DFP$REPEAT$MSG	DB	CR,LF,'Will continously play the current track.$'
DFP$PAUSE$MSG	DB	CR,LF,'Will pause play of the current track.$'
DFP$PLAY$MSG	DB	CR,LF,'Will play of the current track.$'
DFP$PLAY$ALL$MSG DB	CR,LF,'Will continously play all tracks.$'
DFP$RESET$MSG	DB	CR,LF,'Will reset the DFP Player.$'
DFP$QUERY$MSG	DB	CR,LF,'Will query the DFP Player.$'

P$SEND$MSG	DB	CR,LF,'Send data to 8255A (U9) ports A, B & C.$'
P$SENDA$MSG	DB	CR,LF,'Enter 8255A Port A (XXH):$'
P$SENDB$MSG	DB	CR,LF,'Enter 8255A Port B (XXH):$'
P$SENDC$MSG	DB	CR,LF,'Enter 8255A Port C (XXH):$'
OUT$RESULT$MSG	DB	CR,LF,LF,'8255A Ports    A           B              C$'
OUT$RESULT1$MSG DB	CR,LF,'           $'
OUT$RESULT2$MSG	DB	'    $'
OUT$RESULT3$MSG	DB	'       $'

P$GET$MSG	DB	CR,LF,'Get data from 8255A (U9) ports A, B & C.$'

				;DFP Player Commands
FILE$NUMBER$CMD		DB	07EH,0FFH,06H,03H,00H,00H
DFP$VOLUME$CMD		DB	07EH,0FFH,06H,06H,00H,00H
DFP$REPEAT$CMD		DB	07EH,0FFH,06H,08H,00H,00H
DFP$PAUSE$CMD		DB	07EH,0FFH,06H,0EH,00H,00H
DFP$PLAY$CMD		DB	07EH,0FFH,06H,0DH,00H,00H
DFP$RESET$CMD		DB	07EH,0FFH,06H,0CH,00H,00H
DFP$ALL$PLAY$CMD	DB	07EH,0FFH,06H,11H,00H,00H
DFP$QUERY$VOL$CMD	DB	07EH,0FFH,06H,42H,00H,00H


STATUS$COUNT	DW	0H
FX$FILE$NO	DB	0H
FX$BUFFER	DB	'        '	;8 SPACES
FX$BUFFER$EXT	DB	'   '		;3 spaces

DFP$VARIABLE	   DB	0H
DFP$VARIABLE$HIGH  DB	0H
DFP$CURRENT$TRACK  DB	0H
			
PORT$A$STORE	DB	0H
PORT$B$STORE	DB	0H
PORT$C$STORE	DB	0H
LOOP$COUNT	DB	0H
 
			
		DB	0


		DS	300H
	
STACK:			DW	0H 
			DB	'<--End of SIODIAG2 Code           '
