
	.TITLE	INIT
	.IDENT	/BL1.0/
	.MCALL	GTIM$S
;
;	Routine to initialize all the variables
;	and the FLAG set up routines
;
;
;
;	DEFAULT FLAG TABLE
;
	.PSECT	$TABL,RO,D,LCL,CON
FLTAB:				; CONTAINS DEFAULT FLAG VALUES
	.WORD	'_		; FLAG ACCEPT (-=NO)
	.WORD	'<+100000	; FLAG CAPITALIZE ENABLE (-=NO)
	.WORD	'&		; UNDERLINE SWITCH (-=NO)
	.WORD	'\		; LOWERCASE SWITCH (-=NO)
	.WORD	'^		; UPPERCASE SHIFT SWITCH (-=NO)
	.WORD	'#		; QUOTED SPACE SWITCH (-=NO)
	.WORD	'%+100000	; OVERSTRIKE FLAG ENABLE (-=NO)
	.WORD	'>+100000	; INDEX FLAG ENABLE (-=NO)
	.WORD	'=+100000	; FLAG HYPHENATE (-=NO)
	.WORD	100000		; ESCAPE FLAG	
	.WORD	'$+100000	; substitute flag
	.WORD	'|+100000	; break flag
	.WORD	100000		; Special flag switch
	.WORD	100000		; Equation flag
	.WORD	'.		; CONTROL FLAG	
FLADD:
	.WORD	$AFLSW
	.WORD	$CFLSW
	.WORD	$UFLSW
	.WORD	$LFLSW
	.WORD	$SFLSW
	.WORD	$QFLSW
	.WORD	$OFLSW
	.WORD	$IFLSW
	.WORD	$HFLSW
	.WORD	$EFLSW
	.WORD	$SBFSW
	.WORD	$BRFSW
	.WORD	$SPFSW		; Special flag switch
	.WORD	$EQFSW		; Equation flag address
	.WORD	$NFLSW
FLCHR:
AFL=.-FLCHR
	.BYTE	GC.AFL
CFL=.-FLCHR
	.BYTE	GC.CFL
UFL=.-FLCHR
	.BYTE	GC.UFL
LFL=.-FLCHR
	.BYTE	GC.LFL
SFL=.-FLCHR
	.BYTE	GC.SFL
QFL=.-FLCHR
	.BYTE	GC.QFL
OFL=.-FLCHR
	.BYTE	GC.OFL
IFL=.-FLCHR
	.BYTE	GC.IFL
HFL=.-FLCHR
	.BYTE	GC.HFL
EFL=.-FLCHR
	.BYTE	GC.EFL
SBF=.-FLCHR
	.BYTE	GC.SUB
BRF=.-FLCHR
	.BYTE	GC.BRK
	.BYTE	GC.SPF
	.BYTE	GC.EQ1
NFL=.-FLCHR
	.BYTE	GC.NFL
	.BYTE	0
	.even
;
;	DEFAULT ESCAPE TABLE
;
;	The table consists of:
;		byte 1 = char count = n
;		byte 2+3 = escape key characters
;		bytes 4-n = escape controls
;		bytes n-m = escape sequence
;
ESTAB:
	.IFDF	$FLORD
	.BYTE	6,'^,'>,ES.VSP,-1,ESC,'D	; 1/2 UP SHIFT
	.BYTE	6,'^,'<,ES.VSP,1,ESC,'U		; 1/2 DOWN SHIFT
	.BYTE	6,'^,'(,ES.VSP,-2,ESC,12	; Shift up by 1
	.BYTE	5,'^,'),ES.VSP,2,12		; Shift down by 1
	.BYTE	6,'^,'1,0,ESC,'I,2		; SELECT FONT #1
	.BYTE	6,'^,'2,0,ESC,'I,3		; FONT 2
	.BYTE	6,'^,'3,0,ESC,'I,4		; FONT 3
	.BYTE	6,'^,'4,0,ESC,'I,5		; FONT 4
	.BYTE	6,'^,'5,0,ESC,'I,6		; FONT 5
	.BYTE	6,'^,'8,0,ESC,'I,9.		; FONT 8
	.BYTE	6,'^,'*,ES.CHR!ES.LCK!ES.CHR,0,ESC,'W ; BEGIN SHADOW PRINT
	.BYTE	6,'\,'*,ES.LCK!ES.CHR,100,ESC,'&	; END SHADOW/BOLD PRINT
	.BYTE	6,'^,'=,ES.HSP!ES.PSP!ES.LCK!ES.CHR,0,2,16 ; SO BEGIN ELONGATED
	.BYTE	6,'\,'=,ES.HSP!ES.PSP!ES.LCK!ES.CHR,100,1,17	; SI END ELONGATED
	.ENDC
	.IFDF	$DIAB
	.BYTE	6,'^,'>,ES.VSP,-1,ESC,'D	; 1/2 UP SHIFT
	.BYTE	6,'^,'<,ES.VSP,1,ESC,'U		; 1/2 DOWN SHIFT
	.BYTE	6,'^,'(,ES.VSP,-2,ESC,12	; Shift up by 1
	.BYTE	5,'^,'),ES.VSP,2,12		; Shift down by 1
	.BYTE	6,'^,'!,ES.LCK,0,ESC,'3		; START GRAPHICS MODE
	.BYTE	6,'\,'!,ES.LCK,100,ESC,'4	; STOP GRAPHICS MODE
	.ENDC
