$TITLE('CONTRAVES ENCODER (PARALLEL INPUT)') DEBUG
$NOSYMBOLS MACROFILE PAGEWIDTH(80)
;
;******************************************************
;
	NAME	PARENC
	PUBLIC	INTRR,PGMEM,FPSST,LMPAR,LCPAR,LDXP
	PUBLIC	LP1PAR,YRPAR,XMPAR,LCADR,YRADR,XMADR
	PUBLIC	MTAB,BRTAB,DPART,PARSV,MENULP,CMPAR
	PUBLIC	CMADR,MENUR,XSWST,LDDAY,CTODCT,XPPAR
	PUBLIC	CRPAR,CRADR,DEFLC,IRIGFG,RETFG,XPADR
	EXTRN	TSTNVM,YEAR,LDLPM,CBYTE,FORCK,MENUFG
	EXTRN	LDCHR,RIFF,IRIGSR,RVSPT,LDSPA,ANNOR
	EXTRN	MENU,POSAN,LDCON,RDCLK,CLKST,CKINIT
	EXTRN	B2ACAS,BCDCLK,ASCCLK,EXIT,SETCK,XINIT
	EXTRN	LDASCK,DAY,DMYCV,PDAY,WTPAR,XMCHG,BOX
	EXTRN	LOD,AD,SB,MUL,DIV,STR,MOVE,BCDASC
	EXTRN	INIT,OU,BXHAIR,XOUTDR,ABSPOS,LDASC
	STKLN	20
;	DATE	13 DEC 84
;
;	REVISIONS:
;	13 DEC 84 - CHANGED YEAR TO 85 AND NULL BYTE
;		    FOLLOWING AZ/EL TO ALL 1'S
;
;******************************************************
;
;		EXECUTIVE EQUATES
;
;******************************************************
;
;MEMORY ADDRESSES
;
FXDBF	EQU	3800H		;FIXED DATA BUFFER
FXDST	EQU	38F0H		;FIXED SYSTEM STATUS
ALTPG	EQU	3900H		;PAGE SAVE BUFFER
FPLUT	EQU	3A40H		;F.P. LOOK UP TABLE
PGMEM	EQU	3E00H		;PAGE MEMORY
ENCOD	EQU	4A00H		;ENCODER
AZINP	EQU	4A20H		;AZIMUTH INPUT
ELINP	EQU	4A24H		;ELEVATION INPUT
RNGIN	EQU	4A28H		;RANGE INPUT
;
;I/O PORT ADDRESSES
;
IPB	EQU	5		;IRIG PORT B
ISP	EQU	6		;IRIG STATUS PORT
ICM	EQU	7		;IRIG COMMAND PORT
;
FDADR	EQU	8		;FXD DATA ADDRESS PORT
FDCMD	EQU	9		;FXD DATA COMMAND PORT
FDIST	EQU	8		;FXD DATA STATUS PORT
FDINP	EQU	9		;FXD DATA INPUT PORT
FDHSK	EQU	10		;FXD DATA H'SHAKE PORT
;
STATUS	EQU	47H		;VSP INTR STATUS PORT
FPSIO	EQU	48H		;FRONT PANEL SWITCHES
;
;******************************************************
;
;		SYSTEM INITIALIZATION
;
;******************************************************
;
	ASEG			;START OF PROGRAM
;
START:
	DI			;DISABLE INTERRUPTS
	LXI	SP,STACK	;LOAD STACK POINTER
	CALL	TSTNVM		;MOVE PARAMETERS TO RAM
	LDA	LCPAR		;FETCH LINE COUNT
	LXI	H,PGMEM		;CLEAR PAGE
	CALL	ANNOR
	LXI	H,LCPAR		;LOAD LINE POS MEMORY
	CALL	LDLPM
	LHLD	PONWD		;POWER ON TEST WORD
	LXI	D,55AAH		;POWER ON CONSTANT
	MOV	A,H		;POWER ON INIT?
	CMP	D
	JNZ	INIT05		;YES-AHEAD
	MOV	A,L
	CMP	E
	JZ	INIT40		;NO-AHEAD
INIT05:
	XCHG			;ELSE-STORE CONSTANT
	SHLD	PONWD
	XRA	A		;RESET OTHER TEST BYTES
	STA	CBYTE
	MVI	C,5		;INIT CTR FOR OPT TEST
	CALL	RVSPT		;RESET TIMER
	JMP	INIT10		;AHEAD
	NOP
	NOP
;
;******************************************************
;
;		INTERRUPT PROCESSING
;
;******************************************************
;
INTR:
	PUSH	PSW		;SAVE REGISTERS
	PUSH	B
	PUSH	D
	PUSH	H
	LXI	H,INTRR		;RET ADDR TO STACK
	PUSH	H
;
;TEST FOR VSP INTERRUPT
;
	IN	STATUS		;FETCH VSP F/F STATUS
	RLC			;SET?
	JNC	INT10		;NO-AHEAD
	LXI	H,VSPFG		;SET FLAG
	MVI	M,0FFH
	CALL	RIFF		;RESET INTR F/F
	LXI	H,ENCOD		;POINT AT ENCODER
	MVI	M,0		;STORE NULL BYTE
	INX	H
	MVI	M,10110011B	;STORE SYNC BYTE
	INX	H
	PUSH	H		;SAVE POINTER
	LDA	FXDCT		;FETCH FXD DATA COUNT
	OUT	FDADR		;OUTPUT ADDRESS
	XRA	A		;RESET FLAG
	STA	FDIFG
	CALL	RDCLK		;READ CLOCK
	POP	H		;LOAD POINTERS
	LXI	D,BCDCLK
	MVI	C,3		;FIRST 3 BYTES
	LDA	ROPPAR		;RANGE OPTION?
	SUI	66
	JM	INT05		;NO-AHEAD
	LDAX	D		;FETCH CLOCK STATUS
	ANI	0F0H		;MASK LSB'S
	MOV	B,A		;SAVE IN B
	LXI	D,RDATA		;POINT AT RANGE DATA
	LDAX	D		;FETCH 1ST BYTE
	ANI	0FH		;MASK MSB'S
	ORA	B		;COMBINE CLOCK STATUS
	MOV	M,A		;STORE IN ENCODER
	INX	H
	INX	D
	DCR	C		;2 MORE BYTES
INT05:
	CALL	LDCHR		;LOAD ENCODER
	MVI	A,2		;RANGE OPTION?
	CMP	C
	JNZ	$+4		;NO-AHEAD
	INR	A		;ELSE-A=3
	STA	AERFG		;INIT DATA READY FLAG
	LXI	D,BCDCLK+3	;COMPLETE TIME LOAD
	MVI	C,4
	CALL	LDCHR
	CALL	LDASCK		;CONV CLK TO ASCII
	LXI	H,PGMEM		;POINT AT PAGE
	CALL	LDDAY		;LOAD DAY
	CALL	CTODCT		;COMPUTE TOD COUNT
	CALL	LDCHR		;LOAD TIME
	LDA	IRIGFG		;IRIG IN SYSTEM?
	ORA	A
	JNZ	$+8		;NO-AHEAD
	LDA	ASCCLK		;ELSE-STORE STATUS
	MOV	M,A
	INX	H
	MVI	M,' '		;SPACE
	INX	H
	SHLD	PGPTR		;SAVE POINTER
	RET
