$TITLE('HEI516 DATA FILE') DEBUG PAGEWIDTH(80)
$NOSYMBOLS
;
;******************************************************
;
	NAME	DAT516
	PUBLIC	VESCH,VESBT,RESPAR,BKPM,DIAPM,EOSPM
	PUBLIC	ANOPM,LCTPM,ROMCT,ROMEND,RAMST,ESCBF
	PUBLIC	RETPM,DIASU,HPMAX,SYSP
	EXTRN	ESBAD,ESCRA,POSCUR,CLRPG,CLRELN,CLRCUR
	EXTRN	ESCEFG,RDENC,ENIPT,LDCON,EXDIA,EDFLG
	EXTRN	XSTAT,ESCFG,RESCB,ENFLG,INTFG
	EXTRN	INESB,ESCR,ESCB,ESCF,DIAST,LDAPB
	EXTRN	OUTCT,OUTBF,OUTPT,LDMSG,CRLF,CMDRG
	EXTRN	PGMEM,ANNOR,TXON
;	DATE	6 SEP 85
	CSEG
;
;******************************************************
;
;VALID ESCAPE SEQUENCE CHARACTERS
;
VESCH:	DB	'EHJKQUYRBFTI',0DH
;
;******************************************************
;
;VALID ESCAPE SEQUENCE BRANCH TABLE
;
VESBT:
	DW	VESE		;ESC E
	DW	VESH		;ESC H
	DW	CLRPG		;ESC J
	DW	CLRELN		;ESC K
	DW	VESQ		;ESC Q
	DW	VESU		;ESC U
	DW	VESY		;ESC Y
	DW	ESCR		;ESC R
	DW	ESCB		;ESC B
	DW	ESCF		;ESC F
	DW	VEST		;ESC T
	DW	VESI		;ESC I
;
;******************************************************
;
;ESCAPE SEQUENCE ROUTINES
;
VESH:				;HOME CURSOR
	LXI	H,0		;CURSOR POS=0,0
	JMP	POSCUR
;
VESQ:
	CMA			;SET DIAGNOSTIC FLAG
	STA	DIAPM
	RET
;
VEST:
	LDA	INTFG		;GPIB INTERFACE?
	ORA	A
	RZ			;YES-IGNOR
	CALL	LDAPB		;ELSE-LOAD BUFFER
	SHLD	OUTPT		;STORE POINTER
	STA	OUTCT
	JMP	TXON		;ENABLE TRANSMITTER
;
VESU:
	JNZ	VESU1		;IF POINTER <> 0
	INR	M		;ELSE-BUMP POINTER
	RET			;WAIT FOR PARAMETER
VESU1:
	MVI	M,0		;RESET POINTER
	MOV	A,C		;FETCH PARAMETER
	ANI	3		;REMOVE BIAS
	STA	BKPM		;SET/RESET PARAMETER
	JMP	CLRCUR		;CLEAR CURSOR
;
VESY:
	INR	M		;BUMP POINTER
	MVI	A,2		;WAIT FOR 2 CHARS
	LXI	H,VEY05		;THEN VEY05
	JMP	INESB
VEY05:
	LDAX	D		;FETCH LINE
	INX	D
	SUI	32		;REMOVE BIAS
	MOV	H,A		;H <- LINE
	LDAX	D		;FETCH COLUMN
	SUI	32		;L <- COLUMN
	MOV	L,A
	JMP	POSCUR		;POSITION CURSOR
;
VESE:
	LDA	EDFLG		;ENCODER IN SYSTEM?
	INR	A
	RNZ			;NO-RETURN
	STA	ENIPT		;ELSE-RESET POINTER
	CMA			;SET FLAG
	STA	ESCEFG
	INR	M		;BUMP POINTER
	LXI	H,RDENC		;STORE NEW BRANCH ADDR
	SHLD	ESBAD
	RET
