/FOCAL: PLOT, LABEL, MARK   JVZ

/THESE ROUTINES ADAPT FOCAL TO A CALCOMP 565 DIGITAL INCRE-
/MENTAL PLOTTER BY PROVIDING THE COMMAND 'PLOT X,Y,L,M' AND
/ALTERING THE MEANING OF THE 'TYPE $' COMMAND.  PLOT ESTAB-
/LISHES A COORDINATE SYSTEM RELATIVE TO AN ARBITRARY ORIGIN
/AND MOVES THE PEN IN A STRAIGHT LINE BETWEEN POINTS GIVEN
/AS THE X,Y ARGUMENTS OF THE COMMAND.

/COORDINATES ARE EXPRESSED IN UNITS OF .01" AND THE RANGE
/IS + OR - 20.47 INCHES.  ADDITIONALLY CHANGES ARE LIMITED
/TO THIS RANGE.  'PLOT 100*X,100*Y' MAY BE USED TO CONVERT
/TO INCH UNITS.

/L CONTROLS THE PEN POSITION: L=0 SETS THE PEN UP (THUS 0=
/'NO LINE'), WHILE L=1 LOWERS THE PEN.  EXPANSION OF THE
/PROGRAM COULD PERMIT L=2... TO DESIGNATE VARIOUS DOTTED &
/DASHED LINES.  L=-1 IS USED TO ESTABLISH A NEW ORIGIN AT
/THE (X,Y) POSITION INDICATED.  THE PEN IS RAISED DURING
/THIS MOTION.  THIS CALL IS FREQUENTLY USED AT THE BEGIN-
/NING OF A PROGRAM TO RUN THE PEN OFF-SCALE AND THEN SET
/THE ORIGIN A FIXED DISTANCE IN FROM THE EDGE.  IT IS ALSO
/USED AT THE END OF A PLOT TO ADVANCE THE PAPER:

/PLOT 1000,0,-1;C RUN OUT 10" OF PAPER ALONG X

/L=-2 SETS VARIOUS ROTATIONS AS DISCUSSED ON THE NEXT PAGE.

/M SPECIFIES THE MARK TO BE DRAWN AT THE CONCLUSION OF THE
/MOVE.  MARK 0 IS A BLANK.  THE OTHER 15 MARKS MAY BE USED
/FOR DISPLAYING DATA POINTS - WITH SAY A FITTED LINE DRAWN
/THROUGH THEM:  1-DOT  2-BAR  3-TICK  4-PLUS MARK  5-X MARK
/6-CIRCLE  7-FILLED CIRCLE  8-TRIANGLE  9-FILLED TRIANGLE
/10-SQUARE  11-FILLED SQUARE  12-DIAMOND  13-FILLED DIAMOND
/14-STAR  15-MALTESE CROSS.  SPACE IS AVAILABLE FOR OTHERS.

/IN GENERAL ONLY THOSE ARGUMENTS WHICH DIFFER FROM A PRE-
/VIOUS CALL NEED TO BE WRITTEN.  THUS IF M NEVER CHANGES
/FROM ITS INITIAL VALUE OF 0 IT CAN BE OMITTED.  HOWEVER
/IF AN ARGUMENT IS CHANGED ALL PRECEEDING ONES MUST BE IN-
/DICATED BY THE PROPER NUMBER OF COMMAS.  OMITTING A VALUE
/IN THIS CASE IS THE SAME AS SPECIFYING 0.  SUCH SHORTCUTS
/MAY BE USED TO SPEED PROGRAM WRITING AND TO SAVE SPACE IN
/THE TEXT STORAGE AREA.  NOTE THAT THE PLOT COMMAND MUST BE
/FOLLOWED BY A TERMINATOR (SPACE, COMMA, SEMICOLON, OR CAR-
/RIAGE RETURN) AND THAT THE ARGUMENTS (IF MORE THAN ONE)
/MUST BE SEPARATED BY COMMAS (PLUS OPTIONAL SPACES).
/EXAMPLE:  (DRAWS A RECTANGLE)

/P,,1;P X;P X,Y;P;P,;P,,

/IS THE SAME AS:

/PLOT 0,0,1,0;PLOT X,0,1,0;PLOT X,Y,1,0
/PLOT 0,Y,1,0;PLOT 0,0,1,0;PLOT 0,0,0,0
/ANNOTATION IN THE FORM OF TEXT (LABELS) AND VARIABLES CAN
/BE WRITTEN ON THE PLOTTER WITH THE FOCAL 'TYPE' (OR 'ASK')
/COMMANDS BY INSERTING A $ AHEAD OF PLOTTER OUTPUT.  THIS
/USE OF THE $ ELIMINATES THE SYMBOL TABLE DUMP.  A SINGLE
/COMMAND CAN BE USED TO PRODUCE BOTH TTY AND PLOTTER OUT-
/PUT PROVIDED THE TTY INFORMATION IS WRITTEN FIRST.  OUT-
/PUT AUTOMATICALLY RETURNS TO THE TTY AT THE END OF THE
/COMMAND AND THE PEN IS RETURNED TO THE START OF THE FIRST
/CHARACTER (LOWER LEFT-HAND CORNER).  A PROGRAM INTERRUPT
/(SUCH AS A FUNCTION ERROR OR HITTING CTRL F) PERFORMS THE
/SAME OPERATIONS.  THERE IS NO 'WRITE $' COMMAND, BUT IF
/DESIRED THE COMMANDS TYPE $;WRITE ... CAN BE USED TO LIST
/PROGRAMS ON THE PLOTTER.  SUCH OUTPUT IS TERMINATED BY A
/'TYPE' COMMAND.  THE OPERATIONS PERFORMED BY '!' AND '#'
/ARE SIMULATED, BUT IN GENERAL ARE EFFECTIVE ONLY DURING
/ONE COMMAND BECAUSE OF THE AUTOMATIC PEN RETURN AT THE END
/THIS MAY BE DEFEATED FOR THE PURPOSE OF PRODUCING TABLES,
/ETC. BY ENDING ALL BUT THE LAST TYPE COMMAND WITH AN UN-
/BALANCED QUOTE (") MARK FOLLOWED BY A CARRIAGE RETURN:

/01.10 TYPE $"TITLE 1 - WHICH IS A VERY LONG TITLE
/01.20 TYPE !"TITLE 2 - WHICH IS SOMEWHAT SHORTER"

/VARIABLES WILL BE PLOTTED JUST AS THEY WOULD BE TYPED -
/ACCORDING TO THE FORMAT SPECIFICATION (%) IN USE.  THUS
/PLOTTER OUTPUT IS ESSENTIALLY IDENTICAL TO TTY OUTPUT BUT
/BOTH THE SIZE AND THE ORIENTATION OF THE WRITING MUST
/BE SPECIFIED.  LETTER SIZES ARE MULTIPLES OF .05" X .07"
/(INCLUDING SEPARATION) AND WRITING CAN BE DONE ALONG ANY
/OF THE 8 BASIC PLOTTER DIRECTIONS (0-7) WHERE DIRECTION 0
/IS ALONG THE +Y AXIS, DIRECTION 2 IS ALONG THE +X AXIS
/ETC.  WRITING ALONG A DIAGONAL IS LARGER BY THE SQRT(2).

/THE SIZE AND DIRECTION ARE SPECIFIED BY PLOT WHEN L=-2. X
/IS THE SIZE AND Y IS THE DIRECTION.  EXAMPLE: PLOT 3,2,-2
/THIS SPECIFIES SIZE 3 LETTERS ALONG THE X-AXIS (DIR 2).
/EXPANSION OF THE PROGRAM CAN PROVIDE FOR VARIOUS CHARACTER
/STYLES (UPPER OR LOWER CASE FOR EXAMPLE) DETERMINED BY M.

/L=-2 IS ALSO USED TO SPECIFY THE ORIENTATION OF THE MARKS.
/IN THIS CASE X=0,Y=THE DESIRED ROTATION, AND M=THE MARK.
/AGAIN ODD ROTATIONS CREATE LARGER MARKS. EX: PLOT,1,-2,12

/FINALLY L=-2 IS USED TO SPECIFY A GENERAL ROTATION OF THE
/AXES WHICH IS EFFECTIVE FOR ALL PLOTTER OPERATIONS.  THIS
/PERMITS ROTATING THE X-AXIS (WHICH NORMALLY RUNS ALONG THE
/LENGTH OF THE PAPER) SO THAT IT RUNS ALONG THE CARRIAGE
/INSTEAD: A CONVENIENCE FOR SMALL PLOTS SO THAT THEY CAN BE
/VIEWED WITHOUT TWISTING ONE'S HEAD.  SUCH ROTATIONS ARE
/SPECIFIED BY SETTING X=0, Y=ROTATION, AND M=0. THE EXAMPLE
/MENTIONED ABOVE IS CODED: PLOT,2,-2,(CARRIAGE RETURN OR ;)

/THESE ROUTINES LOAD INTO FIELD 2 FROM 6200 TO 7577 AND DO
/NOT ALTER THE AMOUNT OF TEXT OR THE NUMBER OF VARIABLES IN
/ANY WAY. 'TDUMP' AND THE FUNCTION FDIS HAVE BEEN REPLACED.
/SYSTEM SYMBOLS:

	CDI=6203
	PLSF=6501
	PLCF=6502
	PLPU=6504
	PLPR=6511
	PLDU=6512
	PLDD=6514
	PLPL=6521
	PLUD=6522
	PLPD=6524
	FIXTAB

/FOCAL SYMBOLS:

	FIELD 1

	ATLIST=1567
	AUTO=16
	CHAR=66
	COMGO=1160
	COMLST=770
	ERROR2=4566
	EVAL=1613
	FIXIT=4453
	GETC=4545
	ILIST=2414
	MCOM=72
	MCR=116
	OUTDEV=63
	PUSHJ=4540
	SORTJ=4547
	TASK4=1232
	TDUMP=3052
	TLIST=1400
	XDYS=1142






/MULTIPLY ROUTINE FOR EAE HARDWARE (SEE PAGE 11)
/
/
/MULT,	0
/	AND N7		/MASK LOW ORDER DIGIT
/	MQL MUY		/MULTIPLY BY SIZE
/SIZE,	0
/	SWP		/PUT RESULT IN AC
/	JMP I MULT
/
/	ZBLOCK 4	/FOR STANDARD ROUTINE
/THIS IS THE ARGUMENT FETCH PART OF PLOT WHICH RESIDES
/WHERE FDIS ONCE DID.  PLOT MAY HAVE FROM 1 TO 4 ARGU-
/MENTS: X,Y,L,M.  THESE ARE STORED IN FIELD 2 AND WHEN
/THE LAST ONE HAS BEEN EVALUATED, THE PROGRAM BRANCHES
/TO XPLT.

	*COMLST+21
	"P		/PLOT

	*COMGO+21
	PLT		/PLOT COMMAND ENTRY

	*XDYS

CONT,	GETC		/SKIP OVER COMMA
	PUSHJ		/EVALUATE ARGUMENT
	    EVAL	/(MAY BE AN EXPRESSION)
	FIXIT		/LOAD AC WITH INTEGER
	CDI 20
	DCA I AUTO	/STORE ARGUMENTS IN SEQUENCE
	TAD CHAR	/CHECK NEXT CHARACTER
	TAD MCOM	/TO SEE IF IT IS A COMMA
	SZA CLA
	JMP I .+3	/NO: CALL PLOTTING ROUTINE
	CDI 10
	JMP CONT	/YES: MORE ARGUMENTS
	XPLT

	*ATLIST+10
	TRAP		/ ;
	TRAP		/CR
/THESE ROUTINES TRAP A $ AND SEND SUBSEQUENT OUTPUT TO
/THE PLOTTER UNTIL A ; OR A CR IS ENCOUNTERED.  ALSO
/INCLUDED IN THIS AREA IS THE INITIALIZE PART OF PLOT.
/THE ERROR RECOVERY ROUTINE USES TRAP TO RETURN THE PEN
/IN CASE OF A BREAK OR FUNCTION ERROR DURING LABEL OUTPUT.

	*3001
PATCH,	CDI 10		/PART OF RECOVR
	JMP TRAP-1

	*TDUMP		/LOCATION OF $ TRAP

POUT,	CDI 20
	JMP I .+1	/PICK UP CURRENT LOCATION AND
	INITL		/TELL PLOT WHAT DIRECTION TO USE
	TAD XLABEL
	DCA OUTDEV	/CHANGE OUTPUT TO PLOTTER
	JMP I .+1
	TASK4		/AND CONTINUE VIA LABEL

LABEL,	0
	TAD MCR		/SET UP AC FOR CR TEST
	CDI 20
	JMS I .+2
	JMP I LABEL	/BACK FOR MORE
	DRAW

	DCA CHAR	/FORCE AN EXIT FROM SORTJ
TRAP,	TAD LABEL	/CHECK TO SEE IF THE
	SNA CLA		/PLOTTER HAS BEEN USED
	JMP RETURN	/NO
	TAD 3174	/YES: RESTORE TTY OUTPUT
	DCA OUTDEV
	CDI 20		/RETURN PEN TO THE START
	JMS I FINAL
	DCA LABEL	/CLEAR FLAG

RETURN,	SORTJ		/FIGURE OUT WHERE TO GO
	    TLIST	/ ; OR CR
	    ILIST-TLIST	/PROCESS OR PC1
	TAD CHAR	/CHECK FOR RECOVR
	SZA CLA
	ERROR2		/FAULTY PLOT COMMAND
	CDI
	IOF
	JMP I 3177	/CONTINUE WITH RECOVR

XLABEL,	LABEL
FINAL,	LTAD

	X-1		/INITIAL ADDRESS
PLT,	TAD .-1		/PLOT COMMAND
	DCA AUTO	/SET UP INDEX REGISTER
	JMP I .+1	/AND FETCH PARAMETERS
	CONT+1
/PDP 8 PLOTTING ROUTINE USING STANDARD D.E.C. INTERFACE

/CALLING SEQUENCE:
/	PLOT    = JMS I (PL0T)
/	X	X COORDINATE
/	Y	Y COORDINATE
/THIS VERSION SKIPS THE NEXT TWO WORDS

/C(AC) DETERMINES POSITION OF THE PEN:
/  C(AC)= -2  SET (SIZE), DIRECTION
/  C(AC)= -1  PEN UP; POSITION AT END OF MOTION SET TO 0,0
/  C(AC)=  0  PEN UP (ZERO MEANS "NO LINE")
/  C(AC)=  1  PEN DOWN
/  C(AC)=  2...  RESERVED FOR DOTTED AND DASHED LINES, ETC.

/COORDINATES ARE EXPRESSED IN UNITS OF PLOTTER STEPS: 0.01"
/THUS MAXIMUM MOTION IS +20.47" AND -20.47" FROM THE ORIGIN
/IN FACT THE MAXIMUM DIFFERENCE BETWEEN TWO POINTS IS ALSO
/RESTRICTED TO +20.47" OR -20.47" SO THAT IN SOME CASES TWO
/CALLS MAY BE REQUIRED TO REACH A POINT.

/THIS VERSION PERMITS ROTATING THE AXES IN 45 DEGREE STEPS.
/THIS FEATURE IS USEFUL FOR PLACING THE X AXIS ALONG THE
/CARRIAGE (ROTATION BY 2) AND IS ALSO USED BY THE LABEL
/ROUTINE.  PLOTTING DONE WITH A ROTATION OF AN ODD MULTI-
/PLE OF 45 DEGREES WILL BE "STRETCHED" UNIFORMLY BY THE
/SQRT(2) DUE TO THE NATURE OF THE PLOTTER MOTIONS.

	FIELD 2
	*6200

PLD0,	PLPL		/PLOTTER OPERATION TABLE
PLD1,	JMS I PLD9
PLD2,	PLDD
PLD3,	PLPR PLDD
PLD4,	PLPR
PLD5,	PLPR PLDU
PLD6,	PLDU
PLD7,	PLPL PLUD
PLD8,	0
	PLPL
	PLDD
	JMP I PLD8
PLOP,	PLD0		/PLOTTER OP CODE FOR DIRECTION 0:+Y
PLD9,	PLD8		/FOR MARK'S CONVENIENCE

DX,	0		/ABSOLUTE VALUE OF X MOTION
DY,	0		/ABSOLUTE VALUE OF Y MOTION

PLPO,	PEN		/PEN CONTROL ROUTINE
PLDR,	DRXN		/SIZE AND DIRECTION ROUTINE
PL07,	7		/MASK
PDIR,	0		/PLOT ROTATION
LDIR,	0		/LABEL DIRECTION
TDIR,	0
PL0T,	0
	IOF		/NO INTERRUPTIONS
	SMA		/TEST FOR NEGATIVE LINE VALUE
	JMP .+5		/CONTINUE IF C(AC)=0 OR 1
	STL RAR		/ARITHMETIC SHIFT RIGHT
	SNL		/EVEN OR ODD ?
	JMP I PLDR	/GET PLOT, LABEL PARAMETERS
	DCA DIAG	/CLEAR AC AND SAVE -1
	JMS I PLPO	/CHECK & SET PEN POSITION

	JMS DXY		/GET X, COMPARE WITH OLD VALUE
LX,	0		/LAST X VALUE
	DCA DX		/STORE ABSOLUTE X MOTION
	JMS DXY		/GET Y, COMPARE WITH OLD VALUE
LY,	0		/LAST Y VALUE
	STL CIA		/NEGATE DY
	TAD DX		/AC=DX-DY
	SZL CLA		/LINK=0 IF DX>DY
	JMP DYGTDX

DXGTDY,	TAD DX		/EXCHANGE DY AND DX
	DCA DXY
	TAD DY
	DCA DX
	TAD DXY
	DCA DY
	IAC		/SET BIT 10 (SIGN OF X)

DYGTDX,	IAC		/SET BIT 11 (SIGN OF Y)
	AND DIAG	/CHECK FOR NEGATIVE VALUES
	SNL		/SKIP IF DY>DX
	RAR		/SIGN OF X -> BIT 11; LINK=0
	CML RTL		/BIT 11 + LINK = DIRECTION/4
	JMS ROTATE	/ADD ROTATION
	DCA AXIS	/STORE IN AXIS INSTRUCTION

	TAD DIAG	/CHECK ON SIGNS AGAIN
	RTR
	SZL		/MODIFY SIGNS TO REFLECT
	CMA		/PLOTTER DIRECTIONS
	RTL
	STL RAL		/2*RESULT+1 = DIRECTION
	JMS ROTATE	/ADD ROTATION
	DCA DIAG	/STORE IN DIAGONAL INSTRUCTION

STRCH,	IAC		/FIND OUT IF ROTATION
	AND DXY		/IS EVEN OR ODD
	SZA CLA		/TABLE AT EVEN ADDRESS
	JMP SETUP	/EVEN: CONTINUE
	TAD DX		/ODD: ADJUST RATIO
	TAD DY
	DCA DY
	TAD DX		/DOUBLE DIAGONAL STEPS
SETUP,	TAD DX		/DX IS MINOR MOTION
	CIA		/NEGATE FOR EASY SUBTRACTION
	DCA DX
	TAD DY		/DY IS MAJOR MOTION
	CMA		/AND DETERMINES STEP COUNT
	DCA DXY
	TAD DY		/HALF THE TOTAL MOTION
	CLL RAR		/IS SET IN THE AC
	JMP AXIS+4

LOOP,	TAD DX		/SUBTRACT DIAGONAL INCREMENT
	SMA		/TEST IF DIAG MOTION REQUIRED
	JMP AXIS	/NO
	TAD DY		/YES: RESTORE AXIS INCREMENT
DIAG,	0		/COMBINED MOTION (X + Y)
	SKP
AXIS,	0		/SINGLE MOTION (X OR Y)
	PLSF		/WAIT 'TILL DONE
	JMP .-1
	PLCF
	ISZ DXY		/COUNT THE STEPS
	JMP LOOP
EXIT,	DCA DIAG	/CLEAR AC & DIAG BITS 0-1
	ION		/DONE: INTERRUPTS OK NOW
	ISZ PL0T	/ADVANCE PAST
	ISZ PL0T	/NEXT TWO WORDS
	JMP I PL0T	/AND RETURN

DXY,	0
	TAD I DXY	/GET LAST X OR LAST Y
	CIA		/NEGATE
	TAD I PL0T	/AC=NEW-OLD
	CLL		/SET LINK FOR POSITIVE SIGN
	SPA		/TEST FOR SIGN
	CML CIA		/REMEMBER SIGN & NEGATE
	DCA DY		/STORE ABSOLUTE Y MOTION
	TAD DIAG
	RAL		/SAVE MINUS SIGN
	DCA DIAG
	SNL		/CHECK FOR NEW ORIGIN
	TAD I PL0T	/GET NEW VALUE
	DCA I DXY	/REPLACE PREVIOUS ONE
	TAD DY		/SET AC FOR NEXT OPERATION
	ISZ PL0T	/SET NEXT ADDRESS 
	ISZ DXY		/SET RETURN ADDRESS
	JMP I DXY	/RETURN

ROTATE,	0		/ROTATE IN 45 DEGREE STEPS
	TAD PDIR	/ADD PLOT ROTATION (0-7)
	TAD TDIR	/AND LABEL ROTATION (IF ANY)
	AND PL07	/MODULO EIGHT
	TAD PLOP	/ADD CODE FOR PLD0
	DCA DXY		/SAVE TABLE ADDRESS
	TAD I DXY	/GET INSTRUCTION
	JMP I ROTATE	/AND RETURN
/THIS ROUTINE DRAWS ANY ASCII SYMBOL ON THE PLOTTER.
/IN ADDITION TO THE 63 ASCII SYMBOLS, THE CODES FOR 
/CR AND LF ARE RECOGNIZED AND USED TO SIMULATE THESE
/COMMANDS.  SYMBOLS ARE BASED ON A 5 X 7 GRID OF WHICH
/4 X 6 IS USED SO AS TO PROVIDE SPACING.  SIZE 2 CHAR-
/ACTERS ARE THUS .08" X .12" WITH .02" BETWEEN THEM.
/LF MOVES .1" X SIZE BELOW THE PRESENT LINE, BUT IS EF-
/FECTIVE ONLY DURING A SINGLE OUTPUT COMMAND AS THE PEN
/IS ALWAYS RETURNED TO THE STARTING POSITION AT THE END.

	SX
INITL,	TAD LDIR	/GET LABEL DIRECTION
	DCA TDIR
	TAD LX		/SAVE CURRENT POSITION
	DCA I .-4
	TAD LY		/PAGE BOUNDARY
	DCA SY
	TAD SX		/"S" MEANS STARTING
	DCA RX		/"R" MEANS RUNNING
	TAD SY
	DCA RY
	CDI 10
	JMP I .+1	/CONTINUE WITH OUTPUT
	POUT+3

DRAW,	0
	SNA		/ASCII-CR IN AC
	JMP CR		/RETURN PEN TO (SX,RY)
	TAD N3
	SNA		/TEST FOR LF
	JMP LF		/PLACE PEN AT (RX,RY-.1*SIZE)
	TAD FIVE+2	/RESTORE ORIGINAL CODE
	AND N77		/ONLY NEED SIX BITS
	SNA		/IGNORE ZERO
	JMP SEVEN	/("@" NOT AVAILABLE)
	CIA		/NEGATE
	DCA TWO		/LETTER COUNTER
	TAD TBAD	/LOAD STARTING ADDRESS
	DCA LTAD	/INTO SEARCH ADDRESS
	JMP HALF	/AND GO SEARCH 

	ZBLOCK 3	/PATCH FOR ALTERNATE MODES

ZERO,	TAD I LTAD	/LOOK AT THIS WORD
	ISZ LTAD	/POINT TO NEXT ONE
	CMA
	AND N77
	SNA CLA		/DOES IT END IN 77 ?
HALF,	ISZ TWO		/YES: FOUND IT ?
	JMP ZERO	/NO:  KEEP GOING
ONE,	TAD I LTAD	/GET FIRST MOVE
	RTR		/COULD USE
	RTR		/BSW = 7002
	RTR		/ON PDP 8/E
	JMS TWO
	TAD I LTAD	/GET SECOND MOVE
	JMS TWO
	ISZ LTAD	/ADVANCE TO NEXT WORD
	JMP ONE		/CONTINUE

TWO,	0
	AND N77		/GET RID OF THE OTHER PIECE
	DCA MOVE	/AND SAVE MOVE

THREE,	STL RTL		/=2 - TRICKY WAY TO GET -76
	TAD FOUR	/THIS INSTRUCTION ADDS 7700
	TAD MOVE	/ADD -76 TO MOVE
	SZA
	JMP FOUR	/NOT PEN UP, CHECK FOR END
	DCA LN		/76 MEANS RAISE THE PEN
	JMP I TWO	/AND CONTINUE

FOUR,	SMA CLA		/TEST FOR 77 (INST. = 7700)
	JMP SIX		/MOVE TO POSITION (5,0)

FIVE,	TAD MOVE	/GET X MOTION
	RAR
	RTR		/THIS INSTRUCTION ENDS IN 12
	JMS MULT	/MULTIPLY BY SIZE
	DCA IX		/"I" MEANS "INCREMENTAL"
	TAD MOVE	/GET Y MOTION
	JMS MULT
	JMS MOVE	/"IY" IS IN AC
	ISZ LN		/INCREASE LINE VALUE 
	JMP I TWO	/GET NEXT BYTE

SIX,	TAD N5		/EQUALS WIDTH OF LETTER
	JMS MULT	/TIMES SIZE
	DCA IX		/STORE MOTION AND SET IY=0
	DCA LN		/MOVE WITH PEN UP
	JMS MOVE	/"IY"=0
	TAD IX
	DCA RX		/UPDATE CURRENT X VALUE

SEVEN,	CDI 10
	JMP I DRAW	/END OF THIS LETTER

N3,	3
N5,	5
N7,	7
N77,	77
CR,	TAD SX		/GET STARTING VALUE
	DCA RX		/AND RESET RX
	JMP SIX+2	/CLEAR IX,IY(=AC), AND LN

LF,	DCA IX		/SET IX TO ZERO
	TAD N5
	JMS MULT	/5*SIZE
	CMA IAC		/NEGATE
	CLL RAL		/AND MULTIPLY BY 2
	JMS MOVE	/TO (RX,-10*SIZE)
	TAD IY
	DCA RY		/UPDATE RY
	JMP SEVEN	/RETURN TO CALLING PROG.

MULT,	0
	AND N7		/MASK LOW ORDER DIGIT
	CMA		/EQUALS -(MOVE+1)
	DCA IY		/STORE IN STEP COUNTER
	SKP		/IN CASE MLPR=0
	TAD SIZE	/ADD MCND UNTIL
	ISZ IY		/MLPR RUNS OUT
	JMP .-2
	JMP I MULT
SIZE,	0		/THIS IS THE LETTER SIZE

MOVE,	0		/ROUTINE TO CALL PLOT
	TAD RY		/ADD STARTING VALUE TO AC
	DCA IY		/TO GET NEXT Y POSITION
	TAD RX		/GET START OF THIS LETTER
	TAD IX		/ADD IN X INCREMENT
	DCA IX		/TO GET NEXT X POSITION
	TAD LN		/GET LINE VALUE
	SZA CLA		/CHECK FOR PEN UP
	IAC		/OTHERWISE SET AC=1 (PEN DOWN)
	PLOT		/GET PLOT TO MOVE THE PEN
IX,	0		/X COORDINATE
IY,	0		/Y COORDINATE
RX,	0		/THESE TWO ARE SKIPPED
RY,	0
	JMP I MOVE

LTAD,	0
	PLOT		/RETURN TO THE BEGINNING
SX,	0
SY,	0
LN,	0
TBAD,	LTRA
	CDI 10
	JMP I LTAD	/AND RETURN TO FOCAL

	TDIR		/ADDRESSES FOR XPLT
	L

	PLOT=JMS I .
	PL0T
/PDP 8 CALCOMP ROUTINE:  MARK

/THIS ROUTINE DRAWS A SPECIFIED MARK CENTERED AT THE
/CURRENT PLOTTER POSITION.  MARK 0 IS A NULL AND NO
/ACTION OCCURS.  SPECIFYING A NON-EXISTENT MARK WILL
/CAUSE A SIMILAR EXIT.

/MARKS ARE CODED AT THE END OF THE PROGRAM ACCORDING
/TO THE FOLLOWING PLAN:  RDRD,RDRD,... WHERE R =
/REPETITION NUMBER (0-7) AND D = PLOTTER DIRECTION
/(0-7).  DIRECTIONS ARE COMPUTED RELATIVE TO ANY RO-
/TATION SPECIFIED BY PLOT. THIS PERMITS MARKS WITHOUT
/C/8 SYMMETRY TO FOLLOW ROTATIONS OF THE AXES.
/RD = 00/01 SPECIFIES PEN UP/DOWN AND RD = 07 OR 0707
/SIGNIFIES THE END OF A MARK.  THE CODE 0706 FOLLOWS 
/THE LAST MARK.  THE TABLE MAY BE CHANGED AS DESIRED.


XPLT,	DCA I .-3	/ENTRY FROM PLOT CALL
	TAD I .-3	/CLEAR TDIR & GET L

	PLOT
X,	0		/CALLING PARAMETERS
Y,	0		/ARE STORED HERE IN
L,	0		/SEQUENCE
M,	0

MARK,	ZBLOCK 1	/TOO MANY COMMAS!
	TAD M		/GET MARK NUMBER
	SPA SNA		/TEST FOR MARK >0
	JMP BACK	/ZERO = NONE
	CIA		/NEGATE
	DCA ZWEI	/STORE IN MARK COUNTER
	TAD TABL	/GET START OF MARK TABLE
	DCA MKAD
	JMP HALB
	PLD8		/FOR DIRECTION 1

TABL,	DOT		/FIRST MARK
MKAD,	0

NULL,	IAC		/TEST FOR END OF TABLE
	SNA CLA
	JMP BACK	/NON-EXISTENT MARK
	TAD I MKAD	/LOOK AT THIS WORD
	ISZ MKAD	/AND POINT TO NEXT
	AND K77		/ONLY KEEP LOWER BYTE
	TAD M7
	SNA		/END OF THIS MARK ?
HALB,	ISZ ZWEI	/HAVE WE FOUND IT ?
	JMP NULL	/NO
	IOF		/PROTECT PLOT ORIGIN
EINS,	TAD I MKAD	/GET FIRST MOTION
	RTR		/COULD USE
	RTR		/BSW = 7002
	RTR		/ON PDP 8/E
	JMS ZWEI
	TAD I MKAD	/GET SECOND MOTION
	JMS ZWEI
	ISZ MKAD	/ADVANCE
	JMP EINS	/CONTINUE

ZWEI,	0
	AND K77		/GET RID OF THE OTHER PIECE
	DCA X		/TEMPORARY STORAGE
	TAD M7
	TAD X		/NOW LOOK AT CODE
	SNA		/TEST FOR END OF MARK
	JMP BACK	/RETURN WITH AC=0
	SMA CLA		/TEST FOR PEN MOTION
	JMP DREI	/EXECUTE XY MOTION
	TAD X		/GET PEN CODE
	JMS PEN		/MOVE PEN IF NECESSARY
	JMP I ZWEI	/DO NEXT OPERATION

DREI,	TAD X		/GET DIRECTION
	TAD MDIR	/ADD ROTATION
	JMS I PLTR	/FORMULATE AND
	DCA VIER+1	/SAVE INSTRUCTION
	TAD MDIR
	TAD I BACK-7	/CHECK ROTATION
	AND X		/FOR ODDNESS
	CMA RAR		/SAVE -(BIT 11)
	CLA CMA
	AND X		/GET REPETITION
	AND .+1		/STRIP BITS 6-8
	SNA SZL		/SAME AS SZL BUT CODE XX70
	CLL RAR		/SKIP = EFFECTIVE X2
	RTR		/SHIFT INTO PLACE
	CIA		/NEGATE

VIER,	IAC		/INCREMENT LOOP COUNT
	0		/PLOTTER INSTRUCTION
	PLSF		/WAIT FOR PLOTTER
	JMP .-1
	PLCF
	SZA		/TEST LOOP COUNT
	JMP VIER	/KEEP GOING
	JMP I ZWEI	/GET NEXT BYTE

MDIR,	0		/MARK ROTATION
PLTR,	ROTATE

K77,	77
M7,	-7
PEN,	0		/CHECK PEN POSITION
	CLL RTL		/AC=0>>PEN UP; AC=1>>DOWN
	STL RTL		/SHIFT BIT INTO PLACE
	TAD PNOP+3	/ADD CODE FOR PEN UP
	CIA		/NEGATE
	TAD PNOP	/OLD - NEW
	SNA		/OLD = NEW ?
	JMP I PEN	/YES: DON'T MOVE PEN
	CIA		/NEW - OLD
	TAD PNOP	/NEW
	DCA PNOP
PNOP,	PLPU		/ASSUME PEN UP INITIALLY
	PLSF		/ALLOW PLOTTER TO FINISH
	JMP .-1
	PLCF
	JMP I PEN

DRXN,	CLA		/THIS ROUTINE ENTERED
	TAD X		/FROM PLOT WHEN L=-2
	SZA		/TEST X
	JMP BACK-4	/IF X IS NON-ZERO SET SIZE
	TAD M		/OTHERWISE CHECK M
	SNA CLA
	JMP .+4		/IF ZERO GET PLOT ROTATION

	TAD Y
	DCA MDIR	/SAVE MARK ROTATION
	JMP BACK

	TAD Y
	DCA I .+2	/SAVE PLOT ROTATION
	JMP BACK
	PDIR

	SIZE
	LDIR
	DCA I .-2	/SAVE LETTER SIZE
	CMA CLL RAL	/SET AC=-2 BECAUSE LETTERS
	TAD Y		/ARE CODED FOR DIRECTION 2
	DCA I .-4

BACK,	ION		/RE-ENABLE INTERRUPTS
	CDI 10
	JMP I .+1
	RETURN		/COMMAND RETURN


/NEXT COME THE MARKS:
DOT,	0110		/MARK NUMBER 1
	1315
	1016
	2216
	1015
	1310
	0007
BAR,	0152		/MARK NUMBER 2
	5656
	5207
TICK,	0150		/MARK NUMBER 3
	5054
	5407
	0142		/MARK NUMBER 4
	4646
	4244
	4040
	4407
XMARK,	0131		/MARK NUMBER 5
	6531
	3367
	3307
CIRCLE,	0025		/MARK NUMBER 6
	0117
	2021
	2223
	2425
	2617
	0021
	0707
SCIRCL,	0125		/MARK NUMBER 7
	1720
	2122
	2324
	2526
	1730
	1122
	1324
	1526
	3022
	2416
	1007
TRIANG,	0021		/MARK NUMBER 8
	0113
	1413
	1413
	5656
	1021
	1011
	1011
	1011
	1423
	1400
	2507
STRIAN,	0121		/MARK NUMBER 9
	1314
	1314
	1356
	5610
	2110
	1110
	1110
	1114
	2334
	1314
	7621
	1011
	1011
	1412
	3413
	4611
	1011
	2407
SQUARE,	0035		/MARK NUMBER 10
	0160
	6264
	6600
	3107
SSQUAR,	0137		/MARK NUMBER 11
	6264
	6650
	5244
	4630
	3224
	2610
	1207
DIAMND,	0023		/MARK NUMBER 12
	0125
	4741
	4325
	0027
	0707
SDIAMN,	0123		/MARK NUMBER 13
	2547
	4143
	2516
	1537
	3133
	1516
	1527
	2123
	1615
	1711
	1407
STAR,	0024		/MARK NUMBER 14
	0125
	1615
	1011
	2011
	2011
	2011
	1413
	1413
	2413
	2413
	1417
	1627
	1627
	1627
	6262
	2516
	2516
	0020
	0707
CROSS,	0032		/MARK NUMBER 15
	1001
	2721
	6623
	2527
	6421
	2325
	6227
	2123
	6025
	0014
	3607
LAST,	0706		/END OF MARK TABLE

	PAGE		/ROOM FOR ADDITIONS
LTRA,	0004	/CHARACTER TABLE FOR CALCOMP PLOTTER
	1636
	4443
	0343
	4077
LTRB,	0333
	4241
	3000
	0636
	4544
	3377
LTRC,	4536
	1605
	0110
	3041
	7777
LTRD,	3000
	0636
	4541
	3077
LTRE,	4606
	0333
	0300
	4077
LTRF,	0003
	3303
	0646
	7777
LTRG,	4536
	1605
	0110
	3041
	4323
	7777
LTRH,	0006
	0343
	4640
	7777
LTRI,	0040
	2026
	0646
	7777
LTRJ,	0201
	1030
	4146
	7777
LTRK,	0600
	0246
	2440
	7777
LTRL,	0600
	4077
LTRM,	0006
	2346
	4077
LTRN,	0006
	4046
	7777
LTRO,	4130
	1001
	0516
	3645
	4177
LTRP,	0006
	3645
	4433
	0377
LTRQ,	2240
	1001
	0516
	3645
	4130
	7777
LTRR,	0006
	3645
	4433
	0323
	4077
LTRS,	0110
	3041
	4233
	1304
	0516
	3645
	7777
LTRT,	2026
	0646
	7777
LTRU,	0601
	1030
	4146
	7777
LTRV,	0620
	4677
LTRW,	0610
	2330
	4677
LTRX,	0046
	2306
	4077
LTRY,	2023
	0623
	4677
LTRZ,	0646
	0040
	7777
LBRAKT,	3616
	1030
	7777
BSLASH,	0640
	7777
RBRAKT,	1636
	3010
	7777
UPAROW,	2026
	0426
	4477
LFAROW,	1103
	1503
	4377
SPACE,	7777
EXCLPT,	2011
	2215
	2635
	2231
	2077
QUOTE,	1614
	7636
	3477
NUMSGN,	1026
	2414
	4446
	3242
	1232
	3077
DOLLAR,	0110
	3041
	4233
	1304
	0516
	3645
	3626
	2077
PERCNT,	0046
	7614
	0516
	2514
	7630
	2132
	4130
	7777
AMPER,	4220
	0001
	2516
	0540
	7777
APOST,	2624
	7777
LPAREN,	2012
	1426
	7777
RPAREN,	2032
	3426
	7777
ASTER,	0145
	2320
	2623
	0541
	7777
PLUS,	2125
	2303
	4377
COMMA,	1021
	2212
	1121
	7777
MINUS,	0343
	7777
PERIOD,	2122
	1211
	2177
SLASH,	0046
	7777
NMBR0,	4130
	1001
	0516
	3645
	4177
NMBR1,	0040
	2026
	1577
NMBR2,	0516
	3645
	4401
	0040
	7777
NMBR3,	0110
	3041
	4233
	1333
	4445
	3616
	0577
NMBR4,	3036
	0242
	7777
NMBR5,	0110
	3041
	4233
	0306
	4677
NMBR6,	2602
	0110
	3041
	4233
	2377
NMBR7,	2046
	0677
NMBR8,	1333
	4241
	3010
	0102
	1304
	0516
	3645
	4433
	7777
NMBR9,	2044
	4536
	1605
	0413
	3377
COLON,	1121
	2212
	1176
	1424
	2515
	1477
SCOLON,	1021
	2212
	1121
	7624
	2515
	1424
	7777
LSTHAN,	3513
	3177
EQUAL,	4404
	7602
	4277
GTTHAN,	1133
	1577
QUESTN,	1426
	3645
	4433
	3077	/END OF CHARACTER TABLE
	$