;
;TEST FOR INTERFACE INTERRUPT
;
INT10:
	LXI	D,AZINP		;AZIMUTH INTERRUPT?
	LDAX	D
	RAL
	JC	INT15		;NO-AHEAD
	LXI	H,AZDAT		;ELSE-POINT AT BUFFER
	JMP	INT25		;STORE AHEAD
INT15:
	LXI	D,ELINP		;ELEVATION INTERRUPT?
	LDAX	D
	RAL
	JC	INT20		;NO-AHEAD
	LXI	H,ELDAT		;STORE AHEAD
	JMP	INT25
INT20:
	LDA	ROPFG		;RANGE OPTION?
	ORA	A
	JNZ	INT55		;NO-AHEAD
	LXI	D,RNGIN		;RANGE INTERRUPT?
	LDAX	D
	RAL
	JC	INT55		;NO-AHEAD
	LXI	H,RGDAT		;POINT AT BUFFER
INT25:
	MVI	C,4		;READ 4 BYTES
	CALL	LDCHR
	LXI	H,AERFG		;ALL DATA IN?
	DCR	M
	RNZ			;NO-RETURN
	LXI	D,AZDAT		;POINT AT DATA
	LXI	H,ENCOD+9	;POINT AT ENCODER
	LDA	DATPAR		;BINARY DATA?
	SUI	66
	JNZ	INT30		;NO-AHEAD
	LDA	AZDAT+3		;MASK LSB'S
	ANI	11111000B
	STA	AZDAT+3
	INX	D		;ELSE-BUMP POINTER
	MVI	C,3		;ENCODE 1ST 3 BYTES
	CALL	LDCHR
	INX	D		;BUMP POINTER
	LDA	ELDAT+3		;MASK LSB'S
	ANI	11111000B
	STA	ELDAT+3
	CALL	LDCHR		;ENCODE LAST 3 BYTES
	MVI	M,0FFH		;INDICATE BINARY DATA
	INX	H
	JMP	INT40		;AHEAD
INT30:
	MVI	C,3		;SET C=3
	LDA	AZDAT		;MASK MSB'S
	ANI	3
	STA	AZDAT
	LDA	ELDAT
	ANI	3
	STA	ELDAT
INT35:
	PUSH	H		;SAVE POINTER
	LDAX	D		;FETCH BCD BYTE
	INX	D		;BUMP POINTER
	MOV	H,A		;1ST BYTE TO H
	LDAX	D		;FETCH 2ND BYTE
	MOV	L,A		;2ND BYTE TO L
	DAD	H		;SHIFT LEFT (4)
	DAD	H
	DAD	H
	DAD	H
	MOV	A,H		;MSB'S TO A
	MOV	B,L		;LSB'S TO B
	POP	H		;POINT AT ENCODER
	MOV	M,A		;ENCODE MSB'S
	INX	H		;BUMP POINTERS
	INX	D
	LDAX	D		;FETCH 3RD BYTE
	DCR	C
	JZ	INT37
	RRC			;SHIFT RIGHT (4)
	RRC
	RRC
	RRC
INT37:
	ANI	0FH		;MASK
	ORA	B		;COMBINE
	MOV	M,A		;ENCODE 2ND BYTE
	INX	H
	DCR	C		;DONE?
	JP	INT35		;NO-BACK
	INX	D		;ENCODE LAST 3 BYTES
	MVI	C,3
	CALL	LDCHR
INT40:
	LDA	FXDCT		;FETCH FXD DATA COUNT
	MOV	B,A		;SAVE COUNT
	MOV	M,A		;ENCODE COUNT
	INX	H
	PUSH	H		;SAVE POINTER
	SUI	240		;COUNT >=240?
	JC	INT45		;NO-AHEAD
	LXI	D,FXDST		;POINT AT F.D. STATUS
	ORA	E		;ADD OFFSET
	MOV	E,A		;POINT AT FIXED DATA
	JMP	INT50		;ENCODE AHEAD
INT45:
	IN	FDIST		;FETCH BOARD STATUS
	ANI	3		;THUMBWHEEL I'FACE?
	JZ	INT47		;YES-AHEAD
	CALL	RDFDI		;ELSE-READ FIXED DATA
	JMP	INT50		;AHEAD
INT47:
	IN	FDINP		;READ THUMB SWITCHES
	LXI	H,FXDBF		;POINT AT BUFFER
	MOV	E,B		;COUNT TO DE
	MVI	D,0
	DAD	D		;ADD OFFSET
	MOV	M,A		;STORE FIXED DATA
	XCHG			;POINTER TO DE
INT50:
	POP	H		;RESTORE POINTER
	LDAX	D		;FETCH FIXED DATA
	MOV	M,A		;ENCODE FIXED DATA
	INX	H		;ENCODE NULL
	MVI	M,0
	CALL	DSPFD		;DISPLAY FIXED DATA
	XRA	A		;DISABLE FDI INTERRUPT
	CMA
	STA	FDIFG
	LXI	H,FXDCT		;BUMP COUNT
	INR	M
	CALL	RDFPS		;READ F.P. SWITCHES
;
;SET CONVERT FLAG IF CONVERSION COMPLETE
;
	LXI	H,CNVFG		;CONVERT FLAG SET?
	XRA	A
	ORA	M
	RNZ			;YES-RETURN
	CMA			;ELSE-SET FLAG
	MOV	M,A
	LXI	H,AEIBF		;POINT AT BUFFER
	LXI	D,AZDAT		;POINT AT DATA
	MVI	C,12		;12 BYTES
	JMP	LDCHR		;MOVE NEW DATA
;
;TEST FOR FIXED DATA INPUT INTERRUPT
;
INT55:
	IN	FDIST		;FIXED DATA INTERRUPT?
	ANI	1
	JNZ	RDFDI		;YES-READ FXD DATA
;
;TEST FOR IRIG INTERRUPT
;
INT60:
	LDA	IRIGFG		;IRIG IN SYSTEM
	ORA	A
	RNZ			;NO-RETURN
	POP	H		;RESET STACK POINTER
	IN	ISP		;INTERRUPT?
	ANI	8
	JNZ	IRIGSR		;YES-SERVICE INTR
;
;RETURN FROM INTERRUPT
;
INTRR:
	POP	H		;RESTORE REGISTERS
	POP	D
	POP	B
	POP	PSW
	EI			;ENABLE INTERRUPTS
	RET			;RETURN TO PROGRAM
;
;******************************************************
;
;		CONTINUE INITIALIZATION
;
;******************************************************
;
INIT10:
	XRA	A		;TEST FOR RETICLE GEN
	OUT	31H		;OUTPUT ZERO
	IN	STATUS		;TIMEOUT?
	RLC
	JC	INIT15		;YES-AHEAD
	DCR	C		;DONE?
	JNZ	INIT10		;NO-BACK
INIT15:
	MOV	A,C		;SET/RESET PARAMETER
	STA	RETFG		;ZERO=RETICLE GEN
;
;TEST FOR RANGE OPTION BOARD
;
	MVI	C,5		;PRESET COUNT
	CALL	RVSPT		;RESET TIMER