;
VESI:
	INR	M		;BUMP POINTER
	MVI	A,2		;WAIT FOR 2 CHARACTERS
	LXI	H,VEI05		;THEN VEI05
	JMP	INESB
VEI05:
	LDAX	D		;FETCH PARAM CODE
	INX	D
	LXI	H,EOSPM		;POINT AT PARAMETERS
	CPI	'E'		;SET EOS PARAMETER?
	JZ	VEI10		;YES-AHEAD
	INX	H
	CPI	'A'		;SET ANNO PARAMETER?
	JZ	VEI10
	INX	H
	CPI	'L'		;SET LINE PARAMETER?
	RNZ			;NO-IGNOR OTHERS
VEI10:
	LDAX	D
	ANI	3		;MASK MSB'S
	MOV	M,A		;STORE PARAMETER
	RET
;
;*****************************************************
;
;EXTENDED DIAGNOSTICS ROUTINE
;
EXTD:
	LDA	INTFG		;GPIB INTERFACE?
	ORA	A
	JNZ	EXD05		;NO-AHEAD
	LDA	DIAST		;FETCH MEMORY STATUS
	ORI	40H		;SET RSV BIT
	OUT	2BH		;GENERATE SRQ
	RET
EXD05:
	LDA	OUTCT		;OUTPUT IN PROCESS?
	ORA	A
	JNZ	EXD05		;YES-WAIT
	LXI	H,OUTBF		;POINT AT BUFFER
	SHLD	OUTPT		;STORE POINTER
	LXI	D,STMSG		;POINT AT MESSAGE
	LDAX	D		;FETCH COUNT
	INR	A		;ALLOW FOR STATUS
	MOV	B,A		;SAVE IN B
	CALL	LDMSG		;LOAD MESSAGE
	LDA	DIAST		;FETCH MEMORY STATUS
	ORI	30H		;ADD ASCII BIAS
	MOV	M,A		;STORE
	INX	H
	MOV	C,B		;COUNT TO C
	CALL	CRLF		;INSERT CR/LF
	STA	OUTCT		;STORE COUNT
	JMP	TXON		;ENABLE TRANSMITTER
;
STMSG:	DB	7,'STATUS='
;
;*****************************************************
;
;DIAGNOSTICS SETUP ROUTINE
;
DIASU:
	LXI	H,PGMEM		;CLEAR PAGE
	MVI	A,16
	CALL	ANNOR
	LXI	H,EXTD		;STORE BRANCH ADDRESS
	SHLD	EXDIA
	RET
;
;*****************************************************
;
;RESET ESCAPE SEQUENCE PARAMETERS
;
RESPAR:
	CALL	RESCB		;RESET ESCAPE BUFFER
	XRA	A
	LXI	H,DATBF		;POINT AT BUFFER
	MVI	C,DATLN		;C <- LENGTH
	JMP	LDCON		;RESET
;
;******************************************************
;
;SYSTEM PARAMETERS
;
SYSP:	DB	21,'MODEL:516B  REV:AUG85',0DH
HPMAX:	DW	999,479
RAMST:	DW	3C00H		;START OF RAM
ROMCT:	DB	'2'		;ROM CHIP COUNT
ROMEND:	DB	0FFH		;ROM MOD 8 CHECKSUM
;
;******************************************************
;
;MODULE DEFILED MEMORY
;
	DSEG
;
DATBF	EQU	$
BKPM:	DS	1		;BLINK CURSOR PARAM
DIAPM:	DS	1		;DIAGNISTICS PARAM
EOSPM:	DS	1		;EOS PARAMETER
ANOPM:	DS	1		;ANNOTATION PARAMETER
LCTPM:	DS	1		;LINE COUNT PARAMETER
RETPM:	DS	1		;RETICLE FORM PARAMETER
ESCBF:	DS	7		;ESCAPE SEQ BUFFER
DATLN	EQU	$-DATBF
;
	END