ESEND:	.BYTE	0
LEVTAB:	.BYTE	3,1,6,7,7,4,2,14,2,1,6,6	; Default header level data
CHTAB:	.BYTE	24.,2,6,-1,-1,0		; Default chapter style
CHPMP:	.ASCII	/CHAPTER/		; Chapter header prototype
	.BYTE	NXS,0
APNMP:	.ASCII	/APPENDIX/		; Appendix header prototype
	.BYTE	NXS,0
	.EVEN
TIMTB:	.WORD	HOUIN,MININ,SECIN,DAYIN,MONIN,YEAIN
MONTB:	.WORD	JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC
JAN:	.ASCIZ	/January/
FEB:	.ASCIZ	/February/
MAR:	.ASCIZ	/March/
APR:	.ASCIZ	/April/
MAY:	.ASCIZ	/May/
JUN:	.ASCIZ	/June/
JUL:	.ASCIZ	/July/
AUG:	.ASCIZ	/August/
SEP:	.ASCIZ	/September/
OCT:	.ASCIZ	/October/
NOV:	.ASCIZ	/November/
DEC:	.ASCIZ	/December/
	.even
	.PSECT	$VARS,RW,D,LCL,CON
DATE:	.WORD	2
	.WORD	TIME-DATE
	.ASCIZ	/$DATE/
DATIN:	.BLKB	10.
TIME:	.BYTE	YEAR-DATE,0
	.ASCIZ	/$TIME/
TIMIN:	.BLKB	9.
YEAR:	.BYTE	MONTH-DATE,0
	.ASCIZ	/$YEAR/
	.ASCII	/19/
YEAIN:	.BLKB	3
MONTH:	.BYTE	DAY-DATE,0
	.ASCIZ	/$MONTH/
MONIN:	.BLKB	10.
DAY:	.BYTE	HOUR-DATE,0
	.ASCIZ	/$DAY/
DAYIN:	.BLKB	3
HOUR:	.BYTE	MINUTE-DATE,0
	.ASCIZ	/$HOURS/
HOUIN:	.BLKB	3
MINUTE:	.BYTE	SECOND-DATE,0
	.ASCIZ	/$MINUTES/
MININ:	.BLKB	3
SECOND:	.BYTE	0,0
	.ASCIZ	/$SECONDS/
SECIN:	.BLKB	3
SECFIN:
	.EVEN
DAYTIM:	.BLKW	8.

	.PSECT	$CODE,I,RO,LCL,CON
;
; **- INITL-Initialize RUNOFF VARIABLES
;-
;
;	First clear whole list of variables
;
INITL::	MOV	#VARBEG,R0	; First variable
10$:	CLR	(R0)+		; Clear variables
	CMP	R0,#VAREND	; Done?
	BLO	10$		; No
	DECB	$FIRPG		; Make this the first page of document
	MOV	#JUSTF+PJUSTF+FILLF,F.1	;Initial FLAGS
;
;	Reset the FLAG characters in character table
;
	MOV	#128.,R0	; NUMBER OF ASCII CHARS
