;***************************************************************************; ; ; ; Visual 50 Terminal Driver ; ; (Hazeltine Esprit III Terminal Driver) ; ; ; ; By David F. Pallmann ; ; ; ;***************************************************************************; ;01-Jun-83 DFP created from TVI925.M68 as released by Alpha Micro ;22-Nov-83 DFP add null strings to screen-oriented functions SEARCH SYS SEARCH SYSSYM SEARCH TRM OBJNAM VISUAL.TDV LI=33 ; lead-in code TFEATS=TD$LID!TD$CID!TD$DIM!TD$EOS!TD$EOL!TD$BLN!TD$UND!TD$RVA!TD$MLT ;******************** ;* VISUAL * ;******************** ;Terminal driver communications area VISUAL: WORD TD$NEW ; terminal attributes BR JMPINP ; input routine RTN ; output routine BR ECHO ; echo routine BR JMPCRT ; crt control RTN ; no init routine yet WORD 0 ; no impure area yet BYTE 24. ; number of rows BYTE 80. ; number of columns LWORD TFEATS ; terminal has: ; insert/delete line ; insert/delete character ; dim video attribute ; erase to end of screen ; erase to end of line JMPINP: JMP INP ; go handle input characters JMPCRT: JMP CRT ; go handle tcrt codes ;******************** ;* ECHO * ;******************** ;Special echo processing is performed here ;Rubouts will backspace and erase the previous character ;Control-U will erase the entire line by backspacing and erasing ECHO: CMPB D1,#25 ; control-u BEQ CTRLU CMPB D1,#177 ; rubout BNE ECHX ;Rubouts are handled by the old backspace-and-erase game ;Special handling must be performed if we are rubbing out a tab ;D6 contains the character being rubbed out RUBOUT: CMPB D6,#11 ; was it a tab? BEQ RBTB ; yes ;Rubout was of a printable character - queue up the backspace sequence KRTG: MOV #3,D3 ; set character count LEA A6,ERUB ; set buffer address MOV A6,D1 ; into d1 TRMBFQ ; queue the backspace sequence RTN ERUB: BYTE 10,40,10,0 ;Rubout was of a tab - we must calculate how big the tab was and backup over it RBTB: CLR D3 ; preclear D3 MOVW T.POB(A5),D3 ; set beginning position count MOV T.ICC(A5),D2 ; set input character count MOV T.IBF(A5),A6 ; set input buffer base KRTS: DEC D2 ; done with scan? BMI KRTQ ; yes MOVB (A6)+,D1 ; scan forward calculating position CMPB D1,#11 ; tab BEQ KRTT CMPB D1,#15 ; cr BEQ KRTC CMPB D1,#33 ; altmode BEQ KRTI CMPB D1,#40 ; control-char BLO KRTS CMPB D1,#172 BHI KRTS KRTI: INC D3 ; increment position for one character BR KRTS KRTT: ADD #10,D3 ; adjust position for tab AND #^C7,D3 BR KRTS KRTC: CLR D3 ; clear position for cr BR KRTS KRTQ: COM D3 ; calculate necessary backspaces AND #7,D3 INC D3 MOV #10,D1 ; set immediate backspace character TRMBFQ ; queue the backspaces ECHX: RTN ;Echo a control-u by erasing the entire line CTRLU: TST D6 ; no action if nothing to erase BEQ CTUX CLR D3 ; preclear D3 MOVW T.POO(A5),D3 ; calculate backspace number to erase the line SUBW T.POB(A5),D3 BEQ ECHX CMP D3,T.ILS(A5) ; insure not greater than terminal width BLOS CLUA MOV T.ILS(A5),D3 CLUA: MOV #10,D1 ; queue up backspaces TRMBFQ ASL D1,#2 ; queue up spaces TRMBFQ MOV #10,D1 ; queue up backspaces TRMBFQ CTUX: RTN ;******************** ;* INP * ;******************** ;Input character processing subroutine ;Return a negative flag to indicate possible multi-byte key codes ;Detect a negative flag which indicates the multi-byte processing return INP: BMI INMLT ; skip if multi-byte processing CMPB D1,#1 ; function code? BEQ INPM ; yes - could be multi-byte sequence CMPB D1,#33 ; escape? BEQ INPM ; yes - could be multi-byte sequence LCC #0 ; no - normal processing RTN INPM: LCC #PS.N ; possible multi-byte - return N flag RTN ;Multi-byte processing is done here ;This occurs when TRMSER has accumulated all bytes of a multi-byte keystroke ;D0 contains the character count and A0 indexes the data string ;A5 indexes the terminal definition block and must be preserved ;The translated character must be returned in D1 for storage ;This routine may destroy only A0,A3,A6,D0,D6,D7 INMLT: MOVB (A0)+,D1 ; get the first character DECB D0 ; no translation if single character BEQ INMX CMPB D1,#1 ; function sequences start with SOH BEQ INMF ; function sequence - ;Escape sequences are translated directly by setting bit 7 on ;This will cause them to map to 240-377 MOVB (A0)+,D1 ; get the second character INMG: ORB #200,D1 ; set bit 7 on BIT #T$XLT,@A5 ; are we doing translation? BEQ INMNOT ; no - check for another translation INMX: LCC #0 ; reset the flags INMX2: RTN ;Function codes require additional translation so that they become 200-237 INMF: MOVB (A0)+,D1 ; get the second character SUBB #'@,D1 ; offset so that F1 becomes 0 BR INMG ; and go finish up ;Come here if program is not doing translation and we must do our own INMNOT: LEA A6,XLTTBL ; index the translation table 10$: MOVB (A6)+,D7 ; get character BEQ INMX2 ; end of table - ignore the character CMPB D1,D7 ; is it in the table? BEQ 20$ ; yes - INC A6 ; no - bypass translation BR 10$ ; loop for more - ;Come here to translate the character 20$: MOVB @A6,D1 ; translate the character BR INMX ;Translation table XLTTBL: BYTE 000,000 PAGE ;******************** ;* CRT * ;******************** ;Special crt control processing ;D1 contains the control code for X,Y positioning or special commands ;If D1 is positive we have screen positioning (row in hi byte, col in lo byte) ;If D1 is negative we have the special command in the low byte CRT: TSTW D1 ; is it cursor position? BMI CRTS ; no ;Cursor positioning - D1 contains X,Y coordinates TTYI ; send position command BYTE LI,17.,0,0 SUB #401,D1 ORW #100200,D1 TTY RORW D1,#8. ; send column second TTY RTN ;Special commands - D1 contains the command code in the low byte CRTS: AND #377,D1 ; strip the high byte BNE CRTU ; and branch unless clear screen TTYI ; special case for clear screen BYTE LI,'\-'@,0 EVEN CRTZ: TTYL CRTNUL ; output some nulls RTN ;Command processing per director tables CRTU: PUSH A2 ; save A2 ASL D1 ; times 2 (word offset). CMP D1,#CRCB-CRCA ; check for valid code BHI CRTX ; and bypass if bad LEA A2,CRCA-2 ; index the table ADD D1,A2 ; add command code MOVW @A2,D1 ; pick up data field offset ADD D1,A2 ; make absolute data address TTYL @A2 ; print the data field CMPB @A2,#36 ; sleep if home command BEQ CRTXZ CMPB 1(A2),#100 ; sleep if erase command BHI CRTXZ CRTX: POP A2 ; restore A2 ; RTN BR CRTZ CRTXZ: POP A2 ; restore A2 BR CRTZ ; and go output nulls ;Escape sequence translation table ; EXTB: BYTE 67,73,105,111,120,121,122,124,127,131,377,377 ;Null characters for long commands ; CRTNUL: BYTE 200,200,200,200,200,200,200,200,200,200,200,0 EVEN ;Byte offset and data tables follow for all commands ; CRCA: WORD C1-.,C2-.,C3-.,C4-.,C5-.,C6-.,C7-.,C8-. WORD C9-.,C10-.,C11-.,C12-.,C13-.,C14-.,C15-.,C16-. CRCB: PAGE C1: BYTE LI,'R-'@,0 ; cursor home (move to column 1,1) C2: BYTE 215,0 ; cursor return (move to column 1) C3: BYTE LI,'L-'@,0 ; cursor up C4: BYTE LI,'K-'@,0 ; cursor down C5: BYTE 'H-'@,0 ; cursor left C6: BYTE 'P-'@,0 ; cursor right C7: BYTE LI,'U-'@,0 ; lock keyboard C8: BYTE LI,'F-'@,0 ; unlock keyboard C9: BYTE LI,'O-'@,0 ; erase to end of line C10: BYTE LI,'k,0 ; erase to end of screen C11: BYTE LI,'Y-'@,0 ; enter backgroud display mode (reduced intensity). C12: BYTE LI,'_-'@,0 ; enter foreground display mode (normal intensity) C13: ; enable protected fields C14: BYTE 0 ; disable protected fields C15: BYTE LI,'S-'@,0 ; delete line C16: BYTE LI,'Z-'@,0 ; insert line EVEN END .