	.TITLE	STYLE
	.SBTTL	/BL1.0/
;
;	This module contains the following commands
;
;	AUTOSUBTITLE
;	AUTOBREAK
;	DISPLAY commands
;	LAYOUT
;	LOCK
;	NUMBER commands
;	PAGING
;	SAVE STATUS
;	STYLE
;	TOC	Table of contents commands
;	UNDERLINE
;
;
;	Table of constants
;
	.const
CRTAB:	.BYTE	CR,LF
LAYTB:	.BYTE	16.			; Max value
	.BYTE	0			; 0 layout
	.BYTE	LAY.NB!LAY.CP!LAY.CT	; 1
	.BYTE	LAY.NB!LAY.CP!LAY.OT	; 2
	.BYTE	LAY.NB!LAY.CP		; 3
	.BYTE	LAY.NB			; 4
	.BYTE	LAY.NB!LAY.CT		; 5
	.BYTE	LAY.NB!LAY.OP!LAY.CT	; 6
	.BYTE	LAY.NB!LAY.OP!LAY.OT	; 7
	.BYTE	LAY.NB!LAY.OP		; 8
	.BYTE	LAY.NB!LAY.OT		; 9
	.BYTE	LAY.NB!LAY.LP!LAY.CT	; 10
	.BYTE	LAY.NB!LAY.LP!LAY.OT	; 11
	.BYTE	LAY.NB!LAY.LP		; 12
	.BYTE	LAY.NB!LAY.RT!LAY.LP	; 13
	.BYTE	LAY.NB!LAY.RT!LAY.CP	; 14
	.BYTE	LAY.NB!LAY.RT!LAY.OP	; 15
	.BYTE	LAY.NB!LAY.RT		; 16
TOCTB1:	.BYTE	2,-1,-1,0,2,0
TOCTB2:	.BYTE	24.,2,6,-1,-1,0
STHDTB:	.Byte	3,1,6,7,7,4,2,7,2,6
	.EVEN
;
;	display table of formats
;
DSPTAB:	RAD	spc,spc,D
	.WORDA	NM.DEC
LU:	RAD	spc,L,U
	.WORDA	NM.ALP+NM.UC
	RAD	spc,L,L
	.WORDA	NM.ALP
	RAD	spc,L,M
	.WORDA	NM.ALP+NM.MC
	RAD	spc,R,U
	.WORDA	NM.ALP+NM.ROM+NM.UC
	RAD	spc,R,L
	.WORDA	NM.ALP+NM.ROM
	RAD	spc,R,M
	.WORDA	NM.ALP+NM.ROM+NM.MC
	.WORDA	0		; end of table
APTAB:	.WORDA	APNMG
	.worda	APNDSP
	.worda	APNM2
CHTAB:	.WORDA	CHPMG
	.worda	CHPDSP
	.worda	CHPM2
NUTAB:	.WORDA	PAGHD
	.worda	PAGDSP
	.worda	PAGH2
TTTAB:	.WORDA	TTLHD1
	.worda	0
	.worda	TTLHD2
STTAB:	.WORDA	STLHD1
	.worda	0
	.worda	STLHD2
;
;	Impure data - variables
;
	.vars
HEADA:	.BLKA	1
NUMBR:	.BLKA	1
HEADB:	.BLKA	1

;
;	Code section
;
	.code
;
;	AUTOBREAK command
;
AULIN::	BICB	R5,$LINBR		; Set autobreak on
	MOV	#CH.BRK+FL.DIS,R4	; Set autobreak
	return
NAULIN::BISB	R5,$LINBR
	MOV	#CH.BRK,R4	; Clear autobreak
	return
;
;	AUTOBREAK command
;
AUBRK::	BICB	R5,$AUBRK		; Set autobreak on
	MOV	#CH.BRK+FL.DIS,R4	; Set autobreak
	BR	UNL1
NAUBRK::BISB	R5,$AUBRK
	MOV	#CH.BRK,R4	; Clear autobreak
	BR	UNL1
