.TITLE AUXSUB - AUX Subroutines. .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: AUXSUB.MAC ; Author: Robin Miller ; Date: July 23, 1985 ; ; Description: ; ; This module contains various subroutines for the AUX program. ; ;- .ENABL AMA .NLIST BEX .MCALL ASTX$S, CMKT$S, DIR$, MRKT$S, QIOW$, TTSYM$ ; Bit and offset definitions: TTSYM$ ; Define the terminal symbols. ; Local equates: DLYTIM = 2 ; The number of seconds to delay SECNDS = 2 ; Time unit for seconds. ; QIOW's to get and set the terminal characteristics. GETCHA: QIOW$ SF.GMC,TOLUN,TOEFN,,TIOSB,, ; Get term. char. SETCHA: QIOW$ SF.SMC,TOLUN,TOEFN,,TIOSB,, ; Set term. char. CLRTAH: QIOW$ SF.SMC,TOLUN,TOEFN,,TIOSB,, ; Clear typeahead. GETTAH: QIOW$ SF.GMC,TOLUN,TOEFN,,TIOSB,, ; Get typehead. DOWRAP: QIOW$ SF.SMC,TOLUN,TOEFN,,TIOSB,, ; Clear/set wrap. DOWDTH: QIOW$ SF.SMC,TOLUN,TOEFN,,TIOSB,, ; Change the width. ; Local storage: TTYBUF: .BYTE TC.TTP ; Get the terminal type. TTYPE:: .BYTE T.V100 ; Default to a VT100. .BYTE TC.WID ; Get the terminal width. TTYWID: .BYTE 0 ; And store the value here. .BYTE TC.ACR ; Automatic wrap-around. TTWRAP: .BYTE 0 ; And store the value here (<>=on). TTYSIZ = .-TTYBUF ; Size of status table. SETBUF: .BYTE TC.ESQ,0 ; Enable escape sequences. SETSIZ = .-SETBUF TAHBUF::.BYTE TC.TBF,1 ; Clear/get typeahead buffer count. TAHSIZ = .-TAHBUF WDTHBF: .BYTE TC.WID ; Change the terminal width. WIDTH: .BYTE 0 ; Width to change terminal to. WDTHLN = .-WDTHBF ; Size of set options. WRAPBF: .BYTE TC.ACR ; Clear/set automatic wrap-around. WRMODE: .BYTE 0 ; Wrap-around mode (0/1 = off/on). WRAPLN = .-WRAPBF ; Size of set options. .SBTTL ADDBEL - Add a bell to a buffer. ;+ ; ; ADDBEL - Add a bell to a buffer. ; ; This routine is called to a BELL character to a buffer. The bell is ; not added to the buffer if suppressing of the bell has been requested. ; ; Inputs: ; R0 = The buffer address. ; ; Outputs: ; R0 = The updated buffer address. ; ; All other registers are preserved. ; ;- ADDBEL:: ;*** BIT #B.BELL,SWMASK ; Is ringing of bell suppressed ? ;*** BEQ 10$ ; If EQ, yes. MOVB #BELL,(R0)+ ; Nope, append the bell. CLRB (R0) ; And terminate with a null. 10$: RETURN WRTBEL::JSR R2,$SAVVR ; Save R0 - R2. MOV #FMTBUF,R0 ; Set the output buffer address. CALL ADDBEL ; Add the bell to the buffer. JMP VTYPE ; And go ring the bell. .SBTTL CTTYPE - Check the terminal type. ;+ ; ; CTTYPE - Check the terminal type. ; ; This routine is used to ensure the terminal being used is a VT100 ; family terminal. If it is not, an appropriate error message is ; displayed and we exit from the program. ; ; Inputs: ; None. ; ; Outputs: ; C bit clear/set = success/failure. ; ; All registers are preserved. ; ;- .ENABL LSB CTTYPE::CALL $SAVAL ; Save all registers. DIR$ #GETCHA ; Get the terminal type. CALL CHKERR ; Check for any errors. BCS 30$ ; If CS, we've had an error. ; Find out what the terminal width is. CMPB TTYWID,#80. ; Are we on a wide screen ? BLOS 5$ ; If LOS, no. BIS #B.132,STATUS ; Show the screen is set wide. ; Ensure the terminal is of the VT100 family. 5$: CMPB TTYPE,#T.V100 ; Are we running on a VT100 ? BEQ 10$ ; If EQ, yes (continue ...). ; Range of VT100 terminals is T.V101 (24) through T.V132 (31). CMPB TTYPE,#T.V101 ; Is this possible VT100 family ? BLO 20$ ; If LO, no CMPB TTYPE,#T.V132 ; Really a VT100 family terminal ? BHI 20$ ; If HI, no BIS #B.AVO,SWMASK ; Presume we have the AVO option. 10$: CALL ANSI ; Put the VT100 in ANSI mode. BIC #B.STUP,SWMASK ; Show no longer in startup code. DIR$ #SETCHA ; Disable software escape sequences. CALL CHKERR ; Check for any errors. BR 30$ ; And return with C bit clear/set. 20$: ERRMSG NVT100,<%AUX-F-NVT100, not a VT100 family terminal.> SEC ; Show the terminal check failed. 30$: RETURN .DSABL LSB .SBTTL CTYPAH - Clear the typeahead buffer. ;+ ; ; CTYPAH - Clear the typeahead buffer. ; ; Inputs: ; None. ; ; Outputs: ; All registers are preserved. ; ;- CTYPAH::DIR$ #CLRTAH ; Clear the typehead buffer. CALL CHKERR ; Check/report any errors. RETURN .SBTTL GTYPAH - Get the typeahead buffer count. ;+ ; ; GTYPAH - Get the typeahead buffer count. ; ; Inputs: ; None. ; ; Outputs: ; C bit clear/set = typeahead count / no count. ; ; R1 = The typeahead buffer count. ; ;- GTYPAH::DIR$ #GETTAH ; Get the typeahead buffer count. CALL CHKERR ; Check/report any errors. BCS 10$ ; If CS, we had an error. MOVB TAHBUF+1,R1 ; Else, copy typeahead count. BNE 10$ ; If NE, there was a count. SEC ; Show there was nothing. 10$: RETURN .SBTTL DOPARS - Parse the command line. ;+ ; ; DOPARS - Parse the command line. ; ; Use .TPARS to parse the command line. ; ; Inputs to DOPARS: ; R0 = The buffer address. ; R1 = The buffer byte count. ; R5 = The starting state address. ; ; Inputs to .TPARS: ; R1 = Bit 0 in the low byte controls processing of blanks/tabs: ; if 0, ignore blanks, if 1 then pass blanks and tabs. ; The high byte contains the number of characters that ; keywords are alloewed to be abbreviated (0 = exact). ; R2 = The keyword table address. ; R3 = The input string byte count. ; R4 = The input buffer address. ; R5 = The starting state address. ; ; Outputs from .TPARS: ; C bit clear/set = success/failure. ; ; R3 = Zero on success or ; remaining byte count on syntax error. ; R4 = End of input string or ; updated buffer address on syntax error. ; ; All other registers from .TPARS are preserved. ; ;- DOPARS::CALL $SAVAL ; Save all registers. MOV R0,R4 ; Copy the buffer address. MOV R1,R3 ; Copy the buffer byte count. MOV #<<400*1>+0>,R1 ; Ignore blanks, match 1 character. MOV #KEYWRD,R2 ; Address of the keyword table. CALL .TPARS ; Now parse the command line. .IF NDF STRICT BCC 100$ ; If CC, success. .IFF BCS 10$ ; If CS, we had an error. BIT #B.CMNT,STATUS ; Was a comment line encountered ? BNE 100$ ; If NE, yes (don't report error). ; Don't flag error if spaces and/or tabs at end of command line. CALL SKIP ; Skip any tabs and/or spaces. TST R3 ; Any unprocessed characters ? BEQ 100$ ; If EQ, no (this is success). .ENDC ;STRICT 10$: CALL WRTSYN ; Write the syntax error. 100$: RETURN .SBTTL SKIP - Skip tabs and/or spaces. ;+ ; ; SKIP - Skip tabs and/or spaces. ; ; Inputs: ; R3 = The byte count. ; R4 = The buffer address. ; ; Outputs: ; R3 & R4 are adjusted past any tabs and/or spaces. ; ; All other registers are preserved. ; ;- SKIP: TST R3 ; Any byte count left ? BEQ 100$ ; If EQ, no. CMPB (R4),#SPACE ; Is this a space ? BEQ 10$ ; If EQ, yes. CMPB (R4),#HT ; Is this a horizontal tab ? BNE 100$ ; If NE, no. 10$: INC R4 ; Adjust the buffer address. SOB R3,SKIP ; And loop on the byte count. 100$: RETURN .SBTTL STIMER - Start the timer. ;+ ; ; STIMER - Start the timer. ; ; This routine is called to start a timer which when it expires will enter ; an AST routine to display the working message at the screen. ; ; Inputs: ; None. ; ; Outputs: ; All registers are preserved. ; ;- STIMER::JSR R2,$SAVVR ; Save R0 - R2. BIC #B.CTIM,SWMASK ; Clear the timer aborted flag. MRKT$S ,#2,#SECNDS,#DOWORK ; Start working message timer. CALL CHKDIR ; Check/display any errors. RETURN .SBTTL CTIMER - Cancel the timer. ;+ ; ; CTIMER - Cancel the timer. ; ; This routine is called to disable a previously enabled timer. ; ; Inputs: ; None. ; ; Outputs: ; All registers are perserved. ; ;- CTIMER::BIS #B.CTIM,SWMASK ; Show timer has been aborted. CMKT$S ; Cancel all outstanding timers. RETURN .SBTTL DOWORK - Display the working message. ;+ ; ; DOWORK - Display the working message. ; ; This routine is entered after the timer expires to display the working ; message at the screen. ; ; Inputs: ; None. ; ; Outputs: ; All registers are preserved. ; ;- DOWORK::CALL WRTWRK ; Call routine to write message. BIT #B.CTIM,SWMASK ; Has the timer been aborted ? BNE 10$ ; If EQ, yes (don't start again). CALL STIMER ; Start the timer again. 10$: TST (SP)+ ; Clear event flag from stack. ASTX$S ; Exit from the AST routine. .SBTTL CLWRAP - Clear automatic wrap-around. ;+ ; ; CLWRAP - Clear automatic wrap-around. ; ; This routine is used to disable the terminal drivers automatic wrap-around. ; If this characteristic is enabled, the terminal driver does an auto-wrap ; when we are editing the command line. ; ; Inputs: ; None. ; ; Outputs: ; All registers are preserved. ; ;- CLWRAP::TSTB TTWRAP ; Is auto-wrap already off ? BEQ 100$ ; If EQ, yes. CLRB WRMODE ; Get ready to turn wrap off. DIR$ #DOWRAP ; Turn the characteristic off. CALL CHKERR ; Check/report any errors. 100$: RETURN .SBTTL SEWDTH - Set the terminal width. ;+ ; ; SEWDTH - Set the terminal width. ; ; Implicit Inputs: ; B.132 in STATUS off/on = 80/132 columns. ; ; Outputs: ; All registers are preserved. ; ;- SEWDTH::MOVB #80.,WIDTH ; Set for narrow screen. BIT #B.132,STATUS ; Did we guess right ? BEQ 10$ ; If EQ, yes. MOVB #132.,WIDTH ; No, set for wide screen. 10$: DIR$ #DOWDTH ; Set the terminal width. CALL CHKERR ; Check/report any errors. RETURN .SBTTL SEWRAP - Set automatic wrap-around. ;+ ; ; SEWRAP - Set automatic wrap-around. ; ; This routine is used to enable automatic wrap-around if it was disabled. ; ; Inputs: ; None. ; ; Outputs: ; All registers are preserved. ; ;- SEWRAP::TSTB TTWRAP ; Was auto-wrap initially off ? BEQ 100$ ; If EQ, yes. MOVB #1,WRMODE ; Get ready to turn wrap on. DIR$ #DOWRAP ; Turn the characteristic off. CALL CHKERR ; Check/report any errors. 100$: RETURN .END