; FLOWER - Pretty radial pattern

; Constants about machine.

COREND	= 8.*2048.	; First unusable word. (8K words of store: two 4K pages)
WIDTH	= 1024.		; Height of display
HEIGHT	= 768.		; Width of display

; Address of registers.

DPC     = 172000        ; VT40 Program counter
DSR     = 172002        ; VT40 Status register
XSR     = 172004        ; X status register
YSR     = 172006        ; Y status register

; Recommended mnemomics

CHAR    = 100000        ; Character mode
SHORTV  = 104000        ; Short vector mode
LONGV   = 110000        ; Long vector mode
POINT   = 114000        ; Point mode
GRAPHX  = 120000        ; Graphplot X mode
GRAPHY  = 124000        ; Graphplot Y mode
RELATV  = 130000        ; Relative point mode

INT0    = 2000          ; Intensity modes
INT1    = 2200
INT2    = 2400
INT3    = 2600
INT4    = 3000
INT5    = 3200
INT6    = 3400
INT7    = 3600

LPOFF   = 100           ; Light pen off
LPON    = 140           ; and on

BLKOFF  = 20            ; Blink off
BLKON   = 30            ; and on

LINE0   = 4             ; Solid line
LINE1   = 5             ; Long dash
LINE2   = 6             ; Short dash
LINE3   = 7             ; Dot dash

DJMP    = 160000        ; Display jump
DNOP    = 164000        ; Display NOP

STATSA  = 170000        ; Load status A
DSTOP   = 173400        ; Display stop and interrupt

SINON   = 1400          ; Stop interrupt on
SINOFF  = 1000          ; Stop interrupt off
LPLITE  = 200           ; Light pen hit on
LPDARK  = 300           ; and off

ITAL0   = 40            ; Italics off
ITAL1   = 60            ; and on

SYNC    = 4             ; Halt and resume in Sync

STATSB  = 174000        ; Load status B
INCR    = 100           ; Graphplot increment

INTX    = 40000         ; Intensify vector or point
MAXX    = 1777          ; Max delta-x
MAXY    = 1377          ; Max delta-y

MINUSX  = 20000         ; -ve delta-x
MINUSY  = 20000         ; -ve delta-y

MAXSX   = 17600         ; Max delta-x in short mode
MAXSY   = 77            ; Max delta-y

MISVX   = 20000         ; -ve delta-x
MISVY   = 100           ; -ve delta-y

        .PSECT

;       PDP-11 program

;	The pattern is done by drawing radial lines with a dash pattern which
;	corresponds to the direction of the vector (its argument!).
;	(Its bit pattern laid out sideways, if you like).
;	Doing radial graphics on this Euclidian device is eased by the following
;	circle-drawing algorithm.  The origin (0, 0) is the centre of the screen.
;	r is the radius of the circle.
;
;	x = r; y = 0		Start at centre right of the circle
;
;	do {
;		plot(x, y)
;
;		x = x + y/r	From start, y=0, so go nowhere.
;		y = y - x/r	From start, x=r, so y = y - 1.
;	} until bored
;	
;	as y progresses downwards into the negative, x gets decremented by more
;	and more.  You need a bit of fixed point arithmatic to get a smooth circle.
;	Coordinates are 0-768 in X, which needs 10 bits, so we use a six-bit fractional
;	part.
;
;	The step size of each motion round the circle depends on the size of constant
;	we divide x and y by before addition.  If the divisor is r, the size of the
;	motion is 1, so dx^2 + dy^2 = 1.  This means that the maximum size of the
;	motions along each of the axes is when they are of the same magnitude.
;	This means |dx| = |dy| = sqrt(0.5), = 0.707, in which case nither of them
;	might move.  We want either one or the other, or both, to move by one pixel.
;
;	So we should divide by r / sqrt(0.5)


	MOV	#COREND-2,SP	; Set up stack