;
;	Trailing zero
;
ENTRZ::	BICB	R5,$TRZER	; ENable trailing zeroes
	RETURN
DSTRZ::	BISB	R5,$TRZER	; Disable trailing zeroes
	RETURN
;
;	SET [NO] USER
;
USRCM::	BISB	R5,$USRCM	; Search user commands first
	RETURN
NUSRCM::BICB	R5,$USRCM	; Search user commands last
	RETURN
;
;	UNDERLINE/NO UNDERLINE commands
;
UNLCH::	MOV	#CH.UNL,R4	; Set underline
	BR	UNL1
UNLNC::	MOV	#CH.UNL+FL.DIS,R4 ; Set no underline
UNL1:	CALL	GETLIT		; Get literal
	BCS	UNLEND		; No characters ?
10$:	MOVB	(R0)+,R2	; Get character specified
	ADD	#CHTABL,R2
	BITNE	#FL.DIS,R4,15$	; Set bit ?
	BICB	R4,(R2)		; Clear bit
	BR	20$
15$:	BISB	R4,(R2)		; Set bit
20$:	SOB	R1,10$		; Continue till done
UNLEND:	MOVB	CHTABL+32.,R0	; Get underline status for blank
	BIC	#^C<CH.UNL>,R0	; Clear all but underline stat.
	MOVB	R0,CHTABL+NXS	; Space and NXS have same attributes
	RETURN
UNLSP::	BICB	#CH.UNL,CHTABL+32.	; Set underline
	BR	UNLEND
UNLNS::	BISB	#CH.UNL,CHTABL+32.	; Set no underline
	BR	UNLEND
;
;	ENABLE PAGING command
;	PAGING command
;
ENPAG::	BICB	R5,$PAGNG		; Enable all paging
PGNG::	BICB	#SW.TDS,$PAGNG		; Turn on paging
	RETURN
;
;	DISABLE PAGING command
;	NO PAGING command
;
DSPAG::	BISB	R5,$PAGNG		; Disable all paging
NOPGNG::BISB	#SW.TDS,$PAGNG		; Turn off temporary paging
	CLRB	$PAGPD			; No page pending
	MOVB	#-1,$PAGBR		; Not at top of page
	RETURN
;
;	SAVE STATUS
;
SAVU::	MOV	#USTAT,R2		; Address of user status
SSAV:	JMP	SSTAT			; Save it
;
;	RESTORE STATUS
;
RSTU::	MOV	#USTAT,R2		; Address of user status
	JMP	RSTAT
;
;	SAVE CHAPTER
;
CHSVST::MOV	#CHSTAT,R2		; Save chapter status
	BR	SSAV
;
;	SAVE APPENDIX
;
APSVST::MOV	#APSTAT,R2		; Save appendix status
	BR	SSAV
;
;	SAVE LEVEL
;
LVSVST::MOV	#LVSTAT,R2		; Save level status
	BR	SSAV
;
;	SEND TOC command
;
SENTC::	TSTNEB	$TOCSW,20$		; No TOC ?
	CALL	CCIN
	CMPEQB	R1,#SPC,SENTC		; Skip over spaces
	CMPEQB	R1,#TAB,SENTC		; And tabs
	MOV	BUFADD,R0		; Get input buffer address
	MOV	BF.ADD(R0),R1		; Get current address
	MOV	BF.CNT(R0),R2		; String count
	DEC	R2			; Omit CR,LF
	CALL	OUTTOC			; Output to TOC file
20$:	JMP	COMNT
;
;	Enable/disable TOC
;
ENTOC::	BICB	R5,$TOCSW		; Enable TOC
	RETURN
DSTOC::	BISB	R5,$TOCSW		; Disable TOC
	RETURN
