.TITLE PHOFMT - PHONE FORMATTING ROUTINES .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: PHOFMT.MAC ; Author: Gary N. Larsen & Robin Miller ; Date: August 3, 1982 ; ; Description: ; ; Phone formatting routines for VT100 output. ; ; ; Modification History: ; ;- .ENABL AMA .NLIST BEX .MCALL ALUN$S, GLUN$S, GTIM$S, QIOW$S ; Local equates: LRCRNR = 152 ; LOWER-RIGHT CORNER (j) URCRNR = 153 ; UPPER-RIGHT CORNER (k) ULCRNR = 154 ; UPPER-LEFT CORNER (l) LLCRNR = 155 ; LOWER-LEFT CORNER (m) HORLIN = 161 ; HORIZONTAL LINE (q) VERLIN = 170 ; VERTICAL LINE (x) ; Header message: HEADER: .ASCIZ /RSX-11M Phone Facility/ .EVEN ; Storage for ASCII terminal name. ASCNAM::.BLKB 6 ; STORAGE FOR ASCII TASK NAME ; Escape sequence to clear bottom of screen. CBOTM: .ASCII "[15;1H""[0J" CBOTL = .-CBOTM ; Escape sequences to save and restore cursor attributes. CMSGS: .ASCII "7" ; SAVE CURSOR CMSGSL = .-CMSGS CMSGR: .ASCII "8" ; RESTORE CURSOR CMSGRL = .-CMSGR ; Escape sequence to clear the message line. CMSGM: .ASCII "[3;1H""[0K" ; CLEAR LINE 3 CMSGL = .-CMSGM .EVEN ; Formatting routines for PHONE. ; Registers R0, R1, and R2 may be used by the action routines. ; All other registers must be preserved. ;********************************************************************** ; Put VT100 in ANSI mode. ANSI:: VTMSG ANSIM,^/ ; TURN OFF ALL ATTRIBUTES RETURN ; Turn on bold attribute. BOLD:: VTMSG BOLDM,<[1m> ; TURN BOLD ATTRIBUTE ON RETURN ; Turn on reverse video attribute. REVERSE:: VTMSG REVMSG,<[7m> ; TURN REVERSE VIDEO ON RETURN ;********************************************************************** ; Clear the entire screen. CLRSCR::VTMSG HOMEM,<[H> ; HOME POSITION VTMSG CLEARM,<[J> ; CLEAR THE SCREEN BR CRET ; Clear to end of line. CEOL:: VTMSG CEOLM,<[0K> ; ERASE TO END OF LINE BR CRET ; Clear to end of the screen. CEOS:: VTMSG CEOSM,<[0J> ; ERASE TO END OF SCREEN BR CRET ; Common return for clear screen. CRET: RETURN ;********************************************************************** ; Change character sets. SGRAPH::VTMSG SGRAPM,<(0> ; SPECIAL GRAPHICS RETURN USSET:: VTMSG USSETM,<(B> ; USASCII CHARACTER SET RETURN ;********************************************************************** ; Disable the scrolling region. NOREG:: VTMSG NOREGM,<[r> ; DISABLE SCROLL REGION RETURN .SBTTL MOVEC - MOVE CHARACTER STRING ;+ ; ; MOVEC - Routine to move an ASCIZ string. ; ; Inputs: ; R0 = address of the ASCIZ message. ; BUFPTR = address of the output buffer address. ; ; Outputs: ; BUFPTR is updated to next available byte. ; ;- MOVEC:: MOVB (R0)+,@BUFPTR ; COPY THE NEXT BYTE BEQ 10$ ; IF EQ, ALL DONE INC BUFPTR ; UPDATE THE POINTER BR MOVEC ; AND MOVE THE NEXT 10$: RETURN .SBTTL DOHORI - DO THE HORIZONTAL LINE ;+ ; ; DOHORI - Do the horizontal line. ; ; This routine generates a horizonal line using special graphics. ; ; Inputs: ; BUFPTR = the output buffer pointer. ; ; Outputs: ; BUFPTR = the updated buffer pointer. ; ;- DOHORI::JSR R2,$SAVVR ; SAVE R0 - R2 CALL SGRAPH ; TURN ON SPECIAL GRAPHICS MOV #80.,R1 ; SET THE COUNT 10$: MOVCHR ; MOVE IN HORIZONTAL LINE SOB R1,10$ ; LOOP UNTIL DONE CALL USSET ; USASCII CHARACTER SET RETURN .SBTTL MAKSCR - MAKE THE SCREEN MESSAGE ;+ ; ; MAKSCR - Make the screen message. ; ; This routine is called to build the initial screen message to write ; at startup time to the terminals we are phoning. The routine only ; needs to be called once to format the buffer. ; ; Inputs: ; BUFPTR = pointer to the screen buffer. ; ; Outputs: ; BUFPTR = updated buffer pointer. ; ; All registers are preserved. ; ;- MAKSCR::JSR R2,$SAVVR ; SAVE R0 - R2 MOV #SCRBUF,BUFPTR ; SETUP THE BUFFER POINTER CALL ANSI ; MAKE SURE THE TERMINAL IS SETUP ANSI CALL CLRSCR ; AND CLEAR THE SCREEN ; Setup the header message. MOV #1,R1 ; START AT LINE 1 MOV #30.,R2 ; COLUMN 30 CALL MAKCUR ; MAKE THE CURSOR ADDRESS CALL REVERSE ; AND OUTLINE IT IN REVERSE VIDEO MOVMSG HEADER ; MOVE THE HEADER MESSAGE CALL ATTOFF ; NOW TURN OFF THE REVERSE VIDEO ; Setup the date in the right hand corner. MOV #1,R1 ; START AT LINE 1 MOV #72.,R2 ; COLUMN 72 CALL MAKCUR ; MAKE THE CURSOR ADDRESS GTIM$S #DATBUF ; GET THE DATE MOV #DATBUF,R1 ; CONTAINS THE ADDRESS OF THE DATE MOV BUFPTR,R0 ; POINTER TO THE OUTPUT BUFFER CALL $DAT ; NOW CONVERT THE DATE MOV R0,BUFPTR ; ADJUST THE BUFFER POINTER ; Write the top solid horizontal line. MOV #4.,R1 ; NOW GO TO LINE 4 MOV #1,R2 ; COLUMN 1 CALL MAKCUR ; MAKE THE CURSOR ADDRESS CALL DOHORI ; MAKE THE HORIZONTAL LINE ; Write the phoning terminal's name. MOV #5.,R1 ; NOW TO LINE 5 MOV #38.,R2 ; COLUMN 38 CALL MAKCUR ; MAKE THE CURSOR ADDRESS CALL BOLD ; SET UP THE BOLD ATTRIBUTE MOV BUFPTR,R0 ; COPY THE BUFFER ADDRESS MOV #TILUN,LUN ; TERMINAL NAME FROM TILUN CALL GETTTY ; GET THE BINARY UNIT NUMBER CALL MAKTTY ; MAKE THE TERMINAL NAME MOV R0,BUFPTR ; SAVE NEW BUFFER POINTER CALL ATTOFF ; TURN OFF THE ATTRIBUTES ; Draw the bottom solid horizontal line. MOV #14.,R1 ; NOW GO TO LINE 12 MOV #1,R2 ; COLUMN 1 CALL MAKCUR ; MAKE THE CURSOR ADDRESS CALL DOHORI ; MAKE THE HORIZONTAL LINE ; Position to the prompt line and setup the prompt character. MOV #2,R1 ; NOW GO TO LINE 2 MOV #1,R2 ; COLUMN 1 CALL MAKCUR ; MAKE THE CURSOR ADDRESS MOVCHR <%> ; THIS IS THE PROMPT ; Calculate and save the length of the screen message. MOV BUFPTR,R0 ; UPDATED SCREEN BUFFER ADDRESS SUB #SCRBUF,R0 ; CALCULATE THE BYTE COUNT MOV R0,SCRCNT ; AND STORE IT RETURN .SBTTL WRITTO - WRITE THE PHONED TERMINAL MESSAGE ;+ ; ; WRITTO - Write the phoned terminal message. ; ; Inputs: ; None ; ; Outputs: ; All registers are preserved. ; ;- WRITTO::JSR R2,$SAVVR ; SAVE R0 - R2 MOV BUFPTR,-(SP) ; SAVE THE BUFFER POINTER MOV #MSGBUF,BUFPTR ; OUTPUT MESSAGE BUFFER MOV #15.,R1 ; NOW TO LINE 15 MOV #38.,R2 ; COLUMN 38 CALL MAKCUR ; MAKE THE CURSOR ADDRESS CALL BOLD ; SET UP THE BOLD ATTRIBUTE MOV BUFPTR,R0 ; COPY THE BUFFER ADDRESS MOV #TOLUN,LUN ; TERMINAL NAME FROM TOLUN CALL GETTTY ; GET THE BINARY UNIT NUMBER CALL MAKTTY ; MAKE THE TERMINAL NAME MOV R0,BUFPTR ; SAVE NEW BUFFER ADDRESS CALL ATTOFF ; TURN OFF THE ATTRIBUTES CALL WRTMSG ; NOW WRITE THE MESSAGE MOV (SP)+,BUFPTR ; RESTORE BUFFER POINTER RETURN .SBTTL MAKCUR - MAKE THE CURSOR ADDRESS ;+ ; ; MAKCUR - Make the cursor address. ; ; Inputs: ; R1 = the line number. ; R2 = the column number. ; ; Outputs: ; All registers are preserved. ; ;- MAKCUR::JSR R2,$SAVVR ; SAVE R0 - R2 CALL MAKLIN ; MAKE THE LINE NUMBER MOV R2,R1 ; COPY THE COLUMN # CALL MAKCOL ; NOW MAKE THE COLUMN # RETURN .SBTTL MAKCOL - MAKE THE ASCII COLUMN NUMBER ;+ ; ; MAKCOL - Makes the ASCII column number for VT100 escape sequence. ; ; Inputs: ; R1 = the column number. ; BUFPTR = the output buffer address. ; ; Outputs: ; BUFPTR = updated output buffer address. ; ; All registers are preserved. ; ;- MAKCOL::JSR R2,$SAVVR ; SAVE REGISTERS R0 - R2 CALL MAKNUM ; MAKE THE ASCII LINE # MOVCHR ; END OF CURSER ADDRESSING RETURN .SBTTL MAKE THE ASCII LINE NUMBER ;+ ; ; MAKLIN - Makes the ASCII line number for VT100 escape sequence. ; ; Inputs: ; BUFPTR = pointer to the output buffer. ; R1 = the binary line number. ; ; Outputs: ; BUFPTR = updated buffer pointer. ; ; All registers are preserved. ; ;- MAKLIN::JSR R2,$SAVVR ; SAVE R0 - R2 MOVCHR ; MOVE IN THE MOVCHR <[> ; ESCAPE SEQUENCE CALL MAKNUM ; MAKE AN ASCII LINE # MOVCHR <;> ; PREPARE FOR COLUMN # RETURN .SBTTL MAKNUM - MAKE AN ASCII DECIMAL NUMBER ;+ ; ; MAKNUM - Make an ASCII decimal number. ; ; Inputs: ; BUFPTR = pointer to the output buffer. ; R1 = the binary number. ; ; Outputs: ; BUFPTR = updated buffer pointer. ; ; All registers are preserved. ; ;- MAKNUM::JSR R2,$SAVVR ; SAVE REGISTERS R0 - R2 MOV BUFPTR,R0 ; COPY THE BUFFER POINTER CLR R2 ; SET FOR ZERO SUPPRESSION CALL $CBDMG ; CONVERT TO DECIMAL ASCII MOV R0,BUFPTR ; SAVE THE NEW BUFFER ADDRESS RETURN .SBTTL GETTTY - GET THE TERMINAL UNIT NUMBER ;+ ; ; GETTTY - Get the terminal unit number. ; ; Inputs: ; LUN = the lun for the tty to get information on. ; ; Outputs: ; R1 = the binary unit number. ; ;- GETTTY::GLUN$S LUN,#LUNBUF ; GET LUN INFORMATION MOVB LUNBUF+G.LUNU,R1 ; COPY BINARY UNIT NUMBER RETURN .SBTTL MAKTTY - Make the TTY information ;+ ; ; MAKTTY - Make the TTY information ; ; Inputs: ; R0 = the output buffer address. ; R1 = the binary unit number. ; ; Outputs: ; R0 = points to first byte following "TTnn:" ; ; All other registers are preserved. ; ;- MAKTTY::MOVB #'T,(R0)+ ; MOVE IN MOVB #'T,(R0)+ ; THE "TT" CALL CVTNUM ; CONVERT BINARY TO ASCII MOVB #':,(R0)+ ; LAST PART OF NAME MOVB #SPACE,(R0) ; OVERWRITE WITH A SPACE RETURN .SBTTL CVTNUM - CONVERT BINARY TO OCTAL ASCII ;+ ; ; CVTNUM - Convert binary to octal ASCII. ; ; This routine is used to convert the binary unit number for the terminal ; to octal ASCII. A three digit unit number is converted to a letter and ; a unit number (i.e., 100 = A0). This code is the same as that used by ; DCL so I presume this is the convention used on RSX-11M+. ; ; Inputs: ; R0 = the output buffer address. ; R1 = the binary number to convert. ; ; Outputs: ; R0 = the updated output buffer address. ; R1 is destroyed, R2 is preserved. ; ;- CVTNUM::MOV R2,-(SP) ; SAVE R2 CMP R1,#77 ; DO WE HAVE THREE DIGITS ? BLOS 10$ ; IF LOS, NO (1 OR 2) MOV R1,R2 ; COPY THE UNIT NUMBER ASH #-3,R2 ; DROP OFF RIGHTMOST DIGIT ADD #101-10,R2 ; CONVERT TO AN ASCII LETTER MOVB R2,(R0)+ ; COPY TO THE OUTPUT BUFFER BIC #^C7,R1 ; ISOLATE THE RIGHTMOST DIGIT ADD #60,R1 ; MAKE IT OCTAL ASCII MOVB R1,(R0)+ ; STORE IN OUTPUT BUFFER BR 20$ ; AND CONTINUE ... 10$: CLR R2 ; SET FOR ZERO SUPPRESSION CALL $CBOMG ; CONVERT TO OCTAL ASCII 20$: MOV (SP)+,R2 ; RESTORE R2 RETURN .SBTTL MAKTSK - MAKE THE SECOND PART TASK NAME ;+ ; ; MAKTSK - Make the second part of the task name. ; ; Inputs: ; R3 = the table entry address. ; ; Outputs: ; O.TASK(R3) = the Radix-50 tak name of the form PHOTnn. ; ; All registers are preserved. ; ;- MAKTSK::JSR R2,$SAVVR ; SAVE R0 - R2 MOV O.TNUM(R3),R1 ; COPY THE BINARY UNIT NUMBER MOV #ASCNAM,R0 ; STORE THE ASCII HERE MOVB #'T,(R0)+ ; START WITH ASCII 'T' CALL CVTNUM ; CONVERT BINARY TO ASCII CLRB (R0) ; TERMINATE WITH A NULL MOV #ASCNAM,R0 ; NOW CONVERT TO RADIX-50 MOV #1,R1 ; DON'T ALLOW BLANKS IN CONVERSION CALL $CAT5 ; CONVERT TO RADIX-50 MOV #^RPHO,O.TASK(R3) ; FILL IN FIRST PART OF TASK NAME MOV R1,O.TASK+2(R3) ; STORE SECOND PART OF TASK NAME 10$: RETURN .SBTTL CLRBOT - CLEAR BOTTOM OF SCREEN ;+ ; ; CLRBOT - Clear bottom of screen. ; ; This routine is used to clear the bottom of the screen when either ; we hangup or we've been hung up by the other phoner. ; ;- CLRBOT::CALL SAVEC ; SAVE CURSOR (IF PROMPTING) QIOW$S #IO.WAL,#OULUN,#OUEFN,,,,<#CBOTM,#CBOTL,#0> CALL RESTC ; RESTORE CURSOR RETURN .SBTTL CLRMSG - CLEAR THE MESSAGE LINE ;+ ; ; CLRMSG - Clear the message line. ; ; This routine is called before writing to the message line. It calls ; the routine to save the cursor if we are prompting, but does not call ; the routine to restore the cursor because a message will be written ; next. The OUTMSG routine will restore the cursor after writing the ; message. The saving and restoring of the cursor is performed when ; prompting to leave the cursor on the prompt line. This is neccessary ; since messages are arriving asynchronously through the receive data ; AST routine from the other phoner. ; ; Inputs: ; None. ; ; Outputs: ; All registers are preserved. ; ;- CLRMSG::CALL SAVEC ; SAVE CURSOR (IF PROMPTING) QIOW$S #IO.WAL,#OULUN,#OUEFN,,,,<#CMSGM,#CMSGL,#0> BIC #B.MSG,STATUS ; SHOW NO MESSAGE ON SCREEN RETURN ; Save the cursor attributes if prompting. SAVEC:: BIT #B.RPR,STATUS ; ARE WE READING A COMMAND ? BEQ 10$ ; IF EQ, NO QIOW$S #IO.WAL,#OULUN,#OUEFN,,,,<#CMSGS,#CMSGSL,#0> 10$: RETURN ; Restore the cursor attributes if prompting. RESTC:: BIT #B.RPR,STATUS ; ARE WE READING A COMMAND ? BEQ 10$ ; IF EQ, NO QIOW$S #IO.WAL,#OULUN,#OUEFN,,,,<#CMSGR,#CMSGRL,#0> 10$: RETURN .SBTTL OUTMSG - OUTPUT A MESSAGE TO THE TERMINAL ;+ ; ; OUTMSG - Output a message to the local terminal. ; ; This routine outputs a message to the terminal. ; ; *** Called by error routines so don't check for errors. *** ; ; Inputs: ; R1 = the message address. ; R2 = the message byte count. ; ; Outputs: ; C bit clear/set = directive success/failure. ; ; All registers are preserved. ; ;- OUTMSG::JSR R2,$SAVVR ; SAVE REGISTERS R0 - R2 CLR R0 ; PRESUME NO VERTICAL FORMAT BIT #B.STRT,STATUS ; ARE WE IN THE STARTUP CODE ? BEQ 10$ ; IF EQ, NO (CONTINUE ...) MOV #40,R0 ; YES, SET UP FOR SINGLE SPACING BR 20$ ; AND CONTINUE ... 10$: CALL CLRMSG ; CLEAR THE MESSAGE LINE ; POSITIONS THE CURSOR ALSO ; Output a message to the terminal with no carriage control. 20$: QIOW$S #IO.WAL,#OULUN,#OUEFN,,,, BIT #B.STRT,STATUS ; ARE WE IN STARTUP CODE ? BNE 30$ ; IF NE, YES (DON'T RESTORE) CALL RESTC ; RESTORE CURSOR ATTRIBUTES 30$: BIS #B.MSG,STATUS ; SHOW MESSAGE ON SCREEN RETURN .END