home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / b / krterm.mac < prev    next >
Text File  |  2020-01-01  |  8KB  |  257 lines

  1.     .title    KRTERM    Packet I/O via TT
  2.     .ident    "V03.63"
  3.  
  4. ; /63/    27-Sep-97  Billy Youdelman  V03.63
  5. ;
  6. ;    use hi-efficiency print emt in T.BINWRITE under TSX
  7.  
  8. ; /62/    27-Jul-93  Billy Youdelman  V03.62
  9. ;
  10. ;    add support for RT-11 V4
  11.  
  12. ; /BBS/     1-Dec-91  Billy Youdelman  V03.61
  13. ;
  14. ;    this module has been extensively modified, please refer to it
  15. ;    added SET TT XON (TSX) emt to t.ttxon, uses tsxsav for lnum
  16. ;    add dummy routines for inqdtr, inqcd
  17. ;    ttyini - suspend TSX window processing, as in connect, packets
  18. ;    added support for vlflag under TSX+ to ttyini
  19. ;
  20. ;    drop TSX hi eff term mode and declare a list of activation chars
  21. ;    instead, allowing single char input (so packets can be longer
  22. ;    than TSX's internal I/O buffers) whilst offing ^B, ^T, ^W, etc
  23. ;    so line noise doesn't trigger various annoying things as when
  24. ;    using the server via TT, also allows passing to remote when in
  25. ;    the connect mode
  26.  
  27. ;    Copyright 1984 Change Software, Inc.
  28.  
  29.  
  30.     .include "IN:KRTMAC.MAC"
  31.     .iif ndf  KRTINC  .error    <; .include for IN:KRTMAC.MAC failed>
  32.  
  33. ; /62/    .PEEK,.POKE bypassed for V4, also expanded to allow assy under same
  34.  
  35.     .mcall    .GVAL    ,.RCTRLO,.TTINR    ,.TTYOUT,.TWAIT
  36.  
  37.  
  38.     $TCFIG    =    424        ; terminal configuration word
  39.         CRLF$    =    2    ; ignore width bit
  40.         PAGE$    =    200    ; /BBS/ SET TT [NO]PAGE bit
  41.  
  42.     .psect    $pdata
  43. ttime:    .word    0 ,1            ; a tick sleep for .twait
  44. w$suspen:.byte    3 ,161            ; /BBS/ suspend TSX window processing
  45.  
  46.     .psect    $rwdata    ,rw,d,lcl,rel,con
  47. xonemt:    .byte    1 ,154            ; /BBS/ TSX SET TT XON emt
  48. xonlin:    .byte    0 ,0            ; /BBS/ line_to_XON ,0
  49.     .word    0            ; /BBS/ speed (unused here)
  50. wrtemt:    .byte    0 ,114            ; /63/ TSX hi-eff write to TT emt
  51. wrtloc:    .word    0            ; /63/ address of buffer to write
  52. wrtlen:    .word    0            ; /63/ write this many chars
  53.  
  54.  
  55.     .psect    $code
  56.     .sbttl    Initialize the terminal    ; /BBS/ heavily hacked
  57.  
  58. ;    T T Y I N I
  59. ;
  60. ;    input:      (r5)    = if <> don't force ^W/^B off, as for CONNECT mode
  61. ;    output:       r0    = cleared, no error possible
  62.  
  63. t.ttyini::save    <r1,r2>
  64.     tst    tsxsave            ; running under TSX?
  65.     bne    30$            ; ya, skip to TSX term init
  66.     .gval    #rtwork,#$tcfig        ; no, get term config word addr
  67.     cmp    rt11ver    ,#5        ; /62/ is this RT-11 V5 or above?
  68.     bge    10$            ; /62/ ya, .peek will work
  69.     tst    montyp            ; /62/ if XM and V4..
  70.     bgt    20$            ; /62/ ..tough luck
  71.     bic    #crlf$    ,(r0)        ; /62/ no CR/LF, ignore width that is
  72.     br    20$
  73. 10$:    mov    r0    ,r1        ; copy for peek, which uses r0
  74. ; /62/    .peek    #rtwork    ,r1        ; must do it this way for XM
  75.     MOV    #rtwork    ,R0        ; /62/ expanded to assemble under V4
  76.     MOV    #28.*^o400+1.,@R0    ; /62/ even though V4 can't run it
  77.     MOV    r1    ,2.(R0)        ; /62/
  78.     EMT    ^o375            ; /62/
  79.     mov    r0    ,r2        ; copy for poke, which also uses r0
  80.     bic    #crlf$    ,r2        ; no CR/LF, ignore width that is..
  81. ; /62/    .poke    #rtwork    ,r1,r2        ; stuff in new term config word
  82.     MOV    #rtwork    ,R0        ; /62/ expanded to assemble under V4
  83.     MOV    #28.*^o400+3,@R0    ; /62/ even though V4 can't run it
  84.     MOV    r1    ,2.(R0)        ; /62/
  85.     MOV    r2    ,4.(R0)        ; /62/
  86.     EMT    ^o375            ; /62/
  87. 20$:    .rctrlo                ; force update of it in the os
  88.     br    80$            ; skip past TSX init code
  89.  
  90. 30$:    mov    #1    ,r1        ; offset to second byte
  91.     mov    #11.    ,r2        ; 11 of 'em to do
  92. 40$:    movb    #'D    ,limits(r1)    ; load activation char prefix
  93.     add    #3    ,r1        ; bump to next one
  94.     sob    r2    ,40$        ; next one
  95.  
  96.     tst    (r5)            ; come here via CONNECT?
  97.     bne    50$            ; ya
  98.     movb    limits    ,vl$chr        ; no, ensure ^W gets off'd
  99.     br    60$            ; and continue
  100. 50$:    movb    vlflag    ,vl$chr        ; set/clear ^B/^W lead-in char
  101.     beq    70$            ; ^W stays on, keep windowing on
  102. 60$:    mov    #w$suspen,r0        ; suspend TSX window processing
  103.     emt    375            ; for packets and connect mode
  104. 70$:    wrtall    #limits            ; set some terminal parameters
  105.  
  106. 80$:    mov    #1000    ,r2        ; eat anything that's pending please
  107. 90$:    calls    t.binrea,<#-1>        ; force call to t.binread
  108.     dec    r2            ; don't loop forever please
  109.     beq    100$            ; exit the loop
  110.     tst    r0            ; did we get anything at all?
  111.     beq    90$            ; yes, eat some more input
  112. 100$:    clr    r0            ; indicate success
  113.     unsave    <r2,r1>
  114.     return
  115.  
  116.  
  117.     .sbttl    Binary read
  118.  
  119. ;    B I N R E A
  120. ;
  121. ;    input:      (r5)    = time-out
  122. ;    output:       r1    = character just read
  123. ;           r0    = if <>, error code
  124.  
  125. t.xbinre::                ; same here, different in KRTXL
  126. t.binrea::cmp    (r5)    ,#-1        ; read without any wait?
  127.     bne    10$            ; no
  128.     .ttinr                ; try to read a single character
  129.     bcs    40$            ; nothing was there, so exit
  130.     mov    r0    ,r1        ; return character in r1
  131.     clr    r0            ; no errors
  132.     br    50$            ; done
  133.  
  134. 10$:    mov    (r5)    ,r1        ; get the time-out in seconds
  135.     mul    clkflg    ,r1        ; /BBS/ into ticks now
  136.  
  137. 20$:    .ttinr                ; try and read console
  138.     bcs    30$            ; nothing there
  139.     mov    r0    ,r1        ; save character
  140.     clr    r0            ; success
  141.     br    50$            ; done
  142.  
  143. 30$:    dec    r1            ; been here too long?
  144.     beq    40$            ; yes, exit with error
  145.     .twait    #rtwork    ,#ttime        ; no, sleep one tick
  146.     br    20$            ; and try again please
  147.  
  148. 40$:    mov    #er$nin    ,r0        ; no data today
  149.     clr    r1            ; /BBS/ ensure nothing output
  150. 50$:    return
  151.  
  152.  
  153.     .sbttl    Binary write
  154.  
  155. ;    B I N W R I
  156. ;
  157. ;    output:      r0    = if <>, error code
  158.  
  159. t.binwri::tst    tsxsav            ; /63/ running under TSX?
  160.     beq    10$            ; /63/ no
  161.     mov    2(r5)    ,wrtlen        ; /63/ ya, get the string length
  162.     beq    40$            ; /63/ nothing to do
  163.     mov    @r5    ,wrtloc        ; /63/ get the string address
  164.     mov    #wrtemt    ,r0        ; /63/ point to write emt arg block
  165.     emt    375            ; /63/ do the write to TT
  166.     br    40$            ; /63/ done
  167.  
  168. 10$:    save    <r1,r2>            ; /63/ RT-11 output done here
  169.     mov    2(r5)    ,r2        ; get the string length
  170.     beq    30$            ; /63/ nothing to do
  171.     mov    @r5    ,r1        ; get the string address
  172. 20$:    .ttyou    (r1)+            ; dump one char
  173.     sob    r2    ,20$        ; next please
  174. 30$:    unsave    <r2,r1>            ; /63/
  175.  
  176. 40$:    clr    r0            ; no error possible
  177.     return
  178.  
  179.  
  180.     .sbttl    Reset an XOFF        ; /BBS/ all new
  181.  
  182. t.ttxon::movb    tsxsave    ,xonlin        ; TSX line number
  183.     beq    10$            ; not TSX
  184.     cmp    tsxver    ,#620.        ; TSX, but which version?
  185.     blo    10$            ; if less than 6.2 use RT-11 code
  186.     mov    #xonemt    ,r0        ; load args for XON emt
  187.     emt    375            ; SET TT XON
  188.     br    40$
  189.  
  190. 10$:    save    <r1,r2>
  191.     .gval    #rtwork,#$tcfig        ; get term config word addr
  192.     cmp    rt11ver    ,#5        ; /62/ is this RT-11 V5 or above?
  193.     bge    20$            ; /62/ ya, .peek will work
  194.     tst    montyp            ; /62/ if XM and V4..
  195.     bgt    30$            ; /62/ ..tough luck
  196.     mov    r0    ,r2        ; /62/ copy term config word address
  197.     bic    #page$    ,(r2)        ; /62/ clear page bit
  198.     .rctrlo                ; /62/ force update
  199.     bis    #page$    ,(r2)        ; /62/ restore page bit
  200.     br    30$
  201. 20$:    mov    r0    ,r1        ; save copy as peek eats r0
  202. ; /62/    .peek    #rtwork    ,r1        ; must do it this way for XM
  203.     MOV    #rtwork    ,R0        ; /62/ expanded to assemble under V4
  204.     MOV    #28.*^o400+1.,@R0    ; /62/ even though V4 can't run it
  205.     MOV    r1    ,2.(R0)        ; /62/
  206.     EMT    ^o375            ; /62/
  207.     mov    r0    ,r2        ; save copy as poke also eats r0
  208.     bic    #page$    ,r2        ; clear page bit
  209. ; /62/    .poke    #rtwork    ,r1,r2        ; set tt nopage
  210.     MOV    #rtwork    ,R0        ; /62/ expanded to assemble under V4
  211.     MOV    #28.*^o400+3,@R0    ; /62/ even though V4 can't run it
  212.     MOV    r1    ,2.(R0)        ; /62/
  213.     MOV    r2    ,4.(R0)        ; /62/
  214.     EMT    ^o375            ; /62/
  215.     .rctrlo                ; force update
  216.     bis    #page$    ,r2        ; restore page bit
  217. ; /62/    .poke    #rtwork    ,r1,r2        ; set tt page
  218.     MOV    #rtwork    ,R0        ; /62/ expanded to assemble under V4
  219.     MOV    #28.*^o400+3,@R0    ; /62/ even though V4 can't run it
  220.     MOV    r1    ,2.(R0)        ; /62/
  221.     MOV    r2    ,4.(R0)        ; /62/
  222.     EMT    ^o375            ; /62/
  223. 30$:    unsave    <r2,r1>
  224.  
  225. 40$:    .rctrlo                ; force update again
  226.     .ttyout    #xon            ; send an XON
  227.     clr    r0            ; success
  228.     return
  229.  
  230.  
  231.     .sbttl    Hose the terminal port, cancel type_ahead
  232.  
  233. t.hose::                ; same here, different in KRTXL
  234. t.cantyp::call    t.ttxon            ; /BBS/ dump a possible XOFF then
  235.     jmp    clrcns            ; /62/ eat any pending terminal input
  236.  
  237.  
  238.     .sbttl    Handler functions not needed for TT
  239.  
  240. t.dcdtst::                ; /62/
  241. t.ttspee::clr    r0            ; /62/ not available
  242.     return
  243.  
  244. t.inqcd::
  245. t.inqdtr::
  246. t.ttyfin::
  247.     mov    #-1    ,r0        ; /BBS/ not available
  248.     return
  249.  
  250. t.setspd::mov    #er$spx    ,r0        ; /BBS/ TT speed not settable here
  251.     return
  252.  
  253. t.ttyhan::mov    #er$pls    ,r0        ; /BBS/ please SET LINE first..
  254.     return
  255.  
  256.     .end
  257.