;
;	TOC command
;
BETOC::	MOVB	#-1,$TOCBE		; Signal TOC on
	MOVB	#8.,LIDLV		; Left level indentation
	MOVB	#8.,RIDLV		; Right indentation
	CLRB	BEGLV			; No spaces between levels
	CLRB	ENDLV			; No spaces between levels
	CLRB	TPGLV			; Clear level test page
	BISB	R5,$CHPSW		; No chapter numbers
	MOV	#TABBF,R3		; Get tab buffer
	CALL	CLRBF			; Set no tabs
	BISB	#2,$TABLF		; Set for tab right
	MOV	#TOCTB1,R1		; Input table
	BIS	#FILLF,F.1		; Set fill
	BIC	#JUSTF,F.1
TOC1:	MOV	#CHSK1,R0		; Output table
	MOV	#6,R2			; Entries
10$:	MOVB	(R1)+,(R0)+		; SET IT UP
	SOB	R2,10$
	MOV	#1,APNNX		; Next appendix number
	CLR	APNDN
	MOV	#1,CHPNX		; Next chapter number
	CLR	CHPTN
	RETURN
;
;	END TOC command
;
ENDTOC:: MOV	#TOCTB2,R1		; New chapter format
	CLRB	LIDLV			; No left margin for levels
	CLRB	RIDLV			; No right margin for levels
	BICB	#2,$TABLF		; Set for tab left
	CLRB	$TOCBE			; Signal TOC off
	BICB	R5,$CHPSW		; Allow chapter numbers
	MOVB	#2,BEGLV		; Reset level spacing
	MOVB	#1,ENDLV		; Reset level spacing
	MOVB	#7,TPGLV		; Restore level test page
	BIS	#JUSTF,F.1
	BR	TOC1
;
;	AUTOTITLE command
;
AUTTL::	BICB	R5,$AUTTL	; Enable auto-title
	RETURN
NAUTL::	BISB	R5,$AUTTL	; Disable auto-title
	RETURN
;
;	AUTOSUBTITLE commands
;
AUSTL::	BISB	R5,$AUSTL	; Enable auto subtittle
	MOVB	STLLV,R3	; Get initial value
	CALL	(R4)		; Get input
	BCS	10$		; No Number ?
	MOVB	R3,STLLV	; Subtitle level number
10$:	RETURN
NAUSTL:: BICB	R5,$AUSTL	; Disable auto subtittle
	RETURN
;
;	lock parameters command
;
LOCKP::	BIS	#LCKF,F.1	; lock many params to current value
	RETURN
;
;	LAYOUT	command
;
LAYOU::	CALL	LAY		; Get layout + size
	BGT	10$		; No ?
	CLR	R0		; Set layout 0 as default
10$:	MOVB	R0,NXLAY	; Next layout
	MOVB	R0,PRLAY	; Permanent layout
	TST	R3		; Check for default
	BGE	20$		; Not default ?
	CLR	R3
	TSTEQB	R0,20$		; Layout 0 ?
	MOV	#3*LINSP,R3	; Reserve 3 lines
20$:	MOV	R3,NXEPSP	; Next End of page space
	MOV	R3,PREPSP	; Permanent page spacing
	RETURN
ERRGT:	MOV	#1,R0
	BR	ERR
ERRHI:	MOV	#8.,R0		; Number too big or negative
ERR:	JMP	ILCMA		; Output the error message
;
;	Subroutine to get layout,spacing
;		R0=layout	R3=spacing
;		-1=None specified
;
LAY:	CALL	(R4)		; Get layout number
	BCS	10$		; No chapter layout
	CMPB	R3,LAYTB	; Too big?
	BHI	ERRHI		; Bad ?
	ADD	#LAYTB+1,R3
	MOVB	(R3),-(SP)	; Get layout
	BR	20$		; And complete layout
10$:	MOVB	#-100,-(SP)	; Default layout
20$:	CALL	(R4)		; Get end-of-page spacing
	BCC	21$		; Number ?
	  MOV	#-10,R3		; Default
