; VT102 terminal driver that supports 80 & 132 columns
; Added compatibility for alpha function keys & VT cursor keys
; changes 233's to 33 to make it work with TELIX's VT102 driver
; changed xy =1 to use CUB to move to column 1 for 2.2 compatibility
; updated graphics characters support, only added to feature bitmap when 100%
; compatible.
; added concurrent printing support TCRTs 173,174 8/4/93 rpr

       SEARCH  SYS
       SEARCH  SYSSYM
       SEARCH  TRM

       OBJNAM  .TDV

               TD$VRC=400000000        ;       has variable row count          [152]
               TD$PRO=200000000        ;       has proportional spacing        [152]
               TD$GRY=100000000        ;       has grayscale capability        [152]
               TD$GRA=40000000         ;       has true graphics capability
               TD$NSP=20000000         ;       has "no space" attributes       [137]
               TD$PHR=10000000         ;       has Phineas T. Phart color mode [137]
               TD$MOD=4000000          ;       has "mode" attributes           [137]


;Define capability flags
; VT102 does not have:
;TD$SPL - split screen
;TD$AMS - not an Alpha Micro terminal
;TD$KID - column insert/delete
;TD$SMT,TD$BOX!TD$BLF - smooth scroll,box commands, block fill
;TD$STS no status line
;
TDVFLG=TD$LID!TD$CID!TD$RVA!TD$DIM!TD$BLN!TD$UND!TD$EOS!TD$EOL!TD$MLT
TDVFLG=TDVFLG!TD$PRT!TD$132!TD$MOD!TD$NSP

DEFINE  ANSI    A,B,C,D,E,F,G,H,I       ;
       BYTE    33,'[                   ; do ANSI CSI
       IF      NB,A,BYTE       A
       IF      NB,B,BYTE       B
       IF      NB,C,BYTE       C
       IF      NB,D,BYTE       D
       IF      NB,E,BYTE       E
       IF      NB,F,BYTE       F
       IF      NB,G,BYTE       G
       IF      NB,H,BYTE       H
       IF      NB,I,BYTE       I
       BYTE    0
       ENDM

DEFINE  SANSI   A,B,C,D,E,F,G,H,I       ;
       BYTE    40,33,'[                        ; do space, then ANSI CSI
       IF      NB,A,BYTE       A
       IF      NB,B,BYTE       B
       IF      NB,C,BYTE       C
       IF      NB,D,BYTE       D
       IF      NB,E,BYTE       E
       IF      NB,F,BYTE       F
       IF      NB,G,BYTE       G
       IF      NB,H,BYTE       H
       IF      NB,I,BYTE       I
       BYTE    0
       ENDM

DEFINE  ANSIS   A,B,C,D,E,F,G,H,I       ;
       BYTE    33,'[                   ; do ANSI CSI
       IF      NB,A,BYTE       A
       IF      NB,B,BYTE       B
       IF      NB,C,BYTE       C
       IF      NB,D,BYTE       D
       IF      NB,E,BYTE       E
       IF      NB,F,BYTE       F
       IF      NB,G,BYTE       G
       IF      NB,H,BYTE       H
       IF      NB,I,BYTE       I
       BYTE    40,0
       ENDM

DEFINE  ANSINT  A,B,C,D,E,F,G,H,I       ;  no termination
       BYTE    33,'[                   ; do ANSI CSI
       IF      NB,A,BYTE       A
       IF      NB,B,BYTE       B
       IF      NB,C,BYTE       C
       IF      NB,D,BYTE       D
       IF      NB,E,BYTE       E
       IF      NB,F,BYTE       F
       IF      NB,G,BYTE       G
       IF      NB,H,BYTE       H
       IF      NB,I,BYTE       I
       ENDM

;********************
;*      VT102       *
;********************
;Terminal driver communications area
VT102:  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 one word (2 bytes)
ROWCNT: BYTE    24.                     ; number of rows
       BYTE    80.                     ; number of columns
       LWORD   TDVFLG                  ; terminal flags
       BR      JMPTCH                  ; entry for TRMCHR

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, was it a control char. ?        [106]
       BLO     RBX                     ;    yes -                              [106][107]
;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                             ;                                       [106]


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
       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:
; determine if sequnce is alpha-type function key (total of 2 bytes), or
; VT-style CSI sequnce (3 characters)
       CMPB    D0,#3                   ; 3 characters means VT-type
       BLO     30$                     ; process VT-type command
; could process VT220 keys here, maybe later!
;;      BEQ     10$
;;      CMPB    D0,#5
;;      MOVB    2(A0),D1
;;      CMPB    D1,#'1
; Handle 3 byte  CSI sequences here
10$:    MOVB    2(A0),D1                ; pick up last character of sequence
       ANDB    #^B01111111,D1          ; strip to ASCII
       BR      INMNOT                  ; and translate to single character.


; handle single keypresses
30$:    MOVB    (A0)+,D1                ; get the first character
       DECB    D0                      ;  count down remaining
       BEQ     INMX                    ;   none remain - done.
       MOVB    D1,D7                   ; store 1st character in D7
       ANDB    #^B01111111,D7          ; strip to ASCII
       MOVB    (A0)+,D1                ; get the second character
       ANDB    #^B01111111,D1          ; strip to ASCII
       CMPB    D7,#1                   ; started with SOH?
       BNE     50$                     ;   no, must of started with ESCAPE
       SUBB    #'@,D1                  ;   yes, SOH, so xlate F1 to "0"
50$:    ORB     #200,D1                 ; set bit 7 on to flag it's a function
       BIT     #T$XLT,@A5              ; are we doing translation?
       BEQ     INMNOT                  ;   no - check for another translation
INMX:   LCC     #0                      ; reset the flags
INMX2:  RTN



;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

;Translation table
XLTTBL: BYTE    'A,'K&37                ; up arrow
       BYTE    'B,'J&37                ; down arrow
       BYTE    'C,'L&37                ; right arrow
       BYTE    'D,'H&37                ; left arrow
       BYTE    'H,^O36                 ; home
       BYTE    'P,181.                 ; PF1 => F1
       BYTE    'Q,180.                 ; PF2 => F2
       BYTE    'R,211.                 ; PF3 => F3
       BYTE    'S,192.                 ; PF4 => F4
       BYTE    000,000


PAGE
;********************
;*      INI         *
;********************
;Handle initialization of the terminal
INI:    MOV     T.IDV(A5),A6            ; index the interface driver            [106]
       MOV     T.IMP(A5),A6            ; index impure area
       MOVW    #80.,@A6                ; preset to 80 columns
; do some free advertising
       MOV     T.IDV(A5),A6
       CMP     -4(A6),#[PSE]_16.![UDO]
       BEQ     100$                    ; don't use with pseudo IDVs
       CMP     QFREE,#20.              ; we have queue blocks?
       BLO     100$
       SAVE    D1,D3
       PEA     INISTR
       POP     D1
       MOV     #INISZ,D3
       TRMBFQ
       SLEEP   #2500.
       PEA     INIST2
       POP     D1
       MOV     #INIS2,D3
       TRMBFQ
       REST    D1,D3
100$:   RTN

INISTR:
       ANSINT  '4,'i                   ; Printer controller off
       ANSINT  'H                      ; home cursor (shorthand)
       ANSINT  'J                      ; clear screen
       ANSINT  '0,'m                   ; normal intensity
       BYTE    33,'(,'B                ; end line drawing mode (disable alternate character set)
       ANSINT  '?,'3,'l                ; set 80 column mode
INISZ=.-INISTR

INIST2:
       BYTE    33,'#,'3                ; double high top
       ASCII   "Soft Machines VT-102 driver"
       BYTE    15,12
       BYTE    33,'#,'4                ; double high bottom
       ASCII   "Soft Machines VT-102 driver"
       BYTE    15,12
       BYTE    33,'#,'5                ; single width
INIS2=.-INIST2
       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
       MOVW    @A6,TC.COL(A1)          ; transfer column count
       CLRW    TC.CLR(A1)              ; no colors
       MOVW    #00.,TC.TSL(A1)         ; set length of top status line         [104]
       MOVW    #00.,TC.SSL(A1)         ; set length of shifted status line     [104]
       MOVW    #00.,TC.USL(A1)         ; set length of unshifted status line   [104]
       MOV     D2,D7                   ; get TRMCHR argument flags             [104]
       AND     #TC$BMP,D7              ; does user want bitmap?                [104]
       BEQ     20$                     ;   no - skip bitmap transfer code      [104]