20$:	BICB	#CH.FLG!CH.ES2,CHTABL(R0)	; Clear all busy bits
	BITEQB	#CH.FLC,CHTABL(R0),30$	; NOT A FLAGGABLE CHARACTER?
	MOVB	#GC.MSC,GCTABL(R0)	; YES CLEAR ANY EXISTING FLAGS
30$:	SOB	R0,20$		; TILL DONE
;
;	Setup the FLAG characters
;
	CLR	R1		; Word pointer
	CLR	R0		; Nother pointer (byte)
50$:	MOV	FLTAB(R1),R3	; Get flag
	MOV	R3,@FLADD(R1)	; Load flag
	BLT	60$		; Flag disabled ?
	BISB	#CH.FLG,CHTABL(R3)	; Mark char as flag char
	MOVB	FLCHR(R0),GCTABL(R3)	; Set up branch to flag char.
60$:	ADD	#2,R1		; Next flag
	INC	R0		; Next flag
	TSTNEB	FLCHR(R0),50$	; Not done ?
;
;	ENABLE/DISABLE SWITCHES
;
	MOVB	#-1,$TOCSW	; Totally disable TOC
	MOVB	#100,$UNLSW	; UNDERLINING ENABLED/OFF
	MOVB	#300,$CBRSW	; SET CHANGE BAR DISABLED/OFF
	MOVB	#1,$HDRSW	; No header on first page
	MOV	#-1,$NUMSW	; SET NUMBER PAGE FLAG
	MOVB	#SW.DIS,$PERSW	; SET PUNCTUATION DOUBLE SPACE FLAG
	MOVB	#SW.DIS,$HSPSW	; Set no half spacing
;
;	Initialize various parameters
;
	MOV	IUL,	ULSWT	; Initialize UNDERLINE MODE
	MOV	HWLPP,	LPPG	; SET DEFAULT HARDWARE PAGE SIZE
	MOV	#INLPG,	PNLPG	; SET Initial LENGTH OF PAGE
	MOV	#IHSPAC,HSPAC	; Initial header spacing
	MOV	#ILMRG,PLMRG	; Permanent left margin
	MOV	#IRMRG,PRMRG	; Initial Permanent margin
	MOV	#ILMRG,LMARG	; Initial LEFT margin
	MOV	#IRMRG,RMARG	; Right margin
	MOV	#1,PHSP		; Set permanent horiz. spacing
	MOVB	#-1,CHLAY	; No chapter layout initially
	MOV	#100000,APNDSP	; appendix display format
	MOV	#100000,SUBDSP	; subpage display format
	MOV	#1,R0		; Next page number etc.
	MOV	R0,PAGENO	; SET Initial PAGE NUMBER
	MOV	R0,PAGNX	; And next page number
	MOV	R0,SUBNX	; Next subpage
	MOV	R0,CHPNX	; Next chapter
	MOV	R0,APNNX	; Next appendix
	MOV	#EQSTK+2,EQSTK	; Current equation stack pointer
;
;	Set up header level style
;
	MOV	#LEVTAB,R1	; Level default table
	MOV	#LINLV,R0	; Header level data table
	MOV	#12.,R2		; Number of params
70$:	MOVB	(R1)+,(R0)+	; Set levels to default
	SOB	R2,70$		; Set all of em
;
;	Set up default chapter style
;
	MOV	#CHTAB,R1
	MOV	#CHSK1,R0
	MOV	#6,R2
80$:	MOVB	(R1)+,(R0)+
	SOB	R2,80$
	MOV	#LSTK,LSTKP	; Reset stack pointer
	MOV	#CHPMG,R0	; Initialize chapter header
	MOV	#CHPMP,R1	; Header prototype
90$:	MOVB	(R1)+,(R0)+	; Move text
	BNE	90$		; Not null ?
	MOV	#APNMG,R0	; Appendix header
	MOV	#APNMP,R1	; Message prototype
91$:	MOVB	(R1)+,(R0)+	; Move text
	BNE	91$		; Not null ?
	MOV	#PAGHD,R0	; Initialize PAGE HEADING PROTOTYPE
	MOV	(PC)+,(R0)+	; 
	.ASCII	/Pa/		; 
	MOV	(PC)+,(R0)+	; 
	.ASCII	/ge/		; 
	MOV	(PC)+,(R0)	; 
	.ASCIZ	/ /		; 
	MOV	#ISPNG,NSPNG	; SET Initial SPACING
	MOV	#ISPNG,PSPNG	; And permenant spacing
	MOV	#IPARTP,PARPT	; SET Initial PARAGRAPH PAGE TEST COUNT
	MOV	#IPARVS,PARSP	; SET Initial PARAGRAPH SPACING COUNT
	MOV	IPARIN,PARIND	; Initial PARAGRAPH INDENTING
	MOV	#1,CPOS		; Current character position
	CLR	R0		; CLEAR LOOP COUNTER
	MOV	#8.,R1		; SET Initial TAB STOP VALUE
