
 .TITLE FNEW
 .GLOBL .NEWF
 .GLOBL .AX
 .GLOBL XSPNOR
 .GLOBL FUNERR
 .GLOBL UTRA
 .GLOBL EVAL
 .GLOBL XPUSHJ
 .GLOBL EFUN3
 .GLOBL CHAR
 .GLOBL .AF
 .GLOBL .AW
.NEWF     .NEWFE-.-1/2\777777+1
          .SIXBT 'GRF'
          JMP    PLOT
          .SIXBT 'INT'
          JMP    INIT
          .SIXBT 'PLT'
          JMP    FPLT
          .SIXBT 'CLS'
          JMP    CLOSE
          .SIXBT 'RDM'
          JMP    RANDOM
          .SIXBT 'DPY'
          JMP    DISPLAY
.NEWFE=.
 
PLSF=705561
LBUFF=705222
GATE=705562
CLKON=705201
DACEU=701561
DACY=701524
DRCF=707002
DRSF=707001
DRDA=707004
TLS=700406
TSF=700401
 
PLOT      JMS*  .AX
          DAC   N
          SAD   ONE
          JMP   UPEN
          SAD   TWO
          JMP   DPEN
          SAD   THREE
          JMP   ZERO
          SAD   FOUR
          JMP   PRINT
          JMP*  EFUN3
ZERO      LAC   SEVEN       / ZERO Y AND RESET
          JMS   OUT         / X AND Y
          DZM   XS
          DZM   YS
          DZM   PEN
          JMP*  EFUN3       / RETURN
UPEN      LAC   PEN
          SNA
          JMP   BRIN
          LAC   ONE         / RAISE PEN
          JMS   OUT
          DZM   PEN
          JMP   BRIN
DPEN      LAC   PEN
          SZA
          JMP   BRIN
          LAC   TWO         / LOWER PEN
          JMS   OUT
          LAC   ONE
          DAC   PEN
BRIN      JMS   GETARG      / BRING IN X
          DAC   X1
          JMS   GETARG      / BRING IN Y
          DAC   Y
          SPA               / IF Y < 0 ZERO Y
          DZM   Y
          TAD   FHUN        / SUBTRACT 400
          SPA
          JMP   CONT
          LAC   FHUN
          TCA               / IF Y > 400 SET Y =400
          DAC   Y
CONT      LAC   ONE
          DAC   NUMX        / INITIALIZE THE STEP
          DAC   NUMY        / SIZES TO 1
          LAC   XS
          TCA               / FIND DELTA X
          TAD   X1
          DAC   DELX
          LAC   YS
          TCA               / FIND DELTA Y
          TAD   Y
          DAC   DELY
          LAC   DELX
          SPA
          JMP   L2
          SZA
          JMP   L1
          DZM   NUMX
          JMP   L3
L1        LAC   THREE
          DAC   STEPX       / MAKE X STEP +VE
          JMP   L3
L2        TCA               / MAKE DELX +VE
          DAC   DELX
          LAC   FOUR
          DAC   STEPX       / MAKE X STEP -VE
L3        LAC   DELY
          SPA
          JMP   L5
          SZA
          JMP   L4
          DZM   NUMY
          JMP   L6
L4        LAC   FIVE
          DAC   STEPY       / MAKE Y STEP +VE
          JMP   L6
L5        TCA               / MAKE DELY +VE
          DAC   DELY
          LAC   SIX
          DAC   STEPY       / MAKE Y STEP -VE
L6        LAC   NUMX
          SNA
          JMP   L8
          LAC   NUMY
          SZA
          JMP   L9
          LAC   DELX
          DAC   DX
          JMP   FINX        / STEP OFF X DIRECTION
L8        LAC   NUMY
          SNA
          JMP*  EFUN3       / RETURN
          LAC   DELY
          JMP   FINY        / STEP OFF Y DIRECTION
L9        LAC   DELX
          TCA
          TAD   DELY
          SPA               / IS DELY > DELX
          JMP   L95         / NO
          LAC   DELY        / YES SO EXCHANGE
          DAC   TEMP        / DELX AND DELY
          LAC   DELX        / VALUES
          DAC   DELY
          LAC   TEMP
          DAC   DELX
          LAC   STEPY
          DAC   TEMP
          LAC   STEPX
          DAC   STEPY
          LAC   TEMP
          DAC   STEPX
L95       LAC   DELX
          DAC   DX
L10       LAC   DELY
          TCA
          TAD   DELX
          DAC   Z
          TCA
          TAD   DELY        / IS Z > DELY
          SZA!SMA
          JMP   L11
          ISZ   NUMX        / YES SO SUB. ANOTHER
          LAC   Z           / DELY FROM DELX
          DAC   DELX
          JMP   L10
