; TEL910 terminal driver - hand modified to remove function key code from
; TEL925.M68, which was built by FIXTRM V2.0a/L and then hand modified.
;
; 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, Irvine CA 92714
;
MAYCREF
IF EQ,TDVTYP
WORD 0 ; TDV flags.
IFF
WORD 2000 ; TDV flags, CRT specs included.
ENDC
IF NE,SHIFTE!FUNCTI
BR INPUT ; Handle INPUT routine.
IFF
RTN ; No INPUT routine.
ENDC
IF NE,NULLS!FFNULL
BR OUTPUT ; Handle OUTPUT routine.
IFF
RTN ; No OUTPUT routine.
ENDC
IF NE,KEYBOA
BR ECHO ; Handle keyboard ECHO.
IFF
RTN ; No ECHO routine.
ENDC
IF NE,TDVTYP
BR TCRT ; Handle CRT.
RTN ; No INIT routine.
IMPSIZ= 16.*TDVTYP
IF NE,FDISCA
IMPSIZ =IMPSIZ+2 ; Adjust for function key translation.
ENDC
WORD IMPSIZ ; IMPURE area.
BYTE ROWS,COLUMN ; Terminal size.
LWORD SMART ; Terminal features.
IFF
RTN ; No CRT routine.
RTN ; No INIT routine.
WORD 0 ; No impure area.
ENDC
IF NE,SHIFTE!FUNCTI
PAGE
;****************
; INPUT *
;****************
; Handle input character translation.
;
; Passed:
;
; D1 := Input character.
;
INPUT: SAVE D6,A6 ; Save registers.
IF NE,SHIFTE
; Reverse RUBOUT and UNDERLINE characters so RUBOUT is an unshifted character.
;
AND #177, D1 ; Make character legal.
CMPB D1, #137 ; Underline?
BEQ 10$ ; Yes, convert it.
CMPB D1, #177 ; Rubout?
BNE 20$ ; No, no conversion needed.
10$: XORB #40, D1 ; Convert rubout/underline code.
20$:
ENDC
IF NE,FUNCTI
; If function key translation, do not translate if not in image mode.
;
MOVW T.STS(A5), D6 ; Get terminal status flags.
ANDW #T$IMI, D6 ; Image mode?
BEQ INPUTX ; No - no translation.
IF NE,FDISCA
; Check for function key terminator
;
MOV T.IMP(A5), A6 ; Index impure area.
TSTW @A6 ; Terminator send in progress?
BNE INPC3 ; Yes - discard terminator.
ENDC
AND #177, D1 ; Ignore parity.
CMPB D1, #FLEADI ; Function key leadin?
BEQ DELAY ; Yes - pause to let in code.
; Discard commands go here
;
CMPB T.LCH(A5), #FLEADI ; Last input function key leadin?
BNE INPUTX ; No - no translation.
TST T.ICC(A5) ; Input waiting?
BEQ INPUTX ; No - lost function key.
LEA A6, XLAT ; Get translation table.
INPC1: TSTB @A6 ; End of table?
BEQ INPUTX ; Yes - nonsupported function.
CMPB D1,(A6)+ ; This function?
BEQ INPC2 ; Yes - translate it.
ADD #1, A6 ; No - move to next one.
BR INPC1
INPC2: MOVB @A6, D1 ; Set the proper code.
SUB #1, T.ICC(A5) ; Fool system into discarding leadin.
IF NE,FDISCA
MOV T.IMP(A5), A6 ; Index impure area.
MOVW #FDISCA, @A6 ; Set terminator character count.
ENDC
IF EQ,FLEADI-33
SUB #1, T.BCC(A5) ; If escape, bump break char count.
ENDC
BR INPUTX ; All done.
IF NE,FDISCA
INPC3: MOV T.IMP(A5), A6 ; Index impure area.
SUBW #1, @A6 ; Decrement terminator char count.
ENDC
DISCAR: CLRB D1 ; Discard char.
DELAY: MOV #DELAYC, D6
DLY: SOB D6, DLY ; Stall until code comes in.
ENDC
; All done. Restore registers and return.
;
INPUTX: REST D6,A6 ; Restore registers.
RTN ; Return to caller.
ENDC
IF NE,NULLS!FFNULL
PAGE
;********************
;* OUTPUT *
;********************
; Check for required delays and append nulls if so.
;
; Passed:
;
; D1 := Output character.
;
OUTPUT: SAVE A3 ; Save registers.
IF NE,NULLS
; Output nulls after line feed?
;
CMPB D1, #12 ; Output nulls after LF?
BNE 10$ ; No.
LEA A3, T.OQX(A5) ; Index output queue.
QINS A3 ; Insert queue block.
MOV #NULLS, 4(A3) ; Set null count.
10$: LCC #PS.N ; Signal to handle normally.
ENDC
IF NE,FFNULL
; Output nulls after form feed?
;
CMPB D1, #14 ; Output nulls after FF?
BNE 20$ ; No.
LEA A3, T.OQX(A5) ; Index output queue.
QINS A3 ; Insert queue block.
MOV #NULLS, 4(A3) ; Set null count.
20$: LCC #PS.N ; Signal we did something.
ENDC
; All done. Restore registers and return. Pass condition codes back to
; caller to indicate whether or not anything happened.
;
OUTPTX: REST A3 ; Restore registers.
RTN ; Return to caller.
;****************
; POSCUR *
;****************
; Special CRT control processing.
; If D1 is positive we have screen position (row in high, column in low byte)
; else we have the special command in the low byte.
;
; Passed:
;
; D1 := Cursor position.
;
POSCUR: SAVE D1,D3,A0,A2 ; Save regies.
TSTW D1 ; Is it cursor position?
BMI TCRTS ; No - special command.
LEA A0, CURPOS ; Index cursor positioning command.
CLR D3 ; Clear character count.
MOV T.IMP(A5), A2 ; Index the impure area.
IF NE,FDISCA
ADD #2, A2 ; Bypass function key translation flag.
ENDC
10$: ADD #1, D3 ; Bump counter.
MOVB (A0)+, (A2)+ ; Move bytes.
TSTB @A0 ; All done?
BNE 10$ ; No.
IF NE,OFFSET
ADD #<OFFSET_8.>+<OFFSET&377>, D1 ; Adjust positional offsets.
ENDC
OR #100200, D1 ; Prevent control code conversions.
IF EQ,ROW
RORW D1, #8. ; Send row first.
ENDC
MOVB D1, (A2)+ ; Set first position.
RORW D1, #8. ; Index high byte.
MOVB D1, (A2)+ ; Set second position.
ADD #2, D3 ; Bump count.
MOV T.IMP(A5), A2 ; Set character index.
IF NE,FDISCA
ADD #2, A2 ; Bypass function key translation flag.
ENDC
TBUF ; Send position sequence.
IF NE,SNOOZE
MOVB CURPOS+1, D6 ; Get cursor position code.
CMPB D6, #200 ; Nulls after cursor position?
BHIS TCRTZ ; Yes, go sleepy-bye.
ENDC
BR TCRTX ; All done.
; Special commands - D1 contains the command code in the low byte
;
TCRTS: AND #377, D1 ; Strip the high byte.
LEA A2,CRCA ; Index AM table
CMP D1, #CRCB-CRCA ; Check for valid code
BLOS 1$ ; Valid code in AM range (<64.)
LEA A2,CRCB ; Index user code section
SUBB #100, D1 ; See if user code (>=64.)
CMP D1, #CRCC-CRCB ; Within user range?
BHI TCRTX ; Bypass if bad.
1$: ADDW D1, A2 ; Add command code.
CLR D1 ; Preclear D1.
MOVB @A2, D1 ; Pick up data field offset.
ADD D1, A2 ; Make absolute data address.
TTYL @A2 ; Print the data field.
IF NE,SNOOZE
2$: CMPB (A2)+,#0 ; Fix AM bug - TTYL doesn't update
BNE 2$ ; A2 to point to null (inferential
CMPB (A2),#200 ; evidence only)
; CMPB 1(A2), #200 ; Sleep if long command.
BLO TCRTX
TCRTZ: SLEEP #SNOOZE ; Sleep long enough for command to finish.
ENDC
; All done, restore registers and return.
;
TCRTX: REST D1,D3,A0,A2 ; Restore registers.
RTN ; Return to caller.
PAGE
;****************
; ECH *
;****************
; Special echo processing
; Rubouts will backspace and erase the previous character
; Control-U will erase the entire line by backspacing and erasing
;
; Passed:
;
; D1 := Character to echo.
; D6 := Previous input character.
;
ECH: SAVE D1-D4,D6,D7,A2,A6 ; Save registers.
; Rubouts are handled by the old backspace-and-erase game
; D3 contains the character being rubbed out
;
DELCHR: CMPB D6, #11 ; Was it a TAB?
BEQ RBTB ; Yes - rub it out.
; Rubout was of a printable character - queue up the backspace sequence
;
KRTG: MOV #3, D3 ; Set char count.
LEA A6, ERUB ; Get buffer address.
MOV A6, D1 ; Set index.
TRMBFQ ; Queue the backspace sequence.
JMP ECHX ; All done.
; Rubout was of a tab - we must calculate how big the tab was and backup over it
;
RBTB: CLR D4 ; Preclear.
MOVW T.POB(A5), D4 ; Set beginning position count.
MOV T.ICC(A5), D2 ; Set input char count.
MOV T.IBF(A5), A3 ; Set input buffer base.
KRTS: SUB #1, D2 ; Done with scan?
BMI KRTQ ; Yes - output backspaces.
MOVB (A3)+, D1 ; Scan forward calculating position.
CMPB D1, #11 ; TAB?
BEQ KRTT ; Yes.
CMPB D1, #15 ; CR?
BEQ KRTC ; Yes.
CMPB D1, #33 ; ALTMODE (ESCAPE)?
BEQ KRTI ; Yes.
CMPB D1, #40 ; CONTROL-CHAR?
BLO KRTS ; Yes.
CMPB D1, #176 ; Check high end...
BHI KRTS ; Yes, unprintable character.
KRTI: ADD #1, D4 ; Increment position for one char.
BR KRTS
KRTT: ADD #10, D4 ; Adjust position for TAB.
AND #^C<7>, D4
BR KRTS
KRTC: CLR D4 ; Clear position for CR.
BR KRTS
KRTQ: COM D4 ; Calculate necessary backspaces.
AND #7, D4
ADD #1, D4
MOV D4, D3 ; Set char count.
MOV #10, D1 ; Set immediate backspace char.
TRMBFQ ; Queue the backspaces.
BR ECHX ; All done.
; Handle control-U.
;
CTRLU: TST D6 ; No action if nothing to erase.
BEQ ECHX
CLR D3 ; Preclear.
MOVW T.POO(A5), D3 ; Get current output position.
CLR D4 ; Preclear.
MOVW T.POB(A5), D4 ; Get beginning output position.
SUB D4, D3 ; Calculate spaces/backspaces needed.
BEQ ECHX ; None.
CMP D3, T.ILS(A5) ; Insure not greater than terminal width.
BLOS 10$
MOV T.ILS(A5), D3
10$: MOV #10, D1 ; Queue up backspaces.
TRMBFQ ; Do it.
MOV #32., D1 ; Queue up spaces.
TRMBFQ ; Do it.
MOV #10, D1 ; Queue up backspaces.
TRMBFQ ; Do it.
; All done. Restore registers and return.
;
ECHX: REST D1-D4,D6,D7,A2,A6 ; Restore registers.
RTN ; Return to caller.