;User has requested bitmap -- return it to him                                  [104]
       PUSH    A1                      ; save argument block index             [104]
       ADDW    #TC.BMP,A1              ; index bitmap return area              [104]
       LEA     A6,TCHBMP               ; index our bitmap                      [104]
       MOV     #<256./16.>-1,D7        ; get amount to transfer                [104]
10$:    MOVW    (A6)+,(A1)+             ; transfer to user                      [104]
       DBF     D7,10$                  ; loop until done                       [104]
       POP     A1                      ; restore register                      [104]
20$:    RTN                             ; return to TRMCHR monitor routine      [104]

;Define feature bitmap                                                          [104]
; b i t s         76543210
TCHBMP: BYTE    ^B01111111              ; 0 - 7  -7
       BYTE    ^B10011110              ; 8 - 15 -8,13-14
       BYTE    ^B11101111              ; 16 - 23 -20
       BYTE    ^B11000001              ; 24 - 31 -25-29
       BYTE    ^B11001111              ; 32 - 39 -36-37
       BYTE    ^B11111111              ; 40 - 47
       BYTE    ^B00001011              ; 48 - 55 -50,52-55
       BYTE    ^B00000000              ; 56 - 63 -56-63
       BYTE    ^B00000100              ; 64 - 71 -64-65,67-71
       BYTE    ^B10001000              ; 72 - 79 -72-74,76-79
       BYTE    ^B00001111              ; 80 - 87 -84-87
       BYTE    ^B10000000              ; 88 - 95 -88-94
       BYTE    ^B11111000              ; 96 - 103 -96-98
       BYTE    ^B11111111              ; 104 - 111
       BYTE    ^B11111111              ; 112 - 119
       BYTE    ^B00000000              ; 120 - 127
       BYTE    ^B00000000              ; 128 - 135
       BYTE    ^B00000000              ; 136 - 143
       BYTE    ^B00000000              ; 144 - 151
       BYTE    ^B00000000              ; 152 - 159
       BYTE    ^B11111000              ; 160 - 167
       BYTE    ^B01111111              ; 168 - 175
       BYTE    ^B00000000              ; 176 - 183
       BYTE    ^B00000000              ; 184 - 191
       BYTE    ^B00000000              ; 192 - 199
       BYTE    ^B00000000              ; 200 - 207
       BYTE    ^B00000000              ; 208 - 215
       BYTE    ^B00000000              ; 216 - 223
       BYTE    ^B00000000              ; 224 - 231
       BYTE    ^B00000000              ; 232 - 239
       BYTE    ^B00000000              ; 240 - 247
       BYTE    ^B00000000              ; 248 - 255

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 -
       TTYI                            ; Send cursor position command.
       BYTE    33,'[,0                 ; do ANSI CSI
       EVEN
       PUSHW   D1                      ; save value
       CLR     D1                      ; pre-clear D1
       MOVB    1(SP),D1                ; get row
       DCVT    0,OT$TRM                ; output the row
       TYPE    <;>                     ; seperator
       MOVB    @SP,D1                  ; get column
       DCVT    0,OT$TRM                ; output the column
       TYPE    <H>                     ; finish with 'H
       POPW    D1
       RTN                             ; Return to caller.

;Special commands - D1 contains the command code in the low byte
CRTS:   CMPB    D1,#80.                 ; set to wide format?
       BEQ     CRTWID                  ;   yes - special handling
       CMPB    D1,#81.                 ; set to normal format?
       BEQ     CRTNOR                  ;   yes - special handling
;[103]
; Special handling of the printer port calls...
;
       CMPB    D1,#82.                 ; Turn on the printer port ?
       BEQ     PRTON                   ;  Yes.
       CMPB    D1,#83.                 ;  No. Turn port off ?
       BEQ     PRTOFF                  ;   Yes.
;
;
       AND     #377,D1                 ; strip the high byte
       BNE     CRTU                    ;   and branch unless clear screen
       TTYI                            ; special case for clear screen
       BYTE    33,'[                   ; do ANSI CSI
       BYTE    'H                      ; home cursor (shorthand)
       ANSI    'J                      ; clear entire display (shorthand)
       EVEN
CRTZ:   RTN

;Set terminal to wide format
CRTWID: TTYI
       ANSI    '?,'3,'h                ; set 132 column mode
       EVEN
       MOV     #132.,D1                ; get new width
