/

/COPYRIGHT (C) 1975

/DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

/

/THIS SOFTWARE IS FURNISHED UNDER A LICENSE FOR USE ONLY

/ON A SINGLE COMPUTER SYSTEM AND MAY BE COPIED ONLY WITH

/THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS

/SOFTWARE, OR ANY OTHER COPIES THEREOF, MAY NOT BE PRO-

/VIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON

/EXCEPT FOR USE ON SUCH SYSTEM AND TO ONE WHO AGREES TO

/THESE LICENSE TERMS.  TITLE TO AND OWNERSHIP OF THE

/SOFTWARE SHALL AT ALL TIMES REMAIN IN DEC.

/

/THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE

/WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS A COM-

/MITMENT BY DIGITAL EQUIPMENT CORPORATION.

/

/DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY

/OF ITS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.

	.EJECT

/

/FORTRAN CALLABLE LIGHT PEN TRACK ROUTINE

/FOR  VT-15 DISPLAY SYSTEM

/

/CHARLES F. DAVIS         SEPT.  1970

/COPYRIGHT 1970, DIGITAL EQUIPMENT CORP.

/MAYNARD, MASS.

/

/ EDIT #001  12/19/72  S. ROOT

/ EDIT #002	10/24/73 S. ROOT UPDATE FOR F4 044

/ EDIT #003	8/3/74	SCR	DRAW OPTION NEEDS ADDT'NL ARG. UNDER F4 044

/				SINCE NO ARRAY DESCRIPTOR BLOCK WITH ARRAY SIZE

/ EDIT #004	8/5/74	SCR	F4 044 CAN'T TELL A PROVIDED ZERO FROM A PROVIDED

/				ARRAY WITH FIRST LOC ZERO. USE PRESENCE OF 5TH

/				ARG. TO TELL DRAWING FROM TRACKING!

/ EDIT #005	8/1/75	SCR	CHECK MF.102=0; TRACK SYMBOL CENTERED

/ EDIT #006	8/20/75	SCR	ERROR .INIT CAL;DRAW FILE HEADR

/ EDIT #007	9/2/75	SCR	COPYRIGHT

/

	.IODEV	10,-3

/

/   REMOVE REFERENCE TO VTIOB IN VTA. HANDLER. CALL TO TRACK

/  WITH OUTSTANDING LTORPB WILL LOOP ON CAL UNTIL LTORPB DONE.

/  VTIOB NO LONGER IN .GLOBL; DZM* VTIOB PRIOR TO LABEL TCK1

/  REMOVED. NO OTHER CHANGES MADE FOR EDIT #001.   S. ROOT.

/

	.GLOBL	TRACK, MF.102, .DA

/

/SYMBOL DEFINITIONS

/

PX=144000		/X-PARAMETER

PY=140000		/Y-PARAMETER

INT=020000		/INTENSIFICATION

/

VI0=420000		/INTENSIFIED VECTORS IN THE DIRECTIONS INDICATED (0-7)

VI1=422000

VI2=424000

VI3=426000

VI4=430000

VI5=432000

VI6=434000

VI7=436000

/

V0=400000		/NON-INTENSIFIED VECTORS IN THE DIRECTIONS INDICATED (0-7)

V1=402000

V2=404000

V3=406000

V4=410000

V5=412000

V6=414000

V7=416000

/

OSETF=210002		/OFFSET OFF

ROTOF=210040		/ROTATE OFF

BKOF=211000		/BLINK OFF

INCROF=200020		/INCREMENT OFF

/

LDNM=234400		/LOAD NAME REGISTER

LPON=210014		/LIGHT PEN ON

LPOF=210010		/LIGHT PEN OFF

/

DNOP=200000		/DISPLAY NOP

DJMP=600000		/DISPLAY JUMP

DJMPI=620000		/DISPLAY JUMP INDIRECT

DJMS=640000		/DISPLAY JMS

DJMSI=660000		/DISPLAY JMS INDIRECT

DSKP=235000		/DISPLAY SKIP

