;**************************************************************************;
; ;
; TELEVIDEO 910+ TERMINAL DRIVER ;
; ;
;**************************************************************************;
; ASL-00152-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:
;
;[111] 27 Mar 1987
; Converted to drive Televideo 910+ and added routines to give it
; a status line of sorts. /JLM
;[110] 8 May 1985
; Correct my boo-boo in edit 109. /RJH
;[109] 2 May 1985
; Fixed problem with rubbing out control characters. /RJH
;[108] 26 Nov 1984
; Update to conform the new standard: Update the TRMCHR routine to support
; new fields and bitmap. /bys
;[107] 24 April 1984
; Add new TCRT codes to support new video attributes. /RBC
;[106] 22 December 1983
; Correct cursor read code, add scroll on and off to protect on and
; off, don't output initialization if PSEUDO interface driver or
; not enough queue blocks. /RBC
;[105] 14 June 1983
; change clear screen to use the clear unprotected sequence. /JP
;[104] 11 April 1983
; Add code to save/restore D3 in delay routine. /RBC
;[103] 27 December 1982
; Add split segment codes
;
SEARCH SYS
SEARCH SYSSYM
SEARCH TRM
OBJNAM 0,0,[TDV]
;Define capability flags
;
TDVFLG = TD$BLN!TD$CID!TD$DIM!TD$EOL!TD$EOS!TD$LID!TD$MLT!TD$PRT!TD$RVA!TD$UND [111]
;TDVFLG = TDVFLG!TD$STS ; VER messes things up when set. [111]
;********************
;* TVI910 *
;********************
;Terminal driver communications area
TVI910: 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 4 ; impure area of one longword.
ROWCNT: BYTE 24. ; number of rows
COLCNT: BYTE 80. ; number of columns
LWORD TDVFLG ; terminal has:
BR JMPTCH
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 call
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, is it a control char. ? [109]
BLO RBX ; yes - [109][110]
;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 ; [109]
ERUB: BYTE 210,40,210,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
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
;Function codes translation
INMF: MOVB (A0)+,D1 ; get the second character
MOV T.IBF(A5),A6
ADD T.ICC(A5),A6
MOVB #7,@A6 ; force ^G ahead of this char
INC T.ICC(A5)
INC T.BCC(A5)
INMX: LCC #0 ; reset the flags
RTN
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 #INIS1,D3 ; get size of string to send
LEA A6,INISTR ; index the string
MOV A6,D1
TRMBFQ ; output the string
REST D1,D2 ; restore registers
5$: MOV T.IMP(A5),A6 ; index impure area
MOVW #80.,@A6 ; preset to 80 columns
RTN
INISTR: BYTE 233,'X ; turn off monitor mode
BYTE 233,'* ; clear screen, home cursor
BYTE 233,'# ; disable keyboard
BYTE 233,'A ; stop printing
BYTE 233,'.,'0 ; turn off cursor
BYTE 233,'3 ; clear all tabs
BYTE 217 ; reset xon/xoff mode
BYTE 212,212 ; position cursor
ASCII /System booting . . ./
INIS1=.-INISTR
EVEN
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 [103]
MOVW D6,TC.COL(A1) ; transfer column count. [103]
; MOVW @A6,TC.COL(A1) ; transfer column count [103]
CLRW TC.CLR(A1) ; no colors
MOVW #0.,TC.TSL(A1) ; set length of top status line [108]
MOVW #0.,TC.SSL(A1) ; set length of shifted status line [108]
MOVW #80.,TC.USL(A1) ; set length of unshifted status line [108]
MOV D2,D7 ; get TRMCHR argument flags [108]
AND #TC$BMP,D7 ; does user want bitmap [108]
BEQ 20$ ; no - skip transfer code [108]
; user has requested bitmap -- return to him
PUSH A1 ; save argument block index [108]
ADDW #TC.BMP,A1 ; index bitmap return area [108]
LEA A6,TCHBMP ; index our bitmap [108]
MOV #<256./16.>-1,D7 ; get amount to transfer [108]
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 -
;
; Special XY routine to prevent cursor loads beyond line 24
;
; Cursor positioning - D1 contains x,y coordinates
; For ADM style terminals (also Soroc, Televideo, etc)
;
TTYI ; send position command
BYTE 233,75,0,0
ADDW #^H1F1F,D1 ; add position offsets
RORW D1,#8. ; send row first
CMPB D1,#'7 ; test against row 24 code
BLOS 1$
MOVB #'7,D1 ; if larger than row 24 make it 24
1$: TTY
ROLW 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 CRTU1 ; and branch unless clear screen
TTYI ; special case for clear screen
BYTE 233,':,0,0 ; ...clear only the unprotected if on. [105]
JMP WAIT
; finish up the status line received terminate code. [111]
CRTU2:
; SAVE A2,A6
; MOV T.IMP(A5),A2
PUSH A6
SLEEP #10000. ; give'm a second to read it
TTYI ; send cursor position command
BYTE 233,75,66,40,0,0
; MOVB (A2)+,D1 ; get row
; TTY ; send it
; MOVB (A2)+,D1 ; get col
; TTY ; send it
; REST A2,A6
POP A6
RTN
; start up the status line & save where we were. [111]
CRTU3:
; MOVW @A5,D1 ; save terminal status
; SAVE A2,D1
; ORW #T$IMI!T$ECS,@A5 ; set terminal status
; MOV T.IMP(A5),A2
; TTYI
; BYTE 233,'?,0,0
; KBD ; get row
; MOVB D1,(A2)+ ; store it
; KBD ; get col
; MOVB D1,(A2)+ ; store it
; KBD ; get rtn and toss it
TTYL C128
; REST A2,D1
; ANDW D1,@A5 ; reset terminal status
RTN
;Command processing per director tables
CRTU: PUSH D1
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
POP D1 ; Restore TCRT code
CMPB D1,#9. ; If a clear to end of line, do wait
BEQ WAIT
CMPB D1,#10. ; If a clear to end of screen, do wait
BEQ WAIT
; CMPB D1,#16. ; if a insert line, do wait
; BEQ WAIT
RTN ; Anything else, wait not required
WAIT: SSTS -(SP) ; stack status
1$: SVLOK ; lock so things can't change
MOVW @A5,D7
ANDW #T$OIP,D7 ; is output in progress?
BNE 2$ ; YES - wait
TST T.OQX(A5) ; is output queued?
BNE 2$ ; YES - wait
LSTS (SP)+ ; restore status
RTN ; return to user
2$: JWAIT J.TOW ; let TRMSER wake us (UNLOCK's)
BR 1$ ; re-test
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