21$:	INC	R3		; Add 1 to account for number
	CALL	CVSP		; Convert vertical spacing
	CMP	R3,#<MAXPS+1>*LINSP	; Check size
	BLE	30$		; Not too big ?
	JMP	ERRGT		; Too big
30$:	MOVB	(SP)+,R0	; Restore Layout
	RETURN
;
;	CHAPTER LAYOUT
;
CLAYOU:: CALL	LAY		; Get layout + spacing
	MOVB	R0,CHLAY	; Get chapter layout
	BMI	20$
	TST	R3		; Spacing ?
	BGE	10$		; Not default
	MOVB	PREPSP,R3	; Get regular spacing
10$:	MOVB	R3,CHEPSP	; Next End of page space
20$:	RETURN
;
;	STYLE HEADERS COMMAND
;
STYHD:: MOV	#LINLV,-(SP)	; Current variable
	MOV	(SP),R1		; Variables
	MOV	#STHDTB,R0	; Constants to default to
	MOV	#10.,R2		; Number of variables
10$:	MOVB	(R0)+,(R1)+	; Transfer 1 value
	SOB	R2,10$		; Till done
	MOVB	TPGLV,R0	; Get test page
	ADD	PARPT,R0	; Add on paragraph test page
	MOVB	R0,TPGLV	; Now is default test page
	CALL	GETP1		; Get header level # 1 Max run in title
	CALL	GETP1		; Get header level # 2 Max all uppercase
	CALL	GETP1		; Get header level # 3 Max capitalized
	CALL	GETP1		; Get header level # 4 Min no seq numbers
	CALL	GETP1		; Get header level # 5 Min flush left
	CALL	GETP0		; Get blank lines befor section head
	CALL	GETP0		; Blank lines after section head
	CALL	GETP1		; Test page count
	CALL	GETP1		; Spaces between number and title
	CALL	GETP1		; Highest level as a.b
	TST	(SP)+		; Pop
	RETURN
;
;	INDENT LEVELS command
;
INDLV:: MOV	#LIDLV,R5	; Current variable
	MOV	#2,R2		; Counter
	MOV	#20.,-(SP)	; limit
INDLV1:	CALL	(R4)		; Get header level number
	BCC	1$		; Number ?
	  MOVB	(r5),R3		; keep old value as default
1$:	CMP	R3,(SP)		; Too big?
	BLOS	20$		; Not too big ?
	JMP	ERRHI		; Too big
20$:	MOVB	R3,(R5)+	; Save it
	SOB	R2,INDLV1
	TST	(SP)+
	RETURN
;
;	INDENT LEVELS command
;
INDLTI:: MOV	#TIDLV,R5	; Current variable
	MOV	#LEVSIZ,R2	; Count
	MOV	#100.,-(SP)	; Limit
	BR	INDLV1		; Get levels
;
;	STYLE CHAPTER
;
GETNUM:	CALL	(R4)		; Get header level number
	BCS	10$		; Default ?
	CMP	R3,#20.		; Too big?
	BLE	5$		; Not too big ?
	JMP	ERRGT		; Yes
5$:	CMP	R3,#-20.	; Too small?
	BLT	ERRLT		; Yes
	RETURN
10$:	TST	(SP)+		; Dump return
	BR	GETP3
GETP0:	CALL	GETNUM		; Get number
	TST	R3
	BLE	GETP2		; Negative ?
	CALL	CVSP
	BR	GETP2
GETP1:	CALL	GETNUM		; get number
GETP2:	MOVB	R3,@$wordl(SP)	; Save it
GETP3:	INC	$wordl(SP)		; Next var
	RETURN
STYCH:: MOV	#CHSK1,-(SP)	; Current variable
	CALL	GETP0		; Get spacing
	CALL	GETP0		; Get spacing
	CALL	GETP0		; Get spacing
	CALL	GETP1		; Get indentation
	CALL	GETP1		; Get indentation
	CALL	GETP1		; Get indentation
	TST	(SP)+		; Pop address
	RETURN
