.title scrft Screen package for foreign terminals .ident 'V03-000' .sbttl copyright notice ; ;**************************************************************************** ;* * ;* COPYRIGHT (c) 1978, 1979, 1980 * ;* BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. * ;* * ;* THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED * ;* ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE * ;* INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR ANY OTHER * ;* COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY * ;* OTHER PERSON. NO TITLE TO AND OWNERSHIP OF THE SOFTWARE IS HEREBY * ;* TRANSFERRED. * ;* * ;* THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE * ;* AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT * ;* CORPORATION. * ;* * ;* DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS * ;* SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL. * ;* * ;**************************************************************************** ; .page .sbttl Program description ; ; Facility ; ; Screen Package for foreign terminal functions ; ; Environment ; ; Native mode, User mode, Shared library routines ; ; When this program is linked, the image should be copied to ; SYS$LIBRARY:SCRFT.EXE and, if desired, installed to improve ; the image activation speed. The screen package will automatically ; "merge" this image into the calling image's address space when ; needed. To debug it, simply link it /DEBUG and define a logical name ; SCRFT to be the file spec of the test image. NOTE: The debugger ; performs a $EXIT system service upon exit, therefore you will only ; be able to debug the first invocation of SCRFT. ; ; Author ; ; Tim Halvorsen, February 1980 ; ; Modified by ; R. Garland Columbia University Chemistry Dept. ; July 1982 - V3.0 ; /FT2 Hazeltine 1500 ; /FT3 Datamedia 1521 ; ;-- .sbttl Symbol Definitions ; ; Symbol Defintions ; $scrdef ; Screen package definitions nul = ^x00 ; Null Rg bs = ^x08 ; Backspace lf = ^x0a ; Line feed cr = ^x0d ; Carriage return esc = ^x1b ; Escape character cb = ^x1f ; Line/column bias in message lb = ^a'[' ; Left bracket (vt100) semi = ^x3b ; Semi-colon (vt100) tilde = ^a'~' ; Tilde (Hazeltine lead-in) Rg VT100_SC = ^A'f' ; VT100 set cursor position VT100_DWN = ^A'M' ; VT100 down scroll VT100_EOS = ^A'J' ; VT100 erase to end of screen VT100_EOL = ^A'K' ; VT100 erase to end of line HAZELTINE_SC = ^X11 ; Hazeltine set cursor position Rg HAZELTINE_DWN = ^X1A ; Hazeltine set to home and erase screen Rg HAZELTINE_EOS = ^X18 ; Hazeltine erase to end of screen Rg HAZELTINE_EOL = ^X0F ; Hazeltine erase to end of line Rg DATAMEDIA_SC = ^X1E ; Datamedia set cursor position Rg DATAMEDIA_EOS = ^X0B ; Datamedia erase to end of screen Rg DATAMEDIA_EOL = ^X1D ; Datemedia erase to end of line Rg ; ; Macro definitions ; .macro string text,?l1,?l2 .save .psect _scr$strings,exe,nowrt,pic l1: .ascii text l2: .restore .long l2-l1 .long l1-<.-4> ; self-relative address .endm string .macro case,src,displist,type=w,limit=#0,nmode=s^#,?base,?max case'type src,limit,nmode'</2>-1 base: .irp ep, .word ep-base .endr max: .endm .psect _scr$code,exe,nowrt,pic .sbttl DISPATCHER Dispatch to proper request routine ;--- ; ; This is the main entry point of the image. Dispatch ; to the proper screen package routine for the foreign ; terminal. ; ; Inputs: ; ; 28(ap) = Address of argument list: ; 00) Number of longword arguments ; 04) Address of SCR argument list ; 08) Screen package request # ; 12) Foreign terminal # ; 16) Address of retbuf descriptor ; 20) Address of retlen word ; ; Outputs: ; ; Dispatch to routine with: ; ; ap = Address of SCR argument list ; r1 = Foreign terminal number (biased at zero; ft1=0) ; r11 = Address of above argument list ; ;--- dispatcher: .word ^m movl 28(ap),r11 ; r11 = address of SCRFT args callg @4(r11),b^10$ ; call with SCR argument list ret 10$: .word 0 subl3 #1,12(r11),r1 ; r1 = Foreign terminal number - 1 cmpl r1,#3 ; FT1=VT100, FT2=Hazeltine, FT3=Datamedia Rg bgequ 20$ ; ignore others case 8(r11),type=w,<- ; Case on request type put_screen,- ; PUT_SCREEN get_screen,- ; GET_SCREEN erase_page,- ; ERASE_PAGE erase_line,- ; ERASE_LINE set_cursor,- ; SET_CURSOR down_scroll,- ; DOWN_SCROLL 20$,- ; SCREEN_INFO - always handled by SCR ; put_line,- ; PUT_LINE ; move_cursor,- ; MOVE_CURSOR ; set_scroll,- ; SET_SCROLL ; up_scroll - ; UP_SCROLL > 20$: movl #1,r0 ret .sbttl POS_OUTPUT Insert line,col in output message ;--- ; ; This routine is used to insert a screen position ; into a string before writing the message to the ; terminal. ; ; Calling sequence: ; ; Branch from CALLed routine ; ; Inputs: ; ; R1 = Address of control string descriptor (address is self-relative) ; 4(ap) = Line number ; 8(ap) = Column number ; r11 = SCRFT arguments ; ; 1 optional argument to the fao string may be placed ; on the top of the stack on entry to this routine. ; ;--- hextoasc: .ascic '!UL;!UL' ; Convert to VT100 sequences pos_output: movl (sp),r0 ; Save optional argument case 12(r11),type=b,limit=#1,<- ; Case on terminal type 20$,- ; vt100 requires ; in middle 30$,- ; Hazeltine uses 0 - 79 Rg 40$> ; Datamedia uses 32 - 111 Rg 20$: subl #16,sp ; Allocate FAO output buffer pushr #^m ; Save registers pushab 9(sp) ; Create descriptor of buffer pushl #15 movab hextoasc,r1 ; Address of FAO control string movzbl (r1)+,r0 movq r0,-(sp) ; Push descriptor of string onto stack movl sp,r0 ; Address of stack arguments pushl 8(ap) ; Column number pushl 4(ap) ; Line number $fao_s (r0),8(r0),8(r0) ; Convert to ASCII characters movb 16(sp),32(sp) ; Copy length into ASCIC string addl #24,sp ; Leave buffer on top of stack popr #^m ; Restore registers brb 50$ 30$: subb3 #1,8(ap),(sp) ; Line number subb3 #1,4(ap),1(sp) ; Column number movb #2,-(sp) ; Length of string brb 50$ ; Rg 40$: addb3 #31,8(ap),(sp) ; Line number Rg addb3 #31,4(ap),1(sp) ; Column number Rg movb #2,-(sp) ; Length of string Rg 50$: subl #2048,sp ; Allocate FAO buffer pushl sp ; Create descriptor for buffer pushl #2048 movq (r1),-(sp) ; Move descriptor of string on stack addl r1,4(sp) ; Relocate self-relative address pushl r0 ; Optional extra argument movab 4(sp),r0 pushab 4+16+2048(sp) ; Address of counted string $fao_s (r0),8(r0),8(r0) ; Insert into output string addl #16,sp ; Pop everything but fao buffer movl sp,r1 ; Address of descriptor subl sp,4(r1) ; Make into self-relative address brb output .sbttl OUTPUT Write string to terminal ;--- ; ; OUTPUT ; ; This routine writes the specified string to the ; terminal without carriage control. ; ; Calling sequence: ; ; Branch from CALLed routine ; ; Inputs: ; ; r1 = Address of string descriptor (the address is self-relative) ; ;--- output: movq @16(r11),r2 ; Get descriptor of output buffer cmpw (r1),r2 ; Check if enough room in buffer bgtru 80$ ; branch if buffer overflow movw (r1),@20(r11) ; Store length of output string movc (r1),@4(r1)[r1],(r3) ; store in output buffer incl r0 ; success brb 90$ 80$: movl #ss$_bufferovf,r0 ; set error 90$: ret .sbttl ERASE_PAGE Erase to end of screen ;--- ; ; ERASE_PAGE ; ; This routine causes the screen to be erased ; from the specified position to the end of the ; screen. If the position is not specified, the ; current screen position is assumed. ; ; Inputs: ; ; (AP) = Number of arguments ; 4(AP) = Line number (optional) ; 8(AP) = Column number (optional) ; ; If no arguments are specified, the current cursor ; position is assumed. ; ;--- erase_page: tstb (ap) ; Any arguments specified? bneq 10$ ; Branch if so movaq b^erase_table[r1],r1 ; Address of output string brw output 10$: movaq b^erase_table2[r1],r1 ; Output string with 2 args brw pos_output erase_table: ; ERASE TO END OF SCREEN string <> ; VT100 string <> ; Hazeltine Rg string <> ; Datamedia Rg erase_table2: ; ERASE FROM POSITION STRING <"!AC"- ; vt100 > string <"!AC"- ; Hazeltine Rg > ; Rg string <"!AC"- ; Datamedia Rg > ; Rg .sbttl ERASE_LINE Erase to end of line ;--- ; ; ERASE_LINE ; ; This routine causes the screen to be erased ; from the specified position to the end of the ; line. If the position is not specified, the ; current screen position is assumed. ; ; Inputs: ; ; (AP) = Number of arguments ; 4(AP) = Line number (optional) ; 8(AP) = Column number (optional) ; ; If no arguments are specified, the current cursor ; position is assumed. ; ;--- erase_line: tstb (ap) ; Any arguments specified? bneq 10$ ; Branch if so movaq b^line_table[r1],r1 ; Address of output string brw output 10$: movaq b^line_table2[r1],r1 ; Output string with 2 args brw pos_output line_table: ; ERASE TO END OF LINE string <> ; vt100 string <> ; Hazeltine Rg string <> ; Datamedia Rg line_table2: ; ERASE FROM POSITION string <"!AC"- ; vt100 > string <"!AC"- ; Hazeltine Rg > ; Rg string <"!AC"- ; Datamedia Rg > ; Rg .sbttl SET_CURSOR Set cursor position ;--- ; ; SET_CURSOR ; ; This routine causes the cursor to be moved to ; to the specified position. ; ; Inputs: ; ; 4(AP) = Line number ; 8(AP) = Column number ; ;--- set_cursor: movaq b^cursor_table[r1],r1 ; Output string with 2 args brw pos_output cursor_table: ; SET CURSOR string <"!AC"> ; vt100 string <"!AC"> ; Hazeltine Rg string <"!AC"> ; Datamedia Rg .sbttl DOWN_SCROLL Move cursor up, scrolling downward ;--- ; ; DOWN_SCROLL ; ; This routine causes the cursor to be moved up ; 1 line to same column of the previous line. ; If the cursor was on the top line to begin with, ; it stays where it was, but all the information ; on the screen appears to move down one line. ; The information that was on the bottom line of ; the screen is lost and a blank line appears at ; the top. ; ; Inputs: ; ; None ; ;--- down_scroll: movaq b^scroll_table[r1],r1 ; Output string with 2 args brw output scroll_table: ; DOWN SCROLL string <> ; VT100 string <- ; Hazeltine Rg > ; Rg string <""> ; Datamedia - nothing Rg .sbttl PUT_SCREEN Write message to terminal ;--- ; ; PUT_SCREEN ; ; This routine is used to write messages to the ; terminal. ; ; Inputs: ; ; 4(AP) = Address of descriptor of output string ; 8(AP) = (OPTIONAL) Line number ; 12(AP) = (OPTIONAL) Column number ; 16(AP) = (OPTIONAL) Text attributes ; ;--- put_screen: cmpl (ap),#1 ; Check if only one argument bgtr 10$ ; Branch if coords given movl 4(ap),r1 ; Address of descriptor movq (r1),-(sp) ; Copy descriptor to stack subl sp,4(sp) ; and make self-relative movl sp,r1 ; Address of self-relative desc. brw output 10$: pushl 4(ap) ; Optional fao argument addl #4,ap ; Pass coords in 4(ap),8(ap) movaq b^put_table[r1],r1 ; Address of fao string brw pos_output PUT_TABLE: ; Write with embedded cursor string <"!AC""!AS"> ; vt100 string <"!AC!AS"> ; Hazeltine Rg string <"!AC!AS"> ; Datamedia Rg .sbttl GET_SCREEN Read input string from terminal ;--- ; ; GET_SCREEN ; ; This routine accepts input from the terminal into ; a user specified buffer. An optional prompt string ; may be given. ; ; Inputs: ; ; 4(AP) = Address of buffer descriptor ; 8(AP) = Address of prompt descriptor (optional) ; ;--- get_screen: callg (ap),g^lib$get_input ; Read terminal input ret .end dispatcher