INIT20:
	LDA	RNGIN		;READ BYTE
	IN	STATUS		;TIMEOUT?
	RLC
	JC	INIT23		;YES-AHEAD
	DCR	C		;DONE?
	JNZ	INIT20		;NO-BACK
INIT23:
	MOV	A,C		;SET-RESET PARAMETER
	STA	ROPFG
;
;TEST FOR IRIG BOARD
;
	MVI	C,5		;TEST FOR IRIG
	CALL	RVSPT		;RESET TIMER
INIT25:
	MVI	A,0C0H		;TEST FOR IRIG
	OUT	ICM		;INIT IRIG 8255
	IN	STATUS		;TIMEOUT?
	RLC
	JC	INIT30		;YES-AHEAD
	DCR	C		;DONE?
	JNZ	INIT25		;NO-BACK
INIT30:
	MOV	A,C		;SET/RESET PARAMETER
	STA	IRIGFG		;ZERO=IRIG BOARD
	XRA	A		;RESET MENU FLAG
	STA	MENUFG
	LDA	XMPAR		;INIT RETICLE MODE
	STA	XSWST
INIT40:
	LDA	MENUFG		;RST0 FROM MENU?
	ORA	A
	JNZ	INIT45		;YES-AHEAD
	LXI	H,FXDBF		;RESET FIXED DATA
	MVI	C,240
	CALL	LDCON
	LXI	H,ENCOD		;RESET ENCODER
	MVI	C,32
	CALL	LDCON
	LXI	H,ALTPG		;CLEAR PAGE SAVE BUFFER
	MVI	A,8
	CALL	ANNOR
	LXI	H,FXDST		;CLEAR FIXED STATUS
	MVI	C,16
	CALL	LDSPA
	LXI	H,LN2BF		;CLEAR LINE 2 BUFFER
	MVI	C,32
	CALL	LDSPA
	LDA	ANOPAR		;FETCH ANNO PARAMETER
	STA	ANOFG		;INIT ANNO FLAG
INIT45:
	XRA	A		;RESET MENU FLAG
	STA	MENUFG
	LXI	H,ZROST		;RESET FLAGS
	MVI	C,ZROLN
	CALL	LDCON
	CMA			;SET CONVERT FLAG
	STA	CNVFG
	LXI	D,ALTPG		;MOVE ANNOTATION
	LXI	H,PGMEM+64
	MVI	A,8
	CALL	MOVE
	MVI	B,0		;B=0
	LDA	IRIGFG		;IRIG IN SYSTEM?
	ORA	A
	JNZ	INIT50		;NO-AHEAD
	MVI	A,0C0H		;INIT IRIG 8255
	OUT	ICM
	LDA	CMPAR		;IRIG MODE?
	CPI	'I'
	JNZ	INIT50		;NO-AHEAD
	INR	B		;B=1
INIT50:
	MOV	A,B		;CLOCK STATUS
	STA	CLKST
	CALL	CKINIT		;INIT CLOCK
	CALL	XINIT		;INIT RETICLE
	CALL	INIT		;INIT F.P. PACKAGE
	LXI	H,FPLUT		;INIT POINTER
	PUSH	H
	MVI	A,24		;INIT COUNTER
	STA	FPCTR2
	LXI	H,F180		;START WITH 180 DEG
	CALL	LOD
INIT60:
	POP	H		;FETCH POINTER
	CALL	STR		;STORE FP VALUE
	INX	H		;BUMP POINTER
	PUSH	H		;SAVE IT
	LXI	H,FTWO		;DIVIDE BY 2
	CALL	DIV
	LXI	H,FPCTR2	;DONE?
	DCR	M
	JNZ	INIT60		;NO-BACK
	POP	H		;RESET STACK POINTER
	CALL	RIFF		;RESET INTR F/F
	LDA	AZINP		;RESET AZ INTR
	LDA	ELINP		;RESET EL INTR
	MVI	A,1		;RESET FDI INTR
	OUT	FDCMD
	EI			;ENABLE INTERRUPTS
;
;******************************************************
;
;		EXECUTIVE LOOP
;
;******************************************************
;
RUN:
	LXI	H,VSPFG		;VSP INTERRUPT?
	XRA	A
	CMP	M
	JZ	RUN		;NO-WAIT
	MOV	M,A		;ELSE-RESET FLAG
	LDA	RETFG		;RETICLE GENERATOR?
	ORA	A
	JNZ	RUN05		;NO-AHEAD
	CALL	XOUTDR		;ELSE-OUTPUT POS
	LXI	H,FXDST+1	;POINT AT F.D. STATUS
	LXI	D,ABSPOS	;POINT AT POSITION
	MVI	C,6
	CALL	LDCHR		;UPDATE POSITION
	LDA	XSWST		;FETCH RETICLE FORM
	MOV	B,A		;SAVE IN B
	ORI	40H		;ADD ASCII BIAS
	STA	FXDST		;STORE STATUS
	MOV	A,B		;RETICLE ON?
	ANI	7
	LHLD	PGPTR		;FETCH PAGE POINTER
	LXI	D,ABSPOS	;POINT AT POSITION
	CNZ	LDXP		;YES-UPDATE ANNO
	SHLD	PGPTR		;STORE POINTER
RUN05:
	LHLD	PGPTR		;FETCH POINTER
	MVI	A,32		;LAST CHAR IN LINE?
	CMP	L
	JZ	$+9		;YES-AHEAD
	MVI	M,' '		;ELSE-SPACE FILL
	INX	H
	JMP	$-7		;BACK
;
;UPDATE LINE 2 ANNOTATION
;
	LXI	H,PGMEM+32	;POINT AT PAGE
	LXI	D,LN2BF		;LINE 2 ANNOTATION
	MVI	C,32		;32 CHARACTERS
	CALL	LDCHR		;UPDATE LINE 2
;
;UPDATE FIXED DATA FLAGS
;
	LDA	DATPAR		;FETCH DATA TYPE
	LXI	H,FXDST+7	;POINT AT FIXED DATA
	MOV	M,A		;STORE DATA TYPE
	INX	H
	LDA	ROPPAR		;RANGE OPTION PARAM
	MOV	M,A
	INX	H
	XCHG
	LXI	H,ASCCLK+1	;POINT AT CLOCK
	MOV	B,M		;FETCH YEAR
	XCHG
	MOV	M,B		;STORE YEAR
	INX	H
	SUI	66		;RANGE OPTION?
	MVI	C,6
	JP	$+9		;YES-AHEAD
	CALL	LDSPA		;SPACE FILL
	JMP	$+7		;AHEAD
	INX	D		;ELSE-STORE TIME
	CALL	LDCHR
RUN10:
	LDA	CNVFG		;CONVERT FLAG SET?
	ORA	A
	JZ	RUN		;NO-WAIT
	LXI	H,LN2BF		;POINT AT ANNO BUF
	LXI	D,AZELMG	;POINT AT TEXT
	MVI	C,3		;STORE "AZ:"
	CALL	LDCHR
	PUSH	D		;SAVE POINTER
	XCHG
	LDA	DATPAR		;FETCH DATA TYPE
	SUI	66		;BINARY DATA?
	MOV	B,A		;SAVE COUNT & FLAG
	PUSH	B
	LXI	H,RUN15		;RET ADDR TO STACK
	PUSH	H
	LXI	H,AEIBF		;POINT AT AZIMUTH
	JZ	AB2ASC		;YES-CONVERT FOR BINARY
	JMP	BCD2A		;ELSE-CONVERT FOR BCD
