	.TITLE	AUXSCR - VT100 Screen Formatting
	.IDENT	/1.0/
	.ENABL	LC
;+
;
;			  Free software BY
;		Project Software & Development, Inc.
;
; This  software  is  furnished  for  free and may be used and copied as
; desired.  This software or any other copies thereof may be provided or
; otherwise  made  available  to  any  other  person.  No  title  to and
; ownership of the software is hereby transferred or allowed. 
;
; The  information  in this software is subject to change without notice
; and  should  not  be  construed  as  a commitment  by PROJECT SOFTWARE
; AND DEVELOPMENT, INC.
;
; PROJECT SOFTWARE assumes no responsibility for the use or  reliability  
; of this software on any equipment whatsoever.
;
;	Project Software & Development, Inc.
;	14 Story St.
;	Cambridge, Ma. 02138
;	617-661-1444
;
;
; Title:	AUXSCR.MAC
; Author:	Robin Miller
; Date:		July 23, 1985
;
; Description:
;
;	These routines do the screen formatting for the VT100.
;
;-
	.ENABL	AMA
	.NLIST	BEX


;	Local equates:	Edited F. borger to make errors work right

	MSLINE	=	23.		; The message line number.
	PRLINE	=	MSLINE+1	; The prompt line number.
	LNBIAS	=	10.		; The line bias for no AVO.
	HORLIN	=	161		; Horizontal line (q).

;	Local messages:

ACTM:	.ASCIZ	"Active"
	ACTS = <.-ACTM>-1		; Size of active message.
WORKM:	.ASCIZ	"Working ... record "
	WORKS = <.-WORKM>-1		; Size of working message.
	.EVEN

	.SBTTL	CLRMSG - Position/clear the message line.
