;*; Updated on 01-Nov-91 at 4:00 PM by James A. Jarboe I V; edit time: 0:13:16
;****************************************************************************
;* *
;* ANSI Terminal Driver *
;* VT100, Link MC70, Wyse 350 terminals *
;* *
;****************************************************************************
;Copyright (C) 1991 UltraSoft Corporation. All Rights Reserved.
;
;[101] 01-Nov-91 by James A. Jarboe I V
; TCHBMP was incorrect.
;
;[100] 31 August 1991 16:32 Edited by David Pallmann
; Created.
;**********
;* ANSI *
;**********
;Terminal driver communications area
ANSI: WORD TD$NEW!TD$TCH ; terminal attributes
BR JMPINP ; input routine
RTN ;
BR ECHO ; echo routine
BR JMPCRT ; crt control
BR JMPINI ; no init routine yet
WORD 4 ; impure area of 4 bytes (last 2 unused)
BYTE 24. ; number of rows
BYTE 80. ; number of columns
LWORD TDVFLG ; terminal has:
; insert/delete line
; insert/delete character
; dim video attribute
; erase to end of screen
; erase to end of line
; multi-byte keystrokes
BR JMPTCH ; return terminal characteristics
JMPINP: JMP INP ; go handle input characters
JMPTCH: JMP TCH ; go return terminal characteristics
JMPCRT: JMP CRT ; go handle tcrt codes
JMPINI: JMP INI ; go initialize terminal
;********************
;* 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
;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,#ESC ; 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,#ESC ; 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
CMPB D1,#ESC ; is first character ESC?
BNE INMX ; no
CMPB D0,#2 ; check size
BLO INMX ; <2 characters - no translation
MOVB @A0,D1 ; get second character
LEA A6,XLTTBL ; point to translation table
10$: TSTB @A6 ; end of table?
BEQ INMQ ; yes - escape sequence is invalid
CMPB D1,(A6)+ ; match?
BEQ 20$ ; yes
INC A6 ; no - increment index
BR 10$ ; and try next table entry
20$: MOVB @A6,D1 ; put translated char in D1
BR INMX ; and return to program
INMQ: MOVB #'?,D1 ;
INMX: LCC #0 ; reset the flags
INMX2: RTN
XLTTBL: BYTE ^H08,'H-'@ ; left arrow = ESC ^H
BYTE ^H0A,'J-'@ ; down arrow = ESC ^J
BYTE ^H0B,'K-'@ ; up arrow = ESC ^K
BYTE ^H0C,'L-'@ ; right arrow = ESC ^L
BYTE ^H06,164. ; insert = 164.
BYTE ^H05,165. ; delete = 165.
BYTE ^H07,166. ; home = 166.
BYTE ^H0D,167. ; end = 167.
BYTE ^H22,168. ; page up = 168.
BYTE ^H24,169. ; page down = 169.
BYTE 'A,128. ; F1 = ESC A = 128.
BYTE 'B,129. ; F2 = ESC B = 129.
BYTE 'C,130. ; F3 = ESC C = 130.
BYTE 'D,131. ; F4 = ESC D = 131.
BYTE 'E,132. ; F5 = ESC E = 132.
BYTE 'F,133. ; F6 = ESC F = 133.
BYTE 'G,134. ; F7 = ESC G = 134.
BYTE 'H,135. ; F8 = ESC H = 135.
BYTE 'I,136. ; F9 = ESC I = 136.
BYTE 'J,137. ; F10 = ESC J = 137.
BYTE 'K,138. ; F11 = ESC K = 138.
BYTE 'L,139. ; F12 = ESC L = 139.
BYTE 'a,140. ; sF1 = ESC a = 140.
BYTE 'b,141. ; sF2 = ESC b = 141.
BYTE 'c,142. ; sF3 = ESC c = 142.
BYTE 'd,143. ; sF4 = ESC d = 143.
BYTE 'e,144. ; sF5 = ESC e = 144.
BYTE 'f,145. ; sF6 = ESC f = 145.
BYTE 'g,146. ; sF7 = ESC g = 146.
BYTE 'h,147. ; sF8 = ESC h = 147.
BYTE 'i,148. ; sF9 = ESC i = 148.
BYTE 'j,149. ; sF10 = ESC j = 149.
BYTE 'k,150. ; sF11 = ESC k = 150.
BYTE 'l,151. ; sF12 = ESC l = 151.
BYTE 0,0 ; ** end of table **
PAGE
;*********
;* INI *
;*********
;Handle initialization of the terminal
INI: MOV T.IDV(A5),A6 ; index the interface driver [106]
CMP -(A6),#<[PSE]_16.>+[UDO]; is it the pseudo interface driver? [106]
BEQ 5$ ; yes - no initialization wanted [106]
CMP QFREE,#12. ; are there at least 12 queue blocks? [106]
BLO 5$ ; no - skip the initialization [106]
SAVE D1,D2 ; save registers
MOV #5,D3 ; get size of first command
LEA A6,INISTS ; index the first init string
MOV A6,D1
TRMBFQ
;de-comment this section for Link MC-70 or Wyse 370 terminal to pre-load
;function keys.
;
; MOV #FKYSIZ,D3 ; get size of first command
; LEA A6,INIFKY ; index the first init string
; MOV A6,D1
; TRMBFQ
REST D1,D2 ; restore registers
5$: MOV T.IMP(A5),A6 ; index impure area
MOVB #1,(A6)+ ; store foreground color
MOVB #0,(A6)+ ; store background color
; MOVW #80.,@A6 ; preset to 80 columns
RTN
PAGE
;*********
;* TCH *
;*********
;Handle TRMCHR call
;A1 points to argument block, A2 indexes this TDV, D2 contains flags
;Can only use A1,A2,A6,D1,D2,D6,D7
TCH: MOV TD.FLG(A2),TC.FLG(A1) ; transfer flags
MOV JOBCUR,A6 ; index job
MOV JOBTRM(A6),A6 ; index terminal control area
MOV T.IMP(A6),A6 ; index impure area
CLR D6 ; preclear register
MOVB #24.,D6 ; get row count
MOVW D6,TC.ROW(A1) ; transfer row count
MOVW #80.,TC.COL(A1) ; set column count
MOVB (A6)+,D6 ; get foreground color
MOVW D6,TC.FGC(A1)
MOVB (A6)+,D6 ; get background color
MOVW D6,TC.BGC(A1)
MOVW #8.,TC.CLR(A1) ; eight colors
MOVW #0.,TC.TSL(A1) ; set length of top status line
MOVW #0.,TC.SSL(A1) ; set length of shifted status line
MOVW #78.,TC.USL(A1) ; set length of unshifted status line
MOVW #0,TC.SVA(A1) ; set number of saved characters
MOV D2,D7 ; get TRMCHR argument flags
AND #TC$BMP,D7 ; does user want bitmap?
BEQ 20$ ; no - skip bitmap transfer code
;User has requested bitmap -- return it to him
PUSH A1 ; save argument block index
ADDW #TC.BMP,A1 ; index bitmap return area
LEA A6,TCHBMP ; index our bitmap
MOV #<256./16.>-1,D7 ; get amount to transfer
10$: MOVW (A6)+,(A1)+ ; transfer to user
DBF D7,10$ ; loop until done
POP A1 ; restore register
20$: RTN ; return to TRMCHR monitor routine
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: SAVE D1 ;
TSTW D1 ; is it cursor position?
BMI CRTU ; no
;Cursor positioning - D1 contains X,Y coordinates
TTYI
BYTE ESC,'[,0,0
SAVE D0
MOV D1,D0
RORW D1,#8.
AND #377,D1
DCVT 0,OT$TRM
TTYI
BYTE ';,0
MOV D0,D1
AND #377,D1
DCVT 0,OT$TRM
TTYI
BYTE 'f,0
REST D0
REST D1 ;
RTN
;Special commands - D1 contains the command code in the low byte
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 ; 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
CRTX: POP A2 ; restore A2
CRTR: REST D1 ;
RTN
SETFGD: AND #377,D1 ;
10$: CMPB D1,#7 ;
BLOS 20$ ;
SUBB #8.,D1 ;
BR 10$ ;
20$: MOV JOBCUR,A6 ; index job
MOV JOBTRM(A6),A6 ; index terminal control area
MOV T.IMP(A6),A6 ; index impure area
MOVB D1,@A6 ; store new foreground color
BNE 30$ ; not zero
TSTB 1(A6) ; is background also black?
BNE 30$ ; no
MOVB #1,D1 ; yes - change to white
MOVB D1,@A6 ;
30$: TTYI ;
BYTE ESC,'[,'4,'8,';,0 ;
EVEN ;
LEA A2,FGDTBL ;
ADD D1,A2 ;
MOVB @A2,D1 ;
TTY ;
TTYI ;
BYTE 'w,0 ;
EVEN ;
SF.RTN: REST D1 ;
RTN ;
;table of foreground colors
FGDTBL: BYTE '5 ; 0 black
BYTE '0 ; 1 white
BYTE '2 ; 2 blue
BYTE '1 ; 3 magenta (red)
BYTE '1 ; 4 red
BYTE '3 ; 5 yellow (amber)
BYTE '6 ; 6 green
BYTE '7 ; 7 cyan
EVEN
SETBGD: AND #377,D1 ;
10$: CMPB D1,#7 ;
BLOS 20$ ;
SUBB #8.,D1 ;
BR 10$ ;
20$: MOV JOBCUR,A6 ; index job
MOV JOBTRM(A6),A6 ; index terminal control area
MOV T.IMP(A6),A6 ; index impure area
MOVB D1,1(A6) ; store new background color
TTYI ;
BYTE ESC,'[,'4,'9,';,0 ;
EVEN ;
LEA A2,BGDTBL ;
ADD D1,A2 ;
ADD D1,A2 ;
MOVB (A2)+,D1 ;
TTY ;
MOVB @A2,D1 ;
TTY ;
TTYI ;
BYTE 'w,0 ;
EVEN ;
SB.RTN: REST D1 ;
RTN ;
;table of background colors
BGDTBL: BYTE '0,'1 ; 0 black
BYTE '6,'4 ; 1 white
BYTE '0,'1 ; 2 blue
BYTE '5,'0 ; 3 magenta
BYTE '4,'8 ; 4 red
BYTE '6,'0 ; 5 yellow
BYTE '1,'2 ; 6 green
BYTE '1,'5 ; 7 cyan
EVEN
;Escape sequence translation table
;
EXTB: BYTE 67,73,105,111,120,121,122,124,127,131,377,377
EVEN
;Byte offset and data tables follow for all commands
;
CRCA: WORD C0-.,C1-.,C2-.,C3-.,C4-.,C5-.,C6
-.,C7-.
WORD C8-.,C9-.,C10-.,C11-.,C12-.,C13-.,C14-.,C15-.
WORD C16-.,C17-.,C18-.,C19-.,C20-.,C21-.,C22-.,C23-.
WORD C24-.,C25-.,C26-.,C27-.,C28-.,C29-.
WORD C30-.,C31-.,C32-.,C33-.,C34-.,C35-.,C36-.,C37-.,C38-.,C39-.
WORD C40-.,C41-.,C42-.,C43-.,C44-.,C45-.,C46-.,C47-.,C48-.,C49-.
WORD C50-.,C51-.,C52-.,C53-.,C54-.,C55-.,C56-.,C57-.,C58-.,C59-.
WORD C60-.,C61-.,C62-.,C63-.,C64-.,C65-.,C66-.,C67-.,C68-.,C69-.
WORD C70-.,C71-.,C72-.,C73-.,C74-.,C75-.,C76-.,C77-.,C78-.,C79-.
WORD C80-.,C81-.,C82-.,C83-.,C84-.,C85-.,C86-.,C87-.,C88-.,C89-.
WORD C90-.,C91-.,C92-.,C93-.,C94-.,C95-.,C96-.,C97-.,C98-.,C99-.
WORD C100-.,C101-.,C102-.,C103-.,C104-.,C105-.,C106-.,C107-.
WORD C108-.,C109-.,C110-.,C111-.,C112-.,C113-.,C114-.,C115-.
WORD C116-.,C117-.,C118-.,C119-.,C120-.,C121-.,C122-.,C123-.
WORD C124-.,C125-.,C126-.,C127-.,C128-.,C129-.,C130-.,C131-.
CRCB:
PAGE
;***************************
;* *
;* Special CRT Functions *
;* *
;***************************
;
; NOTE: special functions blinking/reverse_video/underlining are coded to
; print an extraneous space. This makes the driver compatible with
; such software as AlphaMENU that is coded in expectation of
; TeleVideo-type graphics that print an attribute character.
;
; If the space is not desireable for your application, remove all
; references to the number 40. For example:
;
; change BYTE ESC,'[,'X,40,0 to BYTE ESC,'[,'X,0
;
C0: BYTE ESC,'[,'2,'J ;ED clear screen
C1: BYTE ESC,'[,'0,';,'0,'H,0 ;CUP cursor home
C2: BYTE ESC,'E,0 ;NEL cursor return
C3: BYTE ESC,'[,'1,'A,0 ;CUU cursor up
C4: BYTE ESC,'[,'1,'B,0 ;CUD cursor down
C5: BYTE ESC,'[,'1,'D,0 ;CUB cursor left
C6: BYTE ESC,'[,'1,'C,0 ;CUF cursor right
C7: ;XXX lock keyboard
C8: BYTE 0 ;XXX unlock keyboard
C9: BYTE ESC,'[,'0,'K,0 ;EL erase to end of line
C10: BYTE ESC,'[,'0,'J,0 ;ED erase to end of screen
C11: BYTE ESC,'[,'2,'m,0 ;SGR enter backgroud display mode (reduced intensity).
C12: BYTE ESC,'[,'0,'m,0 ;SGR enter foreground display mode (normal intensity)
C13: ;XXX enable protected fields
C14: BYTE 0 ;XXX disable protected fields
C15: BYTE ESC,'[,'1,'M,0 ;DL delete line
C16: BYTE ESC,'[,'1,'L,0 ;IL insert line
C17: BYTE ESC,'[,'1,'P,0 ;DCH delete character
C18: BYTE ESC,'[,'1,'@,0 ;ICH insert character
C19: ;XXX read cursor address
C20: BYTE 0 ;XXX read character at current cursor position
C21: BYTE ESC,'[,'5,'m,40,0 ;SGR start blink field
C22: BYTE ESC,'[,'0,'m,40,0 ;SGR end blink field
C23: BYTE ESC,'(,'0,0 ;XXX start line drawing mode (enable alternate character set)
C24: BYTE ESC,'(,'B,0 ;XXX end line drawing mode (disable alternate character set)
C25: ;XXX set horizontal position
C26: ;XXX set vertical position
C27: BYTE 0 ;XXX set terminal attributes
C28: BYTE ESC,'[,'?,'2,'5,'h,0 ;RM cursor on
C29: BYTE ESC,'[,'?,'2,'5,'l,0 ;SM cursor off
C30: BYTE 40,ESC,'[,'4,'m,0 ;SGR start underscore [102]
C31: BYTE ESC,'[,'0,'m,40,0 ;SGR end underscore [102
C32: BYTE 40,ESC,'[,'7,'m,0 ;SGR start reverse video [102]
C33: BYTE ESC,'[,'0,'m,40,0 ;SGR end reverse video [102]
C34: BYTE 40,ESC,'[,'7,'m,0 ;SGR start reverse blink [102]
C35: BYTE ESC,'[,'0,'m,40,0 ;SGR end reverse blink [102]
C36: BYTE ESC,'[,'3,'0,'h,0 ;XXX turn off screen display [102]
C37: BYTE ESC,'[,'3,'0,'l,0 ;XXX turn on screen display [102]
C38: BYTE 'l,0 ;XXX top left corner
C39: BYTE 'k,0 ;XXX top right corner
C40: BYTE 'm,0 ;XXX bottom left corner
C41: BYTE 'j,0 ;XXX bottom right corner
C42: BYTE 'w,0 ;XXX top intersect
C43: BYTE 'u,0 ;XXX right intersect
C44: BYTE 't,0 ;XXX left intersect
C45: BYTE 'v,0 ;XXX bottom intersect
C46: BYTE 'q,0 ;XXX horizontal line
C47: BYTE 'x,0 ;XXX vertical line
C48: BYTE 'n,0 ;XXX intersection
C49: BYTE 'a,0 ;XXX solid block
C50: BYTE 'a,0 ;XXX slant block
C51: BYTE 'a,0 ;XXX cross-hatch block
C52: BYTE 'q,0 ;XXX double line horizontal
C53: BYTE 'x,0 ;XXX double line vertical
C54: ;XXX send message to function key line
BYTE ESC,'[,'1,'$,'} ; <- select bottom status line
BYTE ESC,'[,'1,';,'1,'H ; <- position at (1,1)
BYTE ESC,'[,'0,'K ; <- clear to end of line
BYTE 0
C55: ;XXX send message to shifted function key line
BYTE ESC,'[,'1,'$,'} ; <- select bottom status line
BYTE ESC,'[,'1,';,'1,'H ; <- position at (1,1)
BYTE ESC,'[,'0,'K ; <- clear to end of line
BYTE 0
C56: BYTE ESC,'[,'0,'v,0 ;XXX set normal display format
C57: BYTE ESC,'[,'1,'v,0 ;XXX set horizontal split (follow with row code)
C58: BYTE ESC,'[,'8,'v,0 ;XXX set vertical split (39 char columns)
C59: BYTE ESC,'[,'8,'v,0 ;XXX set vertical split (40 char columns)
C60: BYTE ESC,'[,'8,'v,0 ;XXX set vertical split column to next char
C61: BYTE ESC,'[,'0,'t,0 ;XXX activate split segment 0
C62: BYTE ESC,'[,'2,'t,0 ;XXX activate split segment 1
C63: BYTE 0 ;XXX send message to host message field
C64: BYTE '^,0 ;XXX up-arrow
C65: BYTE 'V,0 ;XXX down-arrow
C66: BYTE 200+'7,0 ;XXX raised dot
C67: BYTE '`,0 ;XXX end of line marker
C68: BYTE 'u,0 ;XXX horizontal tab symbol
C69: BYTE 200+'6,0 ;XXX paragraph
C70: BYTE 'n,0 ;XXX dagger
C71: BYTE 200+'',0 ;XXX section
C72: BYTE 200+'",0 ;XXX cent sign
C73: BYTE 200+'<,0 ;XXX one-quarter
C74: BYTE 200+'=,0 ;XXX one-half
C75: BYTE 200+'0,0 ;XXX degree
C76: BYTE 'T,0 ;XXX trademark
C77: BYTE 200+'),0 ;XXX copyright
C78: BYTE 200+'.,0 ;XXX registered
C79: BYTE 0 ;XXX print screen
C80: BYTE ESC,'[,'?,'3,'h,0 ;XXX reserved for set to wide mode
C81: BYTE ESC,'[,'?,'3,'l,0 ;XXX reserved for set to normal mode
C82: ;XXX enter transparent print mode
C83: ;XXX exit transparent print mode
C84: ;XXX begin writing to alternate page
C85: ;XXX end writing to alternate page
C86: ;XXX toggle page
C87: ;XXX copy to alternate page
C88: ;XXX insert column
C89: ;XXX delete column
C90: ;XXX block fill with attribute
C91: ;XXX block fill with character
C92: ;XXX draw a box
C93: ;XXX scroll box up one line
C94: ;XXX scroll box down one line
C95: ;XXX select jump scroll
C96: ;XXX select fast smooth scroll
C97: ;XXX select med-fast smooth scroll
C98: ;XXX select med-slow smooth scroll
C99: ;XXX select slow smooth scroll
C100: ;XXX start underscore/blink
C101: ;XXX end underscore/blink
C102: ;XXX start underscore/reverse
C103: ;XXX end underscore/reverse
C104: ;XXX start underscore/reverse/blink
C105: ;XXX end underscore/reverse/blink
C106:
C107:
C108:
C109:
C110:
C111:
C112:
C113:
C114:
C115:
C116:
C117:
C118:
C119:
C120:
C121:
C122:
C123:
C124:
C125:
C126:
C127:
C128: BYTE 0
C129: BYTE ESC,'[,'0,'$,'},0 ; end status line
C130:
BYTE ESC,'[,'1,'$,'} ; <- select bottom status line
BYTE ESC,'[,'1,';,'1,'H ; <- position at (1,1)
BYTE ESC,'[,'0,'K ; <- clear to end of line
BYTE 0
EVEN