WORD .TW1.,.TW0.,.TW3.,.TW2.,.TW5.,.TW4.,.TW7.,.TW6.,.TW9.,.TW8.
WORD 0,0,0,0,0,0
RAD50 /SUPER /
RAD50 /VUE/
RAD50 /T925 /
;End SuperVUE compatibility area
JMPINP: JMP INPUT ;Jump to input routine
JMPCRT: JMP CRT ;Jump to CRT routine
;**********
;* ECHO *
;**********
;Special echo processing is performed here
;<DEL>s will backspace and erase the previous character
;^U will erase the entire line by backspacing and erasing
;Character deletions are handled by the old backspace-and-erase game
;Special handling must be performed if we are deleting out a <TAB>
;D6 contains the character being deleted
RUBOUT: CMPB D6,#'I-'@ ;was it a <TAB>?
BEQ RBTB ; yes
;Delete 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
;Deletion 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 ; <ESC>
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 ^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
;***********
;* INPUT *
;***********
;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
INPUT: 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
CMPB D1,#'V-'@ ;DOWN ARROW?
BNE 10$
MOVB #'J-'@,D1
10$: 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
;Unshifted function keys map to 200-212
;Shifted function keys map to 240-252
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 -
;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 ESC,75,0,0
ADD #17437,D1 ;add position offsets
ROR D1,#8. ;send row first
TTY
ROL 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 ESC,52,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),#'f ;no nulls if program status cmd
BEQ CRTX
CMPB 1(A2),#'G ;no nulls for attribute cmd
BEQ CRTX
CMPB 1(A2),#100 ;sleep if erase command
BHI CRTXZ
CRTX: POP A2 ;restore A2
RTN
CRTXZ: POP A2 ;restore A2
BR CRTZ ; and go output nulls
;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-.,C9-.,C10-.
WORD C11-.,C12-.,C13-.,C14-.,C15-.,C16-.,C17-.,C18-.,C19-.,C20-.
WORD C21-.,C22-.,C23-.,C24-.,C25-.,C26-.,C27-.,C28-.,C29-.,C30-.
WORD C31-.,C32-.,C33-.,C34-.,C35-.,C36-.,C37-.,C38-.,C39-.,C40-.
WORD C41-.
CRCB:
DEFINE CRT CODE1,CODE2,CODE3
.NUM=.NUM+1
.TAW.=<.NUM/16.>&^H0F
.TAWB.=.NUM-<.TAW.*16.>
.TAW.\.TAW.=<1_.TAWB.>!.TAW.\.TAW.
IF NB,CODE1,BYTE CODE1
IF NB,CODE2,BYTE CODE2
IF NB,CODE3,BYTE CODE3
BYTE 0
ENDM
C0: CRT ;clear screen
C1: CRT 30. ;Home cursor
C2: CRT 200+13. ;Cursor to column 1
C3: CRT 11. ;Cursor up
C4: CRT 10. ;Cursor down
C5: CRT 8. ;Cursor left
C6: CRT 12. ;Cursor right
C7: CRT ESC,43 ;Lock keyboard
C8: CRT ESC,42 ;Unlock keyboard
C9: CRT ESC,'T ;Erase to end of line
C10: CRT ESC,'Y ;Erase to end of screen
C11: CRT ESC,') ;Low intensity
C12: CRT ESC,'( ;High intensity
C13: CRT ESC,'& ;Enable protected fields
C14: CRT ESC,'' ;Disable protected fields
C15: CRT ESC,'R ;Delete line
C16: CRT ESC,'E ;Insert line
C17: CRT ESC,'W ;Delete character
C18: CRT ESC,'Q ;Insert character
C19: CRT ESC,'? ;Read cursor address
C20: CRT ESC,'1 ;Read character at current cursor position
C21: CRT ESC,'G,'2 ;Blink on
C22: CRT ESC,'G,'0 ;Blink off
C23: CRT ;Start line drawing mode
C24: CRT ;End line drawing mode
C25: CRT ;Set horizontal position
C26: CRT ;Set vertical position
C27: CRT ESC,'. ;Set terminal attributes
C28: CRT ESC,'.,'2 ;Cursor on
C29: CRT ESC,'.,'0 ;Cursor off
C30: CRT ESC,'G,'8 ;Underscore on
C31: CRT ESC,'G,'0 ;Underscore off
C32: CRT ESC,'G,'4 ;Reverse video on
C33: CRT ESC,'G,'0 ;Reverse video off
C34: CRT ESC,'G,'6 ;Reverse blink on
C35: CRT ESC,'G,'0 ;Reverse blink off
C36: CRT ESC,'o ;Screen off
C37: CRT ESC,'n ;Screen on
;*** LMS DEFINED FUNCTIONS ***
C38: CRT ESC,'f ;Program status line *** LMS
C39: CRT 13. ;End status line *** LMS
C40: CRT ESC,'g ;Status line on *** LMS
C41: CRT ESC,'h ;Status line off *** LMS