INT7=203600		/INTENSITY LEVEL 7

INT3=202600		/INTENSITY LEVEL 3

	.EJECT

/

/LIGHT PEN TRACK ROUTINE

/VT-15 DISPLAY SYSTEM

/

TRACK	0

	JMS*	.DA		/GETS CALL ARGUMENTS

	JMP	.+6		/JUMP PAST ARGUMENT STORAGE

TX	.DSA	0		/X POSITION

TY	.DSA	0		/Y POSITION

TOPTA	.DSA	0		/OPTION DESIRED

TARRA	.DSA	0		/ARRAY POINTER

TSIZE	.DSA	0		/SIZE OF DRAW ARRAY (EDIT #003)

/OPTIONS	 0-NO CONSTRAINTS

/		 1-MOVEMENT RESTRICTED IN +Y AND -Y DIRECTIONS

/		 2-MOVEMENT RESTRICTED IN +X AND -X DIRECTIONS

/		 3-MOVEMENT RESTRICTED IN -X DIRECTION

/		 4-MOVEMENT RESTRICTED IN -Y DIRECTION

/		 5-MOVEMENT RESTRICTED IN +X DIRECTION

/		 6-MOVEMENT RESTRICTED IN +Y DIRECTION

/

TCK1	LAW	-5

	TAD*	TRACK

	XOR	TRACK

	AND	(7777

	SNA

	DZM	TARRA		/EDIT #004, TELL TRACK FROM DRAW

/

	LAC	(PX		/SET INITIAL POSITION TO BEGIN TRACK

	DAC	TNAM2		/INITIALIZE TNAM2 TO VALUE OTHER THAN  0-7

	TAD*	TX		/GET INITIAL X VALUE

	DAC	TRCK1		/DEPOSIT POINT X IN THE DISPLAY FILE

	LAC	(PY!INT		/GET INTENSIFIED POINT Y INSTRUCTION

	TAD*	TY		/GET INITIAL Y VALUE

	DAC	TRCK1+1		/DEPOSIT POINT Y IN THE DISPLAY FILE

TCK2	LAC*	MF.102		/GET POINTER TO BOTTOM OF MAIN FILE

	SNA			/SKIP IF MAIN FILE RUNNING  ##005##

	JMP*	TRACK		/NO, SO JUST EXIT           ##005##

	DAC	TTEMP1		/STORE POINTER TO MAIN FILE BOTTOM

	DAC	TTEMP2

	DAC	TTEMP3

	ISZ	TTEMP1		/MOVE POINTER TTEMP1 TO BOTTOM +1

	ISZ	TTEMP3		/MOVE POINTER TTEMP3 TO BOTTOM +2

	ISZ	TTEMP3

	LAC*	TTEMP2		/MOVE DJMP* TOP+1 DOWN ONE LOCATION

	DAC*	TTEMP1

	LAC	TRCKA		/GET ADDRESS OF TRACK DISPLAY FILE

	DAC*	TTEMP3

	LAC	TTEMP3

	AND	(17777		/MASK 13 BITS TO GET ADDRESS

	TAD	(DJMSI		/CREATE DJMS* TO TRACK DISPLAY FILE

	DAC*	TTEMP2		/PUT THE DJMS* IN THE MAIN FILE

TCK3	LAC*	TOPTA		/USES OPTION ARGUMENT AS AN INDEX VALUE

	TAD	(TDISP		/GET BASE ADDRESS OF DISPATCH TABLE

	DAC	TTEMP3		/STORES INDEXED DISPATCHED TABLE ADDRESS

	LAC	TSIDEX		/GET LOAD NAME REGISTER INSTRUCTION (167)

	JMP*	TTEMP3		/JUMPS TO DISPATCH TABLE

TTEMP1	0			/POINTER TO MAIN FILE

TTEMP2	0			/POINTER TO FOLLOWING MAIN FILE LOCATION

TTEMP3	0

	.EJECT

/

/DISPATCH TABLE TO JUMP TO USER SPECIFIED OPTION

/THE OPTIONS SET UP THE VECTOR TABLE TO RESTRICT MOVEMENT

/

TDISP	JMP	TARSET		/OPTION DISPATCH TABLE, OPTION 0

TOPT1	JMP	THORZ		/OPTION 1

	JMP	TVERT		/OPTION 2

	JMP	TDIR0		/OPTION 3

	JMP	TDIR2		/OPTION 4

	JMP	TDIR4		/OPTION 5

	JMP	TDIR6		/OPTION 6

TARSET	LAC	TARRA		/IS TRACKING OR DRAWING (EDIT #004)

	SNA			/NON-ZERO IF DRAW PRESENT

	JMP	TREAD		/JUMP TO FIRST READ IF ARRAY NOT PRESENT

	DAC	TARPT0		/SETS POINTER TO ARRAY TOP

	TAD	(+2		/POINT TO SETPOINT POSITION IN FILE

	DAC	TARPT1		/SETS POINTER TO WORD 3 OF ARRAY

	LAC	(4		/(EDIT #006)INIT FILE TOP POINTER

	DAC*	TARPT0		/(EDIT #006)

TCK4	LAC	TRCK1		/SET ORIGIN OF THE TRACKING POINT IN THE USERS ARRAY

	DAC*	TARPT1		/SET X POSITION

	ISZ	TARPT1

	LAC	TRCK1+1

	DAC*	TARPT1		/SET Y POSITION

	LAC	TARPT1

	DAC	TARPT2

	ISZ	TARPT1

TCK5	LAC	(+1

	TAD	TARPT0		/GET ADDRESS OF ARRAY LOCATION 1, FIRST ARRAY ELEMENT

	DAC	TRCK3

	AND	(17777)

	TAD	(DJMPI		/COMBINE ADDRESS WITH DJMPI INSTRUCTION

	DAC*	TARPT1		/DEPOSIT DJMPI INTO ARRAY WORD 3

	LAC	TRCK3A		/GET DJMSI  TRCK3 INSTRUCTION

	DAC	TRCK2		/DEPOSIT JMSI TO ARRAY+1 IN TRCK DISPLAY FILE

/				/EDIT (#003) REMOVE 3 LINES

	LAW	-6		/COMPUTE CONTROL COUNT FROM ARRAY SIZE

	TAD*	TSIZE		/USER SUPPLIED SIZE (EDIT #003)

	AND	(17777)		/GET THE ARRAY SIZE, LAST 13 BITS

	SPA!CMA			/MAKE NEGATIVE COUNT, SKIP IF OK (EDIT #004)

	JMP	TMESS		/FLAG ILLEGAL COUNT WITH FULL MESS (EDIT #004)

	DAC	TARCNT		/COUNTER TO TEST AVAILABLE LOCATIONS

	DAC	TSTCNT		/COUNTER FOR INITIALIZATION 

	LAC	TARPT1

	DAC	TTEMP3		/SET UP INITIALIZATION POINTER

	LAC*	TARPT1

	ISZ	TTEMP3

	DAC*	TTEMP3		/FILL UP USERS VECTOR ARRAY WITH DJMPI TO TOP+1

	ISZ	TSTCNT

	JMP	.-3

	JMP	TREAD		/GO TO FIRST READ

	.EJECT

/

/ROUTINES TO SET UP NAME REGISTERS IN TRACK DISPLAY FILE

/AS DETERMINED BY OPTION CALLED FOR

/SET UP PERFORMED BY INTERCHANGING NAME REGISTERS

/

TDIR0	DAC	TSIDE4		/RESTRICTS MOVEMENT IN -X DIRECTION

	LAC	TSIDE2

	DAC	TSIDE3

	LAC	TSIDE6

	DAC	TSIDE5

	JMP	TARSET

/

TDIR2	DAC	TSIDE6		/RESTRICTS MOVEMENT IN -Y DIRECTION

	LAC	TSIDE4

	DAC	TSIDE5

	LAC	TSIDE0

	DAC	TSIDE7

	JMP	TARSET

/

TDIR4	DAC	TSIDE0		/RESTRICTS MOVEMENT IN +X DIRECTION

	LAC	TSIDE2

	DAC	TSIDE1

	LAC	TSIDE6

	DAC	TSIDE7

	JMP	TARSET

/

TDIR6	DAC	TSIDE2		/RESTRICTS MOVEMENT IN +Y DIRECTION

	LAC	TSIDE0

	DAC	TSIDE1

	LAC	TSIDE4

	DAC	TSIDE3

	JMP	TARSET

/

THORZ	DAC	TSIDE2		/RESTRICTS MOVEMENT IN +Y AND -Y DIRECTIONS

	DAC	TSIDE6

	LAC	TSIDE0

	DAC	TSIDE1

	LAC	TSIDE4

	DAC	TSIDE3

	JMP	TDIR2+1

/

TVERT	DAC	TSIDE0		/RESTRICTS MOVEMENT IN +X AND -X DIRECTIONS

	DAC	TSIDE4

	LAC	TSIDE2

	DAC	TSIDE1

	LAC	TSIDE6

	DAC	TSIDE7

	JMP	TDIR0+1

	.EJECT

/

/MOVE TABLE CONTAINING THE X AND Y DISPLACEMENT

/VALUES TO MOVE THE TRACKING POINT

/(POINT IN CENTER OF OCTAGON)

/DISPLACEMENTS ARE 2 RASTOR UNITS IN + OR - DIRECTION

/16 ENTRIES, AN X AND Y FOR EACH AXIS DIRECTION

/

TMVPT1	TMOVE			/POINTER TO TOP OF MOVE TABLE

TMVPT2	0			/FLOATING MOVE TABLE POINTER

/

TMOVE	2			/X-DISPLACEMENT

	0			/Y-DISPLACEMENT

	2

	2

	0

	2

	-2

	2

	-2

	0

	-2

	-2

	0

	-2

	2

	-2

/

/VECTOR TABLE TO BUILD OPTIONAL TRACKING DISPLAY FILE

/8 ENTRIES, ONE FOR EACH AXIS DIRECTION

/

TVCPT1	TVECT			/POINTER TO TOP OF VECTOR TABLE

TVCPT2	0			/FLOATING VECTOR TABLE POINTER

/

TVECT	VI0!2			/INTENSIFIED VECTOR, 2 RASTOR UNITS IN DIRECTION 0

	VI1!2

	VI2!2

	VI3!2

	VI4!2

	VI5!2

	VI6!2

	VI7!2

	.EJECT

/

/THE FOLLOWING MACRO READS SPECIFIED REGISTERS

/AND SERVICES SPECIFIED INTERRUPTS

/SERVICES PUSHBUTTON AND LIGHT PEN INTERRUPTS, AND READS NAME REGISTER

TREAD	DZM	TBUFF			/ZERO FIRST WORD OF ARGUMENT RETURN BUFFER

	.READ	10,7,TBUFF,1

	300100

/

TCK7	LAC	TBUFF			/GET DESCRIPTOR WORD

	SNA				/SKIP WHEN READ EXECUTED, TBUFF NON ZERO

	JMP	.-2			/READ TEST LOOP

	AND	(200000)		/TEST FOR PUSHBUTTON

	SZA				/SKIP IF ZERO, NO PUSHBUTTON HIT

	JMP	TEXIT			/EXIT TRACK IF PUSHBUTTON HIT

	LAC	TBUFF+1			/GET NAME REGISTER

	TAD	(-170			/TEST FOR NON TRACK NAME REGISTER

	SPA				/SKIP IF POSITIVE, VALID NAME REGISTER

	JMP	TREAD			/GO TO NEXT READ IF INVALID NAME REG

	DAC	TNAM1			/UPDATE NAME REGISTER STORAGE

	TAD	TVCPT1			/ADD VECTOR TABLE BASE ADDRESS

	DAC	TVCPT2			/STORES INDEXED VECTOR TABLE POINTER

TCK11	LAC	TNAM1			/GET INDEX VALUE (0-7)

	CLL!RAL				/DOUBLE THE VALUE

	TAD	TMVPT1			/ADD MOVE TABLE BASE ADDRESS

	DAC	TMVPT2			/STORES INDEXED MOVE TABLE POINTER

	LAC*	TMVPT2			/GET CHANGE IN X

	TAD	TRCK1			/UPDATE X POSITION

	DAC	TRCK1			/RETURN UPDATED VALUE

	ISZ	TMVPT2			/INCREMENT MOVE TABLE POINTER TO Y VALUE

	LAC*	TMVPT2			/GET CHANGE IN Y

	TAD	TRCK1+1			/UPDATE Y POSITION

	DAC	TRCK1+1			/RETURN UPDATED VALUE

TCK12	LAC	TARRA			/(EDIT #004) TRACK OR DRAW

	SNA

	JMP	TREAD			/GO TO NEXT READ IF NO ARRAY

	LAC	TNAM1			/TEST DIRECTION OF THIS HIT

	SAD	TNAM2			/AGAINST DIRECTION OF LAST HIT

	JMP	TSAME			/HITS IN SAME DIRECTION, COMBINE

	DAC	TNAM2			/IF NOT SAME UPDATE LAST NAME REG

TCK13	LAC*	TVCPT2			/GET VECTOR FROM TABLE

	DAC*	TARPT1			/DEPOSIT IN USER VECTOR ARRAY

	ISZ*	TARPT0			/UPDATE LENGTH, ARRAY WORD ONE

	ISZ	TARCNT			/CHECK FOR ARRAY OVERFLOW

	SKP				/UNCONDITIONAL SKIP

	JMP	TMESS			/IF OVERFLOW OCCURS TYPE MESSAGE ANE EXIT

	ISZ	TARPT1			/MOVE ARRAY POINTER 1 TO NEXT LOCATION

	ISZ	TARPT2			/MOVE ARRAY POINTER 2 TO NEXT LOCATION

	JMP	TREAD			/GO TO NEXT READ

	.EJECT

/

/THIS ROUTINE COMBINES A TWO RASTOR UNIT VECTOR WITH THE LAST

/VECTOR IN THE USER ARRAY, WHEN TWO OR MORE LIGHT PEN

/HITS HAVE OCCURED IN THE SAME DIRECTION, ONE AFTER THE OTHER

/

TSAME	LAC	(+2			/SET AC=+2			

	TAD*	TARPT2			/ADD 2 TO MAGNITUDE OF LAST ARRAY VECTOR

	DAC*	TARPT2			/REDEPOSIT THE LENGTHENED VECTOR

	JMP	TREAD			/GO TO NEXT READ

/

/

/THIS ROUTINE PRINTS A MESSAGE TO THE USER WHEN HIS

/VECTOR DISPLAY ARRAY HAS FILLED--AND THEN EXITS TRACK

/

TMESS	.INIT	-3,1,0			/(EDIT #006)INITIALIZE TTY

	.WRITE	-3,2,TMB1,16

	.WAIT	-3

	JMP	TEXIT

	

TMB1	TMB2-TMB1/2*1000+2

	0

	.ASCII "ARRAY OVERFLOW"<015>

TMB2=.

	.EJECT

/

/SUBROUTINE TO RESTORE NAME REGISTERS

/WHEN EXITING FROM TRACK

/

TREST	0				/SUBROUTINE TO RESTORE NAME REGISTERS

	LAC	(-10			/SET LOOP COUNTER TO -10 OCTAL

	DAC	TNAM1

	LAC	(TSIDE0			/SET POINTER TO FIRST LOAD NAME REGISTER INSTRUCTION

	DAC	TVCPT2

	LAC	TSIDEX

	DAC*	TVCPT2

	ISZ*	TVCPT2

	LAC*	TVCPT2

	ISZ	TVCPT2

	ISZ	TVCPT2

	ISZ	TVCPT2

	ISZ	TVCPT2

	ISZ	TNAM1

	JMP	.-10

	JMP*	TREST

/

/

/

/THIS ROUTINE EXITS FROM TRACK AND

/RETURNS CONTROL TO CALLING PROGRAM

/

TEXIT	JMS	TREST			/GO TO SUBROUTINE, RESTORES NAME REGISTERS

	LAC*	TTEMP1

	DAC*	TTEMP2			/REMOVES LINK TO TRACK DISPLAY FILE

	LAC	TRCK1			/GET X-PARAMETER FROM DISPLAY FILE

	AND	(1777)

	DAC*	TX			/RETURN FINAL X POSITION

	LAC	TRCK1+1			/GET Y-PARAMETER FROM DISPLAY FILE

	AND	(1777)

	DAC*	TY			/RETURN FINAL Y POSITION

TCK15	LAC	(DNOP			/GET DNOP INSTRUCTION

	DAC	TRCK2			/REMOVE LINK FROM TRACK DISPLAY FILE TO USER ARRAY

	JMP*	TRACK			/RETURN TO CALLING PROGRAM

	.EJECT

        .LTORG

	.EBREL

TRCKA   TRCK

TRCK3A  DJMSI   TRCK3

TARCNT	0		/COUNTS AVAILABLE ARRAY LOCATIONS

TARPT0	0		/POINTER TO TOP OF USER ARRAY

TARPT1	0		/POINTER TO USER ARRAY, FOLLOWS BEHIND TARPT2

TARPT2	0		/FLOATING POINTER TO USER ARRAY

TSTCNT	0		/INITIALIZATION COUNTER

TNAM1	0		/STORES NAME REGISTER OF PRESENT LIGHT PEN HIT

TNAM2	0		/STORES NAME REGISTER OF LAST LIGHT PEN HIT

TBUFF	.BLOCK 3	/.READ BUFFER

/

/

/

/NOTES:

/THE INITIAL X,Y, POSITION LIMITS  <0...1023> DECIMAL, <0...1777> OCTAL

/THE FINAL X,Y, POSITION LIMITS  <24...999> DECIMAL, <30...1747> OCTAL

/CAUSE OF THE LIMIT DIFFERANCE:

/THE TRACKING PATTERN IS UNABLE TO BE MOVED WITHIN 24 DECIMAL RASTOR 

/UNITS OF THE SCREEN EDGE BECAUSE INTENSIFIED VECTORS DISAPPEAR WHEN 

/ANY PART OF THE VECTOR VIOLATES A SCREEN EDGE.

/

	.EJECT

/

/TRACK RESIDENT DISPLAY FILE

/PUTS TRACKING POINT AND SURROUNDING OCTAGON ON THE DISPLAY

/

TRCK	0		/STORES RETURN ADDRESS

	OSETF!ROTOF!BKOF!LPON

TRCK1	DNOP		/X-POSITION OF TRACK POINT

	DNOP		/Y-POSITION OF TRACK POINT

	INT7!INCROF	/SET INTENSITY LEVEL 7

	V0!30

	V6!12

TSIDE0	LDNM!170	/LOAD NAME REGISTER

	565124

	565124

	564522

TSIDE1	LDNM!171

	566733

	566532

	566532

TSIDE2	LDNM!172

	571144

	571144

	570542

TSIDE3	LDNM!173

	572753

	572552

	572552

TSIDE4	LDNM!174

	574564

	574564

	574562

TSIDE5	LDNM!175

	576773

	576572

	576572

TSIDE6	LDNM!176

	561104

	561104

	560502

TSIDE7	LDNM!177

	562713

	562512

	562512

TSIDEX	LDNM!167

	INT3

	LPOF		/LIGHT PEN OFF

	V4!30		/RETURN BEAM TO CENTER OF SYMBOL  ##005##

	V2!12		/SO ITEM CAN FOLLOW TRACKING      ##005##

TRCK2	DNOP		/STORES DJMSI TO ARRAY+1, IF ARRAY PRESENT

	DJMPI	TRCK	/RETURNS TO MAIN FILE

TRCK3	0		/POINTER TO ARRAY WORD 2, FOR INDIRECT ADDRESSING

	.END
