;**************************************************************************; ; ; ; WYSE 350 TERMINAL DRIVER ; ; ; ;**************************************************************************; SEARCH SYS SEARCH SYSSYM SEARCH TRM OBJNAM 0,0,[TDV] CTRL$B = 2. CTRL$C = 3. CTRL$D = 4. CTRL$F = 6. CTRL$H = 8. CTRL$I = 9. CTRL$J = 10. CTRL$K = 11. CTRL$L = 12. CTRL$M = 13. CTRL$Q = 17. CTRL$R = 18. CTRL$T = 20. CTRL$U = 21. CTRL$V = 22. CTRL$X = 24. CTRL$Z = 26. ESC = 27. SPACE = 32. DQUOTE = 34. SQUOTE = 39. COMMA = 44. SEMIC = 59. GRAVE = 96. TILDE =126. DELETE =127. HEXCONV = '@-'9 HIBIT = ^H80 ;Define capability flags ; TDVFLG=TD$SMT!TD$132!TD$LID!TD$CID!TD$RVA!TD$DIM!TD$BLN!TD$UND!TD$EOS!TD$EOL TDVFLG=TDVFLG!TD$SPL!TD$MLT ;******************** ;* WY350 * ;******************** ;Terminal driver communications area WY350: WORD TD$NEW!TD$TCH ; terminal attributes BR JMPINP ; input routine br JMPOUT ; output routine BR ECHO ; echo routine BR JMPCRT ; crt control BR JMPINI ; INIT routine WORD 4. ; impure area 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 JMPOUT: JMP OUT ; go handle output chars JMPCRT: JMP CRT ; go handle TCRT codes JMPINI: JMP INI ; go init terminal 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 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: 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 ;***************** ; XLTTBL * ;***************** ;Translation table XLTTBL: BYTE 000,000 page ;****************** ; OUT * ;****************** OUT: cmpb d1,#^H0FF beq OUT$NO lcc #PS.N rtn OUT$NO: lcc #PS.Z 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 #MSG80E-MSG80,D3 ; 80 column screen LEA A6,MSG80 MOV A6,D1 TRMBFQ SLEEP #2500. ; adjust time MOV #MSGNE-MSGNOR,D3 ; normal screen LEA A6,MSGNOR MOV A6,D1 TRMBFQ SLEEP #2500. ; adjust time MOV #MSG1E-MSG1B,D3 ;LENGTH OF STRING LEA A6,MSG1B ;ADDRESS OF STRING MOV A6,D1 TRMBFQ ;OUTPUT STRING REST D1,D2 ; restore registers 5$: MOV T.IMP(A5),A6 ; Get impure area MOVW #80.,@A6 ; Initialize to 80 columns RTN ; return to caller [106] MSG80: BYTE ESC,'`,':,0 ; 80 column mode MSG80E: MSGNOR: BYTE ESC,'x,'0,0 ; set normal display format MSGNE: MSG1B: BYTE ESC,'A,'2,'8 ; top line left BYTE ESC,'A,'3,'4 ; top line right BYTE ESC,'F ; clear top message line BYTE 'W,'Y,'3,'5,'0,'I,CTRL$M BYTE ESC,'A,'1,'p ; bottom message line BYTE ESC,'z,'(,CTRL$M ; clear unshifted message line BYTE ESC,'z,'),CTRL$M ; clear shifted message line MSG1E: 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 CLR D6 ; preclear register MOVB ROWCNT(A2),D6 ; Get row count MOVW D6,TC.ROW(A1) ; transfer row count MOV JOBCUR,A6 ; index job MOV JOBTRM(A6),A6 ; index terminal control area MOV T.IMP(A6),A6 ; index impure area MOVW @A6,D6 ; get column count TSTW D6 ; if zero, assume 80 BNE 30$ MOVW #80.,D6 30$: MOVW D6,TC.COL(A1) ; transfer column count CMPW D6,#132. ; 132 or 80 columns? BEQ 40$ MOVW #46.,TC.TSL(A1) ; set length of top status line [108] MOVW #78.,TC.SSL(A1) ; set length of shifted status line [108] MOVW #78.,TC.USL(A1) ; set length of unshifted status line [108] BR 50$ 40$: MOVW #98.,TC.TSL(A1) ; set length of top status line [108] MOVW #130.,TC.SSL(A1) ; set length of shifted status line [108] MOVW #130.,TC.USL(A1) ; set length of unshifted status line [108] 50$: CLRW TC.CLR(A1) ; no colors 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 ; Define feature bitmap TCHBMP: BYTE ^B11111111 ; 0 - 7 BYTE ^B11111111 ; 8 - 15 BYTE ^B11111111 ; 16 - 23 BYTE ^B11111001 ; 24 - 31 (no horiz or vertical pos) BYTE ^B11111111 ; 32 - 39 BYTE ^B11111111 ; 40 - 47 BYTE ^B00111111 ; 48 - 55 BYTE ^B01110011 ; 56 - 63 BYTE ^B11111111 ; 64 - 71 BYTE ^B01111111 ; 72 - 79 BYTE ^B00000011 ; 80 - 87 (no alternate page ) BYTE ^B10000000 ; 88 - 95 (no smooth scroll) BYTE ^B11111111 ; 96 - 103 BYTE ^B00000011 ; 104 - 111 (no non-space attributes) BYTE ^B00000000 ; 112 - 119 (no non-space attributes) BYTE ^B00001111 ; 120 - 127 (cursor blink & steady) BYTE ^B00001111 ; 128 - 135 (top status line ) BYTE ^B00000000 ; 136 - 143 (no AM-70 style color) BYTE ^B00000000 ; 144 - 151 BYTE ^B00000000 ; 152 - 159 BYTE ^B00000000 ; 160 - 167 BYTE ^B00000000 ; 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? JMI CRTS ; no - CMPB D1,#94. ; Greater than column 94? BHI POS132 ; Yes, use the expanded positioner. TTYI ; send position command BYTE ^O233,^O75,0,0 ADDW #^O17437,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 ; ; 132 column cursor positioning ; Cursor positioning - D1 contains x,y coordinates ; POS132: PUSH D2 TTYI ; output sequence ESC a rr R ccc C BYTE ^O233,'a,0,0 ; send ESC a & force even MOV D1,D2 ; save row and col CLR D1 ; clear D1 RORW D2,#8. ; get row to low byte MOVB D2,D1 ; get byte to D1 CMPB D1,#24. ; test against row 24 BLOS 1$ MOVB #24.,D1 ; if larger than row 24 make it 24 1$: DCVT 0,OT$TRM ; output ASCII to terminal TYPE R CLR D1 ; clear D1 ROLW D2,#8. ; get row to low byte MOVB D2,D1 ; get byte to D1 DCVT 0,OT$TRM ; output ASCII to terminal TYPE C POP D2 ; restore D2 RTN ;Special commands - D1 contains the command code in the low byte CRTS: CMPW D1,#177400 ; make sure it's -1 JLO CRTCOL 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,'*,0 EVEN CRTZ: RTN ;Set terminal to wide format CRTWID: TTYI BYTE 33,'`,';,0 EVEN MOV #132.,D1 ; get new width WIDSET: MOV T.IMP(A5),A6 ; index impure area MOVW D1,@A6 ; store the new width SLEEP #2500. ; Give the terminal a while to adjust RTN ;Set terminal to normal format CRTNOR: TTYI BYTE 33,'`,':,0 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 BYTE ^H12,0 ; Printer port on command. [103] EVEN PRTDUN: SLEEP #5000. ; pause while command completes. [103] RTN ; Turn printer port off and wait the same as when turning it on. ; PRTOFF: SLEEP #10000. TTYI BYTE ^H14,0 ; Printer port off command. [103] EVEN ; SLEEP #10000. RTN ;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 CRTCOL: RTN ; don't handle this 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 C22,C32,C22,C34,C22,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 C22,C102,C22,C104,C22,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,C130,C131,C134,C135,C136,C137,C138,C139,C140 OFFTAB C141,C142,C143,C144,C145,C146,C147 CRCB: PAGE C1: BYTE ESC,'{,0 ; cursor home C2: BYTE HIBIT!CTRL$M,0 ; Cursor return C3: BYTE CTRL$K,0 ; cursor up C4: BYTE CTRL$V,0 ; cursor down C5: BYTE CTRL$H,0 ; cursor left C6: BYTE CTRL$L,0 ; cursor right C7: BYTE ESC,'#,0 ; lock keyboard C8: BYTE ESC,DQUOTE,0 ; unlock keyboard C9: BYTE ESC,'t,0 ; erase to end of line C10: BYTE ESC,'y,0 ; erase to end of screen C11: BYTE ESC,'),0 ; protect field (dim mode) C12: BYTE ESC,'(,0 ; unprotect field (normal mode) C13: BYTE ESC,'&,0 ; enable protection of fields C14: BYTE ESC,SQUOTE,0 ; disable protection of fields C15: BYTE ESC,'R,0 ; delete line C16: BYTE ESC,'E,0 ; insert line C17: BYTE ESC,'W,0 ; delete char C18: BYTE ESC,'Q,0 ; insert char C19: BYTE ESC,'?,0 ; read cursor address C20: BYTE ESC,'M,0 ; read char at cursor address C21: BYTE ESC,'G,'p,0 ; BLI C22: BYTE ESC,'G,'0,0 ; STOP C23: BYTE ESC,'H,CTRL$B,0 ; start line draw C24: BYTE ESC,'H,CTRL$C,0 ; end line draw C25: ; set horizontal position (obsolete) C26: BYTE 0 ; set vertical position (obsolete) C27: BYTE ESC,'A,0 ; set terminal attributes C28: BYTE ESC,GRAVE,'1,0 ; turn cursor on C29: BYTE ESC,GRAVE,'0,0 ; turn cursor off C30: BYTE ESC,'G,'8,0 ; UND X31: ; STOP C32: BYTE ESC,'G,'4,0 ; REV X33: ; STOP C34: BYTE ESC,'G,'t,0 ; REV BLI X35: ; STOP C36: BYTE ESC,GRAVE,'8,0 ; turn off screen display C37: BYTE ESC,GRAVE,'9,0 ; turn on screen display C38: BYTE '2,0 ; top left corner C39: BYTE '3,0 ; top right corner C40: BYTE '1,0 ; bottom left corner C41: BYTE '5,0 ; bottom right corner C42: BYTE '0,0 ; top intersect C43: BYTE '9,0 ; right intersect C44: BYTE '4,0 ; left intersect C45: BYTE '=,0 ; bottom intersect C46: BYTE ':,0 ; horizontal line C47: BYTE '6,0 ; vertical line C48: BYTE '8,0 ; intersection C49: BYTE '7,0 ; solid block C50: BYTE '?,0 ; slant block C51: BYTE SEMIC,0 ; cross-hatch block C52: BYTE '<,0 ; double line horizontal C53: BYTE '>,0 ; double line vertical C54: ; function key line C55: BYTE 0 ; shifted function key line C56: BYTE ESC,'x,'0,0 ; set normal display format C57: BYTE ESC,'x,'1,0 ; set horizontal split (follow with row code) C58: ; set vertical split (39 char columns) C59: ; set vertical split (40 char columns) C60: BYTE 0 ; set vertical split column to next char C61: BYTE ESC,'],0 ; activate split segment 0 C62: BYTE ESC,'},0 ; activate split segment 1 C63: ; TOP STATUS LINE C64: ; up-arrow C65: BYTE 0 ; down-arrow C66: BYTE '.,0 ; raised dot C67: ; end of line marker C68: ; horizontal tab symbol C69: ; paragraph C70: ; dagger C71: ; section C72: ; cent sign C73: ; one-quarter C74: ; one-half C75: ; degree C76: ; trademark C77: ; copyright C78: ; registered C79: BYTE 0 ; PRINT SCREEN C80: BYTE ESC,GRAVE,SEMIC,0 ; 132 C81: BYTE ESC,GRAVE,':,0 ; 80 C82: ; 082 - 087 RESERVED FOR PAGE STUFF C83: C84: C85: C86: C87: C88: ; 088 - 094 RESERVED FOR COLUMN/BOX C89: C90: C91: C92: C93: C94: BYTE 0 C95: BYTE ESC,GRAVE,'@,0 ; JUMP SCROLL C96: BYTE ESC,GRAVE,'?,0 ; FAST SMOOTH SCROLL C97: BYTE ESC,GRAVE,'>,0 ; MED-FAST SMOOTH SCROLL C98: BYTE ESC,GRAVE,'=,0 ; MED-SLOW SMOOTH SCROLL C99: BYTE ESC,GRAVE,'<,0 ; SLOW SMOOTH SCROLL C100: BYTE ESC,'G,'x,0 ; UND BLI X101: ; STOP C102: BYTE ESC,'G,'<,0 ; UND REV X103: ; STOP C104: BYTE ESC,'G,'|,0 ; UND REV BLI X105: ; STOP C106: ; 106 - 119 RESERVED FOR W/O SPACE ATTRS C107: C108: C109: C110: C111: C112: C113: C114: C115: C116: C117: C118: C119: BYTE 0 C120: BYTE ESC,GRAVE,'5,0 ; CURSOR BLINKING BLOCK C121: BYTE ESC,GRAVE,'2,0 ; CURSOR STEADY BLOCK C122: BYTE ESC,GRAVE,'3,0 ; CURSOR BLINKING LINE C123: BYTE ESC,GRAVE,'4,0 ; CURSOR STEADY LINE C124: ; 124 - 127 RESERVED C125: C126: C127: BYTE 0 C128: BYTE ESC,'F,0 ; START TOP LINE MESSAGE C129: BYTE HIBIT!CTRL$M,0 ; STOP MESSAGE C130: BYTE ESC,'z,'(,0 ; START BOTTOM LINE MESSAGE C131: BYTE ESC,'z,'),0 ; START SHIFTED LINE MESSAGE C132: ; 132 - 147 RESERVED FOR COLOR C133: C134: C135: C136: C137: C138: C139: C140: C141: C142: C143: C144: C145: C146: C147: BYTE 0 C148: ; 148 - 255 RESERVED EVEN END .