L11       LAC   NUMX
          TAD   DELY
          TCA
          TAD   DELX
          DAC   ZS
          SZA!SMA
          JMP   L12
          LAC   ONE         / IF ZS .LE. 0 MAKE
          DAC   ZS          / IT =1
L12       JMS*  .AF         / DIVIDE
          LAC   DELY
          JMS*  .AF
          DAC   R
          TAD   M1          / SUBTRACT 1
          SMA
          JMP   L14
          LAC   ZS
          TCA
          TAD   DELY
          JMS*  .AF
          LAC   DELY
          JMS*  .AF
          DAC   R
          LAC   NUMX
          DAC   NUMR
          ISZ   NUMX
          JMP   L145
L14       LAC   NUMX
          TAD   ONE
          DAC   NUMR
L145      LAC   R
          DAC   RC
L15       LAC   NUMX
          DAC   COUNT
L16       LAC   STEPX
          JMS   OUT
          LAC   COUNT
          TAD   M1
          DAC   COUNT
          LAC   DX
          TAD   M1
          DAC   DX
          SNA               / ARE ALL THE X STEPS USED UP
          JMP   FINY        / YES SO FINISH THE Y STEPS
          LAC   COUNT
          SZA
          JMP   L16
          LAC   STEPY
          JMS   OUT
          LAC   DELY
          TAD   M1
          DAC   DELY
          SNA               / ARE ALL THE Y STEPS USED UP
          JMP   FINX        / YES SO FINISH X
          LAC   RC
          TAD   M1
          SZA
          JMP   L15
          LAC   NUMR
          DAC   COUNT
          LAC   R
          DAC   RC
          JMP   L16
FINX      LAC   DX
          SNA
          JMP   DONE
          LAC   STEPX
          JMS   OUT
          LAC   DX
          TAD   M1
          DAC   DX
          JMP   FINX
FINY      LAC   DELY
          SNA  
          JMP   DONE
          LAC   STEPY
          JMS   OUT
          LAC   DELY
          TAD   M1
          DAC   DELY
          JMP   FINY
DONE      LAC   X1
          DAC   XS
          LAC   Y
          DAC   YS
          JMP*  EFUN3       / RETURN TO FOCAL
                            /