ERRLT:	MOV	#2,R0		; Param too small
	JMP	ILCMA
;
;	ENABLE LEVELS
;
ENALV::	MOVB	OUTLV,R3	; First value
	CALL	(R4)		; Get new value
	BCC	10$		; Number ?
	  MOV	#LEVSIZ,R3	; Default
10$:	MOVB	R3,OUTLV	; Set up new levels to enable
	MOVB	TOCLV,R3	; First value
	CALL	(R4)		; Get new value
	BCC	20$		; Number ?
	  MOV	#LEVSIZ,R3	; Default
20$:	MOVB	R3,TOCLV	; Set up new levels to enable
	RETURN
;
; NUMBER APPENDIX COMMAND
;
NAPDX::	MOV	APNNX,R3	; next appendix value
	CALL	NUPAG0		; get new value
	MOV	R3,APNNX	; save next value
	RETURN			; 
;
;	NUMBER CHAPTER COMMAND
;
NCHPT::	MOV	CHPNX,R3	; next chapter number
	CALL	NUPAG0		; GET CHAPTER NUMBER
	MOV	R3,CHPNX	; SET FOR NEXT CHAPTER COMMAND
	BITNE	#LCKF,F.1,10$	; parameters locked
	BICB	#SW.TDS,$CHPSW	; enable chapter numbers
10$:	RETURN			; 
NOCHP:: BITNE	#LCKF,F.1,10$	; params locked?
	BISB	#SW.TDS,$CHPSW	; disable chapter numbers
	CLR	CHPTN		; turn off chapter/appendix numbers
	CLR	APNDN
10$:	RETURN
;
;	ENABLE NUMBERING CHAPTER
;
ENMCH::	BICB	#SW.TD2,$CHPSW	; Enable chapter numbering
	RETURN
DNMCH::	BISB	#SW.TD2,$CHPSW	; Disable chapter numbering
	RETURN
;
;	NUMBER PAGE commands
;
NUMON:: MOV	PAGNX,R3	; get next page number
	CALL	NUPAG0		; Get new page number
	INCB	$SETPG		; Note page renumbered
	MOV	R3,PAGNX	; next page number
	BITNE	#LCKF,F.1,10$	; params locked?
	BICB	#SW.TDS,$NUMSW	; TURN on NUMBERING.
10$:	RETURN			; 
NUMOF::	BITNE	#LCKF,F.1,10$	; params locked?
	BISB	#SW.TDS,$NUMSW	; TURN OFF NUMBERING.
10$:	RETURN			; 
NUMER:	JMP	ERRHI		; Numbering error
;
;	ENABLE NUMBERING
;	DISABLE NUMBERING
;
ENMPG::	BICB	#SW.TD2,$NUMSW	; Enable page numbering
	RETURN
DNMPG::	BISB	#SW.TD2,$NUMSW	; Enable page numbering
	RETURN
;
;	number subpage
;
NSPAG::	MOV	SUBNX,R3	; next subpage
	CALL	NUPAG0		; get new value
	MOV	R3,SUBNX	; save next subpage number
	BISB	#SW.DIS,$SBPSW	; start subpage
	RETURN
;
;	NUMBER LEVEL command
;
NLEVL::	MOV	#LEVSIZ,R4	; Maximum number of levels
	MOV	#LEVNM,R5	; First level address
10$:	MOV	(R5),R3		; Current value
	DECB	LEVEL		; Decrement number of levels
	BGE	15$		; Not past last one ?
	MOV	#1,R3		; Default
15$:	BGT	16$		; Not last ?
	INC	R3
16$:	CALL	NUPAG		; Get number
	BCS	30$		; None?
20$:	MOV	R3,(R5)+	; Save number
	INCB	LEVEL		; Count levels
	SOB	R4,10$		; Continue till last one
30$:	CLR	(R5)		; Clear next level
	MOV	#LEVSIZ,R0	; LEvel size
	SUB	R4,R0		; Number of levels
	MOVB	R0,LEVEL
	BEQ	40$		; No levels ?
	DEC	-(R5)		; Current level -1