100$:	MOVB	R1,TABTAB(R0)	; SET STANDARD TAB STOPS
	ADD	#8.,R1		; ADVANCE TO NEXT TAB STOP
	INC	R0		; INCREMENT LOOP COUNTER
	CMPNE	R0,#17.,100$	; LOOP IF END OF LOOP NOT REACHED
	MOV	R0,NTABS	; SET NUMBER OF TAB STOPS
	MOV	INI$SW,	$SWTCH	; Initial SWITCH SETTINGS
	MOV	BUFTAB,R0	; FIRST BUFFER HEADER
	MOV	R0,BUFADD	; IS CURRENT BUFFER
	CLR	BF.CNT(R0)	; SET NO CHARS IN BUFFER
	MOV	HFOUT,HFOUT+4	; SET CHARACTER COUNTS
	MOV	#OUBUF,HFOUT+2	; Initialize POINTERS
	MOV	#-1,HGHPAG
	MOV	#-1,HGHCHP	; hi chapter limit
	MOV	#-1,HGHAPN	; default highest appendix #
;
;	SET BUFFERS TO EMPTY
;
	MOV	#F.1,R5		; FLAG WORD
	MOV	#FOTBF,R3	; FOOTNOTE
	CALL	CLRBF
	BIS	#FOTF,F.1	; SET FOOTNOTE FLAG
	CALL	LINSET		; SET UP HEADER
	BIC	#FOTF,F.1	; CLEAR FOOTNOTE FLAG
	CALL	LINSET		; CLEAR SECONDARY BUFFER
	MOV	#TTLBF,R3	; TITLE
	CALL	CLRBF
	MOV	#STLBF,R3	; SUBTITLE
	CALL	CLRBF
	MOV	#INXBF,R3	; index buffer
	CALL	CLRBF
	MOV	#IFBF,R3	; If buffer
	CALL	CLRBF
	MOV	#TXDBF,R3	; Text deferred buffer
	CALL	CLRBF
;
;	Set up default escape sequences
;
	MOV	#ESCTAB,R4
	MOV	#17.,R0		; Number of char to clear
102$:	CLRB	(R4)+		; Clear char
	SOB	R0,102$		; Till done
	MOV	#ESCBF,R3	; escape table buffer
	CALL	CLRBF
	MOV	#ESTAB,R2	; default escape sequences
	MOV	#ESCTAB,R4	; To save locked sequences
101$:	MOVB	(R2)+,R1	; Count ?
	BEQ	109$		; Done ?
	MOV	R1,R5		; Save counter
	CALL	PBYT		; Save in buffer
	DEC	R5
	MOVB	(R2)+,R1	; Get byte first char
	CALL	PBYT		; Save it
	DEC	R5
	MOVB	(R2)+,R1	; Get byte second escape char
	BISB	#CH.ES2,CHTABL(R1)	; Declare this char as escape char
	MOVB	R1,(R4)		; Save character
	CALL	PBYT		; Save in buffer
	DEC	R5
	MOVB	(R2)+,R1	; Options character
	CALL	PBYT		; Save it
	BITEQB	R1,#ES.LCK,105$	; Not lock ?
	DEC	R5
	MOVB	(R2)+,R1	; Get lock byte
	BNE	103$		; Already defined ?
	INC	R4		; Point to next empty slot
103$:	ADD	R4,R1
	SUB	#ESCTAB+1,R1	; Get index
	CLC
	ASL	R1		; 2 word index
	CALL	PBYT
105$:	MOVB	(R2)+,R1	; Get 1 char
	CALL	PBYT		; And save it
	SOB	R5,105$		; Continue with rest of escape seq
	CMP	R2,#ESEND	; At end of seq
	BLO	101$		; Not yet
