/T-4002 PLOTTING ROUTINES   JVZ

/THESE ROUTINES PROVIDE FDIS(I,X,Y) & FJOY(I) FUNCTIONS FOR
/CONTROLLING A TEKTRONIX T-4002 GRAPHICS TERMINAL. THEY ARE
/ADAPTED FROM PS/8 FOCAL VERSIONS $ HAVE NOT BEEN TESTED !!
/IT APPEARS THAT THEY WILL NOT WORK FOR THE T-4010 TERMINAL

/FLOATING POINT INSTRUCTIONS

	FENT=4407
FIXMRI	FPUT=6000
FIXMRI	FNOR=7000
	FEXT=0000
	FIXTAB

/FOCAL SYMBOLS:

	FIELD 1
	PT1=30
	AC1H=41
	AC1L=42
	FLAC=44
	EXP=44
	HORD=45
	LORD=46
	EFOP=56
	C214=73
	P13=110
	C100=111
	END=134
	FNTABF=355
	GS1=1430
	EVAL=1613
	FNTABL=2155
	OUT=2466
	XI33=2661
	FIXIT=4453
	TYPEC=4463
	PUSHJ=4540
	PRINTC=4551
	FLOAT=5512
	RETURN=5536

	*END
	STVAR		/FEWER VARIABLES

	*FNTABF+17
	FJOY
	*FNTABF+22
	FDIS

	*FNTABL+17
	"J^2+"O^2+"Y
	*FNTABL+22
	"D^2+"I^2+"S
	*1142		/OVERLAY OLD FDIS
FCHK,	0		/PRINTC CALL CHANGES TO ALPHA MODE
	DCA TM		/SAVE CHARACTER
	TAD TOUT
	DCA 151		/RESTORE PRINTC
	TAD US
	TYPEC		/RESTORE ALPHA MODE
	TAD TM
	PRINTC
	DCA I .+2	/RESET MODE FLAG
	JMP I FCHK
	FDSW
TM,	0
US,	37
TOUT,	OUT


	*3224
FDIS,	TAD FCHKP	/PRINTC TRAP
	DCA 151
	FIXIT		/BRING 'I' INTO THE AC
	SMA SZA CLA
	TAD FDSW	/GRAPHICS MODE?
C40,	SZA CLA
	JMP PLOT	/YES, AND I=+1
	TAD LORD
	SPA CLA		/CHECK I AGAIN
	CMA		/CREATE FS=GS-1
	TAD GS
	TYPEC		/SET GRAPHICS MODE
	DCA XHIGH
	DCA YHIGH
PLOT,	PUSHJ		/EVALUATE X
	    EVAL-1
	FIXIT
	DCA XTM		/SAVE X FOR LATER
	PUSHJ
	    EVAL-1
	FIXIT
	JMS HIGH	/CHECK FIRST BYTE
YHIGH,	0
	TAD C40		/FILL IN TAG BIT
	TYPEC
	TAD XTM
	JMS HIGH	/SEND X BYTES
XHIGH,	0
	TYPEC
	RETURN
FDSW=.
HIGH,	0		/CHECK 1ST & 3RD BYTES
	DCA AC1H	/SAVE COORDINATE
	TAD AC1H
	CLL RAR
	RTR
	RTR
	AND J37		/TOP 5 BITS
	TAD C40		/PLUS TAG BIT
	DCA AC1L
	TAD AC1L
	TAD I HIGH
	SNA CLA		/SAME AS LAST TIME?
	JMP HXIT	/YEP
	TAD AC1L	/NOPE
	TYPEC
	TAD AC1L
	CIA
	DCA I HIGH	/SAVE FOR NEXT COMPARISON

HXIT,	ISZ HIGH
	TAD AC1H
	AND J37		/STRIP LOWER 5 BITS
	TAD C100	/ADD TAG BIT
	JMP I HIGH

XTM=.
JLOOK,	0		/VARIABLE LOOKUP FOR FJOY
	DCA EFOP	/SAVE NAME
	PUSHJ
	    GS1		/LOOK IT UP
	JMS I XJ33	/READ FIRST BYTE
	AND J37
	CLL RAL
	RTL
	RTL
	DCA HORD	/SAVE TEMPORARILY
	JMS I XJ33	/READ SECOND BYTE
	AND J37
	TAD HORD
	JMS JFLOAT	/CHANGE TO F.P.
	FENT
	FNOR FLAC
	FPUT I PT1	/STASH IT AWAY
	FEXT
	JMP I JLOOK

JFLOAT,	0		/FLOAT 10-BIT INTEGER
	DCA HORD
	DCA LORD
	TAD P13
	DCA EXP
	JMP I JFLOAT
FJOY,	FIXIT		/BRING ARGUMENT INTO AC
	SNA CLA		/+ OR - 1
	TAD C214	/C214=DC1-ENQ (ONLY FOR T-4002)
	TAD J5		/=ENQ
	PRINTC		/TURN ON THE CURSOR
	TAD LORD
	SPA SNA CLA	/CHECK I AGAIN
	JMS I XJ33	/READ STATUS OR KEYBOARD
	DCA I FCHKP	/SAVE TO RETURN AS VALUE OF FJOY
	TAD XJ
	JMS JLOOK	/PICK UP THE VARIABLE 'XJ'
	TAD YJ
	JMS JLOOK
	TAD J37
	TYPEC		/RETURN TO ALPHA MODE
	TAD I FCHKP
	FLOAT		/RETURN KEYBOARD OR STATUS

J5,	5
J37,	37
GS,	235
XJ,	3012
YJ,	3112
XJ33,	XI33
FCHKP,	FCHK
STVAR=.
	$
