/T-4010 PLOTTING ROUTINES   JVZ

/THESE ROUTINES PROVIDE FDIS(I,X,Y) & FJOY(I) FUNCTIONS FOR
/CONTROLLING A TEKTRONIX T-4010 GRAPHICS TERMINAL. THEY ARE
/SIMILAR TO THE ORIGINAL PS/8-FOCAL VERSIONS BUT INCLUDE
/SEVERAL IMPROVEMENTS BY BRUCE BON OF GEO. WASHINGTON UNIV.

/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
	P13=110
	C100=111
	END=134
	FNTABF=355
	GS1=1430
	EVAL=1613
	FNTABL=2155
	OUT=2466
	XI33=2661
	XOUTL=2676
	FNEW=3224
	FIXIT=4453
	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 I TCHK	/SAVE CHARACTER
	TAD TOUT
	DCA 151		/RESTORE PRINTC
	TAD US
	JMS I TTYO	/RESTORE ALPHA MODE
	TAD I TCHK
	PRINTC
	DCA I TCHK	/RESET MODE FLAG
	JMP I FCHK
US,	37
TOUT,	OUT
TCHK,	FDSW
TTYO,	XOUTL


	*FNEW
FDIS,	TAD FCHKP	/PRINTC TRAP
	DCA 151
	FIXIT
	DCA I FCHKP	/SAVE 'I' FOR LATER
	TAD LORD
	SMA SZA CLA
	TAD FDSW	/GRAPHICS MODE?
C40,	SZA CLA
	JMP PLOT	/YES, AND I=+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
	ISZ I FCHKP	/DID WE HAVE I=-1?
	RETURN		/NO
	TAD I XJ33	/YES - RECALL LAST BYTE AND SEND
	JMP .-4		/IT AGAIN TO BRIGHTEN THE SCREEN
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
	DCA HORD	/FLOAT 10-BIT INTEGER
	DCA LORD
	TAD P13
	DCA EXP
	FENT
	FNOR FLAC
	FPUT I PT1	/STASH IT AWAY
	FEXT
	JMP I JLOOK
FJOY,	TAD ESC		/BEGIN WITH 'ESCAPE'
	TYPEC		/WOULD 'PRINCTC' BE BETTER?
	FIXIT		/NOW BRING ARGUMENT INTO AC
	SNA CLA		/+ OR - 1
	TAD J25		/=SUB-ENQ (ONLY FOR T-4010)
	TAD ENQ
	TYPEC		/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
	JMS I XJ33	/SKIP THE CR BYTE -OR ELSE RESTRAP
	CLA		/THIS OPTION AND SAVE TWO WORDS !!
	TAD I FCHKP
	FLOAT		/RETURN KEYBOARD OR STATUS (OR 0)

J25,	25
J37,	37
ENQ,	205
ESC,	233
GS,	235
XJ,	3012
YJ,	3112
XJ33,	XI33
FCHKP,	FCHK
	XOUTL
TYPEC=	JMS I .-1
STVAR=.
	$