RUN15:
	POP	B		;RESTORE COUNT AND FLAG
	POP	D		;RESTORE TEXT POINTER
	INR	C		;STORE " EL:"
	CALL	LDCHR
	XCHG
	LXI	H,RUN20		;RET ADDR TO STACK
	PUSH	H
	LXI	H,AEIBF+4	;POINT AT ELEVATION
	XRA	A		;BINARY DATA?
	ORA	B
	JZ	AB2ASC		;YES-CONVERT FOR BINARY
	JMP	BCD2A		;ELSE-CONVERT FOR BCD
RUN20:
	LXI	D,RUN55		;RET ADDR TO STACK
	PUSH	D
	LDA	ROPPAR		;RANGE OPTION?
	SUI	66
	JP	RUN25		;YES-AHEAD
	MVI	C,9		;ELSE-SPACE FILL
	JMP	LDSPA
RUN25:
	MVI	M,' '		;STORE SPACE
	INX	H
	MVI	M,'R'		;STORE "R"
	INX	H
	JZ	RUN35		;IF BINARY
	MVI	M,':'		;STORE COLON
	INX	H
	LXI	D,AEIBF+9	;POINT AT DATA
	XCHG
	CALL	BCDASC		;CONVERT 1ST DIGIT
	XCHG
	MOV	M,A		;STORE
	PUSH	H		;SAVE POINTER
	INX	H
	CALL	B2ACAS		;COMPLETE CONVERSION
	CALL	B2ACAS
	POP	H
	PUSH	H		;LEFT JUSTIFY
	MVI	C,4
	MVI	A,'0'
	JMP	RUN45		;AHEAD
RUN35:
	PUSH	H		;SAVE POINTER
	LXI	H,AEIBF+9	;POINT AT DATA
	CALL	B20BCD		;CONVERT TO BCD
	LXI	H,ARG		;STORE TEMP.
	PUSH	H
	MOV	M,D
	INX	H
	MOV	M,E
	INX	H
	MOV	M,B
	INX	H
	MOV	M,C
	POP	H		;RESTORE POINTERS
	POP	D
	PUSH	D
	CALL	BCDASC		;CONVERT 1ST DIGIT
	XCHG
	MOV	M,A		;STORE 10^6
	INX	H
	MVI	C,3		;COMPLETE CONVERSION
RUN40:
	CALL	B2ACAS
	DCR	C
	JNZ	RUN40
	POP	H		;POINT AT 10^6
	MVI	A,'0'		;10^6 DIGIT?
	CMP	M
	RNZ			;YES-EXIT
	MVI	M,':'		;ELSE-STORE COLON
	INX	H
	PUSH	H
	MVI	C,5		;SET COUNT
RUN45:
	CMP	M		;CHARACTER ="0"?
	JNZ	RUN50		;NO-AHEAD
	INX	H		;NEXT CHARACTER
	DCR	C		;DONE?
	JNZ	RUN45
RUN50:
	POP	D		;1ST CHARACTER POS
	XCHG
	INR	C		;CHARS DISPLAYED
	CALL	LDCHR
	MVI	A,6		;TOTAT CHAR POSITIONS
	SUB	C		;REMAINING
	MOV	C,A
	JNZ	LDSPA		;SPACE FILL
	POP	D		;RESET STACK POINTER
RUN55:
	XRA	A		;RESET FLAGS
	STA	CNVFG
	STA	VSPFG
	JMP	RUN		;LOOP BACK
;
AZELMG:	DB	'AZ: EL:'
;
;******************************************************
;
;		EXECUTIVE SUBROUTINES
;
;******************************************************
;
;READ FRONT PANEL SWITCHES
;
RDFPS:
	LXI	H,FPSST		;POINT AT SWITCH STATUS
	IN	FPSIO		;READ SWITCHES
	ANI	0FH		;ALL OFF?
	JNZ	RDS05		;NO-AHEAD
	MOV	M,A		;ELSE-RESET STATUS
	RET
RDS05:
	CMP	M		;CHANGE?
	RZ			;NO-IGNOR
	MOV	M,A		;STORE NEW STATUS
	RRC			;MENU?
	JNC	RDS10		;NO-AHEAD
	LXI	H,ALTPG		;PAGE SAVE BUFFER
	LXI	D,PGMEM+64	;PAGE MEMORY
	MVI	A,8		;8 LINES
	CALL	MOVE		;SAVE ANNOTATION
	JMP	MENU		;GO DO MENU
RDS10:
	MVI	A,0CH		;BOX OR B/W?
	ANA	M
	LXI	H,XSWST		;RETICLE SWITCH STATUS
	JZ	RDS15		;NO-AHEAD
	XRA	M		;ELSE-COMPLEMENT
	MOV	M,A		; STATUS BIT
	JMP	XINIT		;REINIT RETICLE
RDS15:
	MOV	A,M		;FETCH STATUS
	ANI	0CH		;SAVE BOX,B/W STAT
	MOV	B,A
	MOV	A,M		;INCR CROSS STATUS
	INR	A
	ANI	3		;MASK
	ORA	B		;COMBINE STATUS
	MOV	M,A
	JMP	XINIT
;
;******************************************************
;
;DISPLAY FIXED DATA SUBROUTINE
;
DSPFD:
	LXI	H,FXDBF		;POINT AT FIXED DATA
	LXI	D,PGMEM+64	;POINT AT PAGE
	LDA	FXDCT		;FETCH COUNT
	MOV	C,A		;COUNT TO BC
	MVI	B,0
	DAD	B		;ADD OFFSET
	LDA	ANOFG		;FETCH ANNO FLAG
	ORA	A		;ANNOTATE?
	JNZ	DFD03		;YES-AHEAD
	XCHG			;POINT AT PAGE
	DAD	B		;ADD OFFSET
	MVI	M,' '		;ELSE-SPACE FILL
	RET
DFD03:
	CPI	0FFH		;ANNOTATE IN ASCII?
	JNZ	DFD15		;NO-AHEAD
	MOV	A,M		;FETCH FIXED DATA
	ANI	7FH		;MASK MSB
	CPI	20H		;CONTROL CHARACTER?
	JNC	DFD05		;NO-AHEAD
	MVI	A,' '		;ELSE-STORE SPACE
	JMP	DFD10
DFD05:
	CPI	60H		;LOWER CASE CHAR?
	JC	DFD10		;NO-AHEAD
	SUI	32		;ELSE-CONV TO UC
DFD10:
	XCHG			;ELSE-POINT AT PAGE
	DAD	B		;ADD OFFSET
	MOV	M,A		;STORE SPACE
	RET
DFD15:
	CPI	0FH		;ANNO TOP IN HEX?
	JNZ	DFD20		;NO-AHEAD
	MOV	A,C		;FETCH COUNT
	CPI	128		;COUNT >=128
	RNC			;YES-RETURN
	JMP	DFD25		;CNV & STR AHEAD
DFD20:
	CPI	0F0H		;ANNO BOT IN HEX?
	RNZ			;NO-RETURN
	MOV	A,C		;FETCH COUNT
	SUI	128		;COUNT >=128?
	RM			;NO-RETURN
