;**************************************************************************;
; ;
; AM-70 TERMINAL DRIVER ;
; ;
; NOTE: this one handles "auto turn off" from TRMOFF.LIT ;
; ;
;**************************************************************************;
; ASL- -00
; NOTICE
;
;All rights reserved. This software is the property of Alpha Microsystems
;and the material contained herein is the proprietary property and trade
;secrets of Alpha Microsystems, embodying substantial creative efforts and
;confidential information, ideas and expressions, no part of which may be
;reproduced or transmitted in any form or by any means, electronic,
;mechanical, or otherwise, including photocopying or input into any
;information storage or retrieval system without the express written
;permission of Alpha Microsystems.
;
;CAUTION: Unauthorized distribution or reproduction of this material may
;subject you to legal action.
;
;Copyright (C) 1982 - Alpha Microsystems
;
;Edit History:
;
;[116] 9 May 1985
; Correct the reverse yellow escape code. /BYS
;[115] 8 May 1985
; Correct my boo-boo in edit 114. /RJH
;[114] 2 May 1985
; Fixed problem with rubbing out control characters. /RJH
;[113] 28 Nov 1984
; Update to conform the new standards: Update TRMCHR routine to support
; new fields and the bitmap. /bys
;[112] 23 August 1984
; Added jump scroll select. /RJH
;[111] 15 August 1984
; Added smooth scroll flag and 'print screen' function. Also deleted
; the code to return color info in the TRMCHR routine. /RJH
;[110] July 1984
; Add support for printer port usage. /RJH
;[109] 14 June 1984
; Created from the AM-7X driver to support the Esprit III color
; terminal. /RJH
;[108] 24 April 1984
; Add the very latest video attribute TCRT calls, plus fix edit [107]
; so that we also ignore -4 TCRT codes.
;[107] 22 March 1984
; Make sure we ignore minus TCRT codes other than -1, -2, or -3.
;[106] 1 March 1984
; Enable proper display of trademark symbol and correct problem with
; set wide and set narrow commands.
;[105] 17 February 1984
; Adapt contrasting color code to new color map.
;[104] 15 February 1984
; Adapt to conform to new color map.
;[103] 1 February 1984
; Add support for extended commands.
;[102] 18 January 1984
; Make driver preserve user's color selection. /RBC
;[101] 17 Jan 1984
; Convert from WY-300 to AM-62 /jp
;[100] 6 May 1983
; Convert from AM-60.
;
SEARCH SYS
SEARCH SYSSYM
SEARCH TRM
OBJNAM .TDV
;Define capability flags
;
;[109] Modified flags for Esprit III.
;
TDVFLG=TD$LID!TD$CID!TD$RVA!TD$DIM!TD$EOS!TD$EOL!TD$MLT!TD$PRT!TD$SMT
TDVFLG=TDVFLG!TD$CLR!TD$PHR
;********************
;* WYSE *
;********************
;Terminal driver communications area
WYSE: WORD TD$NEW!TD$TCH ; terminal attributes
BR JMPINP ; input routine
RTN ; output routine
BR ECHO ; echo routine
BR JMPCRT ; crt control
BR JMPINI ; INIT routine
WORD 2 ; impure area of two bytes
ROWCNT: BYTE 24. ; number of rows
COLCNT: BYTE 80. ; number of columns
LWORD TDVFLG ; terminal attributes
BR JMPTCH ; handle TRMCHR call [102]
JMPINP: JMP INP ; go handle input characters
JMPCRT: JMP CRT ; go handle TCRT codes
JMPINI: JMP INI ; go handle initialization
JMPTCH: JMP TCH ; go handle TRMCHR [102]
PAGE
;********************
;* 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 -
CMPB D6,#40 ; no, was it a control char. ? [114]
BLO RBX ; yes - [114][115]
;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
RBX: RTN ; [114]
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 ; carriage return -
BEQ KRTC
CMPB D1,#33 ; escape -
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 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
PAGE
;********************
;* 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
;
;++++++ NEW STUFF FOR AUTO TURN-ON WITH TRMOFF.LIT +++++++++
;
PUSH D1 ;save everything (paranoid we are)
PUSH D7
PUSH A6
PUSH D3
CLR D1 ;clear the reg
MOVW T.STS(A5),D6 ;get the terminal status word
PUSH D6 ;and save the original
ANDW #20000,D6 ;get this bit
CMPW D6,#20000 ;see if this bit is on (tv OFF)
BLO CONT ;NO, tv is ON, so normal processing
POP D6 ;tv OFF, so get the status word
MOVW #20000,D7 ;and the bit indicating it's OFF
COMW D7 ;complement
ANDW D7,D6 ;and turn this bit off (tv will be ON)
MOVW D6,@A5 ;move this into the status word
LEA A6,C37 ;get the "turn on" byte string address
MOV A6,D1 ;move this address to D1 for TRMBFQ
MOV #2,D3 ;the number of bytes for turn on
TRMBFQ ;turn tv ON
CONT: POP D6 ;restore junk
POP D3
POP A6
POP D7
POP D1
;
;++++++ END OF "NEW HOT STUFF" - ZOUNDS! ++++++++++++++++
;
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
PAGE
;********************
;* INI *
;********************
;Handle initialization of the terminal
INI: MOV T.IMP(A5),A6 ; index color
MOVB #5,(A6)+ ; default to yellow on black
CLRB @A6
MOV T.IDV(A5),A6 ; index the interface driver
CMP -(A6),#<[PSE]_16.>+[UDO]; is it the pseudo interface driver?
BEQ 5$ ; yes - no initialization wanted
CMP QFREE,#12. ; are there at least 12 queue blocks?
BLO 5$ ; no - skip the initialization
SAVE D1,D2 ; save registers
;
; Clear screen and print 'please wait' message.
;
MOV #INISIZ,D3 ; Get size of command.
LEA A6,INISTR ; Index command.
MOV A6,D1 ;
TRMBFQ ;
SLEEP #5000. ; wait for reset to complete. [109]
REST D1,D2 ; restore registers. [109]
5$: RTN ; [109]
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 ROWCNT(A2),D6 ; get row count
MOVW D6,TC.ROW(A1) ; transfer row count
MOVB COLCNT(A2),D6 ; get column count
MOVW D6,TC.COL(A1) ; transfer column count
; MOVW #8.,TC.CLR(A1) ; eight colors [111]
; MOVB (A6)+,D6 ; get foreground color [111]
; MOVW D6,TC.FGC(A1) ; store it [111]
; MOVB @A6,D6 ; get background color [111]
; MOVW D6,TC.BGC(A1) ; store it [111]
MOVW #0,TC.TSL(A1) ; set length of top status line [113]
MOVW #0,TC.SSL(A1) ; set length of shifted status line [113]
MOVW #0,TC.USL(A1) ; set length of unshifted status line [113]
MOV D2,D7 ; get TRMCHR argument flags [113]
AND #TC$BMP,D7 ; does user want bitmap [113]
BEQ 20$ ; no - skip transfer code [113]
; user has requested bitmap -- return to him
PUSH A1 ; save argument block index [113]
ADDW #TC.BMP,A1 ; index bitmap return area [113]
LEA A6,TCHBMP ; index our bitmap [113]
MOV #<256./16.>-1,D7 ; get amount to transfer [113]
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: TSTW D1 ; is it cursor position?
BMI CRTS ; no -
;Cursor positioning - D1 contains x,y coordinates
TTYI ; send position command
BYTE 33,'X,33,75,0
EVEN
ADDW #17437,D1 ; convert to coded format
RORW D1,#8. ; send row first
TTY
ROLW D1,#8. ; send column second
TTY
RTN
;Special commands - D1 contains the command code in the low byte
CRTS: CMPW D1,#177400 ; is it -1 in high byte?
BLO CRTCOL ; no - is a set color command
AND #377,D1 ; strip the high byte
BNE CRTU ; and branch unless clear screen
TTYI ; special case for clear screen
BYTE 33,'X,33,';,0
EVEN
CRTZ: MOV #11.,D3 ; get 11 nulls
MOV #0,D1
TRMBFQ ; output some nulls
RTN
;Command processing per director tables
CRTU: CMPB D1,#23. ; enter graphics mode?
BEQ ENTGRF ; yes -
CMPB D1,#24. ; exit graphics mode?
JEQ EXTGRF ; yes -
PUSH 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
CRTX: POP A2 ; restore A2
RTN
;Got a color command - check for foreground or background change
CRTCOL: RTN ; Ignore color commands [110]
CMPW D1,#177000 ; is it -2? [107]
BHIS 10$ ; yes - must be foreground change [107]
BR IGNCMD ; No. Ignore background request.
10$: MOV T.IMP(A5),A6 ; index impure storage
ANDB #7,D1 ; get just the color [104]
MOVB D1,@A6 ; store new foreground color
;Set the color to current specification
CURCLR: TTYI ; send the color selection command
BYTE 33,'G,0,0 ; Set color command for ESPRIT III [109]
MOV T.IMP(A5),A6 ;
CLR D1 ; preclear register [104]
MOVB @A6,D1 ; get the foreground color
MOVB CLRMAP[D1],D1 ; adapt to terminal map [104]
TTY ; send the character
IGNCMD: RTN ; and return [107]
; [109]
; Define color map for ESPRIT III
;
CLRMAP: BYTE '8 ; black [104]
BYTE '3 ; white [104]
BYTE '9 ; blue [104]
BYTE '; ; magenta [104]
BYTE ': ; red [104]
BYTE '2 ; yellow [104]
BYTE '0 ; green [104]
BYTE '1 ; cyan [104]
;Enter Graphics Mode
;Set color to CYAN on current background, unless background is CYAN
; in which case we use BLACK on current background
ENTGRF: TTYI
BYTE 33,'$,0 ; enter line drawing mode
EVEN
RTN
;Exit Graphics Mode - reset color to user selection
EXTGRF: TTYI
BYTE 33,'%,0 ; end line drawing mode
EVEN
RTN
DEFINE OFFTAB A1,A2,A3,A4,A5,A6,A7,A8,A9,A10
IF NB, A1, WORD A1-.
IF NB, A2, WORD A2-.
IF NB, A3, WORD A3-.
IF NB, A4, WORD A4-.
IF NB, A5, WORD A5-.
IF NB, A6, WORD A6-.
IF NB, A7, WORD A7-.
IF NB, A8, WORD A8-.
IF NB, A9, WORD A9-.
IF NB, A10, WORD A10-.
ENDM