.TITLE ACTION - TPARS ACTION ROUTINES .IDENT /03.10/ .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: ACTION.MAC ; Author: Robin Miller ; Date: June 17, 1982 ; ; Description: ; ; Table parse action routines for VTM program. ; ; ; Modification History: ; ;- .ENABL AMA .NLIST BEX .MCALL ALUN$S, DIR$, GTIM$ ; Local equates: BELL = 7 ; ASCII FOR BELL ESC = 27. ; ASCII FOR ESCAPE SPACE = 32. ; ASCII FOR SPACE ; Local storage: GTIM: GTIM$ TIMBUF ; GET THE TIME TIMBUF: .BLKW 8. ; AND SOTRE IT HERE ; Macro to generate a VT100 escape sequence. .MACRO VTMSG LABEL,MSG .PSECT $VTMSG,RO,D,REL,CON LABEL: .ASCIZ "MSG" .PSECT MOV #LABEL,R0 CALL MOVEC .ENDM ; Macro to write a VT100 escape sequence immediatly. .MACRO VTWRT LABEL,MSG .PSECT $VTMSG,RO,D,REL,CON .NCHR $$$,^/MSG/ LABEL: .ASCII "MSG" .PSECT MOV #LABEL,R1 MOV #<$$$+1>,R2 CALL WRITIT .ENDM .MACRO MOVCHR CHAR .NCHR $$$,^/CHAR/ .IF EQ $$$-1 MOVB #''CHAR,@BUFPTR .IFF MOVB #CHAR,@BUFPTR .ENDC INC BUFPTR .ENDM ; Action routines for TPARS. ; Registers R0, R1, and R2 may be used by the action routines. ; All other registers must be preserved. ;********************************************************************** ; Put VT100 in ANSI mode. ANSI:: VTWRT ANSIM,^/ ; SET VT52 MODE RETURN ;********************************************************************** ; Application keypad mode. APPKEY::VTMSG APPKM,<=> ; APPLICATION KEYPAD MODE RETURN ; Numeric (normal) keypad mode. NUMKEY::VTMSG NUMKM,^/>/ ; NUMERIC KEYPAD MODE RETURN ;********************************************************************** ; Turn all attributes off. ATTOFF::BIC #B.ATTR,STATUS ; SHOW ATTRIBUTES ARE OFF VTMSG NOATTR,<[0m> ; TURN OFF ALL ATTRIBUTES RETURN ; Turn on all attributes except for underscore. ALLATT:: VTMSG ALLMSG,<[1;5;7m> ; BOLD / BLINK / REVERSE RETURN ; Turn on blink attribute. BLINK:: VTMSG BLINKM,<[5m> ; TURN BLINK ATTRIBUTE ON 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 ; Turn on underscore attribute. UNDER:: VTMSG UNDERM,<[4m> ; TURN UNDERSCORE ON RETURN ;********************************************************************** ; Move in a bell. MBELL:: MOVCHR ; MOVE A BELL TO THE BUFFER RETURN ;********************************************************************** ; Set black (normal) screen. BLACK:: VTMSG BLACKM,<[?5l> ; SET BLACK (NORMAL) SCREEN RETURN ; Set a white (reverse) screen. WHITE:: VTMSG WHITEM,<[?5h> ; SET WHITE (REVERSE) SCREEN 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 beginning of line. CBOL:: VTMSG CBOLM,<[1K> ; ERASE TO BEGINNING OF LINE BR CRET ; Clear the entire line. CLIN:: VTMSG CLINM,<[2K> ; ERASE LINE INCLUSIVE BR CRET ; Clear to end of the screen. CEOS:: VTMSG CEOSM,<[0J> ; ERASE TO END OF SCREEN BR CRET ; Clear to the beginning of the screen. CBOS:: VTMSG CBOSM,<[1J> ; ERASE TO BEGINNING OF SCREEN BR CRET ; Clear the entire screen, cursor does not move. CSCR:: VTMSG CSCRM,<[2J> ; ERASE THE ENTIRE SCREEN BR CRET ; Common return for clear screen. CRET: BIC #B.CLR,STATUS ; SHOW SCREEN CLEARED RETURN ;********************************************************************** ; Cursor movement commands. CUP:: VTMSG CUPM,<[A> ; CURSOR UP RETURN CDOWN:: VTMSG CDOWNC,<[B> ; CURSOR DOWN RETURN CRIGHT::VTMSG CRIGHM,<[C> ; CURSOR RIGHT RETURN CLEFT:: VTMSG CLEFTM,<[D> ; CURSOR LEFT RETURN ;********************************************************************** ; Double height top and bottom halfs. DHTOP:: VTMSG DHTOPM,<#3> ; DOUBLE HEIGHT TOP HALF RETURN DHBOT:: VTMSG DHBOTM,<#4> ; DOUBLE HEIGHT BOTTOM HALF RETURN ; Double width single height line. DWIDTH::VTMSG DWMSG,<#6> ; DOUBLE WIDTH SINGLE HEIGHT RETURN ; Set for single width single height line. SWIDTH::BIC #B.DBLH!B.DBLW,STATUS ; SHOW DOUBLE WIDTH OFF VTMSG SWMSG,<#5> ; SINGLE WIDTH SINGLE HEIGHT RETURN ;********************************************************************** ; Tell TPARS to ignore blanks during parse. ; This is used to ignore blanks in the options. IBLANK::CLRB .PFLAG ; IGNORE BLANKS MOV R4,BEOPT ; SAVE POINTER TO OPTION RETURN ; Action routine to tell TPARS to pass blanks. ; This is used to pass blanks in the message. PBLANK::MOVB #1,.PFLAG ; PASS BLANKS RETURN ;********************************************************************** ; Change character sets. SGRAPH::VTMSG SGRAPM,<(0> ; SPECIAL GRAPHICS RETURN UKSET:: VTMSG UKSETM,<(A> ; UNITED KINGDOM SET RETURN USSET:: VTMSG USSETM,<(B> ; USASCII CHARACTER SET RETURN ACSET:: VTMSG ACSETM,<(1> ; ALTERNATE CHARACTER SET RETURN AGSET:: VTMSG AGSETM,<(2> ; ALTERNATE GRAPHICS SET RETURN ;********************************************************************** ; Home position on screen. HOME:: MOV #1,LINE ; SET FOR LINE 1 MOV #1,COLUMN ; COLUMN 1 RETURN ;********************************************************************** ; Forward index. INDEX:: VTMSG INDEXM, ; FORWARD INDEX ; Reverse index. RINDEX::VTMSG RINDXM, ; REVERSE INDEX RETURN ;********************************************************************** ; Set jump scroll mode. JUMP:: VTMSG JUMPM,<[?4l> ; JUMP SCROLL MODE RETURN ; Set smooth scrol mode. SMOOTH::VTMSG SMOTHM,<[?4h> ; SMOOTH SCROLL MODE RETURN ;********************************************************************** ; Turn on/off LEDS on the keyboard. LEDS:: VTMSG LEDSM,<[1;2;3;4q> ; ALL LEDS ON RETURN LED1:: VTMSG LED1M,<[1q> ; LED #1 ON RETURN LED2:: VTMSG LED2M,<[2q> ; LED #2 ON RETURN LED3:: VTMSG LED3M,<[3q> ; LED #3 ON RETURN LED4:: VTMSG LED4M,<[4q> ; LED #4 ON RETURN LED0:: VTMSG LED0M,<[0q> ; TURN OFF ALL LEDS RETURN ;********************************************************************** ; Set screen to 80 column mode. NARROW::BIC #B.CLR!B.WIDE,STATUS ; SET APPROPRIATE STATUS MOV #80.,RMARGN ; SET RIGHT MARGIN TO 80. VTWRT NARSCR,<[?3l> ; SET 80 COLUMN MODE RETURN ; Set the screen to 132 column mode. WIDE:: BIC #B.CLR,STATUS ; SCREEN WILL BE CLEARED MOV #132.,RMARGN ; SET RIGHT MARGIN TO 132. VTWRT WIDSCR,<[?3h> ; SET 132 COLUMN MODE RETURN ;********************************************************************** ; Disable the clear screen option. NOCLR:: BIC #B.CLR,STATUS ; DON'T CLEAR THE SCREEN RETURN ; Disable centering of the message. NOCENT::BIC #B.CENT,STATUS ; DON'T CENTER THE MESSAGE RETURN ; Disable double height double width message. NODH:: BIC #B.DBLH,STATUS ; DISABLE DOUBLE HEIGHT RETURN ; Disable single height double width message. NODW:: BIC #B.DBLW,STATUS ; DISABLE DOUBLE WIDTH RETURN ; Disable the scrolling region. NOREG:: VTMSG NOREGM,<[r> ; DISABLE SCROLL REGION RETURN ; Enable output to local terminal. TTYON:: INC TENTRY ; ENABLE LOCAL TERMINAL RETURN ; Disable output to local terminal. NOTTY:: CLR TENTRY ; DISABLE OUTPUT TO TERMINAL RETURN ;********************************************************************** ; Open the specified output file. OFILE:: CLRB @FILPTR ; TERMINATE THE FILE NAME MOV #OUTFDB,R0 ; ADDRESS OF THE OUTPUT FDB MOV #FILNAM,R1 ; ADDRESS OF THE FILE NAME CALL OPENW ; OPEN THE FILE FOR WRITE BCC 10$ ; IF CC, SUCCESS MOV F.ERR(R0),R0 ; COPY THE ERROR CODE CALL WRTERR ; AND WRITE THE ERROR JMP FAIL ; RETURN FAILURE 10$: BIS #B.FILE,STATUS ; SHOW OUTPUT TO FILE INC FENTRY ; ENABLE OUTPUT TO FILE RETURN ; Save character for output file name. SFILE:: BIT #B.FILE,STATUS ; OUTPUT FILE ALREADY OPEN ? BEQ 10$ ; IF EQ, NO MOV BUFPTR,-(SP) ; SAVE CURRENT BUFFER POINTER CALL MAKPRL ; MAKE THE PROMPT LINE CALL SETBUF ; SET BUFFER AND BYTE COUNT CALL WRTFIL ; WRITE IT TO THE FILE CALL CLOFIL ; NOW CLOSE IT MOV (SP)+,BUFPTR ; RESTORE THE BUFFER POINTER 10$: MOVB .PCHAR,@FILPTR ; SAVE CHARACTER FOR FILE NAME INC FILPTR ; POINT TO NEXT LOCATION RETURN ;********************************************************************** ; Get the scroll region. REGT:: MOV .PNUMB,R0 ; COPY THE LINE NUMBER CMPB R0,#24. ; IS IT A VALID LINE BLT 10$ ; IF LT, YES JMP FAIL ; NOPE, RETURN FAILURE 10$: MOV R0,REGTOP ; SAVE THE TOP LINE # RETURN REGB:: MOV .PNUMB,R0 ; COPY THE LINE NUMBER CMPB R0,REGTOP ; LARGER THAN TOP LINE ? BLE 10$ ; IF LE, NO (TOO SMALL) CMPB R0,#24. ; IS IT A VALID LINE ? BGT 10$ ; IF GT, NO (TOO BIG) MOV R0,REGBOT ; SAVE THE BOTTOM LINE # MOV REGTOP,R1 ; COPY THE TOP LINE # CALL MAKLIN ; MAKLIN DOES "$[n;" MOV REGBOT,R1 ; COPY THE BOTTOM LINE # CALL MAKNUM ; MAKE THE ASCII LINE # MOVCHR ; LAST PART OF SCROLL REGION RETURN 10$: JMP FAIL ; RETURN FAILURE ;********************************************************************** ; Save delay count and do the delay. SDELAY::MOV .PNUMB,R0 ; COPY THE DELAY COUNT MOV R0,DELAYT ; SAVE THE DELAY TIME CALL DELAY ; NOW DO THE DELAY RETURN ;********************************************************************** ; Do VT100 power-up reset. VRESET::BIC #B.CLR,STATUS ; SCREEN WILL BE CLEARED VTWRT RESETM, ; DO VT100 POWER-UP RESET MOV #2,R0 ; NOW DELAY 2 SECONDS CALL DELAY ; AND GO DO IT RETURN ; Do confidence test, fill screen with "Es". TEST:: BIC #B.CLR,STATUS ; DON'T CLEAR THE SCREEN VTWRT TESTM,<#8> ; TEST, FILL SCREEN WITH "Es". RETURN ;********************************************************************** ; Save cursor position and attributes. SAVEC:: VTMSG SAVECM,<7> ; SAVE CURSOR AND ATTRIBUTES RETURN RESTC:: VTMSG RESTCM,<8> ; RESTORE CURSER AND ATTRIBUTES RETURN ;********************************************************************** ; Save character to be written in the message. SCHAR:: INC COUNT ; COUNT THIS BYTE MOVB .PCHAR,@BUFPTR ; MOVE IT TO THE BUFFER INC BUFPTR ; POINT TO THE NEXT LOCATION JMP PBLANK ; AND SET TO PASS BLANKS ; Save the starting column number. SCOL:: MOV .PNUMB,R0 ; SAVE STARTING COLUMN # CMP R0,RMARGN ; IS THE COLUMN IN RANGE ? BGT FAIL ; IF GT, NO (ERROR) MOV R0,COLUMN ; SAVE STARTING COLUMN # RETURN ; Skip several lines. SKIP:: ADD .PNUMB,LINE ; ADD IN COUNT TO SKIP CALL CHKLIN ; CHECK RANGE OF LINE # RETURN ; Save the iteration count. SITER:: BIT #B.ICNT,STATUS ; ALREADY HAVE ITERATION COUNT ? BNE 10$ ; IF NE, YES (SAVE ONLY ONCE) BIS #B.ICNT,STATUS ; SHOW WE HAVE ITERATION COUNT MOV .PNUMB,ICOUNT ; SAVE THE ITERATION COUNT 10$: RETURN ; Save the starting line number. SLINE:: MOV .PNUMB,LINE ; SAVE THE STARTING LINE # CALL CHKLIN ; CHECK RANGE OF LINE # RETURN ; Save the number prompt line number. PLINE:: MOV .PNUMB,R0 ; COPY THE LINE NUMBER BIT #B.REL,STAT1 ; RELATIVE LINE NUMBER ? BEQ 10$ ; IF EQ, NO MOV R0,RELNUM ; SAVE THE RELATIVE COUNT BR 20$ ; USE COMMON RETURN 10$: CMP R0,#24. ; IS THE LINE WITHIN RANGE ? BHI FAIL ; IF HI, NO (RETURN FAILURE) MOV R0,PRLINE ; SAVE THE NEW LINE NUMBER 20$: RETURN ; Make a relative prompt line number. By the time this ; routine is called, the LINE number must be updated. MAKRPL::JSR R2,$SAVVR ; SAVE R0 - R2 MOV LINE,R1 ; COPY THE CURRENT LINE # MOV RELNUM,R0 ; COPY THE RELATIVE COUNT BEQ 20$ ; IF EQ, DON'T ADJUST BIT #B.DIR,STAT1 ; IS THE DIRECTION POSITIVE ? BEQ 20$ ; IF EQ, YES NEG R0 ; NOPE, MAKE IT NEGATIVE 20$: ADD R0,R1 ; ADJUST THE PROMPT LINE MOV R1,R0 ; COPY TO USE COMMON CODE BPL 30$ ; IF PL, POSSIBLE GOOD LINE MOV TPLINE,R0 ; IF MI, START AT TOP LINE 30$: CMP R0,#24. ; IS THE LINE WITHIN RANGE ? BLOS 40$ ; IF LOS, YES MOV BTLINE,R0 ; NO, SET TO THE BOTTOM LINE 40$: MOV R0,PRLINE ; SAVE THE NEW LINE NUMBER RETURN ; Set direction for relative line number. PPLIN:: BIC #B.DIR,STAT1 ; SET POSITIVE DIRECTION RETURN NPLIN:: BIS #B.DIR,STAT1 ; SET NEGATIVE DIRECTION RETURN ; Save the top line number. TLINE:: MOV .PNUMB,R0 ; COPY THE LINE NUMBER CMP R0,BTLINE ; SMALLER THAN BOTTOM LINE ? BGE FAIL ; IF GE, NO (ERROR) MOV R0,TPLINE ; YES, SAVE IT RETURN ; Save the bottom line number. BLINE:: MOV .PNUMB,R0 ; COPY THE LINE NUMBER CMP R0,TPLINE ; LARGER THAN TOP LINE ? BLE FAIL ; IF LE, NO (ERROR) CMP R0,#24. ; IS IT TOO LARGE ? BGT FAIL ; IF GT, YES (ERROR) MOV R0,BTLINE ; SAVE NEW BOTTOM LINE RETURN ; Bad line number encountered. FAIL: ADD #2,(SP) ; RETURN FAILURE ON RETURN ; BAD LINE NUMBER ;********************************************************************** ; Save the left margin. SLMARG::MOV .PNUMB,R0 ; COPY THE LEFT MARGIN CMP R0,#132. ; IS MARGIN IN RANGE ? BGE FAIL ; IF GE, NO MOV R0,LMARGN ; YES, SAVE IT RETURN ; Save the right margin. SRMARG::MOV .PNUMB,R0 ; COPY THE RIGHT MARGIN CMP R0,#132. ; IS MARGIN IN RANGE ? BGT FAIL ; IF GT, NO MOV R0,RMARGN ; YES, SAVE IT RETURN ;********************************************************************** ; Save the first character of the terminal name. STTY1:: CLR TTYNUM ; INITIALIZE UNIT NUMBER MOVB .PCHAR,TTYNAM ; SAVE THE FIRST CHARACTER RETURN ; Save the second character of the terminal name. STTY2:: MOVB .PCHAR,TTYNAM+1 ; SAVE THE SECOND CHARACTER RETURN ; Calculate controller for VAX/VMS. STTYC:: MOVB .PCHAR,R1 ; GET THE CONTROLLER LETTER BIC #^C37,R1 ; ISOLATE LOW ORDER BITS DEC R1 ; BIAS THE CONTROLLER # BEQ 10$ ; CONT. A (101) BECOMES 0 MUL #16.,R1 ; CALCULATE THE UNIT NUMBER MOV R1,TTYNUM ; STORE CONTROLLER # 10$: RETURN ; Save the terminal unit number. STTYN:: ADD .PNUMB,TTYNUM ; SAVE THE TTY UNIT NUMBER RETURN ; Assign LUN to output terminal. TTYA:: INC AENTRY ; ENABLE THIS ENTRY ALUN$S #TTYLUN,TTYNAM,TTYNUM ; ASSIGN LUN TO TERMINAL CALL CHKDIR ; CHECK/REPORT ERRORS BCC 10$ ; IF CC, SUCCESS CLR AENTRY ; DISABLE THIS ENTRY JMP FAIL ; AND RETURN FAILURE 10$: RETURN ;********************************************************************** ; Put the date in the output buffer. DATE:: DIR$ #GTIM ; GET THE TIME CALL CHKDIR ; CHECK/REPORT ERRORS BCC 10$ ; IF CC, SUCCESSFUL JMP FAIL ; ELSE, RETURN FAILURE 10$: MOV BUFPTR,R0 ; COPY THE BUFFER POINTER MOV #TIMBUF+G.TIYR,R1 ; POINT TO THE DATE CALL $DAT ; CONVERT THE DATE MOV R0,BUFPTR ; SAVE UPDATED BUFFER POINTER ADD #9.,COUNT ; AND COUNT FOR CENTERING RETURN ; Put the time in the output buffer. TIME:: DIR$ #GTIM ; GET THE TIME CALL CHKDIR ; CHECK/REPORT ERRORS BCC 10$ ; IF CC, SUCCESSFUL JMP FAIL ; ELSE, RETURN FAILURE 10$: MOV BUFPTR,R0 ; COPY THE BUFFER POINTER MOV #TIMBUF+G.TIHR,R1 ; ADDRESS OF BINARY TIME MOV #3,R2 ; FORMAT = HH:MM:SS CALL $TIM ; CONVERT THE TIME MOV R0,BUFPTR ; SAVE UPDATED BUFFER POINTER ADD #8.,COUNT ; AND COUNT FOR CENTERING 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 .END