;+
;
; CLRMSG - Position/clear the error message line.
; CPYMSG - Copy the position/clear sequence (don't display).
; SETMSG - Same as CPYMSG except the REVERSE attribute is added.
; SET2MS - Same as SETMSG except BOLD and second string is added.
; TYPMSG - Entry point to finish buffer and write the message.
; WRTMSG - Same as SETMSG except append and display the message.
; WRT2MS - Same as WRTMSG except a second message is appended.
; WRT4MS - Same as WRT2MS except four strings are displayed.
;
; The message line is either line 23 or line 13 depending on whether the
; terminal has the AVO or not.  If the VT100 doesn't have the AVO, and
; we're in 132 column mode, only 14 lines can be displayed at one time.
;
; Inputs:
;	R0 = The output buffer address (entry at CPYMSG/SETMSG/TYPMSG).
;	R1 = The message string address (entry at WRTMSG).
;	R2 = The second string address (entry at WRT2MS).
;	R3 = The third string address (entry at WRT4MS).
;	R4 = The fourth string address (entry at WRT4MS).
;
; Outputs:
;	R0 = The updated output buffer address (return from CPYMSG/SETMSG).
;
;	All other registers are preserved.
;
;-
CLRMSG::JSR	R2,$SAVVR		; Save R0 - R2.
	MOV	#FMTBUF,R0		; Set the buffer address.
	CALL	CPYMSG			; Copy the positioning sequence.
	BIC	#B.MSG,STATUS		; Show no message is displayed.
	JMP	VTYPE			; Write it to the terminal.

SETMSG::CALL	SAVEC			; Save the cursor position.
	CALL	CPYMSG			; Copy the positioning sequence.
	CALL	REVERSE			; Add the REVERSE video attribute.
	RETURN

SET2MS::MOV	#FMTBUF,R0		; Set the buffer address.
	CALL	SETMSG			; Setup the message to write.
	CALL	MOVEC			; Append the 1st message string.
	CALL	BOLD			; Copy the BOLD video attribute.
	MOV	R2,R1			; Set address of second message.
	CALL	MOVEF			; Now append the second message.
	RETURN

WRTMSG::JSR	R2,$SAVVR		; Save R0 - R2.
	MOV	#FMTBUF,R0		; Set the buffer address.
	CALL	SETMSG			; Setup the message to write.
	CALL	MOVEC			; Append the message string.
	BR	TYPMSG			; Write it to the terminal.

WRT2MS::JSR	R2,$SAVVR		; Save R0 - R2.
	CALL	SET2MS			; Set to write 2 string message.
	BR	TYPMSG			; And go do it ...

WRT4MS::JSR	R2,$SAVVR		; Save R0 - R2.
	CALL	SET2MS			; Set to write 2 string message.
	CALL	ATTOFF			; Turn off the video attributes.
	CALL	REVERSE			; Add REVERSE video attribute.
	MOV	R3,R1			; Set address of third message.
	CALL	MOVEC			; Now append the third message.
	CALL	BOLD			; Add the BOLD video attribute.
	MOV	R4,R1			; Set address of fourth message.
	CALL	MOVEC			; Now append the fourth message.
					; Fall through to write it ...

TYPMSG::CALL	ATTOFF			; Turn off the video attributes.
	CALL	ADDBEL			; Ring the bell to wakeup the user.
	CALL	RESTC			; Restore the cursor position.
	BIS	#B.MSG,STATUS		; Show a message is displayed.
	JMP	VTYPE			; Write it to the terminal.

CPYMSG::JSR	R5,.SAVR1		; Save R1 - R5.
	MOV	#MSLINE,R1		; Presume VT100 with AVO.
	BIT	#B.132,STATUS		; VT100 in 132 column mode ?
	BEQ	10$			; If EQ, no (80 column mode).
	BIT	#B.AVO,SWMASK		; VT100 with advanced video ?
	BNE	10$			; If NE, yes.
	SUB	#LNBIAS,R1		; No, adjust the message line.

10$:	CALL	MAKLIN			; Make the ASCII line number.
	MOV	#1,R1			; Set the column number.
	CALL	MAKCOL			; Make the ASCII column number.
	CALL	CEOL			; Clear to end of the line.
	RETURN

	.SBTTL	CLRWIN - Clear the display window.
;+
;
; CLRWIN - Clears the display window.
;
; This routine clears all the lines within the current display window.
; The file name and/or ruler (if any) are left on the screen.
;
; Inputs:
;	None.
;
; Outputs:
;	All registers are preserved.
;
;-
CLRWIN::CALL	$SAVAL			; Save all registers.
	MOV	IENTRY,R5		; Get the current entry.
	MOV	#FMTBUF,R0		; Set the buffer address.
	CALL	CPYTOP			; Set to top of the window.
	CALL	CEOS			; Clear to the end of screen.
	JMP	VTYPE			; Write it to the terminal.

	.SBTTL	WRITPR - Make and write the command prompt.
;+
;
; COPYPR - Copy the prompt line sequence.
; WRITPR - Make and write the command prompt.
;
; This routine creates the prompt string from the current record number
; and writes it to the prompt line.
;
; Inputs:
;	R0 = The output buffer address (entry at COPYPR).
;
; Outputs:
;	R0 = The updated buffer address (entry at COPYPR).
;
;	All other registers are preserved.
;
;-
PRMSG:	.ASCII	%ECR>%
	.byte	7,0			; The prompt string.
	PRMSGL = <.-PRMSG>		; Calculate the prompt size.
	.EVEN

WRITPR::CALL	$SAVAL			; Save all registers.
	MOV	#FMTBUF,R0		; Set the output buffer address.
	CALL	COPYPR			; Copy the prompt sequence.
	CALL	CEOL			; Clear to end of the line.
	JMP	VTYPE			; Write it to the terminal.

COPYPR::JSR	R5,.SAVR1		; Save R1 - R5.
	CALL	SETPRL			; Prepare to write to prompt line.
	MOV	IENTRY,R5		; Copy the file entry address.
	MOV	#PRMSG,R1		; Set address of EOF string.
	CALL	MOVEC			; Append it to the output buffer.
	CALL	ATTOFF			; Turn off the video attributes.
	MOVB	#SPACE,(R0)+		; Add a space after the prompt.
	RETURN

	.SBTTL	CLRPRL - Position/clear the prompt line.
;+
;
; CLRPRL - Position/clear the prompt line.
; CPYPRL - Copy the position/clear sequence (don't display).
; POSPRL - Position to the prompt line (no other action).
; SETPRL - Same as CPYPRL except BOLD/REVERSE attributes added.
; WRTPRL - Same as SETPRL except append and display the message.
;
; This routine positions to the prompt line, clears the line, then adds
; the BOLD and REVERSE video attributes presuming a message will be
; displayed next.
;
; Inputs:
;	R0 = The output buffer address (entry at CPYPRL/POSPRL/SETPRL).
;	R1 = The prompt string address (entry at WRTPRL).
;
; Outputs:
;	R0 = The updated output buffer address (return from CPYPRL/SETPRL).
;
;	All other registers are preserved.
;
;-
CLRPRL::JSR	R2,$SAVVR		; Save R0 - R2.
	MOV	#FMTBUF,R0		; Set the buffer address.
	CALL	CPYPRL			; Move positioning sequence.
	JMP	VTYPE			; Write it to the terminal.

SETPRL::CALL	POSPRL			; Position to the prompt line.
	CALL	BOLD			; Add the BOLD video attribute.
	RETURN

WRTPRL::JSR	R2,$SAVVR		; Save R0 - R2.
	MOV	#FMTBUF,R0		; Set the buffer address.
	CALL	SETPRL			; Setup the buffer to write.
	CALL	MOVEC			; Append the prompt string.
	CALL	ATTOFF			; Append video attributes off.
	JMP	VTYPE			; Write it to the terminal.

CPYPRL::CALL	POSPRL			; Position to the prompt line.
	CALL	CEOL			; Clear to end of the line.
	RETURN

POSPRL::JSR	R5,.SAVR1		; Save R1 - R5.
	MOV	#PRLINE,R1		; Presume VT100 with AVO.
	BIT	#B.132,STATUS		; VT100 in 132 column mode ?
	BEQ	10$			; If EQ, no (80 column mode).
	BIT	#B.AVO,SWMASK		; VT100 with advanced video ?
	BNE	10$			; If NE, yes.
	SUB	#LNBIAS,R1		; No, adjust the prompt line.

10$:	CALL	MAKLIN			; Make the ASCII line number.
	MOV	#1,R1			; Set the column number.
	CALL	MAKCOL			; Make the ASCII column number.
	RETURN

	.SBTTL	NXTPAG - Format for the next page.
;+
;
; NXTPAG - Format for the next page.
;
; This routine is called to format the screen for the next display page.
; The message and prompt lines are cleared, the cursor is positioned at the
; last display line, and the window is scrolled up one line in preparation
; of the next line to be displayed.
;
; Inputs:
;	None.
;
; Outputs:
;	All registers are preserved.
;
;-
NXTPAG::CALL	$SAVAL			; Save all registers.
	MOV	IENTRY,R5		; Copy the file entry address.
	MOV	#FMTBUF,R0		; Set the buffer address.
	CALL	CPYMSG			; Clear the message line
	CALL	CPYPRL			;	and the prompt line.

;	Next, position to the last display line.

	MOV	O.BOT(R5),R1		; Copy the bottom line number.
	CALL	MAKLIN			; Make the ASCII line number.
	MOV	#1,R1			; Set for the first column.
	CALL	MAKCOL			; Make the ASCII column number.
	CALL	CPYBLA			; Use CR/LF to scroll the screen up.
	JMP	VTYPE			; Write it to the terminal.

	.SBTTL	CPYBLA - Copy the CR/LF sequence.
;+
;
; CPYBLA - Copy a carriage return/line feed sequence.
; WRTBLA - Write a blank line to the terminal.
;
; Inputs:
;	R0 = The output buffer address.
;
; Outputs:
;	R0 = The updated output buffer address.
;
;	All other registers are preserved.
;
;-
WRTBLA::MOV	#FMTBUF,R0		; Set the output buffer address.
	CALL	CPYBLA			; Fill in a <CR><LF> sequence.
	JMP	VTYPE			; And go display it.

CPYBLA::JSR	R5,.SAVR1		; Save R1 - R5.
	MOVB	#CR,(R0)+		; Append a carriage return
	MOVB	#LF,(R0)+		;	and a line feed.
	CLRB	(R0)			; Terminate the output buffer.
	RETURN

	.SBTTL	CPYTOP - Position to top of display window.
;+
;
; CPYTOP - Copy the positioning sequence (don't display).
; WRTTOP - Write the position to top of display window sequence.
;
; This routine is used to position to the top line of a display window.
;
; Inputs:
;	R0 = The output buffer address (entry at CPYTOP).
;	R5 = The active file entry address (entry at CPYTOP).
;
; Outputs:
;	R0 = The updated output buffer address (return from CPYTOP).
;
;	All other registers are preserved.
;
;-
WRTTOP::CALL	$SAVAL			; Save all registers.
	MOV	IENTRY,R5		; Get the current entry.
	MOV	#FMTBUF,R0		; Set the buffer address.
	CALL	CPYTOP			; Move positioning sequence.
	JMP	VTYPE			; Write it to the terminal.

CPYTOP::JSR	R5,.SAVR1		; Save R1 - R5.
	MOVB	O.TOP(R5),R1		; Copy the top line number.
	CALL	MAKLIN			; Make the ASCII line number.
	MOV	#1,R1			; Set for the first column.
	CALL	MAKCOL			; Now make the column number.
	RETURN

	.SBTTL	SCRDWN - Scroll the screen down.
;+
;
; SCRDWN - Scroll the screen down.
;
; This routine is called to scroll the screen down the specified number
; of lines when we are backing up a partial page.
;
; Inputs:
;	R1 = The number of lines to scroll down.
;
; Outputs:
;	All registers are preserved.
;
;-
SCRDWN::CALL	$SAVAL			; Save all registers.
	MOV	IENTRY,R5		; Copy the file entry address.
	MOV	#FMTBUF,R0		; Set the output buffer address.
	CALL	CPYMSG			; Clear the message line
	CALL	CPYPRL			;	and the prompt line.
	CALL	CPYTOP			; Set to top of display window.
10$:	CALL	RINDEX			; Move screen down (reverse index).
	SOB	R1,10$			; Loop until we're done.
	JMP	VTYPE			; Write it to the terminal.

	.SBTTL	SETNAR - Set VT100 to 80 columns.
;+
;
; SETNAR - Set VT100 to 80 column mode.
;
;-
SETNAR::JSR	R2,$SAVVR		; Save R0 - R2.
	MOV	#FMTBUF,R0		; Set the buffer address.
	CALL	NARROW			; Set to a narrow screen.
	JMP	VTYPE			; Write it to the terminal.

	.SBTTL	SETWID - Set VT100 to 132 columns.
;+
;
; SETWID - Set VT100 to 132 column mode.
;
;-
SETWID::JSR	R2,$SAVVR		; Save R0 - R2.
	MOV	#FMTBUF,R0		; Set the buffer address.
	CALL	WIDE			; Set to a wide screen.
	JMP	VTYPE			; Write it to the terminal.

	.SBTTL	WRTEOF - Write the end of file sequence.
;+
;
; WRTEOF - Write the end of file sequence.
;
; This routine is called when a file is being closed to disable the
; scrolling region, put the keypad back in numeric mode, and to set
; the screen narrow if it was set wide.
;
; Inputs:
;	None.
;
; Outputs:
;	All registers are preserved.
;
;-
WRTEOF::JSR	R2,$SAVVR		; Save R0 - R2.
	MOV	#FMTBUF,R0		; Set the buffer address.
;*	CALL	NOREG			; Remove the scroll region.
	CALL	NUMKEY			; Put keypad back in numeric.
;*	BIT	#B.132,STATUS		; VT100 in 132 column mode ?
;*	BEQ	10$			; If EQ, no (already narrow).
;*	CALL	NARROW			; Yes, set to 80 column mode.
;*	BIC	#B.132,STATUS		; Show we're now in narrow mode.
;*	BR	20$			; And continue ...

10$:	CALL	POSPRL			; Position to the prompt line.

20$:	JMP	VTYPE			; Write it to the terminal.

	.SBTTL	WRTHDR - Write the screen header.
;+
;
; WRTHDR - Writes the screen the active file entry.
;
; This routine sets the terminal to either 80 or 132 column mode, positions
; to and writes the file name (if enabled), enables the application keypad,
; sets up the scrolling region, writes a ruler (if enabled), and then leaves
; the cursor positioned at the first display line.
;
; Inputs:
;	None.
;
; Outputs:
;	All registers are preserved.
;
;-
WRTHDR::CALL	$SAVAL			; Save all registers.
	MOV	IENTRY,R5		; Get the current entry.
	MOV	#FMTBUF,R0		; Set the buffer address.
;***	BIT	#B.2FIL,STATUS		; Are we displaying two files ?
;***	BEQ	10$			; If EQ, no (only one).
;***	CALL	PREHDR			; Clear top or bottom of screen.
;***	BR	20$			; And continue ...

;	We only change the width when displaying a single file.

10$:	CALL	CPYWID			; Copy the current screen width.

20$:	CALL	CPYNAM			; Do the file name processing.
	CALL	APPKEY			; Enable the application keypad.
	CALL	CPYSCR			; Setup the scrolling region.
	CALL	VTYPE			; Write the format buffer.
	JMP	WRTTOP			; Set to top of the display window.

	.SBTTL	WRTNAM - Write the file name.
;+
;
; WRTNAM - Write the file name.
;
; Inputs:
;	R0 = The output buffer address (entry at CPYNAM).
;	R5 = The file entry address (entry at CPYNAM).
;
; Outputs:
;	R0 = The updated output buffer address (entry at CPYNAM).
;
;	All other registers are preserved.
;
;-
WRTNAM::CALL	$SAVAL			; Save all registers.
	MOV	IENTRY,R5		; Copy the file entry address.
	MOV	#FMTBUF,R0		; Set the output buffer address.
	CALL	CPYNAM			; Copy the file name sequence.
	JMP	VTYPE			; And write it to the terminal.

CPYNAM::JSR	R5,.SAVR1		; Save R1 - R5.
;***	BIT	#S.NAME,(R5)		; Is file name display enabled ?
;***	BEQ	100$			; If EQ, no (we're all done).
;***	BIT	#B.2FIL,STATUS		; Are we displaying two files ?
;***	BEQ	10$			; If EQ, no (continue ...)
;***	BIT	#S.RULR,(R5)		; Using ruler in place of name ?
;***	BNE	100$			; If NE, yes (no file name).

10$:	MOVB	O.FLIN(R5),R1		; Get the file name line number.
	CALL	MAKLIN			; Make the ASCII line number.
	MOV	#1,R1			; Set for the first column.
	CALL	MAKCOL			; Make the ASCII column number.
	BIT	#B.132,STATUS		; Are we in 132 column mode ?
	BEQ	20$			; If EQ, no (80 column mode).
	CALL	DWIDTH			; Set for double width.

20$:	CALL	BOLD			; Add the BOLD attribute.
	CALL	REVERSE			; Add the REVERSE attribute.
	MOV	O.FNAM(R5),R1		; Copy address of the file name.
	CALL	MOVEC			; Copy it to the output buffer.
	MOVB	#SPACE,(R0)+		; Spaces between
	MOVB	#SPACE,(R0)+		;    the file name
	MOVB	#SPACE,(R0)+		; 	and the date.
	MOV	O.FDAT(R5),R1		; Copy address of creation date.
	CALL	MOVEC			; Copy it to the output buffer.
	CALL	ATTOFF			; Turn off video attributes.

100$:	RETURN

	.SBTTL	PREHDR - Prepare to write header.
;+
;
; PREHDR - Prepare to write the header.
;
; This routine is used to prepare the screen to write the file name for
; one of the file entrys when displaying two files.  The idea here is to
; clear the screen for one file while the other file is left on the screen.
;
; Inputs:
;	R0 = The output buffer address.
;	R5 = The file entry address.
;
; Outputs:
;	R0 = The updated output buffer address.
;
;	All other registers are preserved.
;
;-
PREHDR::JSR	R5,.SAVR1		; Save R1 - R5.
	CMP	R5,#IFILE1		; Are we doing the top file ?
	BNE	10$			; If NE, no (must be the bottom).

;	Top file processing:

	MOV	O.BOT(R5),R1		; Get the bottom line number.
	CALL	MAKLIN			; Make the ASCII line number.
	MOV	#1,R1			; Set for the first column.
	CALL	MAKCOL			; Make the ASCII column number.
	CALL	CEOL			; Clear to end of the line.
	CALL	CBOS			; Clear to beginning of screen.
	BR	100$			; And continue ...

;	Bottom file processing:

10$:	MOV	O.FLIN(R5),R1		; Get the file name line.
	CALL	MAKLIN			; Make the ASCII line number.
	MOV	#1,R1			; Set for the first column.
	CALL	MAKCOL			; Make the ASCII column number.
	CALL	CEOS			; Clear to the end of screen.
;***	BIT	#S.NAME,(R5)		; Is file name display enabled ?
;***	BNE	100$			; If NE, yes (continue ...)

;	Put a delimiter between the top and bottom files.

	CALL	SGRAPH			; Turn on special graphics.
	MOV	#80.,R2			; Presume in 80 column mode.
	BIT	#B.132,STATUS		; Did we guess correctly ?
	BEQ	20$			; If EQ, yes.
	MOV	#132.,R2		; Else, change the loop count.
20$:	MOVB	#HORLIN,(R0)+		; Set to write a horizontal line.
	SOB	R2,20$			; Loop until done.
	CALL	USSET			; Now, back to the ASCII set.

100$:	RETURN

	.SBTTL	PRESPN - Write the pre-spawn sequence.
;+
;
; PRESPN - Write the pre-spawn sequence.
;
; This routine is called before spawning a command line to disable the
; scrolling region, put the keypad back in numeric mode, and position
; to the last line in preparation for the spawned command output.
;
; Inputs:
;	None.
;
; Outputs:
;	All registers are preserved.
;
;-
PRESPN::JSR	R2,$SAVVR		; Save R0 - R2.
	MOV	#FMTBUF,R0		; Set the buffer address.
;*	CALL	NOREG			; Remove the scroll region.
	CALL	NUMKEY			; Put keypad back in numeric.
	MOV	#PRLINE,R1		; Presume VT100 with AVO.
	CALL	MAKLIN			; Make the ASCII line number.
	MOV	#1,R1			; Set the column number.
	CALL	MAKCOL			; Make the ASCII column number.
	JMP	VTYPE			; Write it to the terminal.

	.SBTTL	AFTSPN - Write the after spawn sequence.
;+
;
; AFTSPN - Write the after spawn sequence.
;
; This routine is called after spawning a command line to re-enable the
; numeric keypad.
;
; Inputs:
;	None.
;
; Outputs:
;	All registers are preserved.
;
;-
AFTSPN::JSR	R2,$SAVVR		; Save R0 - R2.
	MOV	#FMTBUF,R0		; Set the output buffer address.
	CALL	APPKEY			; Enable the application keypad.
	CALL	CPYBLA			; Scroll screen via a blank line.
	JMP	VTYPE			; Now go display the sequence.

	.SBTTL	CPYSCR - Copy the scroll region sequence.
;+
;
; CPYSCR - Copy the scrolling region sequence.
; WRTSCR - Write the scrolling region sequece.
;
; Inputs:
;	R0 = The output buffer address (entry at CPYSCR).
;
; Implicit inputs:
;	O.TOP = The top display window line number.
;	O.BOT = The bottom display window line number.
;
; Outputs:
;	R0 = The updated output buffer address.
;
;	All other registers are preserved.
;
;-
WRTSCR::CALL	$SAVAL			; Save all registers.
	MOV	IENTRY,R5		; Copy the file entry address.
	MOV	#FMTBUF,R0		; Set the output buffer address.
	CALL	CPYSCR			; Copy the scrolling region.
	JMP	VTYPE			; And write it to the terminal.

CPYSCR::JSR	R5,.SAVR1		; Save R1 - R5.
	CALL	HOME			; Put curser in home position.	(01)
	MOVB	O.TOP(R5),R1		; Copy the top line number.
	CALL	MAKLIN			; Make the ASCII line number.
	MOVB	O.BOT(R5),R1		; Set the bottom line number.
	CALL	MAKCOL			; Now make the column number.
	MOVB	#'r,-1(R0)		; Convert to set scroll region.
	RETURN

	.SBTTL	CPYWID - Copy the screen width.
;+
;
; CPYWID - Copy the screen width.
;
; This routine is used to change the terminal width to either narrow
; or wide.
;
; Inputs:
;	R0 = The output buffer address (entry at CPYWID).
;
; Outputs:
;	R0 = The updated output buffer address (entry at CPYWID).
;
;	All other registers are preserved.
;
;-
WRTWID::JSR	R2,$SAVVR		; Save R0 - R2.
	MOV	#FMTBUF,R0		; Set the output buffer address.
	CALL	CPYWID			; Copy the current screen width.
	JMP	VTYPE			; Write it to the terminal.

CPYWID::JSR	R5,.SAVR1		; Save R1 - R5.
	BIT	#B.132,STATUS		; Are we in wide screen mode ?
	BNE	10$			; If NE, yes.
	CALL	NARROW			; No, set to a narrow screen.
	BR	100$			; Use common return ...
10$:	CALL	WIDE			; Set to a wide screen.

100$:	RETURN

	.SBTTL	CPYACT - Copy the active message.
;+
;
; CLRACT - Clear the active message.
; WRTACT - Write the active message.
;
; This routine is used to clear or write the active message on the file
; name line when we're displaying two files.
;
; Implicit inputs:
;	O.FLIN = The file name line number.
;
; Outputs:
;	All registers are preserved.
;
;-
	.ENABL	LSB

CLRACT::CALL	$SAVAL			; Save all registers.
	CALL	50$			; Do the initial processing.
	BCS	100$			; If CS, don't write anything.
	CALL	CEOL			; Clear to the end of line.
	JMP	VTYPE			; Display it at the terminal.

WRTACT::CALL	$SAVAL			; Save all registers.
	CALL	50$			; Do the initial processing.
	BCS	30$			; If CS, show file on message line.
	CALL	REVERSE			; Turn on reverse video attribute.
	CALL	BOLD			; Add the bold attribute also.
	MOV	#ACTM,R1		; Set the active message address.
	CALL	MOVEC			; Copy it to the output buffer.
	CALL	ATTOFF			; Turn off the video attributes.
	CALL	CPYTOP			; Set to top of the display window.
	JMP	VTYPE			; Display it at the terminal.

30$:
;***	CALL	SHOFIL			; Show file name on message line.
	CALL	WRTTOP			; Set to top of the display window.
	BR	100$			; Use common return ...

;	Subroutine to do common code.

50$:	MOV	IENTRY,R5		; Copy the file entry address.
;***	BIT	#B.2FIL,STATUS		; Are we displaying two files ?
;***	BNE	60$			; If NE, yes (continue ...)
	TST	(SP)+			; No, remove the return address.
	RETURN				; To dismiss the action message.

60$:	SEC				; Presume message is disabled.
;***	BIT	#S.RULR,(R5)		; Using ruler in place of name ?
;***	BNE	100$			; If NE, yes (don't write message).
;***	BIT	#S.NAME,(R5)		; Is file name display disabled ?
;***	BEQ	100$			; If EQ, yes.
	MOV	#FMTBUF,R0		; Set the output buffer address.
	CALL	CPYACT			; Set to the active position.
	CLC				; Show we should write message.

100$:	RETURN

	.DSABL	LSB

CPYACT:	JSR	R5,.SAVR1		; Save R1 - R5.
	MOV	O.FLIN(R5),R1		; Copy the top line number.
	CALL	MAKLIN			; Make the ASCII line number.
	MOV	#<80.-ACTS>,R1		; Presume on a narrow screen.
	BIT	#B.132,STATUS		; Did we presume right ?
	BEQ	10$			; If EQ, yes.
	MOV	#<<132./2>-ACTS>,R1	; Else, set for a wide screen.
10$:	CALL	MAKCOL			; Now make the column number.
	RETURN

	.SBTTL	WRTWRK - Display the working message.
;+
;
; WRTWRK - Display the working message.
;
; This is routine is called after the timer expires to display the
; working message on the screen.
;
; Inputs:
;	None.
;
; Ouputs:
;	All registers are preserved.
;
;-
WRTWRK::JSR	R2,$SAVVR		; Save R0 - R2.
	MOV	#FMTBUF,R0		; Set address of format buffer.
	MOV	#MSLINE,R1		; Presume VT100 with AVO.
	BIT	#B.132,STATUS		; VT100 in 132 column mode ?
	BEQ	10$			; If EQ, no (80 column mode).
	BIT	#B.AVO,SWMASK		; VT100 with advanced video ?
	BNE	10$			; If NE, yes.
	SUB	#LNBIAS,R1		; No, adjust the message line.

;	Allow field width of 6 for the record number.

10$:	CALL	MAKLIN			; Make the ASCII line number.
	MOV	#<<80.-WORKS>-6>/2,R1	; Presume we're on narrow screen.
	BIT	#B.132,STATUS		; Did we presume right ?
	BEQ	20$			; If EQ, yes.
	ADD	#<132.-80.>/2,R1	; No, adjust for a wide screen.
20$:	CALL	MAKCOL			; Make the ASCII column number.
	CALL	CEOL			; Clear to end of the line.
	CALL	REVERSE			; Add the reverse video attribute.
	MOV	#WORKM,R1		; Set address of "Working" message.
	CALL	MOVEC			; Copy it to the output buffer.
	MOV	IENTRY,R1		; Copy the file entry address.
;***	ADD	#O.CREC,R1		; Point to current record number.
;***	CALL	CVTDTD			; Convert it to decimal ASCII.
	CALL	ATTOFF			; Turn off the attributes.
	BR	VTYPE			; Now go display the message.

	.SBTTL	CLRTTY - Clear the VT100 screen.
;+
;
; CLRTTY - Clear the VT100 screen.
;
; Inputs:
;	None.
;
; Outputs:
;	All registers are preserved.
;
;-
CLRTTY::JSR	R2,$SAVVR		; Save R0 - R2.
	MOV	#FMTBUF,R0		; Store the message here.
	CALL	CLRSCR			; Clear the entire screen.
;***	BR	VTYPE			; Write it to the terminal.

	.SBTTL	VTYPE - Write the format buffer.
;+
;
; VTYPE - Write the format buffer to the terminal.
;
; Inputs:
;	R0 = The updated output buffer address.
;
; Outputs:
;	R0 = The starting output buffer address.
;
;	All other registers are preserved.
;
;-
VTYPE::	JSR	R5,.SAVR1		; Save R1 - R5.
	MOV	R0,R1			; Copy the buffer address.
	SUB	#FMTBUF,R1		; Calculate the byte count.
	MOV	#FMTBUF,R0		; Setup the starting address.
	CALL	WRITIT			; And go write it.
	RETURN

	.END