WIDSET: MOV     T.IMP(A5),A6            ; index impure area
       MOVW    D1,@A6                  ; store the new width
       SLEEP   #5000.                  ; pause while command completes [108]
       RTN

;Set terminal to normal format
CRTNOR: TTYI
       ANSI    '?,'3,'l                ; set 80 column mode
       EVEN
       MOV     #80.,D1                 ; get the new width
       BR      WIDSET                  ; go store it
;[103]
;
; Code to handle the printer port on/off feature.
;  We must sleep after we either turn it on or off.
;
PRTON:  TTYI
       ANSI    '5,'i                   ; Printer controller on
       EVEN
PRTDUN: SLEEP   #5000.                  ; pause while command completes.        [103]
       RTN

; Turn printer port off and wait the same as when turning it on.
;
PRTOFF: TTYI
       ANSI    '4,'i                   ; Printer controller off
       EVEN                            ;
       BR      PRTDUN                  ; go store it                           [103]

;Command processing per director tables
CRTU:   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

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

;Byte offset and data tables follow for all commands
;
CRCA:   OFFTAB  C1,C2,C3,C4,C5,C6,C7,C8,C9,C10
       OFFTAB  C11,C12,C13,C14,C15,C16,C17,C18,C19,C20
       OFFTAB  C21,C22,C23,C24,C25,C26,C27,C28,C29,C30
       OFFTAB  C31,C32,C33,C34,C35,C36,C37,C38,C39,C40
       OFFTAB  C41,C42,C43,C44,C45,C46,C47,C48,C49,C50
       OFFTAB  C51,C52,C53,C54,C55,C56,C57,C58,C59,C60
       OFFTAB  C61,C62,C63,C64,C65,C66,C67,C68,C69,C70
       OFFTAB  C71,C72,C73,C74,C75,C76,C77,C78,C79,C80
       OFFTAB  C81,C82,C83,C84,C85,C86,C87,C88,C89,C90
       OFFTAB  C91,C92,C93,C94,C95,C96,C97,C98,C99,C100
       OFFTAB  C101,C102,C103,C104,C105,C106,C107,C108,C109,C110
       OFFTAB  C111,C112,C113,C114,C115,C116,C117,C118,C119,C120
       OFFTAB  C121,C122,C123,C124,C125,C126,C127,C128,C129,C130
       OFFTAB  C131,C132,C133,C134,C135,C136,C137,C138,C139,C140
       OFFTAB  C141,C142,C143,C144,C145,C146,C147,C148,C149,C150
       OFFTAB  C151,C152,C153,C154,C155,C156,C157,C158,C159,C160
       OFFTAB  C161,C162,C163,C164,C165,C166,C167,C168,C169,C170
       OFFTAB  C171,C172,C173,C174,C175,C176,C177,C178,C179,C180
       OFFTAB  C181,C182,C183,C184

CRCB:

PAGE
;CRT code tables
;