109$:	CLRB	(R4)
;
;	Set up default substitutions
;
	CLRB	SUBSTK		; no substitution in progress
	MOV	#BUFADD+2,R4	; Substitution buffer headers
	MOV	(R4)+,R3
	CALL	CLRBF
	MOV	(R4)+,R3
	CALL	CLRBF
	MOV	(R4)+,R3
	CALL	CLRBF
	GTIM$S	#DAYTIM
	MOV	#DATIN,R0	; Location for date
	MOV	#DAYTIM,R1	; Date time table
	CALL	$DAT		; Get date
	CLRB	(R0)+		; Chock with null
	MOV	#TIMIN,R0	; Location for time
	MOV	#3,R2		; Convert to HR:MIN:SEC
	CALL	$TIM		; Convert
	CLRB	(R0)+		; Chock with null
	MOV	DAYTIM+G.TIMO,R1 ; Get month
	ASL	R1		; Byte reference
	BEQ	111$		; Bad month ?
	MOV	MONTB-2(R1),R1	; Points to month
	MOV	#MONIN,R0	; Will be month
110$:	MOVB	(R1)+,(R0)+	; Move month
	BNE	110$		; Till all done
111$:	MOV	#TIMIN,R0	; Location of time
	MOV	#TIMTB,R2	; Table of time conversion
120$:	MOV	(R2)+,R1	; Next location to move time to
121$:	MOVB	(R0)+,R3	; Get char
	BEQ	124$		; Done ?
	CMPEQB	R3,#':,123$	; End of chars ?
	MOVB	R3,(R1)+	; Save char
	BR	121$
123$:	CLRB	(R1)+		; Mark end
	BR	120$
124$:	CLRB	(R1)+		; Mark end
	MOV	#DATIN,R0
	MOV	(R2)+,R1	; Next location to move date to
	MOVB	(R0)+,(R1)+	; Move day
	CLRB	(R1)		; Clear next byte in case
	CMPEQB	(R0),#'-,125$	; No more day ?
	MOVB	(R0)+,(R1)+	; Move day
125$:	MOVB	#' ,(R0)+	; Insert blank
	MOV	(R2)+,R1	; Next location to move date to
	MOVB	(R1)+,(R0)+	; Move month
	MOVB	(R1)+,(R0)+	; Move month
	MOVB	(R1)+,(R0)+	; Move month
	MOVB	#' ,(R0)+	; Insert blank
	MOV	(R2)+,R1	; Next location to move date to
	MOVB	(R0)+,(R1)+	; Move year
	MOVB	(R0)+,(R1)+	; Move year
	MOV	BUFADD+2,R3	; Buffer to put substitution in
	MOV	#DATE,R4	; Buffer to transfer
130$:	MOVB	(R4)+,R1	; Byte to transfer
	CALL	PBYT		; Into substitution buffer
	CMP	R4,#SECFIN	; Done ?
	BLO	130$		; Not yet ?
	MOV	BF.FUL(R3),R2	; end of buffer
	MOV	BUFADD+4,R3	; next stack header
	MOV	R2,BF.MAX(R3)	; fill in max
	MOV	BUFADD+6,R3	; next stack header
	MOV	R2,BF.MAX(R3)	; fill in max
	CALL	ULBSET		; RESET UNDERLINE BUFFER
	CLRB	LUNSTK		; Reset logical unit stack
	RETURN			; 

;
;	FLAGS ACCEPT COMMANDS (QUOTING CHARACTERS)
;
ENACFL:: MOV	#AFL,R5	; ACCEPT FLAG	
	BR	NEWFLG		; GET AND ENABLE IT
DSACFL::MOV	#AFL,R5	; DISABLE ACCEPT FLAG
	BR	KILFLG
	RETURN			;		
 
;
;	FLAGS SPACE COMMANDS    (QUOTED SPACE)
;
ENQFL::	MOV	#QFL,R5	; QUOTED SPACE FLAG
	BR	NEWFLG		; GET AND ENABLE FLAG
DSQFL::	MOV	#QFL,R5	; DISABLE QUOTED SPACE
	BR	KILFLG
	RETURN					
;
;	FLAGS UNDERLINE COMMANDS
;
ENUFL::	MOV	#UFL,R5	; UNDERLINE FLAG
	BR	NEWFLG		; GET AND ENABLE NEW FLAG
