	.SYSID <	.TITLE XYU >,< 036>

/

/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

/

/  EDIT #029 11/6/73 S. ROOT  MAKE BUFFER AND TCB IN DOS

/  EDIT #030 1/1/74 P. B. PALETHORPE CONDITIONALIZE CODE FOR XY11/XY311

/                                   PLOTTER INTERFACE

/  EDIT #031	2/23/74	SCR	FIX FOR XY311 CHARSETUP KILLING PEN SETTING

/ EDIT #032	6/13/74	SCR	1. DISABLE XTRA .INIT'S FROM FORTRAN

/				2 ALLOW ZERO LENGTH LINE FOR POINTS

/ EDIT #033	9/8/75	SCR	COPYRIGHT;2^14;MULTI-LINE;BUG;XVM

/ EDIT #034	9/9/75	SCR	EXPERIMENT WITH CHAR. SPACING

/ EDIT #035	9/10/75	SCR	REDO #33 ON LONG LINES
/ EDIT #036	9/29/75	SCR	IOPS12 IF UC15 GONE

/

APISLT=65		/API VECTOR

	.IFUND	APILVL	/(#33)GREATER FLXIBILITY

APILVL=3		/API LEVEL, AND DEFINE SKIP AND CLEAR

	.ENDC

XYSF=APILVL*20+706101	/SKIP ON INTERRUPT

SIOA=706001	/SKIP IF PDP-11 CAN TAKE A REQUEST

LIOR=706006	/SEND TCB ADDR IN AC TO PDP-11

CAPI=APILVL*20+706104	/CLEAR INTERRUPTING FLAG

/

/

/CONDITIONAL ASSEMBLY PARAMETERS

/

/THESE ARE USED TO GENERATE THE PEN SELECTION CODE FOR THE

/XY311 INTERFACE AND TO GENERATE THE DEFAULT CHARACTER SIZES

/SHOWN IN THE TABLE BELOW IN TENTHS OF AN INCH AOR IN MM.

/

/		XY11	XY311

/	1/10

/      INCHES	2	1.25

/

/	MM	5	3

/

/

/PL311 DEFINED GENERATES CODE FOR THE XY311 INTERFACE

/PL311 UNDEFINED GENERATES CODE FOR THE XY11 INTERFACE

/UNITS DEFINED GENERATES CODE BASED ON METRIC UNITS

/UNITS UNDEFINED GENERATES CODE BASED ON ENGLISH UNITS

/SPACE DEFINED (EXPERIMENTAL ONLY!!) INCREASES INTER-CHAR.

/	SPACING. (ALSO DEFINE $SPACE IN PIREX.)

/

/

/

/WE USE THESE PARAMETERS TO DETERMINE DEFAULT CHARACTER SIZE 

/

	.DEC

	.IFDEF	PL311

	.IFDEF	UNITS

DFLCHR=100/5*3		/3 MM. IN .05 MM. STEPS

	.ENDC

	.IFUND	UNITS
DFLCHR=1000/2*1/8	/0.125 INCHES IN .002 STEPS

	.ENDC

	.ENDC

	.IFUND	PL311

	.IFDEF	UNITS

DFLCHR=100/25*5		/5 MM. IN 0.25 MM. STEPS

	.ENDC

	.IFUND	UNITS

DFLCHR=1000/10*2/10	/0.2 INCHES IN 0.01 INCH STEPS

	.ENDC

	.ENDC

	.OCT

/

/

/

/

	.IFUND NOSPL

DEVCOD=6		/CODE FOR XY DRIVER IN PIREX

	.ENDC

	.IFDEF NOSPL

DEVCOD=206		/SAME DRIVER, BUT PREVENT SPOOLING

	.ENDC

/

.SCOM=100

EXERRS=.SCOM+37

XYPPB=12		/10 XY PAIRS PER BUFFER TO PDP11

/

	.DEC

REC10=104858		/2^20 DIVIDED BY 10 FOR UNIT GRID COMPUTATION

	.OCT

/

	.GLOBL	XYA.

/

/

	.EJECT

/

/

/

XYA.	DAC	CALP	/SAVE CAL ADDR

	IAC

	DAC	ARGP	/AND ARGUMENT POINTER

	LACQ		/DOS ASSUMPTION? CAN WE ZAP MQ AT CAL LEVEL??

	DAC	SAVMQ	/LET US ASSUME NOT!

NEW	JMP	INITIT	/INTIALIZE TCB AND BUFFER AND POINTERS

/			/THE VERY FIRST TIME THRU

	LAC*	ARGP	/SET UP DISPATCH TO REQUEST TYPE

	ISZ	ARGP	/MOVE POINTER TO PARAMETERS

	AND	(77

	TAD	(JMP TABL

	DAC	TABL

TABL	HLT		/PLACE DISPATCH HERE

	JMP	INIT	/1=INIT

	JMP	FSTAT	/2=FSTAT,RENAM, DLETE

	JMP	IOPS6	/3=SEEK, ILLEGAL

	JMP	ENTER	/4=ENTER

	JMP	CLEAR	/5=CLEAR

	JMP	CLOSE	/6=CLOSE

	JMP	IOPS6	/7=MTAPE ILLEGAL

	JMP	READ	/10=READ, OBTAINS STATUS INFO

	JMP	WRITE	/11=WRITE

	JMP	WAIT	/12=WAIT OR WAITR

IOPS6	LAW	6

IOPSER	DAC	ERRCOD

	LAC	ERRCOD

	JMS*	(EXERRS	/MONITOR ERROR ROUTINE

	JMP	.-2	/REDO

	LAW	-1

	.SIXBT	'XYA'

ERRCOD	-1

IOPS27	LAW	27

	JMP	IOPSER

IOPS25	LAW	25

	JMP	IOPSER

IOPS7	LAW	7

	JMP	IOPSER
IOPS12	LAW	12	/(SCR-36)UC15 GONE
	JMP	IOPSER	/(SCR-36)FATAL ERROR
IOPS55	LAW	55	/(SCR-36)NO TCB AREA
	JMP	IOPSER	/(SCR-36)
IOPS67	LAW	67	/(#33)>32K ERROR
	JMP	IOPSER	/(#33)

/

	.TITLE	.INIT

INIT	ISZ	ARGP	/MOVE TO BUFFER SIZE

	LAC	INITFX	/IGNORE THIS INIT?

	SZA

	JMP	EXITAP	/YUP

	LAC	(400	/(#33)LARGE IN CASE MULTI-LINE

	DAC	INITFL	/REMEMBER THAT  WE'RE AN INIT!

	DAC*	ARGP	/ONLY PROCESS 132 CHAR.'S

	JMS	XYIOCK	/WAIT IF PDP-11 XY IS BUSY

	DZM	UPDWN	/START PEN UP

	DZM	LASTX	/ZERO STORED X POSITION

	DZM	LASTY	/AND Y

	JMS	RESETL	/RESET LINE BUFFER COUNTER, POINTER

	LAC	(DFLCHR	/STANDARD CHARACTER SIZE

	DAC	XSZ	/SAVE AS DEFAULT

	DAC	YSZ

	DZM	SINX	/'INTEGER SINE FOR HORIZONTAL

	LAC	(200000	/ 200000*COS(0)

	DAC	COSX

	JMP	INNDCH	/FINISH UP IN COMMON WITH CHARST

/

	.TITLE	.WAIT OR .WAITR

/

WAIT	LAC*	CALP	/FIND OUT WHICH

	AND	(1000

	SZA		/SKIP ON REGULAR

	JMP	WAITR

	JMS	XYIOCK	/SIMPLY HANG TIL READY

	JMP	EXITAP+1

WAITR	LAC*	ARGP	/(#33) CHECK >32K

	AND	(700000	/(#33)

	SZA		/(#33) SKIP IF NOT

	JMP	IOPS67	/(#33) WAS, COMPLAIN

	LAC*	ARGP	/(#33) ADDR OF ARGP, BITS OF CALP!

	XOR	CALP	/(#33)

	AND	(700000	/(#33)SORRY ABOUT THIS; IT REALLY WORKS

	XOR*	ARGP	/(#33)

	DAC	CALP	/(#33) GO HERE ON BUSY!

	LAC	XYEV	/CHECK IF UNIT BUSY. CAN'T USE XYIOCK

/			/BECUASE WE NEVERWANT TO COME BACK HERE

	SNA!SPA		/>0 IS NOT BUSY. 0 IS BUSY. - IS ERROR

	JMP	EXITCP	/BUSY, EXIT THRU ADDR. STORED IN CALP

	JMP	EXITAP	/NOT BUSY , CONTINUE

/

	.TITLE	.WRITE

/

/  WARNING, ONLY 1 X-Y LINE PAIR AT A TIME CAN BE WRITTEN

/  IN THE BUFFER TO THE HANDLER!

/

/

WRITE	JMS	XYIOCK	/UNIT BUSY?

	LAC*	ARGP	/ADDR OF BUFFER

	DAC	INITFX	/FORBID ANY INIT'S!!!!!!!

	AAC	2	/ADDR OF DATA

	DAC	LBUF

	AND	(700000	/(#33) CHECK IF >32K

	SZA		/(#33) SKIP IF NOT

	JMP	IOPS67	/(#33) WAS, ERROR OUT

	LAC*	CALP	/MODE FROM LEFT HALF

	SWHA

	AND	(17	/BINARY OR ASCII. BINARY IS X-Y PAIR

/			/ASCI IS TEXT STRING

	SAD	(2	/IOPS ASCII

	JMP	CHARI	/YES, GO DO CHAR'S

	SZA		/SKIP IF IOPS BINARY

	JMP	IOPS7	/NEITHER, ILLEGAL MODE

	LAC*	LBUF	/FIRST WORD

	SAD	OTSJNK	/400000 IS OTS JUNK

	ISZ	LBUF	/MOVE POINTER TO REAL THING

	LAC*	LBUF	/NOW GET RIGHT THING IN AC

	DAC	CODE	/SAVE TYPE (0-12/13 OCTAL) OF WRITE

	ISZ	LBUF	/MOVE POINTER TO NEXT ITEM FOR ALL

	SPA		/CHECK TYPE LIMITS

	JMP	IOPS27	/ILLEGAL TYPE

	.IFUND	PL311

	AAC	-13

	.ENDC

	.IFDEF	PL311

	AAC	-14	/PEN SELECT CODE IS POSSIBLE

	.ENDC

	SMA

	JMP	IOPS27

	.IFUND	PL311

	AAC	5	/TYPES 0-5 SET THE PEN

	.ENDC

	.IFDEF	PL311

	AAC	6	/TYPES 0-5 SET THE PEN

	.ENDC

	SPA		/SKIP IF NOT

	JMS	SETPEN	/REMEMBER PEN SETTING

	LAW	-1	/SETPEN DESTROYS AC!!

	TAD	CODE	/CODE-1

	SNA!SPA!IAC	/NOW HAVE CODE, SKIP IF CODE!>1

	JMP	EXITAP-1	/TYPES 0,1 FINISHED

	SAD	(6	/CHARACTERS

	JMP	CHAR

	SAD	(7	/SET CO-ORDINATE REFERENCE COMMAND

	JMP	SET

	SAD	(12	/CHARACTER CHARACTERSITIC SETUP

	JMP	CHARST

	.IFDEF	PL311

	SAD	(13	/PEN SELECTION COMMAND

	JMP	PIKPEN

	.ENDC

/

/  NOW KNOWN TO BE A LINE (POSITION IS UNINTENSIFIED LINE)

/

/ SET UP TO DO LINE(S)

/

	LAW	17000	/(#33) GET WORD PAIR COUNT

	AND*	INITFX	/(#33) ADDR OF BUFFER HEADR

	SWHA		/(#33) RIGHT JUSTIFY COUNT

	CMA!IAC		/(#33) MAKE MINUS FOR ISZ

	AAC	2	/(#33) CORRECT FOR INFO BEFORE LINES

	DAC	COUNTC	/(#33) GRAB THIS LOC AS COUNTER

LINEL	LAC*	LBUF	/(#33) GRAB AN X

	DAC	IX

	ISZ	LBUF

	LAC*	LBUF

	DAC	IY

	ISZ	LBUF	/(#33) BUMP IN CASE MORE LINES

/NOW TYPES 2,3,10 ARE ABSOLUTE INPUT, 4,5,11 RELATIVE

/WE NEED TO CALCULATE DX TO SEND TP PDP-11, ABS TO SAVE POSITION HERE

/

	LAC	CODE	/GET BACK WHICH KIND

	RTR		/PUT TWO BIT IN LINK

	SZL!RTL		/REMAKE CODE, SKIP IF NOT 2 OR 3

	JMP	ABSOL	/2 OR 3, GO DO ABSOLUTE

	SAD	(10	/OR IS IT 10

	JMP	ABSOL	/ABSOLUTE THERE TOO

DELTA	LAC	IX	/GET INPUT X

	DAC	DX	/THAT IS DELTA X ALSO

	TAD	LASTX	/UPDATE 'PRESENT' POSITION

	DAC	LASTX

	LAC	IY	/SAME FOR Y

	DAC	DY

	TAD	LASTY

	DAC	LASTY

	JMP	LINCOM	/FINISH UP IN COMMON

ABSOL	LAC	LASTX	/DELTA IN THIS-LAST

	CMA!IAC

	TAD	IX

	DAC	DX

	LAC	IX	/ABS IS SIMPLY INPUT

	DAC	LASTX

	LAC	LASTY	/SAME FOR Y

	CMA!IAC

	TAD	IY

	DAC	DY

	LAC	IY

	DAC	LASTY

LINCOM	LAC	DY	/(#33) CHECK THAT THE Y INCREMENT

	JMS	VALID	/DOES NOT EXCEED 2^14-1 STEPS...

	.IFUND	PL311	/(#33) CHECK X ONLY IF NOT PL311

	LAC	DX	/AND X TOO...

	JMS	VALID	/

	.ENDC		/(#33)

	.IFDEF	PL311	/(#33) ALLOW LONG X'S

	LAC	DX	/(#33) IF <2^14, DO NOTHING

	SPA		/(#33)

	CMA!IAC		/(#33)

	AND	(740000	/(#33)

	SNA!CLA!CMA	/(#33) SKIP IF SOMETHING TO DO

	JMP	LINEP	/(#33) NO, GO PLACE LINE

	DAC	SIGN1	/(#35) INIT REMAINDER CALC

	LAC	DX	/(#35) SET UP TO SUBDIVIDE LINE

	DAC	XSH	/(#35)

	DZM	XSL	/(#35) INIT REMAINDER TO 0

	LAC	DY	/(#35) SAME FOR Y

	DAC	YSH	/(#35)

	DZM	YSL	/(#35)

/

E351	LAC	(XSH	/(#35) SET UP POINTER TO X,,Y

	DAC	POINT1	/(#35)

	JMS	DBY2	/(#35) DIVIDE DX BY TWO

	JMS	DBY2	/(#35) AND DY

	LAC	SIGN1	/(#35) UPDATE REMAINDER SIZE

	CLL!RAL		/(#35)

	DAC	SIGN1	/(#35) WHICH IS KEPT MINUS

	LAC	XSH	/(#35) SMALL ENUF YET?

	SPA		/(#35)

	CMA!IAC		/(#35)

	AND	(740000	/(#35)

	SZA		/(#35) SKIP IF DONE DIVIDING

	JMP	E351	/(#35) NOT YET

E352	LAC	XSL	/(#35) REMAINDER COUNT (-)

	IAC		/(#35) UPDATE COUNT

	DAC	XSL	/(#35) NEED IT LATER

	SMA!SZA!CLA!IAC	/(#35) MAKE AC=1 IF XSL MINUS

	CLA		/(#35) AND 0 IF CAME IN PLUS

	TAD	XSH	/(#35) DX

	DAC	DX	/(#35) FOR ADDLIN

	LAC	YSL	/(#35) SAME FOR Y

	IAC

	DAC	YSL

	SMA!SZA!CLA!IAC

	CLA

	TAD	YSH

	DAC	DY

	JMS	ADDLIN	/(#35)PLACE THE LINE

	ISZ	SIGN1	/(#35) LOOP CONTROL

	JMP	E352	/(#35)

	JMP	E353	/(#35) CHECK ANY MORE LINES IN BUFFER

	.ENDC		/(#35)

LINEP	JMS	ADDLIN	/GO PUT LINE INTO BUFFER, FORCE OUTPUT IF

/			/IF NECESSARY

E353	ISZ	COUNTC	/(#35) DONE WITH LINES

	JMP	LINEL	/(#33) NO

	JMP	EXITAP-1	/THAT'S ALL!!!

/

/

CHARST	LAC*	LBUF	/FIRST ONE

	DZM	INITFL	/SAY THAT WE'RE NOT AN INIT

	DAC	XSZ	/SAVE X SIZE OF CHAR BOX IN PEN STEPS

	ISZ	LBUF

	LAC*	LBUF	/GET Y SIZE

	DAC	YSZ

	ISZ	LBUF

	LAC*	LBUF	/SINX *200000 OF ANGLE

	DAC	SINX

	ISZ	LBUF

	LAC*	LBUF

	DAC	COSX	/SZME FOR COSINE

	ISZ	ARGP	/SO WE CAN FINISH IN COMMON WITH INIT!

	JMS	XYIOCK	/IS PLOTTER BUSY, WAIT HERE IF SO

	JMS	DOLINE	/FORCE OUT ANY LINES SITTING IN BUFFER

	JMS	XYIOCK	/AND WAIT FOR THAT IF NECESSARY

INNDCH	LAC	XSZ	/CHARST AND INIT, CALCULATE COUBLE PRECISION

	MUL		/SIZE OF SINGLE GRID STEP AT GIVEN OVERALL

/			/GRID SIZE AND ANGLE

	REC10		/THIS DIVIDES BY 10, MULT BY 4

	DAC	XSH	/SAVE IN TEMPORARY IN BUFFER

	LACQ		/GET LOW HALF

	DAC	XSL

	LAC	YSZ	/DIVIDE Y BY 10 (10UNITS GRID PER BOX)

	MUL

	REC10

	DAC	YSH

	LACQ

	DAC	YSL

/

/  NOW SET UP TO MULT DOUBLE NUMBER IN XSH-XSL AND YSHYSL PAIRS BY

/  SIN AND COS

/

	LAC	XYBUFD	/POINTER TO PLACE VECTORS FOR PDP-11

	DAC	POINTB

	LAC	(XSH	/MAKE POINTER TO DOUBLE NUMBER

	DAC	POINT2

	LAC	(COSX	/MAKE POINTER TO SINGLE NUMBER

	DAC	POINT1

	LAC	(XDXH	/MAKE POINTER TO OUR STORAGE

	DAC	POINTS

	JMS	MX1X2	/CALL ROUTINE, DOUBLE PRESISION MULTIPLY

/			/OF SINGLE NUMBER AT POINT1 TIME DOUBLE NUMBER

/			/AT POINT2. LEAVE DOUBLE ASNWER IN AC,MQ

	JMS	P11	/PLACE ANSWER IN BUFFER AND IN OUR STORAGE

/			/THIS GAVE XDXH AND XDXL

	ISZ	POINT2	/POINT2 TO YSH,YSL

	JMS	MX1X2

	JMS	P11	/NOW HAVE YDYH AND YDYL

	LAC	(SINX	/POINT SINGLE TO SIN

	DAC	POINT1

	LAC	(XSH	/POINT DOUBLE TO X PAIR

	DAC	POINT2

	JMS	MX1X2	/GET XDYH,XDYL

	JMS	P11

/

/  NOW A DIRTY, WE NEED -SIN FOR YDX

/

	LAC	SINX

	CMA!IAC

	DAC	SINX

	ISZ	POINT2	/MOVE POINTER TO Y PAIR

	JMS	MX1X2

	JMS	P11

	LAC	SINX	/RESTORE SIN

	CMA!IAC

	DAC	SINX

	LAC	(1422	/MODE 3, 22 BYTES

	DAC*	XYBUF	/AS BUFFER HEADER

	LAC	INITFL	/FLAG FOR REAL INIT

	DAC*	POINTB	/PUT ON END OF SEND TO PDP-11

	JMS	DOIO	/GO PLACE TO PDP-11

	JMP	EXITAP	/WHEW

/

/MX1X2 SUBROUTINE

/

/   CALL WITH POINTER TO SINGLE PRECISION NUMBER IN POINT1

/    CALL WITH POINTER TO DOUBLE PRECISION NUMBER IN POINT2

/  POINT2 IS INCREMENTED ONCE BY ROUTINE!!!!!!

/

/  RESULTING TRIPLE PRECISION NUMBER IS LEFT IN AC,MQ,T3

/

/  THE ROUTINE HANDLES SIGNS. IT IS ASSUMED THAT THE TOP

/  BIT OF ALL NUMBERS IS SIGN BIT, AND NUMBERS ARE IN TWO-COMPLEMENT FORM

/  NOTE, ONLY TOP BIT OF TOP WORD HAS SIGN, ALL REST DATA.

/

/ROUTINE USES TEMPORARIES T1,T2,T3,SIGN1,SIGN3

/

MX1X2	0

	LAC*	POINT1	/GET SINGLE PRECISION NUMBER

	DAC	SIGN1	/SAVE

	SPA!CLL		/MAKE ABSOLUTE FOR MUL

	CMA!IAC

	DAC	MZOT1	/PLACE IN CORE FOR MUL'S

	DAC	MZOT2

	LAC*	POINT2	/GET HIGH HALF OF DOUBLE NUMBER

	XOR	SIGN1	/FIND SIGN OF ANSWER

	SPA!CLA		/SET UP 0 IF +

	CMA		/STORE 0 OR -1

	DAC	SIGN1

	CMA!IAC

	DAC	SIGN3	/0 OR 1 TO ADD TO LOW ORDER WORD

	LAC*	POINT2	/NOW MAKE DOUBLE PLUS

	SPA!CLL!CML	/LINK ON IF NUMBER +

	CLL!CMA		/TOP HALF ONLY CMA, NO IAC!

	DAC	T1	/HOLD TOP HALF HERE

	ISZ	POINT2	/GET LOW HALF OF TOP

	LAC*	POINT2

	SNL!CLL		/SKIP IF NO NEED TO COMPLEMENT LOW HALF

	CMA!IAC		/LEAVES LINK ON IF CARRY TO UPPER HALF!

	SZL!CLL		/CHECK CARRY

	ISZ	T1	/WAS ONE

	NOP		/JUST IN CASE OF ISZ

	MUL		/MUL BY SINGLE PART

MZOT1	HLT

	DAC	T2	/SAVE PART OF LOW HALF OF ANSWER

	LACQ		/SAVE LOW PART OF LOW HALF

	DAC	T3

	LAC	T1	/NOW MULT HIGH HALF

	MUL

MZOT2	HLT

	DAC	T1	/SAVE HIGH HALF OF ANSWER

	LACQ		/PART OF LOW HALF

	CLL		/LINK ZERO TO CHECK CARRY OUT OF...

	TAD	T2	/ADD TOGHTHER OF LOW HALVES

	SZL!CLL		/NO SKIP IF CARRY

	ISZ	T1	/PICK UP CARRY

	NOP

	DAC	T2

/

/  NOW START COMPLEMENTING  THE THREE NUMBERS

/

	CLL

	LAC	T3

	XOR	SIGN1

	TAD	SIGN3

	DAC	T3

	LAC	T2

	XOR	SIGN1

	SZL!CLL

	IAC

	LMQ		/PUT LOW HALF BACK TO MQ

	LAC	T1	/GET HIGH HALF

	XOR	SIGN1	/COMPLEMENT IF NECESSARY

	SZL!CLL		/SKIP UNLESS NEED CARRY

	AAC	1	/AAC 1 NO CARRY TO LINK!!!

	JMP*	MX1X2	/THAT'S IT

/

/

/  P11DOES SCALING FOR PDP-11 16 BIT WORD, STORES ANSWER

/  IN LOCAL STORE THRU POINTER POINTS

/  AND IN BUFFER FOR PDP-11 THRU POINTER POINTB

/

/  ROUTINE MUST RECEIVE DOUBLE PRECISION NUMBER IN AC,MQ

/

P11	

	DAC*	POINTB	/SAVE TOP HALF

	DAC*	POINTS

	ISZ	POINTS

	ISZ	POINTB

	LACQ		/GET BOTTOM

	RAR		/TRUNCATE LAST TWO BITS

	CLL!RAR

	CLL

	DAC*	POINTB	/SINCE PDP-11 CAN'T SEE TOP TWO

	RTL		/MOVE UP FOR OUR USE

	DAC*	POINTS

	ISZ	POINTS

	ISZ	POINTB

	JMP*	P11

/

/

/  CHARACTER STRING PROCESSING FOR WRITE 2 AND WRITE 0 MODE 6

/

CHAR	LAC*	LBUF	/GET CHAR COUNT

	ISZ	LBUF	/MOVE TO DATA

	SNA!SPA!CMA!IAC	/MAKE - FOR ISZ. CHECK IF >1

	JMP	IOPS25	/CONTROL COUNT 0 OR -, QUIT

CHARI	DAC	COUNTX	/CONTROL COUNT FOR FORTRAN

/			/CHARI ENTERS WITH 2 IN AC!

	DZM	COUNTC	/ZERO COUNTR 

	JMS	XYIOCK	/CHECK FOR DEVICE BUSY

	JMS	DOLINE	/FORCE OUT ANY PENDING LINE OPERATIONS

	JMS	XYIOCK	/WAIT FOR THAT IF NECESSARY

	LAC	(UNPK1	/INIT UNPACKING ROUTINE

	DAC	UNPKX

	LAC	(PACK1	/INIT PACKING ROUTINE

	DAC	PKX

CHARL	JMS	UNPK	/GET A CHARACTER

	SAD	(15	/CR

	JMP	DN	/YES, QUIT

	SAD	(175	/ALT

	JMP	DN	/QUIT

	AAC	-40	/CHAR'S LESS THAT 40 IGNORED!

	SPA

	JMP	CHARC	/GO DO LOOP CONTROL

	AAC	-100	/CHAR'S 140 ARE GREATER ARE MAPPED BACK TO 100

	SMA

	AAC	-40	/MAP BACK, PRIMARILITY FOR LOWER CASE CHAR'S

	AAC	140	/RECREATE CHAR

	JMS	PACK	/GO PLACE IN OUR BUFFER AND COUNT IT

CHARC	ISZ	COUNTX	/FORTRAN, GOT THEM ALL

	JMP	CHARL	/LOOP

/

DN	LAC	COUNTC	/HOW MANY DID WE GET

	TAD	(1000	/FOR HEADER, MODE 2

	DAC*	XYBUF	/THRU OUR POINTER TO DOS BUFFER

	XOR	(1000	/RESTORE ORIG. COUNT

	MUL		/TIMES 10, WE NOW COMPUTE PEN CHANGE OF STRING

	.IFUND	SPACE	/(#34) SPCAING CHANGE ATTEMPT

	12

	.ENDC		/(#34)

	.IFDEF	SPACE	/(#34)

	14		/(#34)

	.ENDC		/(#34)

	LACQ

	DAC	COUNTC	/USE AS TEMP

	LAC	(COUNTC	/POINTER TO SINGE QUANTITY FOR MX1X2

	DAC	POINT1

	LAC	(XDXH	/POINTER TO DOUBLE

	DAC	POINT2

	JMS	MX1X2	/ANSWER IN AC,MQ

	JMS	CHP	/GET MIDDLE THIRD OF ANS, OROUNDED TO AC

	TAD	LASTX

	DAC	LASTX	/UPDATED X, NOW DO Y

	LAC	(XDYH

	DAC	POINT2

	JMS	MX1X2

	JMS	CHP

	TAD	LASTY

	DAC	LASTY

	JMS	DOIO	/PUT IT OUT

	JMS	RESETL	/RESET BUFP

	JMP	EXITAP-1

/

/

/  ROUTINE CHP GETS MIDDLE THIRD OF ANSWER FROM MX1X2

/  AND ROUNDS UP IF HIGH BIT OF LOW THIRD IS SET

/

CHP	0

	LAC	T3	/LOW THIRD OVER HIGH THIRD

	RAL		/SIGN BIT TO LINK

	LACQ		/MIDDLE THIRD

	SZL!CLL		/SKIP IF NO CORRECTION NEEDED

	AAC	1

	JMP*	CHP

/

/

/

/

/CHAR UNPACKER

/

/  CHARACTER UMPACKER GETS CHAR'S IN IOPS

/  ASCII FROM THE POINTER LBUF. EACH CHARACTER IS RETURNED

/  RIGHT JUSTIFIED IN THE AC, WITH HIGH BITS STRIPPED.

/

/  UNPX SERVES AS A POINTER TO THE CORRECT ACTION FOR THE

/  NEXT CHARACTER, THERE BEING DIFERENT ACTION FOR

/  1,2,3,4,5, THEN 6 IS SAME AS 1.

/

/  THE JMS'S IN THE CODE SET UP POINTER IN UNPX FOR THE NEXT

/  CHAR.  THE ROUTINE MUST BE INITED BEFORE FIRST CALL BY

/  PLACING THE ADDRESS UNPK1 INTO UNPX.

/

/

UNPK	0

	JMP*	.+1

UNPKX	HLT

	AND	(177

	JMP*	UNPK

UNPK1	LAC*	LBUF

	LRS	13

	JMS	UNPKX

	LAC*	LBUF

	LRS	4

	JMS	UNPKX

	LAC*	LBUF

	DAC	UNPKX

	ISZ	LBUF

	LAC*	LBUF

	LMQ

	LAC	UNPKX

	LLS	3

	JMS	UNPKX

	LAC*	LBUF

	LRS	10

	JMS	UNPKX

	LAC*	LBUF

	RAR

	JMS	UNPKX

	ISZ	LBUF

	JMP	UNPK1

/

/

/ CHAR PACKER

/

/  THE CHARACTR PACKER RECEIVES ASCII CHARACTERS RIGHT

/  JUSTIFIED IN THE AC. THE CHARACTERS ARE PLACED VIA

/  THE POINTER BUFP.  THE CHARACTERS ARE COUNTED

/  IN THE COUNTER 'COUNT'. THE PACKING FORMAT PER WORD

/  IS FIRST CHARACTER RIGHT JUSTIFIED, SECOND CHARACTER

/  IN BITS 2-9, TOP TWO BITS UNUSED. THE POINTER BUFP

/  IS USED TO CHECK ON THE TOTAL NUMBER OF CHARACTERS.

/  IN CASE OF TOO MANY (>132), THE REMAINING CHARACTERS

/  ARE THROWN AWAY, AND CONTROL GOES TO DN.

/

/  PKX IS POINTER TO NEXT ACTION, AS IN UNPK. PKX IS INITED

/ BEFORE FIRST CALL BY PLACING ADDRESS PACK1 IN TO IT.

/

/

PACK	0

	AND	(177	/STRIP (IM)POSSIBLE XTRA BITS

	ISZ	COUNTC	/COUNT PLACED CHARACTER

	JMP*	.+1

PKX	HLT

	JMP*	PACK

/

PACK1	DAC*	BUFP	/FIRST, JUST PLACE

	JMS	PKX

	CLL!SWHA

	RAR

	XOR*	BUFP	/SECOND IN BITS 2-9

	DAC*	BUFP

	ISZ	BUFP

	LAC	BUFP

	SAD	XYBUFE	/CHECK OVERFLOW WITH CLCULATED END

	JMP	DN

	JMS	PKX

	JMP	PACK1

/

/

	.TITLE	.FSTAT .ENTER .CLEAR

/

/  THIS SECTION TAKEN FROM BLACKETT'S HANDLER

/

/THIS CODE DEPENDS ON THE USER FOLLOWING THE CONVENTION OF ZEROING

/BITS 0-2 OF LOC+2 OF THE CAL SEQUENCE FOR A .FSTAT CAL AS PER 

/DIRECTIONS IN .FSTAT PARAGRAPH OF THE DOS USER MANUAL.

/

FSTAT	CLA

	JMP	EXITAP

ENTER	JMP	EXITAP

CLEAR	JMP	EXITAP+1

/

/

	.TITLE	.READ

/

/  THE READ FUNCTION IS USED TO OBTAIN PLOTTER STATUS

/

/  CAL WITH SEVEN (OR EIGHT FOR XY311) INTEGER ARGUMENTS  TO OBTAIN

/

/  LASTX		/PRESENT X POSITION IN INTEGER STEPS

/  LASTY		/PRESENT Y POSITION IN INTEGER STEPS

/  ISX		/X SIZE IN STEPS OF CHARACTER

/  ISY		/Y SIZE OF CHARACTER IN STEPS

/  ISIN		/INTEGER SIN (200000*SIN(X)) OF SLOPE OF CHARACTERS

/  ICOS		/INTEGER COS (200000*COS(X)) ON SLOPE OF CHARACTERS

/  IPEN		/0 IF PEN UP, 100000 IF DOWN

/  IPENUM	/# OF THE ACTIVE PEN IF XY311 INTERFACE IS INSTALLED

/

/  I.E.

/

/	READ (6) LASTX,LASTY,ISX,ISY,ISIN,ICOS,IPEN,IPENUM

/

READ	LAC*	ARGP	/BUFFER ADDR

	DAC	INITFX	/FORBID INIT'S

	AAC	2	/POINT TO REAL DATA

	DAC	LBUF

	LAC	(OTSJNK	/POINT TO 8 WORDS TO TRANSFER

	DAC	CALP	/GRAB CAL POINTER FOR TEMPORARY

	.IFUND	PL311

	LAW	-10	/LOOP CONTROL

	.ENDC

	.IFDEF	PL311

	LAW	-11	/LOOP CONTROL IF XY311 FUNCTIONSET AVAILABLE

	.ENDC

	DAC	COUNTC	/GRAB COUNTER FROM .WRITE

	LAC*	CALP	/GET WORD

	DAC*	LBUF	/PUT WORD

	ISZ	CALP	/MOVE POINTER

	ISZ	LBUF	/MOVE POINTER

	ISZ	COUNTC	/DONE YET

	JMP	.-5

	JMP	EXITAP-1 /EXIT THRU ARG. POINTER, WE'RE DONE

	.TITLE	.CLOSE

/

CLOSE	JMS	XYIOCK	/IS UNIT BUSY

	DZM	INITFX	/ALLOW INITS AGAIN

	JMS	DOLINE	/NO, FORCE OUT ??A QUESTION??

	JMS	XYIOCK	/MIGHT BE BUSY IF WE HAD TO FORCE SOME

/			/LINES OUT FROM BUFFER

	LAC	(177404	/EOF HEADER (4 BYTES FOR XY311)

	DAC*	XYBUF

	JMS	DOIO	/PUT OUT EOF, PRIMARILY FOR SPOOLER

	JMS	XYIOCK	/HAVE DEVICE IDLE WHEN EXIT

	JMP	EXITAP+1

/

/

	.TITLE	MISCELLANEOUS ROUTINES

/

/  ADDLIN SUBROUTINE PLACES THE DX, DY PAIR INTO THE OUTPUT

/  BUFFER 'BUFF'. THE TOP BIT(PDP-11!) OF DX IS COMPLEMENTED IF THE PEN

/  IS TO BE DOWN, LEFT ALONE FOR UP. THE BUFFER IS TRANSMITTED

/  TO THE PDP-11 WHEN FULL (10 XY PAIRS(DECIMAL)).

/

ADDLIN	0

	LAC	DX

	XOR	UPDWN	/STATE OF PEN

	DAC*	BUFP	/PLACE

	ISZ	BUFP

	LAC	DY

	DAC*	BUFP

	ISZ	BUFP

	ISZ	COUNT	/COUNT OF PAIRS!

	JMP*	ADDLIN	/NO NEED TO FORCE OUT

	JMS	DOLINE	/FORCE OUT, ALSO RESET POINTERS ETC.

	JMP*	ADDLIN

/

/  THE DOLINE ROUTINE OUTPUTS THE BUFFER OF XY PAIRS, AND THEN

/  CALLS RESETL TO SETUP COUNT AND POINTER FOR NEXT

/

DOLINE	0

	LAC	(XYPPB

	TAD	COUNT	/MAKE COUNT OF WORD PAIRS TO BE SENT

	SNA!SPA!CLL	/SKIP IF ANY

	JMP*	DOLINE	/NONE, DO NOTHING

	RTL		/*4 TO GIVE BYTE COUNT FOR SPOOLER

	TAD	(400	/CODE FOR LINE FOR DRIVER

	DAC*	XYBUF	/THAT'S THE HEADER

	JMS	DOIO	/GO DO IO

	JMS	RESETL	/RESET POINTER, COUNT

	JMP*	DOLINE

/

/  THE RESETL ROUTINE RESETS COUNT AND BUFP FOR THE NEXT BUFFER

/

RESETL	0

	LAW	-XYPPB	/10(10) PAIRS FOR NOW

/			/10 IS A GUESS OF WHAT SIZE WILL PACK WELL

/			/INTO SPOOLING BUFFERS, SINCE CHARACTER

/			/STRINGS WILL BE OF RANDOM SIZES

	DAC	COUNT

	LAC	XYBUFD	/POINT TO DATA PORTION OF BUFFER

	DAC	BUFP

	JMP*	RESETL

/

/  SUBROUTINE VALID VERIFIES THAT INPUT CO-ORDINATE VALUES ARE

/  LESS THAN 2^14 STEPS IN MAGNITUDE. CALL WITH VALUE IN AC

/  AC IS DESTROYED.

/

/

/

VALID	0

	SPA		/SKIP IF ALREADY +

	CMA!IAC		/MAKE + FOR TEST

	AND	(740000	/ANY TOP BITS ON

	SZA		/SKIP ON NO, WHICH IS CORRECT

	JMP	IOPS25	/ ** DATA VALUE >2**14-1

	JMP*	VALID

/

/  SUBROUTINE SETPEN TAKES LOW BIT OF AC (PEN UP-DOWN BIT) AND

/  PLACES IT IN THE 100000 BIT OF THE WORD UPDWN.

/  THIS ROUTINE DESTROYS THE AC!

/  CALL WITH THE CODE FOR THE WRITE IN THE AC

/

SETPEN	0

	RAR		/MAGIC BIT IN LINK

	CLA!RAR		/ZAP OTHER BITS, BIT IN 400000

	RTR		/BIT IN 100000

	DAC	UPDWN	/INTO DESTINATION

	JMP*	SETPEN

/

/

/

/  SET ESTABLISHES THE PROVIDED CO-ORDINATES AT THE PRESENT

/  PEN POSITION

/

SET	LAC*	LBUF

	DAC	LASTX

	ISZ	LBUF

	LAC*	LBUF

	DAC	LASTY	/AND LAST Y VALUE

	ISZ	ARGP	/KICK TO EXIT

EXITAP	ISZ	ARGP

	LAC	SAVMQ	/RESTORE MQ

	LMQ

	DBR

	JMP*	ARGP

/

/

/

	.IFDEF	PL311

/

/SUBROUTINE PIKPEN ASSEMBLES THE DATA REQUIRED FOR THE TCB

/TO SELECT AS THE ACTIVE PEN, PEN NO.1,2 OR 3

/CALLED WITH (LBUF) INDEXING DATA BUFFER OF FORTRAN CALL

/

PIKPEN	JMS	XYIOCK	/CHECK FOR DEVICE BUSY

	JMS	DOLINE	/FORCE OUT ANY PENDING LINE OPERATIONS

	JMS	XYIOCK	/WAIT IF WE HAVE TO

	LAC*	LBUF	/EXTRACT DATA

	DAC	NUMPEN	/UPDATE ACTIVE PEN NUMBER

	DAC*	XYBUFD	/DATA WORD FOR THIS TCB

	LAC	(2004	/THIS PUTS MODE=4 AND BYTE COUNT=4 

	DAC*	XYBUF	/INTO THE TCB HEADER

	JMS	DOIO	/SEND COMPLETED TCB TO THE PDP-11

	JMP	EXITAP-1	/RETURN TO CALLING PROGRAM

/

/  DBY2

/

/  ROUTINE DIVIDES QUANTITY POINTED AT BY POINT1

/  BY TWO, RETURNING QUANTIY. THE REMAINDER, IF

/  PRESENT, CAUSES CONTENTS OF SIGN1 TO BE ADDED

/  TO THE LOCATION FOLLOWING THE QUANTITY.

/

/  TYPICALLY, THE LOCATIONS XSH-YSL CONTAIN, AN X,

/  A REMAINDER X, A Y , AND A REMAINDER Y. POINT1

/  IS INCREMENTED TWICE BY  DBY2  SO IT CAN BE AGAIN CALLED

/  FOR Y

/

DBY2	0

	LAC*	POINT1	/FETCH QUANTITY TO BE DIVIDED
	660000		/SIGN TO LINK FROM AC0

	RAR		/AC SET, REMAIN IN LINK

	DAC*	POINT1	/RETURN QUANTITY OK

	ISZ	POINT1	/MOVETO FETCH REMAINDER

	LAC*	POINT1	/REMAIN (OVERALL) TO AC

	SZL		/SKIP IF NO IMMEDIATE REMAIN

	TAD	SIGN1	/KEEP BUILDING OVERALL REMAINDER

	DAC*	POINT1	/RETURN

	ISZ	POINT1	/MOVE ON TO NEXT PAIR

	JMP*	DBY2

/

	.ENDC

/

/

/

	.TITLE	I/O

/

/

/  

/

/  DOIO ROUTINE ISSUE REQEST TO SEND TCB TO PDP-11

/

DOIO	0

	DZM*	XYEV

	DZM	XYIOFL	/RESET XYIOCK'S MEMORY OF WHO'S WAITING!

	LAC	XYTCB	/TCB ADDR ALWAYS SAME

	SIOA		/SKIP IF PDP-11 CAN TAKE IT

	JMP	.-1	/TRY AGAIN TIL IT CAN

	LIOR		/SEND

	JMP*	DOIO

/

/

/  XYIOCK IS ROUTINE TO CHECK IF UNIT BUSY, CONTINUE IF NOT,

/  AND HANG ON CAL IF IT IS. THE TROUBLE IS THAT PEROPLE LIKE

/  .CLOSE, FOR INSTANCE MUST CALL US SEVERAL TIMES, AND THE

/  LOOP ON CAL RE-ENTERS AT THE BEGINNING OF THE CLOSE

/  PROCESSING. THUS WE MUST REMEMBER WHO WAS THE FIRST PERSON

/  TO CALL US AFTER I/O COMMENCED; HE WILL GET CONTROL WHEN

/  THE DEVICE FINALLY BECOMES NON-BUSY. THAT IS WHY .WAITR

/  CAN'T USE US, HE NEVER WAN'T TO HEAR FROM US AFTER HE

/  CHECKS FOR UNIT BUSY.

/

XYIOFL	-6		/ADDR TO RETURN TO, 0 SAYS USE XYIOCK

/			/XYIOFL IS CLEARED WHEN I/O STARTED, AND

/			/WHEN IT IS USED. IT IS SET WHEN 

/			/A CALL IS MADE TO XYIOCK, UNIT IS BUSY,

/			/AND XYIOFL IS FOUND TO BE ZERO.

/			/BY THE WAY, THE -6 IS USED BY INITIT AS

/			/A COUNT, AND IS LEFT AS ZERO FOR NORMAL

/			/USE.

/

XYIOCK	0

	LAC*	XYEV	/IS UNIT BUSY

	SNA!SPA!RTL	/SKIP IF NOT

	JMP	XYIOBS	/GO DO BUSY 

	SPA		/SKIP IF NOT ERROR (TESTING

/			/PDP-11 SIGN BIT!

	JMP	XYIOBS	/TREAT ERROR AS BUSY

	LAC	XYIOFL	/SHOULD WE RETURN THRU XYIOCK OR XYIOFL

	SZA		/0 SAYS XYIOCK

	DAC	XYIOCK	/BOTH CASES, ADDR IN XYIOCK FOR CONVENIENCE

	DZM	XYIOFL	/USED XYIOFL, CLEAR OUT

	JMP*	XYIOCK	/RESUME AT FIRST GUY TO WAIT

/

XYIOBS	LAC	XYIOFL	/BUSY, HAS SOMEONE ELSE ALREADY STORED ADDR.?

	SNA		/SKIP IF HE HAS

	LAC	XYIOCK	/NO, SO STORE OURS

	DAC	XYIOFL	/NOP IF PREVIOUSLY STORED

EXITCP	DBR		/EXIT THRU CAL POINTER (WAITR USES THIS

	JMP*	CALP	/BUT HE  SET UP CALP FOR HIMSELF

/

/

	.TITLE  INTERRUPT SERVICE

/

XYINT	JMP	XYPIC	/PIC ENTRY, GO SERVICE

	DAC	XYAC	/API ENTRY, SAVE AC

	LAC	XYINT	/GET INTERRUPTED PC

	DAC	XYOUT	/SAVE FOR COMMON EXIT

	LAC	(JMP XYPIC /RESTORE PIC ENTRY POINT

	DAC	XYINT

	LAC	(NOP	/WE DON'T NEED ION IN COMMON EXIT

	JMP	XYICM	/FINISH UP WITH PIC CODE

/

XYPIC	DAC	XYAC	/SAVE TH AC HERE TOO

	LAC*	(0	/GET INTERRRUUPTED PC

	DAC	XYOUT	/COMMON EXIT POINT

	LAC	(ION	/PIC NEEDS ION

/

XYICM	DAC	XYISW	/PLACE EITHER NOP OR ION

	CAPI		/CLEAR FLAG

	LAC*	XYEV	/IS PIREX HAPPY?

	RTL		/PDP-11 SIGN BIT TO OUR SIGN BIT

	SPA!RTR		/SKIP IF OK, RESTORE AC

	JMP	XYIERR	/NOT OK, GO CHECK IT OUT

XYIRT	LAC	XYAC	/BRING BACK INTERRUPTED AC

XYISW	HLT		/EITHER ION OR NOP

	DBR

	JMP*	XYOUT

/

/

XYIERR	AND	(177777	/KEEP ONLY PDP-11 BTS

	SAD	(177001	/IS IT OUT OF NODES ERROR

	JMP	RETRY	/YES, TRY AGAIN

	TAD	(600000	/NO, MAKE CODE INTO - NUMBER FOR

	JMP	IOPSER	/AN IOPS MESSAGE.

/			/THIS SHOULD NEVER REALLY HAPPEN.

/

RETRY	JMS	DOIO	/DOIO ENTERED CAL + INTERRUPT LEVEL

	JMP	XYIRT	/DON'T BELIEVE BOTH CAN HAPPEN AT ONCE.

/

/

/

	.TITLE  INITIALIZATION AND STORAGE

/

/  FIRST COME STORAGE LOCATIONS THAT CANNOT OVERLAP

/  INITIALIZATION CODE

/

ARGP	0		/POINTER TO ARGUMENTS IN CAL

CALP	0		/POINTER TO CAL ADDR

SAVMQ	0		/SAVE MQ THRU CAL LEVEL, NECESSARY?

INITFX	0		/ALLOW AN INIT IF THIS IS ZERO!!

/

/  8 WORDS DESCRIBING THE UNIT GRID ON REAL PLOTTER

/

XDXH	2		/HIGH HALF OF X STEPS PER GRID UNIT

XDXL	0		/LOW HALF.11*11 GRID UNITS MAKE CHARACTER 'BOX'

YDYH	2		/Y STEPS PER Y GRID UNIT, HIGH

YDYL	0		/Y STEP, LOW HALF. ORDER MUST MATCH IN PDP-11

XDYH	0		/Y STEPS PER X GRID UNIT, CA OCCUR WITH TIPPED

XDYL	0		/CHARACTERS

YDXH	0

YDXL	0

/

/

/  FOLLOWING 7 (8 FOR XY311) WORDS ARE TRANSFERED OUT ON A .READ. THEY MUST

/  REMAIN IN ORDER

/

OTSJNK	400000		/SOME SORT OF OTS WORD;ALSO USED AS LITERAL

LASTX	0		/PRESENT X CO-ORDINATE PEN POSITION

LASTY	0		/PRESENT Y CO-ORDINATE PEN POSITION

XSZ	DFLCHR		/X SIZE OF A CHARACTER, IN INTEGER STEPS

YSZ	DFLCHR		/Y SIZE OF A CHARACTER IN STEPS

SINX	0		/200000*SIN(X), WHERE X IS TILT OF CHAR.

COSX	200000		/200000*COS(X). STRING FROM HORIZONTAL

UPDWN	0		/PEN STATUS.0=UP.100000=DOWN

	.IFDEF	PL311

NUMPEN	0		/NUMBER OF THE PEN WHICH IS ACTIVE

			/(XY311 INTERFACE ONLY)

	.ENDC

/

/  INITIALIZATION CODE TO SET UP POINTERS TO MONITOR BUFFER

/  AND TCB, AND THEN DO SETUP CAL.

/

/  THIS CODE IS ALSO USED FOR STORAGE AND TEMPORARY LOCATIONS

/  DURING NORMAL PROCESSING

/

/  FIRST DEFINE THE TEMPORARY LLOC'S

/

XYAC			/SAVE AC AT INTERRUPT LEVEL

XYOUT			/SAVE PC AT INTERRUPT LEVEL

XYTCB			/TCB ADDRESS IN MONITOR COMMUNICATION AREA

XYEV			/EVENT VARIABLE FROM PIREX AT TCB+2

XYBUF			/DATA BUFFER HEADER IN COMMUNICATION AREA

XYBUFD			/XYBUF+2, START OF REAL DATA

XYBUFE			/XYBUFD+102 MAX OF 132 CHAR'S CHECK OVERFLOW

CODE			/TYPE OF .WRITE

INITFL	0		/FLAG FOR CHARSET. 0 IF NOT INIT. NON0 IF INIT

COUNT			/-COUNT OF X,Y PAIRS TO OUTPUT BUFFER

COUNTC			/COUNT OF INPUT WORD PAIRS

COUNTX			/CONTROL COUNT FORTRAN CHAR'S

LBUF			/POINTER TO INPUT BUFFER

POINT1			/POINT TO SINGLE WORD OPERAND  MX1X2

POINT2			/POINT TO DOUBLE WORD OPERAND  MX1X2

XSH			/KEEP THIS AND NEXT 3 IN ORDER!!!

XSL			/HIGH AND LOW X-DIR TERMPORARY GRID CALC.

YSH			/HIGH HALF OF Y DIRECTION FOR GRID

YSL			/LOW HALF OF Y

SIGN1			/MX1X2 STORE SIGN OF RESULT

SIGN3			/MX1X2 0 OR 1 TO ADD TO LOW WORD OF RESULT

T1			/3 TERMPORARIES FOR MX1X2

T2

T3

POINTS			/POINT TO 8 WORD BLOCK AT XDXH FOR PLACEMENT

POINTB			/POINT TO OUTPUT BUFFER FOR SAME THINGS

BUFP			/POINTER TO PLACE LINES IN OUTPUT BUFFER

DX			/DELTA X OF PRESENT MOVE FOR LINES TO PDP-11

DY			/DELTA Y, KEEP AS ADDRESS PAIR WITH DX!

IX			/X VALUE INPUT FROM THE USER FOR THIS .WRITE

IY			/AND THE Y VALUE

/

/   NOW THE CODE TO DO THE INITIALIZATION

/

	.LOC XYAC

/

/

INITIT	LAC	(NOP	/PREVENT RE-ENTRY

	DAC	NEW	/BY DESTROYING JUMP TO HERE

/

/  SET UP POINTERS TO MONITOR BUFFER AND TCB

/

	LAC*	(.SCOM+100 /TABLE OF POINTERS

	SNA!SPA		/(SCR-36)>0 IF UC15 STILL HERE
	JMP	IOPS12	/(SCR-36)UC15 GONE

	AAC	3	/OFFSET TO OBTAIN OURS

	DAC	XYAC	/USE AS TEMPORARY

	LAC*	XYAC	/ADDRESS OF OUR COMBINED AREA

	SNA!SPA		/(SCR-36)THIS, TOO, BETTER BE >0
	JMP	IOPS55	/(SCR-36)NO TCB AREA
	DAC	XYAC	/POINTER FOR TCB CONSTRUCTION

	DAC	XYTCB	/AND POINTER FOR OUR MEMORY

	AAC	2	/MAKE POINTER TO EVENT VARIABLE

	DAC	XYEV

	AAC	2	/POINT TO ADDR IN TCB POINTING TO BUFFER

	DAC	XYOUT	/SAVE FOR LATER FILL

	AAC	5	/POINTER TO FIRST DATA WORD IN BUFFER

	DAC	XYBUFD

	AAC	102	/END OF BUFFER +1 FOR OVERFLOW CHECK

	DAC	XYBUFE

/

/  CONSTRUCT TCB

/

	LAC	(APISLT*400+APILVL /FIRST TCB LOC. TELLS

	DAC*	XYAC	/PDP-11 HOW TO WAKE US UP

	ISZ	XYAC

	LAC	(DEVCOD	/DEVICE CODE FOR DRIVER WITHIN PIREX

	DAC*	XYAC	/AS SECOND TCB LOCATION

	ISZ	XYAC	/NOW A LOOP TO ZERO THRU FIRST BUFFER LOC

	DZM*	XYAC

	ISZ	XYIOFL	/NASTY, THIS ASSEMBLED AS LOOP CONTROL

/			/CONSTANT, IS LEFT AT CORRECT 0

	JMP	.-3	/NOT DOEN YET

	LAC	XYAC	/THIS ADDR NOW POINTS TO BUFFER

	DAC*	XYOUT	/SO PLACE IN TCB

	DAC	XYBUF	/AND FOR OUR MEMORY

	ISZ*	XYEV	/!MAKE EVENT VARIABLELOOK LIKE OK OPERATION

/			/FOR FIRST TIME IN!

	JMS	RESETL	/RESET BUFP, COUNT. WARNING! BUFP IS

/			/VERY CLOSE TO THE ADDRESS OCCUPIED

/			/HERE.

	CAL	APISLT	/SETUP CAL TO ATTACH INTERRUPTS

	16

	XYSF

	XYINT

	JMP	NEW	/RETURN TO CAL DECODING

/

	.END