C1:     ANSI    'H                      ; cursor home (move to column 1,1)
C2:     ANSI    '1,'3,'2,'D             ; cursor return (move to column 1)
C3:     ANSI    'A                      ; cursor up
C4:     ANSI    'B                      ; cursor down
C5:     ANSI    'D                      ; cursor left
C6:     ANSI    'C                      ; cursor right
C7:                                     ; lock keyboard
C8:     BYTE    0                       ; unlock keyboard
C9:     ANSI    'K                      ; erase to end of line
C10:    ANSI    'J                      ; erase to end of screen
C11:    ANSI    '1,'m                   ; reduced intensity
C12:    ANSI    '0,'m                   ; normal intensity
C13:                                    ; enable protected  fields
C14:    BYTE    0                       ; disable protected fields
C15:    ANSI    'M                      ; delete line
C16:    ANSI    'L                      ; insert line
C17:    ANSI    'P                      ; delete character
C18:    ANSI    '4,'h,32.,33,'[,'4,'l   ; insert (a) character
C19:    ANSI    '6,'n                   ; read cursor address
C20:    BYTE    0                       ; read character at current cursor position
C21:    SANSI   '5,'m
; start blink field
C22:    ANSIS   '0,'m                   ; end blink field
C23:    BYTE    33,'(,'0,0              ; start line drawing mode (enable alternate character set)
C24:    BYTE    33,'(,'B,0              ; end line drawing mode (disable alternate character set)
C25:                                    ; set horizontal position
C26:                                    ; set vertical position
C27:                                    ; set terminal attributes
C28:                                    ; cursor on
C29:    BYTE    0                       ; cursor off
C30:    SANSI   '4,'m                   ; start underscore
C31:    ANSIS   '0,'m                   ; end underscore
C32:    SANSI   '7,'m                   ; start reverse video
C33:    ANSIS   '0,'m                   ; end reverse video
; doesn't work on WYSE60's VT100 emulation
C34:    SANSI   '4,^O73,'7,'m           ; start underscore; reverse
C35:    ANSIS   '0,'m                   ; end reverse blink
C36:                                    ; turn off screen display
C37:    BYTE    0                       ; turn on screen display
C38:    BYTE    'l,0                    ; top left corner
C39:    BYTE    'k,0                    ; top right corner
C40:    BYTE    'm,0                    ; bottom left corner
C41:    BYTE    'j,0                    ; bottom right corner
C42:    BYTE    'w,0                    ; top intersect
C43:    BYTE    'u,0                    ; right intersect
C44:    BYTE    't,0                    ; left intersect
C45:    BYTE    'v,0                    ; bottom intersect
C46:    BYTE    'q,0                    ; horizontal line
C47:    BYTE    'x,0                    ; vertical line
C48:    BYTE    'n,0                    ; intersection
C49:    BYTE    'a,0                    ; solid block
C50:    BYTE    'a,0                    ; slant block
C51:    BYTE    'a,0                    ; cross-hatch block
C52:    BYTE    '=,0                    ; double line horizontal
C53:    BYTE    'x,0                    ; double line vertical
C54:                                    ; send message to function key line
C55:    BYTE    0                       ; send message to shifted function key line
; leave 56 out - it causes WYSE60's to reset to power-on state!
;C56:   BYTE    33,'c,0                 ; reset to initial state
C56:
C57:                                    ; set horizontal split (follow with row code)
C58:                                    ; set vertical split (39 char columns)
C59:                                    ; set vertical split (40 char columns)
C60:                                    ; set vertical split column to next char
C61:                                    ; activate split segment 0
C62:                                    ; activate split segment 1
C63:    BYTE    0                       ; send message to host message field
C64:    BYTE    '^,0                    ; up-arrow
C65:    BYTE    'V,0                    ; down-arrow
C66:    BYTE    '~,0                    ; raised dot
C67:    BYTE    'h,0                    ; end of line marker
C68:    BYTE    'b,0                    ; horizontal tab symbol
C69:    BYTE    '{,0                    ; paragraph
C70:    BYTE    ' ,0                    ; dagger
C71:    BYTE    ' ,0                    ; section
C72:    BYTE    ' ,0                    ; cent sign
C73:    BYTE    ' ,0                    ; one-quarter
C74:    BYTE    ' ,0                    ; one-half
C75:    BYTE    'f,0                    ; degree
C76:    BYTE    ' ,0                    ; trademark
C77:    BYTE    ' ,0                    ; copyright
C78:    BYTE    ' ,0                    ; registered
C79:    ANSI    'i                      ; print screen
C80:                                    ; reserved for set to wide mode
C81:    BYTE    0                       ; reserved for set to normal mode
C82:    ANSI    '5,'i                   ; enter transparent print mode
C83:    ANSI    '4,'i                   ; exit transparent print mode
C84:                                    ; begin writing to alternate page
C85:                                    ; end writing to alternate page
C86:                                    ; toggle page
C87:                                    ; copy to alternate page
C88:                                    ; insert column
C89:                                    ; delete column
C90:                                    ; block fill with attribute
C91:                                    ; block fill with character
C92:                                    ; draw a box
C93:                                    ; scroll box up one line
C94:    BYTE    0                       ; scroll box down one line
C95:    ANSI    '?,'4,'l                ; select jump scroll
C96:    ANSI    '?,'4,'h                ; select fast smooth scroll
C97:    ANSI    '?,'4,'h                ; select med-fast smooth scroll
C98:    ANSI    '?,'4,'h                ; select med-slow smooth scroll
C99:    ANSI    '?,'4,'h                ; select slow smooth scroll
C100:   SANSI   '4,^O73,'5,'m           ; start underscore/blink
C101:   ANSIS   '0,'m                   ; end underscore/blink
C102:   SANSI   '4,^O73,'7,'m           ; start underscore/reverse
C103:   ANSIS   '0,'m                   ; end underscore/reverse
C104:   SANSI   '4,^O73,'7,^O73,'5,'m   ; start underscore/reverse/blink
C105:   ANSIS   '0,'m                   ; end underscore/reverse/blink
C106:   ANSI    '4,'m                   ; start underscore w/o space
C107:   ANSI    '0,'m                   ; end underscore w/o space
C108:   ANSI    '7,'m                   ; start reverse w/o space
C109:   ANSI    '0,'m                   ; end reverse w/o space
C110:   ANSI    '5,^O73,'7,'m           ; start reverse/blinking w/o space
C111:   ANSI    '0,'m                   ; end reverse/blinking w/o space
C112:   ANSI    '4,^O73,'5,'m           ; start underscore/blinking w/o space
C113:   ANSI    '0,'m                   ; end underscore/blinking w/o space
C114:   ANSI    '4,^O73,'7,'m           ; start underscore/reverse w/o space
C115:   ANSI    '0,'m                   ; end underscore/reverse w/o space
C116:   ANSI    '4,^O73,'7,^O73,'5,'m   ; start underscore/reverse/blink w/o space
C117:   ANSI    '0,'m                   ; end underscore/reverse/blink w/o space
C118:   ANSI    '5,'m                   ; start blink w/o space
C119:   ANSI    '0,'m                   ; end blink w/o space
C120:                                   ; set cursor to blinking block
C121:                                   ; set cursor to steady block
C122:                                   ; set cursor to blinking underline
C123:                                   ; set cursor to steady underline
C124:                                   ;   SPARE
C125:                                   ;   SPARE
C126:                                   ;   SPARE
C127:                                   ;   SPARE
C128:                                   ; select top status line w/o address
C129:                                   ; end status line                       [109]
C130:                                   ; select unshifted status line w/o addr
C131:                                   ; select shifted status line w/o addr
C132:                                   ; select black text
C133:                                   ; select white text
C134:                                   ; select blue text
C135:                                   ; select magenta text
C136:                                   ; select red text
C137:                                   ; select yellow text
C138:                                   ; select green text
C139:                                   ; select cyan text
C140:                                   ; select black reverse text
C141:                                   ; select white reverse text
C142:                                   ; select blue reverse text
C143:                                   ; select magenta reverse text
C144:                                   ; select red reverse text
C145:                                   ; select yellow reverse text
C146:                                   ; select green reverse text
C147:                                   ; select cyan reverse text
C148:                                   ; save section
C149:                                   ; restore section
C150:                                   ; select graphics mode
C151:                                   ; exit graphics mode
C152:                                   ; box w/ rounded corners
C153:                                   ; window box
C154:                                   ; double line box
C155:                                   ; enable bitmap font
C156:                                   ; disable bitmap font
C157:                                   ; select color pallette using RGB
C158:                                   ; enable graphics cursor
C159:                                   ; disable graphics cursor
C160:                                   ; set graphics cursor style
C161:                                   ; inquire graphics cursor position
C162:   BYTE    0                       ; set graphics cursor region
C163:   BYTE    'c                      ; formfeed character
C164:   BYTE    'e                      ; linefeed character
C165:   BYTE    'h                      ; newline character
C166:   BYTE    'i                      ; vertical tab character
C167:   BYTE    'g                      ; plus-or-minus character
C168:   BYTE    'z                      ; greater than or equal character
C169:   BYTE    'y                      ; less than or equal character
C170:   BYTE    '|                      ; not equal character
C171:   BYTE    '}                      ; british pound character
C172:   BYTE    '{                      ; pi character
C173:   BYTE    33,'^                   ; enable concurrent print
C174:   BYTE    33,'_                   ; disable concurrent print
C175:                                   ; set terminal clock
C176:                                   ; set terminal calendar
C177:                                   ; set color callet using HLS
C178:                                   ; select PC character set
C179:                                   ; select default character set
C180:                                   ; select PC emulation mode
C181:                                   ; select normal emulation mode
C182:                                   ; select aux interface port
C183:                                   ; select main interface port
C184:   BYTE    0                       ; toggle interface port

       EVEN

       END END END