DSUFL::	MOV	#UFL,R5	; DISABLE UNDERLINE FLAG
	BR	KILFLG
	RETURN
;
;	FLAGS INDEX
;
ENIFL::	MOV	#IFL,R5
	BR	NEWFLG		; ENABLE INDEX FLAG
DSIFL::	MOV	#IFL,R5	; DISABLE INDEX FLAG
	BR	KILFLG
;
;	Substitution flag commands
;
ENSBFL:: MOV	#SBF,R5	; substitution flag enable
	BR	NEWFLG
DSSBFL:: MOV	#SBF,R5	; substitutuion flag disable
	BR	KILFLG
;
;	FLAGS OVERSTRIKE COMMANDS
;
ENOFL::	MOV	#OFL,R5	; ADDRESS TO PUT NEW FLAG
NEWFLG:	CALL	KILFLG		; FIRST KILL OLD FLAG
	CALL	SKPSP		; Get character
	BCS	10$		; None ?
	BITEQB	#CH.FLC,CHTABL(R1),2$ ; NOT LEGIT FOR FLAG??
	BITEQB	#CH.FLG,CHTABL(R1),5$ ; CHAR FREE FOR FLAGGING?
	MOV	#25.,R0		; Char already in use as flag
	BR	3$
2$:	MOV	#26.,R0		; Character may not be used as flag
3$:	JMP	ILCMA
5$:	MOVB	R1,(R2)		; SAVE NEW FLAG	
	BR	10$		; COMPLETE PROCESS
10$:	MOV	#100000,R4	; ENABLE FLAG BITS
	MOVB	(R2),R0		; flag character
	BISB	#CH.FLG,CHTABL(R0) ; SET FLAG THIS CHAR
NWFLG:	BIC	R4,(R2)		; CLEAR DISABLE BITS
	TSTNEB	1(R2),10$	; FLAG NOT ENABLED?
	MOVB	(R2),R0		; GET FLAG CHAR
	BEQ	10$		; NONE SO SKIP REST
	MOVB	FLCHR(R5),GCTABL(R0)	; Flag code into service table
10$:	RETURN					
DSOFL::	MOV	#OFL,R5	; DISABLE OVERSTRIKE FLAG
KILFLG: MOV	#100000,R4	; BITS TO SET IN FLAG WORD
KLFLG:	MOV	R5,R2
	CLC
	ASL	R2		; Now is byte pointer
	MOV	FLADD(R2),R2	; Now have flag address
	MOVB	(R2),R0		; GET OLD FLAG
	BEQ	10$		; NONE
	MOVB	#GC.MSC,GCTABL(R0) ; KILL FLAG IN TABLE
	TST	R4		; Permanent kill ?
	BGE	10$		; No ?
	BICB	#CH.FLG,CHTABL(R0) ; SET NO FLAG THIS CHAR
10$:	BIS	R4,(R2)		; NOW KILL THE FLAG
	RETURN

;
; FLAG CAPITALIZE COMMANDS
;
DSCFL::	MOV	#CFL,R5	; DISABLE WORD CAPITALIZE
	BR	KILFLG
	RETURN
ENCFL::	MOV	#CFL,R5	; SET UP FOR NEW FLAG
	CALL	UPCAS		; CLEAR CASE CONVERSION VALUE
	BR	NEWFLG		; SET NEW FLAG	
	RETURN 			;
;
;	FLAGS UPPERCASE COMMANDS
;
ENSFL::	MOV	#SFL,R5	; UPPERCASE SHIFT FLAG
	BR	NEWFLG		; GET FLAG AND SET IT ON
DSSFL::	MOV	#SFL,R5	; DISABLE UPPERCASE FLAG
	BR	KILFLG
	RETURN
;
;	FLAGS BREAK
;
ENBRFL:: MOV	#BRF,R5	; enable break flag
	BR	NEWFLG
DSBRFL:: MOV	#BRF,R5	; disable break flag
	BR	KILFLG
;
;	FLAGS LOWERCASE COMMANDS
;
ENLFL::	MOV	#LFL,R5	; LOWER CASE SHIFT FLAG 
	BR	NEWFLG		; GET FLAG AND SET IT 
DSLFL::	MOV	#LFL,R5	; DISABLE LOWERCASE FLAG		
	BR	KILFLG
	RETURN