40$:	RETURN
;
;	NUMBER LIST
;
NULST::	MOV	@LSTKP,R3	; Current value
	CALL	NUPAG		; Get next value
	DEC	R3
	MOV	R3,@LSTKP	; Save it
10$:	RETURN
;
;	get new page/chapter/appendix number
;
NUPAG0:	DEC	R3		; Now is current value
NUPAG:	MOV	R3,-(SP)
	CALL	SKPSP		; Null param?
	BCS	30$		; Yes
	CALL	BKSPI		; No
	CALL	ALPGT2		; get letter code
	BCC	20$		; found one ?
	MOV	(SP),R3		; saved value for increment
	CALL	RCNR		; get numeric value
	BCS	30$		; none
20$:	TST	(SP)+		; pop saved value
	TST	R3		; Check value found
	BLE	40$		; Bad value ?
	CMP	R3,#4000.	; Too big?
	BHIS	40$		; yes
	CLC			; Success
	RETURN
30$:	TST	(SP)+		; Pop saved value
	MOV	#1,R3		; Default value
	SEC			; No success
	RETURN
40$:	JMP	ERRHI		; Numbering error
;
;	DISPLAY ELEMENTS command
;
DSELE::  MOV	LSTKP,R4	; Current list
	CALL	GETLIT		; Get a literal
	BCS	10$		; None!
	CLRB	LS.PRE(R4)	; Clear in case null
	TSTEQ	R1,10$		; Null literal?
	MOVB	(R0),LS.PRE(R4)	; save character
	CMP	R1,#1		; Max number of chars
	BLOS	10$		; Ok ?
	JMP	DSPER2		; Too many ?
10$:	MOV	R4,R3
	ADD	#LS.FMT,R3	; Format address
	CALL	DSPGT		; Get Display value
	CALL	GETLIT		; Final literal
	BCS	20$		; none
	CLRB	LS.PST(R4)	; Clear in case null
	TSTEQ	R1,20$		; Null literal?
	MOVB	(R0),LS.PST(R4)	; save character
	CMP	R1,#1		; Max number of chars
	BLOS	20$		; Ok ?
	JMP	DSPER2		; Too many ?
20$:	RETURN
;
;	DISPLAY LEVELS COMMAND
;
DSLEV::	CLR	R5		; Initial level
10$:	CALL	RCNO		; Get a number
	BCC	20$		; Number ?
	INC	R5		; Previous level +1
	MOV	R5,R3		; Is the default level
	CMP	R5,#LEVSIZ	; Compare with max
	BLE	20$		; More levels ??
	RETURN
20$:	TST	R3
	BLE	24$		; Too small
	CMP	R3,#LEVSIZ	; Check if too big
	BLOS	25$		; Not too Big ?
24$:	JMP	DSPERR		; Too Big ?
25$:	MOV	R3,R5		; Save current level
	MOV	#CHPMG,HEADA	; Pre header address
	MOV	#CHPDSP,NUMBR	; Number address
	MOV	#CHPM2,HEADB	; Post header
30$:	ADD	#CH.HD1+1,HEADA	; Get next header level
	ADD	#$WORDL,NUMBR	; Next one
	ADD	#CH.HD2+1,HEADB	; Get next header level
	SOB	R3,30$		; Until correct one
	MOV	#HEADA,R4	; Now correct in table
	CALL	DSP		; Save entry
	BR	10$
;
;	Move literal to buffer
;
MOVNUM:	TSTEQ	R1,40$
20$:	MOVB	(R2)+,R3	; Get character
	CMPB	R3,#SPC		; Less than space?
	BHI	30$		; No
	MOVB	#SPC,R3		; Make it space
30$:	MOVB	R3,(R0)+	; Save it
	SOB	R1,20$		; Continue till done
40$:	CLRB	(R0)		; Make last char null
	RETURN
