;***************************************************************************;
; ;
; Hazeltine 15XX Terminal Driver ;
; ;
; Author: David F. Pallmann ;
; Copyright (C) 1983 by LMS Technical Services, Inc. ;
; ;
;***************************************************************************;
;* this driver supports SuperVUE
;* DEL/underscore has case swapped for model 1500 to avoid shifted-DELetes
NVALU MODEL
IF LT,MODEL-1500,ASMERP ?specify /V:model
IF EQ,MODEL-1500,OBJNAM HZ1500.TDV
IF EQ,MODEL-1510,OBJNAM HZ1510.TDV
IF EQ,MODEL-1520,OBJNAM HZ1520.TDV
;universals
SEARCH SYS
SEARCH SYSSYM
SEARCH TRM
LI=126. ;lead-in code (tilde)
;ASCII chars
BS=10
LF=12
CR=15
;HZ15XX
;Terminal driver communications area
HZ15XX: WORD TD$NEW ;terminal attributes
BR JMPINP ;input routine
RTN ;output routine
BR ECHO ;echo routine
BR JMPCRT ;crt control
RTN ;no init routine yet
WORD 0 ;no impure area yet
BYTE 24. ;number of rows
BYTE 80. ;number of columns
LWORD TD$LID!TD$DIM!TD$EOL!TD$EOS
;ECHO
;Special echo processing is performed here.
;DEL will backspace and erase the previous character.
;^U will erase the entire line by backspacing and erasing.
;DELs are handled by the old backspace-and-erase game.
;Special handling must be performed if we are deleting a <TAB>.
;D6 contains the character being deleted.
RUBOUT: CMPB D6,#'I-'@ ;was it a tab?
BEQ RBTB ; yes
;DEL 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
;DEL was of a <TAB> - 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 character
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: AND #177,D1 ;strip char to 7 bits
;model 1500s swap case on DEL/underscore key
IF EQ,MODEL-1500
CMPB D1,#'_ ;underscore?
BEQ 100$ ; yes - swap case
CMPB D1,#177 ;del?
BNE 110$ ; no
100$: XORB #40,D1 ;swap case bit
ENDC
110$: LCC #0
RTN
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).
;If D1 is negative we have the special command in the low byte.
CRT: TSTW D1 ;is it cursor position?
BMI CRTS ; no
;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 LI,28.,0
EVEN
;output some <NUL>s after screen-oriented functions
CRTZ: MOV #45.,D0
CLR D1
10$: TTY
SOB D0,10$
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),#100 ;sleep if erase command
BHI CRTXZ
CRTX: POP A2 ;restore A2
RTN
CRTXZ: POP A2 ;restore A2
BR CRTZ ; and go output nulls
;Byte offset and data tables follow for all commands
CRCA: WORD C1-.,C2-.,C3-.,C4-.,C5-.,C6-.,C7-.,C8-.
WORD C9-.,C10-.,C11-.,C12-.,C13-.,C14-.,C15-.,C16-.
WORD C17-.,C18-.,C19-.,C20-.,C21-.,C22-.,C23-.,C24-.
WORD C25-.,C26-.,C27-.,C28-.,C29-.,C30-.,C31-.,C32-.
WORD C33-.