;
;	FLAGS ESCAPE
;
ENEFL::	MOV	#EFL,R5	; GGET ESCAPE FLAG
	BR	NEWFLG
DSEFL::	MOV	#EFL,R5	; DISABLE ESCAPE FLAG
	BR	KILFLG
;
;	CONTROL FLAG
;
ENNFL::	MOV	#NFL,R5	; CONTROL FLAG
	BR	NEWFLG
DSNFL::	MOV	#NFL,R5	; DISABLE CONTROL FLAG (NO MORE COMMANDS)
	BR	KILFLG		; KILL IT

;
; FLAG HYPHENATE COMMANDS
;

ENHFL::	MOV	#HFL,R5	; HYPHENATE FLAG
	BR	NEWFLG		; GET NEW FLAG AND ENABLE
DSHFL::	MOV	#HFL,R5	; DISABLE HYPHENATION
	BR	KILFLG
	RETURN			;
;
;	FLAGS SPECIAL
;
ESPFL::	CALL	SKPSP		; Get character
	BCS	20$		; None ?
	BITEQB	#CH.FLC,CHTABL(R1),30$ ; NOT LEGIT FOR FLAG??
	BITNEB	#CH.FLG,CHTABL(R1),40$ ; Char not free for flagging ?
	MOVB	#GC.SPF,GCTABL(R1)		; Set special flag
	BISB	#CH.FLG,CHTABL(R1)		; And set flag allocated
20$:	BIC	#100000,$SPFSW			; Set special flag enabled
	RETURN
30$:	MOV	#26.,R0		; Char is illegal as flag
	BR	41$
40$:	MOV	#25.,R0		; Char is already flag
41$:	JMP	ILCMA
DSPFL::	CALL	SKPSP		; Get character
	BCS	20$		; None ?
	CMPNEB	GCTABL(R1),#GC.SPF,30$	; Not already special flag ?
	MOVB	#GC.MSC,GCTABL(R1)		; Kill special flag
	BICB	#CH.FLG,CHTABL(R1)		; And set flag free
	RETURN
20$:	BIS	#100000,$SPFSW			; Set special flag enabled
	RETURN
30$:	MOV	#34.,R0
	JMP	ILCMA

;
;	ENABLE ALL FLAGS
;
ENAFL:: MOV	#40000,R4	; BITS TO CLEAR
ENAFL1:	MOV	#$AFLSW,R2	; ADDRESS OF FIRST FLAG
	CLR	R5
	MOV	#NFLAG,R3	; NUMBER OF FLAG WORDS
10$:	CALL	NWFLG		; SET UP TABLE ENTRY
	TST	(R2)+		; NEXT FLAG
	INC	R5
	SOB	R3,10$		; CONTINUE TILL DONE
	RETURN
;
; DISABLE ALL FLAGS
;

DSAFL::	MOV	#40000,R4	; BITS TO SET/RESET
DSAFL1:	MOV	#NFLAG-1,R5	; Kill all flags except for last
10$:	CALL	KLFLG		; KILL TABLE
	DEC	R5		; Next flag
	BGE	10$		; Not done ?
	RETURN			;
;
; LITERAL COMMAND
;
LITRL::	MOV	F.1,LITSV	; SAVE CURRENT FLAGS WORD
	BIS	#LITFG,F.1 	; SET LITERAL FLAG
	MOV	CMADR,LITCM	; SAVE CURRENT EXPECTED COMMAND ADDRESS
	MOV	ELCMD,CMADR	; SET ADDRESS OF EXPECTED COMMAND
	BIC	#FILLF+JUSTF,F.1 ;TURN OFF FILLING AND JUSTIFYING
	MOV	#400,R4		; DISABLE FLAGS BITS
	BR	DSAFL1		; KILL THEM
;
; END LITERAL COMMAND
;
ELTRL::	BITEQ	#LITFG,F.1,20$	; Not in literal mode?
	MOV	LITSV,F.1	; RESTORE PREVIOUS FLAGS WORD
	MOV	LITCM,CMADR	; RESTORE PREVIOUS EXPECTED COMMAND ADDRESS
	MOV	#400,R4		; FLAGS BITS TO CLEAR
	BR	ENAFL1		; ENABLE FLAGS AGAIN
20$:	MOV	#31.,R0		; Literal error
	JMP	ILCMA		; No .LIT commmand
	.END