;
;	DISPLAY NUMBER command
;
DSNUM::	MOV	#NUTAB,R4
	BR	DSP
;
;	DISPLAY CHAPTER command
;
DSCHP::	MOV	#CHTAB,R4
DSP:	CALL	GETLIT		; Get a literal
	BCS	50$		; None!
	MOV	R0,R2		; Literal address
	MOV	(R4),R0		; Chapter header text
	BEQ	DSPERR		; None allowed ??
	CMP	R1,#CH.HD1	; Too big?
	BHI	DSPER2		; Yes?
	CALL	MOVNUM		; Move chars to buffer
50$:	TST	(R4)+
	MOV	(R4)+,R3	; Address of display
	BEQ	60$		; None ??
	CALL	DSPGT		; Get Display value
60$:	CALL	GETLIT		; Final literal
	BCS	90$		; none
	MOV	R0,R2		; Literal address
	MOV	(R4),R0		; Post header
	BEQ	DSPERR		; None allowed ??
	CMP	R1,#CH.HD2	; Too big?
	BHI	DSPER2		; Yes?
	CALL	MOVNUM		; Move chars to buffer
90$:	TST	(R4)+		; Next entry
	RETURN
DSPERR:	JMP	ERRHI		; Bad params
DSPER2:	MOV	#51.,R0		; Literal too long
	JMP	ILCMA
;
;	DISPLAY APPENDIX command
;
DSAPN::	MOV	#APTAB,R4
	BR	DSP
;
;	Display subpage command
;
DSSUBP::MOV	#SUBDSP,R3	; default
	CALL	DSPGT
	RETURN
;
;	Display title command
;
DSTTL::	MOV	#TTTAB,R4
	BR	DSP
;
;	Display subtitle command
;
DSSTL::	MOV	#STTAB,R4
	BR	DSP
;
;	routine to parse display command
;
DSPGT:	MOV	R3,-(SP)	; Save default
	CALL	ALPGT		; get 2 char sequence
	BCS	20$		; None ?
	MOV	#DSPTAB,R0	; table to search
10$:	TST	(R0)		; at end of table?
	BNE	15$		; no
17$:	JMP	ILCM		; bad input
15$:	CMPEQ	R3,(R0)+,18$	; match?
	TST	(R0)+		; NO
	BR	10$		; continue
18$:	MOV	(R0),@(SP)	; get code
20$:	MOV	(SP)+,R3	; Pop
	RETURN
;
;	TYPE command
;
TYPE::	MOV	#74.,R4		; Max number of chars
	MOV	#TTBUF,R2	; Get buffer for string
10$:	CALL	CCIN		; Get a char
	CMP	R1,#SPC		; Compare with space
	BEQ	10$		; Space to skip
	BR	21$		; Save this char
20$:	CALL	CCIN		; Get a char
21$:	CMPEQB	R1,#CR,30$	; End of line ?
	CMPEQB	R1,#LF,30$	; End of line ?
	MOVB	R1,(R2)+		; Save it
	SOB	R4,20$		; Continue till count done
30$:	MOV	#TTBUF,R0	; Address of buffer
	MOVB	#SPC,(R2)+	; Add a single space
	SUB	R0,R2		; String length
	MOV	R2,R1		; Into R1
	.if df	$pass
	BITNEB	#SW.DIS,$OUTSW,40$ ; Second pass ?
	.endc
	MOV	$SWTCH,-(SP)	; Save switch
	BIC	#EROSW,$SWTCH	; No output to .DOC
	CALL	TTOUT		; Output the line
	MOV	(SP)+,$SWTCH	; Restore
40$:	RETURN
;
;	COLUMNS command
;
COLUMN::CALL	(R4)		; Get number of columns
	MOVB	R3,$COLMN	; Number of columns
	MOVB	R3,$COLCT
	CALL	(R4)		; Column margin
	MOV	#0,R3		; No extra margin
	MOV	R3,$COLMR	; Column extra margin
	RETURN
	.END
