	.TITLE	CLEAR
/
/   8 JUL 77 (009; PDH) PROVIDE FOR 'DRAW' TO CALL 'CLEAR' IF NOT CALLED
/  18 JAN 77 (008; PDH) MAKE SOME VERY MINOR COSMETIC CHANGES
/  26 AUG 76 (007; PDH) USE CORRECT BIT PATTERN FOR 'SIC'
/   6 JUL 76 (003: PDH) CONVERT TO XVM/RSX
/  19 MAY 76 (002) PAUL HENDERSON
/
/  COMPLETE RE-WRITE OF AN EARLIER PDP-9 PROGRAM.  THIS ROUTINE
/  COMMUNICATES WITH THE VT15 VIA THE 'VTA.' HANDLER.
/
VTLUN=30			/ LUN FOR VT15 IS 24 (DECIMAL)
/
ASWIM=236000
DJMP=600000
/
	.GLOBL	CLEAR,CLOUDY,FILER,DR.W,C.SWTH,P.BASE
/
CLEAR	0			/ MUST BE ZERO FOR 'DRAW'
	LAC	JPAST
VTEV	DAC	.-1		/ ENSURE ONCE-ONLY CODE
P.BASE	CAL	HINF
P.SIZE	CAL	WAIT
FILER	LAC	VTEV		/ MAKE SURE WE HAVE A VT15
C.SWTH	SPA			/ # FILES CONNECTED COUNTER
CLADR	JMP	ERROR
	AND	(77
	SAD	(13		/ DEVICE CODE IS 13 FOR VT15
	SKP
	JMP	ERROR
	CAL	PARINF		/ GET BASE ADDRESS OF PARTITION
	CAL	PUTCAL		/ ESTABLISH DISPLAY INITIAL CONDITIONS
	LAC	(FBASIC+1
	DAC	FRP1		/ THIS TAKES A TASK ADDRESS
	AAC	-1
	TAD	P.BASE
	DAC	FILER		/ REAL CORE ADDRESS OF BASIC DISPLAY FILE
JPAST	JMP	.+1		/ INSTRUCTION MOVED TO 'CLEAR+1'
	DZM	FCN
	CAL	PUTCAL		/ STOP DISPLAY
	CAL	WAIT		/ ENSURE IT IS STOPPED
	JMS*	DR.W		/ DISCONNECT ALL DISPLAY FILES
	JMP	.+3
DR.W	.+1
	XX
	DZM	C.SWTH		/ ZERO 'FILES' COUNTER
/
/  IT MAY BE NECESSARY TO ADD CODE HERE FOR 'TEXT', ETC
/
	JMP*	CLEAR
/
	.EJECT
/  CAL PARAMETER BLOCKS FOR VARIOUS FUNCTIONS
/
HINF	3600
	VTEV
	VTLUN
/
WAIT	20			/ THIS IS REALLY A 'WAITFOR'
	VTEV
/
PARINF	26
	0
	0; 0			/ PARTITION NAME INSERTED HERE
	P.BASE
/
PUTCAL	3100
	VTEV
	VTLUN
	FCN
/
/  INITIALLY, FCN=6 TO SET INITIAL CONDITIONS IN THE VT15 DISPLAY VIA
/  THE 'SIC' IOT.  THIS IS DONE IN THE ONCE-ONLY SETUP CODE WHERE
/  THE REAL ADDRESS (PARTITION BASE + VIRTUAL ADDRESS' IS CALCULATED
/  AND STORED IN 'FILER' ('FRP1' IS ALSO SET UP THERE).
/
FCN	6
FRP1	655340			/ BIT PATTERN FOR 'SIC'
/
ERROR	CAL*			/ FORCE TERMINAL ERROR
/
	.EJECT
/
CLOUDY	XX
	DZM	FCN
	CAL	PUTCAL		/ STOP THE DISPLAY
	CAL	WAIT
	LAC	CLOUDY
	IAC
	DAC	CLADR		/ FETCH THE ADDRESSES WITHOUT '.DA'
	LAC*	CLADR		/ FETCH THE SUBROUTINE ADDRESS
	SPA
	DAC	CLADR		/ DOUBLE INDIRECT AS NECESSARY
	LAC*	CLADR
	DAC	CLADR		/ THIS IS REALLY THE SUBROUTINE ADDRESS
	JMS*	CLADR		/ EXECUTE THE SUBROUTINE
	LAC	C.SWTH
	SNA
	JMP*	CLOUDY		/ DO NOT RE-START DISPLAY IF NO FILES
	LAC	(7
	DAC	FCN		/ FUNCTION CODE TO START DISPLAY
	CAL	PUTCAL
	CAL	WAIT		/ START DISPLAY, AND WAIT FOR IT
	JMP*	CLOUDY
/
/  BASIC DISPLAY FILE LIVES HERE
/
FBASIC	FBASIC+2
	ASWIM			/ ALWAYS SYNC TO LINE
	DJMP*	.+1
	FBASIC+1
	.END