DFD25:
	ADD	A		;COUNT*2
	MOV	C,A
	MOV	A,M		;FETCH FIXED DATA
	XCHG			;POINT AT PAGE
	DAD	B		;ADD OFFSET
	MOV	B,A		;SAVE DATA
	RRC			;SHIFT RIGHT (4)
	RRC
	RRC
	RRC
	CALL	DFD30		;C & S 1ST CHAR
	MOV	A,B		;FETCH DATA
DFD30:
	ANI	0FH		;MASK MSB'S
	ADI	'0'		;CONVERT TO ASCII
	CPI	':'		;NUMERIC?
	JC	DFD35		;YES-AHEAD
	ADI	7		;ELSE-ALPHA
DFD35:
	MOV	M,A		;STORE
	INX	H		;BUMP POINTER
	RET
;
;******************************************************
;
;LOAD RETICLE POSITION SUBROUTINE
;
LDXP:
	MVI	A,15H		;SET A=15H
	MOV	B,A
	CMP	L		;POINTER <=15H?
	JC	$+5		;NO-AHEAD
	MVI	B,':'		;ELSE-B=COLON
	MVI	M,'X'		;STORE "X:"
	INX	H
	MOV	A,B		;FETCH B
	CPI	':'		;COLON?
	JNZ	LDX05		;NO-AHEAD
	MOV	M,A		;ELSE-STORE COLON
	INX	H
LDX05:
	MVI	C,3
	CALL	LDCHR		;STORE X POSITION
	MVI	M,' '		;SPACE
	INX	H
	MVI	M,'Y'		;STORE "Y:"
	INX	H
	MOV	A,B		;B=COLON?
	CPI	':'
	JNZ	LDCHR		;NO-STORE POSITION
	MOV	M,A		;ELSE-STORE COLON
	INX	H
	JMP	LDCHR		;STORE Y POSITION
;
;******************************************************
;
;READ FIXED DATA INPUT BOARD SUBROUTINE
;
RDFDI:
	LDA	FXDCT		;FETCH COUNT
	MOV	C,A		;COUNT TO BC
	MVI	B,0
	LXI	H,FXDBF		;POINT AT BUFFER
	DAD	B		;ADD OFFSET
	XCHG			;POINTER TO DE
	IN	FDIST		;INTERRUPT PENDING?
	ANI	1
	RZ			;NO-RETURN
	OUT	FDCMD		;ELSE-RESET INTERRUPT
	IN	FDHSK		;READ NEW DATA
	MOV	B,A		;SAVE IN B
	LXI	H,FDIFG		;POINT AT FLAG
	XRA	A		;PREVIOUS INTERRUPT?
	CMP	M
	RNZ			;YES-RETURN
	CMA			;ELSE-SET FLAG
	MOV	M,A
	MOV	A,C		;FETCH COUNT
	CPI	240		;COUNT >=240?
	RNC			;YES-RETURN
	MOV	A,B		;ELSE-STORE NEW DATA
	STAX	D
	RET
;
;******************************************************
;
;ANGULAR BINARY TO ASCII CONVERSION SUBROUTINE
;
AB2ASC:
	PUSH	D		;SAVE POINTERS
	INX	H
	PUSH	H
	XRA	A		;ZERO F.P. BUFFER
	STA	FPBUF
	STA	FPCTR2		;RESET BYTE COUNTER
	LXI	H,0308H		;INIT LOOP COUNTERS
	SHLD	FPCTR1
ABA05:
	POP	H		;FETCH POINTER
	MOV	A,M		;FETCH DATA
	RAL			;SHIFT LEFT
	MOV	M,A		;STORE SHIFTED DATA
	PUSH	H		;SAVE POINTER
	JNC	ABA10		;IF BIT=0
	LXI	H,FPLUT		;POINT AT TABLE
	LDA	FPCTR2		;FETCH COUNT
	ADD	A		;COUNT*4
	ADD	A
	MOV	E,A		;COUNT*4=OFFSET
	MVI	D,0		;TO DE
	DAD	D		;FORM POINTER
	CALL	LOD		;LOAD FROM TABLE
	LXI	H,FPBUF		;ADD TO BUFFER
	PUSH	H
	CALL	AD
	POP	H		;STORE RESULT
	CALL	STR
ABA10:
	LXI	H,FPCTR2	;BUMP BYTE COUNTER
	INR	M
	LXI	H,FPCTR1	;BYTE DONE?
	DCR	M
	JNZ	ABA05		;NO-BACK
	MVI	M,8		;ELSE-REINIT COUNT
	INX	H		;CONVERSION DONE?
	DCR	M
	JZ	ABA15		;YES-AHEAD
	POP	H		;ADJUST POINTER
	INX	H
	PUSH	H
	JMP	ABA05		;BACK
ABA15:
	POP	H		;RESET SP
	LXI	H,FPBUF		;LOAD RESULT
	CALL	LOD
	LXI	H,ARG		;CONVERT TO ASCII
	CALL	OU
	LXI	H,ARG
	MVI	C,13		;13 BYTES
ABA20:
	MOV	A,M		;FETCH BYTE
	ADI	30H		;ADD BIAS
	MOV	M,A		;STORE ASCII
	INX	H		;BUMP POINTER
	DCR	C		;DONE?
	JNZ	ABA20		;NO-BACK
	LDA	ARG+9		;EXPONENT?
	CPI	'E'
	JNZ	ABA30		;NO-AHEAD
	LDA	ARG+12		;FETCH EXPONENT
	LXI	D,ZROMG		;POINT AT ZEROS
	POP	H		;POINT AT BUFFER
	PUSH	H
	SUI	2DH		;TOTAL ZEROS
	MOV	C,A
	CALL	LDCHR		;STORE LEADING ZEROS
	MVI	A,8		;MAX COUNT
	SUB	C		;CHARS REMAINING
	JZ	ABA25		;IF DONE
	MOV	C,A
	LXI	D,ARG+1		;POINT AT DATA
	LDAX	D		;FETCH 1ST CHAR
	MOV	M,A		;STORE
	INX	H
	DCR	C		;DONE?
	JZ	ABA25		;YES-AHEAD
	INX	D		;BUMP POINTERS
	INX	D
	CALL	LDCHR		;COMPLETE
ABA25:
	POP	D		;RESTORE POINTER
	RET
ABA30:
	LXI	D,ARG+4		;POINT AT DATA
	POP	H		;POINT AT BUFFER
	MVI	C,8		;8 CHARACTERS
	LDAX	D		;FETCH 4TH CHARACTER
	CPI	'.'		;DECIMAL
	JZ	ABA35		;YES-AHEAD
	MVI	M,' '		;ELSE-SPACE
	INX	H
	DCX	D
	DCR	C
	LDAX	D		;FETCH 3RD CHARACTER
	CPI	'.'		;DECIMAL
	JZ	ABA35		;YES-AHEAD
	MVI	M,' '		;ELSE-SPACE
	INX	H
	DCR	C
	DCX	D
	LDAX	D		;FETCH 2ND CHARACTER
	CPI	'.'		;DECIMAL?
	JZ	ABA35		;YES-AHEAD
	MVI	M,'0'		;ELSE-ZERO
	INX	H
	DCR	C