PRINT     JMS*  XSPNOR       / OUTPUT ASCII ROUTINE
          SAD   (254
          JMP   .+3
          LAW   1
          JMP*  FUNERR
PR        JMS*  UTRA
          LAC*  CHAR
          SAD   (206
          JMP*  EFUN3
          TAD   C1           / C1 = -240
          DAC   CHR
          TAD   C2           / IS IT A LEGAL CHAR
          SMA
          JMP*  EFUN3        / RETURN IF ILLEGAL
          IOF
          LAC   CHR
          TAD   CHR
          TAD   CHR
          TAD   CHR
          TAD   CHR
          CLL!RAL
          DAC   ADR
          LAC   M10          / M10 = -10
          DAC*  WC           / SET UP WC
          JMS   BLOCK
BSTRT     0
          0
          0
          0
          0
          0
          0
          0
          0
          0
          0
BLOCK     0
          LAC   BLOCK
          DAC*  CA           / SET UP CA
          LAC   ADR
          TAD   DRUM         / GET DRUM SETUP WORD
          DRCF               / CLEAR DRUM FLAG
          DRDA               / OUTPUT DRUM SETUP WORD
          DRSF               / TEST DRUM FLAG
          JMP   .-1
          DRCF
          LAC   M10
          DAC   COUNT
PRN1      LAC   SIX
          TCA
          DAC   DX
          ISZ   BLOCK
PRN2      LAC*  BLOCK
          AND   MASK          / PREPARE 1ST WORD
          SNA
          JMP   FIN
          JMS   OUT
          LAC*  BLOCK
          RTR
          RCR
          DAC*  BLOCK
          ISZ   DX
          JMP   PRN2
          ISZ   COUNT
          JMP   PRN1
FIN       ION
          JMP   PR
                             / STORAGE LOCATIONS
N         0
X1        0
Y         0
PEN       0
ONE       000001
TWO       000002
THREE     000003
FOUR      000004
FIVE      000005
SIX       000006
SEVEN     000007
XS        0
YS        0
FHUN      777160            / = -400
NUMX      0
NUMY      0
DELX      0
DELY      0
STEPX     0
STEPY     0
TEMP      0
M1        777777
NUMR      0
Z         0
ZS        0
R         0
RC        0
COUNT     0
DX        0
M5        777773
C1        777540
C2        777446
CHR       0
ADR       0
M10       777766
DRUM      770000
WC        17764
CA        17765
      / SUBROUTINE GETARG
      / THIS SUBROUTINE GETS AN ARGUMENT
      / AND CONVERTS IT TO AN INTEGER
GETARG    0
          JMS*  XSPNOR      / SKIP SPACES
          SAD   (254        / IS IT A COMMA
          JMP   .+3
          .DEC
          LAW   1           / NO A ??01 ERROR
          .OCT
          JMP*  FUNERR
          JMS*  UTRA        / SKIP COMMA
          LAC   EVAL
          DAC   .+2
          JMS*  XPUSHJ
          XX
          JMS*  .AX
          JMP*  GETARG
      / SUBROUTINE OUT
      / THIS SUBROUTINE TAKES THE CONTROL CODE
      / FROM THE AC AND PUTS IT OUT TO THE PLOTTER
OUT       0
          DAC   TEMP
          AND   MASK
          RTR
          RTR
          PLSF               / TEST PLOTTER FLAG
          JMP   .-1
          LBUFF              / LOAD SERIAL TRANSFER BUFF.
          GATE               / SET THE F-F TO GATE IN THE
                             / DATA AND CLOCK PULSES
          CLKON              / START SERIAL DATA CLOCK
          RTL
          RTL
          TAD   M5
          SPA                / SKP IF Y MOVEMENT IS REQD.
          JMP*  OUT
          TAD   M1
          SMA
          JMP   CLY
          LAC   YSTP
          TAD   CNT          / CNT = 4 PER STEP
          DAC   YSTP
OUTY      RTL
          RTL
          RTL
          DACEU              / ENABLE DACY UNSIGNED
          DACY               / AC 0-11 -> DACY
          LAC   TEMP
          JMP*  OUT
CLY       SNA
          JMP   DOWNY
          LAC   YZERO
          DAC   YSTP
          JMP   OUTY
DOWNY     LAC   YSTP
          TAD   MCNT         / MCNT = -4 PER STEP
          DAC   YSTP
          JMP   OUTY
MASK      000007
YSTP      001000
CNT       000010
YZERO     001000
MCNT      777770
/
INIT IOF     /TURN ON GRAPICS MODE & CLEAR AS SPEC.
 JMS* .AX
 DAC I       /CLEAR FLAGS
 AND (2
 SZA
 JMS CS      /CLEAR SCREEN
 LAC (6      / ^F
 JMS PRNT
 LAC (26     / ^V
 JMS PRNT
 LAC I
 AND (1
 SZA
 JMS CG     /CLEAR ANY GRAPHICS
 ION
 JMP* EFUN3   /RETURN
/
I 0
/
PRNT 0
 TLS
 TSF
 JMP .-1
 JMP* PRNT
/
CS 0       /CLEAR SCREEN
 LAC (24
 JMS PRNT
 JMP* CS
/
CG 0     /CLEAR ANY GRAPHICS DISPLAY
 LAC (10
 JMS PRNT
 JMP* CG
/
CLOSE IOF     /TURN OFF GRAPHICS MODE & CLEAR AS SPEC.
 JMS* .AX
 DAC I
 AND (1
 SZA
 JMS CG
 LAC (7
 JMS PRNT
 LAC I
 AND (2
 SZA
 JMS CS
 ION
 JMP* EFUN3
/
FPLT IOF
 JMS* .AX
 DAC YG      /Y COORDINATE
 AND (77
 XOR (100
 JMS PRNT    /EVEN CHAR.
 LAC YG
 AND (300
 RTR
 RTR
 RTR
 DAC YG     /UPPER BITS OF Y
 JMS GETARG   /GET CONTROL BITS
 AND (7
 CLL
 RTL
 XOR YG
 XOR (140
 JMS PRNT    /ODD CHAR.
 ION
 JMP* EFUN3
/
YG 0
 /
RANDOM	LAW	-6
	DAC	SIXCNT#
CALL	JMS	RAND
	ISZ	SIXCNT#
	JMP	.-2
	DAC	CHI#
	AND	(400077
	SNA
	JMP	CALL
	RCL
	LAC	CHI
	AND	(77
	SZL
	TCA
	JMS*	.AW
	JMP*	EFUN3
RAND	0
%BEGIN	LAC	RNNO
	AND	(400100
	SNA
	JMP	%LAC2
	SAD  (400100
	JMP	%LAC2
	LAC	RNNO
	RCL
	IAC!CLL
	JMP	%DAC1
%LAC2   LAC	RNNO
	RCL
%DAC1	DAC	RNNO
	JMP*	RAND
RNNO	3
ENA=701521
ENB=701541
XFR=701564
DISPLAY	JMS*	.AX
	AND	(777000
	SWHA
	DAC	HOR#
        JMS     GETARG
        AND     (777000
        TAD     HOR
        ENA
        ENB
        XFR
        JMP* EFUN3
	.END