ABA35:
	LXI	D,ARG+1		;POINT AT DATA
	JMP	LDCHR		;STORE IN BUFFER
;
ZROMG:	DB	'  0.0000'
	DB	0,0,0
;
	ORG	$ AND 0FFFCH	;PROTECT BOUNDARY
;
F180:	DB	88H,33H,0FFH,0FFH
FTWO:	DB	82H,00H,00H,00H
;
;******************************************************
;
;BCD TO ASCII CONVERSION SUBROUTINE
;
BCD2A:
	CALL	BCDASC		;CONVERT 1ST BYTE
	MOV	C,A		;SAVE 1ST DIGIT
	CALL	BCDASC		;CONVERT 2ND BYTE
	PUSH	PSW		;SAVE 3RD DIGIT
	MVI	A,'0'		;FIRST DIGIT ZERO?
	CMP	C
	JNZ	B2A05		;NO-AHEAD
	MVI	C,' '		;ELSE-SUPRESS
	CMP	B		;SECOND DIGIT ZERO?
	JNZ	B2A05		;NO-AHEAD
	MVI	B,' '		;ELSE-SUPRESS
B2A05:
	XCHG			;SWAP POINTERS
	MOV	M,C		;STORE 1ST DIGIT
	INX	H
	MOV	M,B		;STORE 2ND DIGIT
	INX	H
	POP	PSW		;STORE 3RD DIGIT
	MOV	M,A
	INX	H
	MVI	M,'.'		;STORE DECIMAL
	INX	H
	CALL	B2ACAS		;CONV & STR FRACTION
	JMP	B2ACAS
;
;******************************************************
;
;20 BIT BINARY TO BCD SUBROUTINE
;
B20BCD:
	MOV	A,M		;FETCH MSB'S
	ANI	0FH		;MASK UPPER NIBBLE
	MOV	D,A		;SAVE IN D
	INX	H		;FETCH NEXT 8 BITS
	MOV	E,M
	INX	H		;FETCH LSB'S
	MOV	H,M
	XCHG
	DAD	H		;LEFT JUSTIFY
	DAD	H
	DAD	H
	DAD	H
	MVI	E,4		;SET BIT COUNTER
	CALL	B2B05		;CONVERT
	MOV	L,D		;BRING IN LSB'S
	MVI	E,16		;COMPLETE 1ST CONV
	CALL	B2B10
	MOV	C,A		;SAVE TENS & UNITS
	DAD	H		;LEFT JUSTIFY
	DAD	H
	MVI	E,14		;DO 2ND CONVERSION
	CALL	B2B05
	MOV	B,A		;SAVE 10^2 & 10^3
	MOV	H,L		;LEFT JUSTIFY
	DAD	H
	MVI	E,7		;DO 3RD CONVERSION
	CALL	B2B05
	MOV	E,A		;SAVE 10^4 & 10^5
	MOV	D,L		;SAVE 10^6
	RET
B2B05:
	XRA	A		;RESET ACC
B2B10:
	DCR	E		;DONE?
	RM			;YES-RETURN
	DAD	H		;SHIFT HL LEFT
	ADC	A		;A=A*2+MSB
	DAA			;CONVERT TO BCD
	JNC	B2B10		;IF A*2+MSB <=99
	INX	H		;INDICATE OVERFLOW
	JMP	B2B10		;CONTINUE
;
;******************************************************
;
;COMPUTE TIME OF DAY COUNT SUBROUTINE
;
CTODCT:
	MVI	C,5		;INITIAL COUNT=5
	LDA	CRPAR		;FETCH PARAMETER
	ANI	7FH		;MASK MSB
	MOV	B,A		;SAVE IN B
	CPI	0		;RESOLUTION TO MINUTES?
	RZ			;YES-RETURN
	MVI	C,8		;SET COUNT=8
	CPI	1		;RESOLUTION TO SECONDS?
	RZ			;YES
CTC05:
	MOV	A,B		;FETCH PARAMETER
	ADD	C		;COMPUTE FOR FRAC SEC
	MOV	C,A		;COUNT TO C
	RET
;
;******************************************************
;
;LOAD DAY OF YEAR SUBROUTINE
;
LDDAY:
	LDA	CRPAR		;JULIAN DISPLAY?
	RLC
	JC	LDY05		;NO-AHEAD
	LXI	D,ASCCLK+1	;POINT AT DAY
	MVI	C,5		;5 CHARACTERS
	JMP	LDCHR		;LOAD JULIAN DAY
LDY05:
	PUSH	H		;SAVE POINTER
	LXI	H,DAYSV		;DAY CHANGE?
	LDA	DAY
	CMP	M
	JZ	LDY10		;NO-AHEAD
	MOV	M,A		;SAVE NEW DAY
	CALL	DMYCV		;UPDATE D-M-Y
LDY10:
	POP	H		;RESTORE POINTER
	LXI	D,PDAY		;POINT AT PRESET DAY
	CALL	B2ACAS		;CONVERT & STORE DAY
	MVI	C,3		;STORE MONTH
	CALL	LDCHR
	CALL	B2ACAS		;CONVERT & STORE YEAR
	MVI	M,' '
	INX	H
	LXI	D,ASCCLK+6	;POINT AT HOUR
	RET
;
;******************************************************
;
;MENU RESET SUBROUTINE
;
MENUR:
	LDA	RETFG		;RETICLE GENERATOR?
	ORA	A
	RNZ			;NO-RETURN
	CMA			;ELSE-DISABLE RETICLE
	OUT	31H
	RET
;
;******************************************************
;
;BORESIGHT RETICLE MENU BRANCH ROUTINE
;
POSRET:
	LXI	H,BXHAIR	;POS RETICLE BRANCH
	JMP	BX05		;AHEAD
CHGBOX:
	LXI	H,BOX		;CHANGE BOX BRANCH
	JMP	BX05
DEFRET:
	LXI	H,XMCHG		;DEF RETICLE BRANCH
BX05:
	LDA	RETFG		;RETICLE IN SYSTEM?
	ORA	A
	JNZ	MENU		;NO-BACK TO MENU
	PCHL			;ELSE-BRANCH
;
;******************************************************
;
;DEFINE ANNOTATION PARAMETER SUBROUTINE
;
DEFANO:
	LXI	H,PGMEM		;POINT AT PAGE
	LXI	D,DANOMG	;POINT AT MESSAGE
	CALL	LDASC		;LOAD HEADER
	CALL	LDASC
	LXI	D,SMSG		;POINT AT EXIT MSG
	CALL	LDASC		;LOAD
	CALL	LDASC
	CALL	LDASC
	CALL	DAN50		;LOAD FORMAT
DAN05:
	IN	STATUS		;WAIT FOR INTR F/F
	RAL
	JNC	DAN05
	CALL	RIFF		;RESET F/F
	LXI	H,FPSST		;POINT AT SWITCH STATUS
	IN	FPSIO		;READ SWITCHES
	ANI	1FH		;ALL OFF?
	JNZ	DAN10		;NO-AHEAD
	MOV	M,A		;ELSE-RESET STATUS
	JMP	DAN05		;BACK
DAN10:
	CMP	M		;CHANGE?
	JZ	DAN05		;NO-BACK
	MOV	M,A		;ELSE-STORE NEW STATUS
	RRC			;MENU?
	JC	MENU		;YES-BACK TO MENU
	RRC			;LEFT?
	JNC	DAN15		;NO-AHEAD
	ANI	4		;ALSO RIGHT
	JZ	DAN05		;NO-BACK
	LXI	H,ANOPAR	;PARAMETER CHANGE?
	LDA	ANOFG
	CMP	M
	JZ	MENU		;NO-BACK TO MENU
	MOV	M,A		;ELSE-WRITE NEW PARAM
	LDA	ANADR
	MVI	C,1
	CALL	WTPAR
	JMP	MENU		;BACK TO MENU
DAN15:
	ANI	3		;UP OR DOWN?
	JZ	DAN05		;NO-BACK
	LXI	H,DAN05		;RET ADDR TO STACK
	PUSH	H
	LXI	H,ANOFG		;POINT AT ANNO FLAG
	MOV	A,M		;FETCH
	ORA	A		;NO ANNOTATION?
	JNZ	DAN20		;NO-AHEAD
	MVI	M,0FH		;ELSE-MAKE IT TOP
	JMP	DAN50		;WRITE NEW MESSAGE
DAN20:
	CPI	0FH		;TOP HEX?
	JNZ	DAN25		;NO-AHEAD
	MVI	M,0F0H		;ELSE-MAKE IT BOT
	JMP	DAN50
DAN25:
	CPI	0F0H		;BOT HEX?
	JNZ	DAN30		;NO-AHEAD
	MVI	M,0FFH		;ELSE-MAKE IT ASCII
	JMP	DAN50
DAN30:
	MVI	M,0		;ELSE-MAKE IT OFF
DAN50:
	LXI	H,ANOFG		;FETCH FLAG
	MOV	A,M
	ORA	A		;NO ANNOTATION?
	LXI	H,PGMEM+40	;POINT AT PAGE
	MVI	C,14		;14 CHARACTERS
	JNZ	DAN55		;NO-AHEAD
	LXI	D,NMSG		;ELSE-STORE MESSAGE
	JMP	LDCHR
DAN55:
	CPI	0FH		;TOP HEX?
	JNZ	DAN60		;NO-AHEAD
	LXI	D,TMSG
	JMP	LDCHR
DAN60:
	CPI	0F0H		;BOT HEX?
	JNZ	DAN65
	LXI	D,BMSG
	JMP	LDCHR
DAN65:
	LXI	D,AMSG		;ELSE-ASCII
	JMP	LDCHR
;
DANOMG:	DB	'FIXED DATA ANNOTATION',0DH
FMSG:	DB	'FORMAT:',0DH
NMSG:	DB	'NO ANNOTATION '
AMSG:	DB	'ASCII         '
TMSG:	DB	'UPPER HALF HEX'
BMSG:	DB	'LOWER HALF HEX'
SMSG:	DB	'PRESS ^ OR V TO SELECT',0DH
EMSG:	DB	'PRESS < AND > TO SAVE',0DH
MMSG:	DB	'PRESS MENU TO EXIT',0DH
;
;******************************************************
;
;DEFINE DATA TYPE ROUTINE
;
DEFDAT:
	LDA	DATPAR		;FETCH DATA TYPE
	CALL	CHGFMT		;CHANGE FORMAT
	LXI	H,DATPAR	;PARAMETER CHANGE?
	CMP	M
	JZ	MENU		;NO-BACK TO MENU
	MOV	M,A		;STORE NEW PARAM
	LDA	DTADR		;ELSE-WRITE NEW
	JMP	DRO05		; PARAMETER
;
DEFROP:
	LDA	ROPPAR		;FETCH RANGE OPTION
	ORI	80H		;SET MSB
	CALL	CHGFMT		;CHANGE FORMAT
	LXI	H,ROPPAR	;PARAMETER CHANGE?
	CMP	M
	JZ	MENU		;NO-BACK TO MENU
	MOV	M,A		;STORE NEW PARAM
	LDA	ROADR		;ELSE-WRITE NEW
DRO05:
	MVI	C,1		;WRITE 1 PARAMETER
	CALL	WTPAR
	JMP	MENU		;BACK TO MENU
;
;******************************************************
;
;CHANGE DATA FORMAT MENU ROUTINE
;
CHGFMT:
	MOV	B,A		;SAVE INPUT FLAG
	LXI	H,PGMEM		;POINT AT PAGE
	LXI	D,DFMSG		;POINT AT MESSAGE
	MVI	C,13		;12 CHARACTERS
	RLC			;RANGE OPT CHANGE?
	JNC	CFT03		;NO-AHEAD
	LDA	ROPFG		;RANGE OPT. IN SYSTEM?
	ORA	A
	JNZ	CFT30		;NO-AHEAD
	LXI	D,ROMSG		;ELSE-CHANGE POINTER
CFT03:
	CALL	LDCHR		;STORE MESSAGE
	CALL	LDDT		;LOAD DATA TYPE
CFT05:
	IN	STATUS		;INTR F/F SET?
	RLC
	JNC	CFT05		;NO-BACK
	CALL	RIFF		;RESET F/F
	LXI	H,FPSST		;POINT AT SW STATUS
	IN	FPSIO		;READ SWITCHES
	ANI	1FH		;ALL OFF?
	JNZ	CFT10		;NO-AHEAD
	MOV	M,A		;ELSE-RESET STATUS
	JMP	CFT05		;BACK
CFT10:
	CMP	M		;CHANGE?
	JZ	CFT05		;NO-BACK
	MOV	M,A		;STORE NEW STATUS
	RRC			;MENU?
	JNC	$+7		;NO-AHEAD
	MOV	A,B		;FETCH DATA FLAG
	ANI	7FH		;MASK MSB
	RET
	MVI	A,7FH		;PARAMETER MASK
	ANA	B		;FETCH PARAMETER
	CPI	'B'		;BINARY DATA?
	JNZ	CFT15		;NO-AHEAD
	MOV	A,B		;ELSE-MAKE IT BCD ("D")
	ANI	80H
	ORI	'D'
	JMP	CFT25		;AHEAD
CFT15:
	JNC	CFT20		;AHEAD IF BCD
	MOV	A,B		;RNG OPT CHG?
	RLC
	JNC	CFT05		;NO-BACK
	MVI	A,80H OR 'B'	;ELSE-ROPPAR ="B"
	JMP	CFT25		;AHEAD
CFT20:
	MOV	A,B		;RANGE OPT CHANGE?
	RLC
	MVI	A,'B'
	JNC	CFT25		;NO-AHEAD
	MVI	A,80H OR ' '	;ELSE-ROPPAR= SPACE
CFT25:
	MOV	B,A		;SET-NEW DATA FLAG
	CALL	LDDT		;UPDATE DATA TYPE
	JMP	CFT05		;BACK
CFT30:
	LXI	D,NROMG		;POINT AT MESSAGE
	CALL	LDASC		;LOAD MESSAGE
	MVI	C,150		;WAIT 2.5 SECONDS
CFT35:
	IN	STATUS		;VSP INTR F/F SET
	RAL
	JNC	CFT35		;NO-BACK
	CALL	RIFF		;RESET F/F
	DCR	C		;TIMEOUT?
	JNZ	CFT35		;NO-BACK
	MVI	A,' '		;SET A=SPACE
	RET
;
LDDT:
	LXI	H,PGMEM+14	;POINT AT PAGE
	MVI	C,6		;6 CHARACTERS
	LXI	D,BINMG		;POINT AT BIN MESG
	MVI	A,7FH		;FETCH PARAMETER
	ANA	B		;BINARY DATA?
	CPI	'B'
	JZ	LDCHR		;YES-STORE "BINARY"
	LXI	D,BCDMG		;OR-STORE "BCD"
	JNC	LDCHR
	LXI	D,NONMG		;ELSE-STORE "NONE"
	JMP	LDCHR
;
DFMSG:	DB	' DATA FORMAT:'
ROMSG:	DB	'RANGE OPTION:'
BINMG:	DB	'BINARY'
BCDMG:	DB	'BCD   '
NONMG:	DB	'NONE  '
NROMG:	DB	' *** NO RANGE OPTION INPUT ***',0DH
;
;******************************************************
;
;		EXECUTIVE TABLES
;
;******************************************************
;
;DEFAULT PARAMETERS TABLE
;
DPART:
NOPAR:	DB	28		;NUMBER OF PARAMETERS
TSTBT:	DB	65H		;TEST BYTE
DEFLM:	DB	10		;MAXIMUM # LINES
DEFLC:	DB	10		;DEFAULT # LINES
DEFLP1:	DB	10,25,40,120,135;DEFAULT LINE POSITIONS
	DB	150,165,180,195,210
DEFCMD:	DB	'M'		;DEFAULT CLOCK MODE
DEFYR:	DB	85H		;DEFAULT YEAR
DEFCR:	DB	3		;DEFAULT RESOLUTION
DEFXMD:	DB	5		;DEFAULT RETICLE
DEFXP:	DW	500,240		;DEFAULT RETICLE POS
DEFBX:	DW	12,4		;DEFAULT BOX SIZE
DEFAN:	DB	0		;DEFAULT ANNOTATION
DEFDT:	DB	'D'		;DEFAULT DATA TYPE
DEFRO:	DB	' '		;DEFAULT RANGE OPTION
;
;PARAMETER ADDRESS TABLE
;
TBADR:	DB	0		;TEST BYTE
LCADR:	DB	2		;LINE COUNT
CMADR:	DB	13		;CLOCK MODE
YRADR:	DB	14		;YEAR
CRADR:	DB	15		;RESOLUTION
XMADR:	DB	16		;RETICLE MODE
XPADR:	DB	17		;RETICLE POSITION
XBADR:	DB	21		;BOX SIZE
ANADR:	DB	25		;ANNOTATION
DTADR:	DB	26		;DATA TYPE
ROADR:	DB	27		;RANGE OPTION
;
;MENU LINE POSITION TABLE
;
MENULP:
	DB	11		;NUMBER OF ENTRIES
	DB	20,38,56,74,92,110
	DB	128,146,164,182,200
;
;MENU ENTRY TABLE
;
MTAB:
	DB	10		;NUMBER OF ENTRIES
	DB	'EXIT MENU',0DH
	DB	'SET CLOCK',0DH
	DB	'FORMAT CLOCK',0DH
	DB	'POSITION TEXT',0DH
	DB	'POSITION RETICLE',0DH
	DB	'CHANGE BOX SIZE',0DH
	DB	'DEFINE ANNOTATION',0DH
	DB	'DEFINE RETICLE',0DH
	DB	'DEFINE DATA',0DH
	DB	'DEFINE RANGE OPTION',0DH
;
;MENU BRANCH TABLE
;
BRTAB:
	DW	EXIT
	DW	SETCK
	DW	FORCK
	DW	POSAN
	DW	POSRET
	DW	CHGBOX
	DW	DEFANO
	DW	DEFRET
	DW	DEFDAT
	DW	DEFROP
;
;******************************************************
;
;		EXECUTIVE DEFINED MEMORY
;
;******************************************************
;
	DSEG			;DATA SEGMENT
;
;FLOATING POINT STORAGE
;
FPBUF:	DS	4		;F.P. BUFFER
ABBUF:	DS	4		;CONVERSION BUFFER
ARG:	DS	13		;F.P. I/O BUFFER
;
;FLAGS ETC. RESET DURING EACH RST0
;
ZROST	EQU	$		;START OF BUFFER
VSPFG:	DS	1		;VSP INTERRUPT FLAG
FXDCT:	DS	1		;FIXED DATA COUNTER
CNVFG:	DS	1		;CONVERT FLAG
AERFG:	DS	1		;DATA READY FLAG
FDIFG:	DS	1		;FIXED DATA INTR FLAG
;
;PARALLEL INPUT DATA BUFFERS
;
AZDAT:	DS	4		;AZIMUTH INPUT BUFFER
ELDAT:	DS	4		;ELEVATION INP BUFFER
RGDAT:	DS	4		;RANGE INPUT BUFFER
;
;ANGULAR BINARY TO ASCII CONVERSION STORAGE
;
FPCTR1:	DS	2		;LOOP COUNTERS
FPCTR2:	DS	1		;BYTE COUNTER
AEIBF:	DS	12		;CONV. INPUT BUFFFER
ZROLN	EQU	$-ZROST		;BUFFER LENGTH
;
;OPTION FLAGS
;
RETFG:	DS	1		;RETICLE FLAG
IRIGFG:	DS	1		;IRIG FLAG
ROPFG:	DS	1		;RANGE OPTION BD FLAG
;
;PARAMETER BUFFER
;
PARSV:
LMPAR:	DS	1		;MAXIMUN # LINES
LCPAR:	DS	1		;ACTUAL # LINES
LP1PAR:	DS	10		;LINE POSITIONS
CMPAR:	DS	1		;CLOCK MODE
YRPAR:	DS	1		;YEAR
CRPAR:	DS	1		;RESOLUTION
XMPAR:	DS	1		;RETICLE MODE
XPPAR:	DS	4		;RETICLE POSITION
XBPAR:	DS	4		;BOX SIZE
ANOPAR:	DS	1		;ANNOTATION
DATPAR:	DS	1		;AZ/EL DATA TYPE
ROPPAR:	DS	1		;RANGE DATA TYPE
;
;MISCELLANEOUS EXECUTIVE STORAGE
;
PONWD:	DS	2		;POWER ON TEST WORD
XSWST:	DS	1		;RETICLE SWITCH STATUS
FPSST:	DS	1		;FRONT PANEL SW STATUS
DAYSV:	DS	1		;DAY SAVE CELL
XCHBF:	DS	6		;RETICLE CHANGE BUFFER
PGPTR:	DS	2		;PAGE POINTER
RDATA:	DS	4		;ENCODER RANGE DATA
ANOFG:	DS	1		;ANNOTATION FLAG
;
;ANNOTATION LINE 2 BUFFER
;
LN2BF:	DS	3		;LINE 2 BUFFER
AZOBF:	DS	8		;AZIMUTH
ELTXT:	DS	4		;ELEVATION TEXT
ELOBF:	DS	8		;ELEVATION
RTXT:	DS	3		;RANGE TEXT
RANGE:	DS	6		;RANGE
;
;******************************************************
;
	END
