home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / pdp11 / k11pco.mac < prev    next >
Text File  |  2020-01-01  |  21KB  |  736 lines

  1.     .title    K11PCO    Connect code for PRO/350 Only
  2.     .ident    /347BDN/
  3.     .psect
  4.     .enabl    gbl
  5.  
  6.  
  7. ;    Copyright (C) 1986 Brian Nelson
  8. ;
  9. ;     This is a reformatting of the OLD K11CON.MAC cleaned up and
  10. ;    specifically for the PRO/350 ONLY. Specific RSX TTDVR things
  11. ;    have been removed. The old K11CON.MAC was getting to be such
  12. ;    a mess that it becoming a pain to maintain.  The CURRENT RSX
  13. ;    connect code is K11MCO.MAC.
  14. ;
  15. ;
  16. ;    05-MAR-86  10:37  Brian Nelson    Initial conversion
  17. ;    03-Apr-86  12:17  Brian Nelson    Get XK read reposted before TT write
  18. ;    04-Apr-86  19:20  Brian Nelson    Add support for spawning PRO/COMM
  19.  
  20.  
  21.  
  22.     .if ndf, K11INC
  23.     .ift
  24.     .include    /IN:K11MAC.MAC/
  25.     .endc
  26.  
  27.     .psect    concod    ,RO,I,LCL,REL,CON
  28.     .psect    condat    ,RW,D,LCL,REL,CON
  29.  
  30.     .mcall    QIO$    QIOW$    QIOW$S    DIR$    wtlo$s
  31.     .mcall    alun$s    dscp$s    encp$s    exit$s    rdaf$s    srex$s
  32.  
  33.  
  34.  
  35.     .sbttl    R/W Data
  36.     .psect    condat
  37.  
  38.  
  39.     EF.REM    = 14.            ; Remote event flag
  40.     EM.REM    = 020000        ; Remote event flag mask
  41.     EF.LOC    = 15.            ; Local event flag
  42.     EM.LOC    = 040000        ; Local event flag mask
  43.     EF.LCW    = 16.            ; Local WRITE
  44.     EF.RMW    = 17.            ; Remote WRITE
  45.  
  46. ; Characteristics buffers
  47.  
  48. savxk:    .byte    TC.BIN,0        ; XK/XT setting for BINARY mode
  49.     .byte    TC.8BC,0        ; XK/XT setting for EIGHT BIT
  50. xkspd:    .byte    TC.RSP,0        ; XK/XT receive speed
  51.     .byte    TC.XSP,0        ; XK/XT transmit speed
  52. sxklen    =    . - savxk        ; Size for SF.GMC call
  53.  
  54. savtt:    .byte    TC.FDX,0        ; TT1: setting for FULL DUPLEX
  55.     .byte    TC.NEC,0        ; TT1: for ECHOing
  56.     .byte    TC.BIN,0        ; TT1: setting for BINARY mode
  57. sttlen    =    . - savtt        ; Size for SF.GMC call
  58.  
  59.  
  60. fdxchr:    .byte    TC.FDX,1        ; Always force FULL DUPLEX
  61.     .byte    TC.NEC,1        ; Always run without echoing
  62.     .byte    TC.8BC,1        ; Always set into eightbit mode
  63.     .byte    TC.BIN,1        ; /50/ Insure TC.BIN turned on
  64.     .byte    TC.BIN,0        ; No binary (maybe in the future)
  65.     .byte    TC.PTH,1        ; Pasthru   (maybe in the future)
  66. ftisiz  =    .-  fdxchr        ; Size of settings for SF.SMC
  67. xkslen:    .word    ftisiz-4        ; Leave TC.BIN on, TC.PTH off for now
  68. ttslen:    .word    4            ; Only FDX and NEC for TT1:
  69.  
  70. xkpth::    .word    0            ; If GBLPAT'ted to <> 0, then turn
  71.                     ; off TC.BIN and turn on TC.PTH
  72.  
  73.  
  74.  
  75.     .sbttl    More GMC and QIO definitions coming
  76.  
  77.  
  78.  
  79. rtab:    .byte    TC.TBF,0        ; #chars in remote typeahead
  80. ltab:    .byte    TC.TBF,0        ; #chars in local typeahead
  81.  
  82.  
  83.  
  84. ; Oft' used QIO DPB's
  85.  
  86. remread:
  87.     QIO$    <io.rne!tf.ral>,lun.xk,ef.rem,,remios,,<rembf,1>
  88. locread:
  89.     QIO$    <io.rne!tf.ral>,lun.co,ef.loc,,locios,,<locbf,1>
  90. remwrite:
  91.     QIOW$    io.wal,lun.xk,ef.rmw,,,,<locbf,1>
  92. locwrite:
  93.     QIOW$    io.wal,lun.co,ef.lcw,,,,<rembf>
  94. locech:
  95.     QIOW$    io.wal,lun.co,ef.lcw,,,,<locbf,1>
  96. remtest:
  97.     QIOW$    sf.gmc,lun.xk,ef.rem,,remios,,<rtab,2>
  98. remtab:
  99.     QIOW$    <io.rne!tf.ral>,lun.xk,ef.rem,,remios,,<rembf+1>
  100.  
  101.  
  102. efbuf:    .blkw    4            ; Event flags buffer
  103. rembf:    .blkb    257.            ; Remote data buffer
  104. locbf:    .blkb    4.            ; Local data buffer
  105.     .even
  106. eseen:    .word    0            ; 1 = escape seen
  107. locios:    .word    0,0            ; IO status blocks
  108. remios:    .word    0,0            ; Ditto
  109. tempbf:    .blkb    257.            ; /50/
  110.     .even
  111.  
  112.     .mcall    SPWN$S    ,STSE$S        ; /50/ If using PRO/COMM
  113.  
  114. dtetask:.rad50    /DTE   /        ; /50/ Name of DTE
  115. dtests:    .blkw    10            ; /50/ Spawn status
  116.  
  117. SPEFN    =    20
  118.  
  119.     .psect    concod            ; End of R/W definitions
  120.  
  121.  
  122.  
  123.     .sbttl    P/OS connect code
  124.  
  125.  
  126.     .enabl    lsb
  127.  
  128.  
  129.  
  130. poscon::tst    procom            ; Should we use DTE today?
  131.     beq    40$            ; No
  132.     call    getprv            ; Do we need privs up?
  133.     message    <Spawning DTE. Use the EXIT key to return to Kermit.>,CR
  134.     message    <Use SETUP to set XK characteristics, such as speed.>,CR
  135.     calls    suspend    ,<#2,#0>    ; Wait a moment
  136.     QIOW$S    #IO.DET,#5        ; Detach terminal
  137.     SPWN$S    #dtetask,,,,,#SPEFN,,#dtests
  138.     bcs    10$            ; See if the DTE spawn worked
  139.     STSE$S    #SPEFN            ; It did, so we wait for DTE exit
  140.     QIOW$S    #IO.ATT,#5        ; Reattach terminal
  141.     call    drpprv            ; Drop privs and exit
  142.     return                ; Back to caller
  143.                     ;
  144. 10$:    movb    @#$DSW    ,r4        ; Save directive status
  145.     message    <Spawn for DTE failed, status = >
  146.     decout    r4            ; Print the directive status
  147.     message    < Entering internal connect code.>,CR
  148.     message    <Function Keys will NOT control terminal emulation>,CR
  149.     br    45$            ;
  150.  
  151. 40$:    tst    concnt            ;
  152.     bne    45$            ;
  153.     message                ;
  154.     message    <Using internal connection module. If you would prefer>,CR
  155.     message    <to use  PRO/Communications,  return to  command level>,CR
  156.     message    <and type SET POS DTE, then CONNECT again.>,CR
  157.     message
  158. 45$:    inc    concnt            ;
  159.     message    <Connecting to >    ; A message
  160.     print    #ttname            ; XK0 or XTn
  161.     message    < Speed: >        ; Inform about the speed also
  162.     calls    ttspeed    ,<#ttname>    ; Get the interface speed
  163.     decout    r0            ; Simple
  164.     message                ; A cr/lf
  165.     message    <Type your local escape sequence to return to the PRO>,cr
  166.  
  167.     tst    xkpth            ; Should we set TC.PTH and turn
  168.     beq    50$            ; off TC.BIN? If eq, then NO
  169.     mov    #FTISIZ,xkslen        ; Yes, reset the SF.SMC size
  170. 50$:    SREX$S    #rsxabo            ; Trap requested aborts
  171.     clr    eseen            ; Insure no escapes already seen
  172.     call    getprv            ; Insure privs for connect mode
  173.     calls    ttpars    ,<#ttname>    ; Get remote unit number
  174.     ALUN$S    #LUN.XK,r1,r0        ; Assign it
  175.     ALUN$S    #LUN.CO,#"TI,#0        ; Assign our local terminal
  176.  
  177.     QIOW$S    #SF.GMC,#LUN.XK,#EF.REM,,,,<#savxk,#sxklen>
  178.     QIOW$S    #SF.GMC,#LUN.CO,#EF.LOC,,,,<#savtt,#sttlen>
  179.     QIOW$S    #SF.SMC,#LUN.XK,#EF.REM,,,,<#fdxchr,xkslen>
  180.     QIOW$S    #SF.SMC,#LUN.CO,#EF.LOC,,,,<#fdxchr,ttslen>
  181.  
  182.     QIOW$S    #IO.DEL,#LUN.CO
  183.     QIOW$S    #IO.ATA,#LUN.CO,,,,,<,#0,#conast>
  184.  
  185.  
  186.  
  187.     .sbttl    RSX Connect code - Remote Input
  188.  
  189. ;    Prime incoming and outgoing streams
  190.  
  191.     DIR$    #remread
  192.     DIR$    #locread
  193.  
  194. ;    Main loop - Handle incoming and outgoing streams
  195. ;    until escape character is detected on outgoing (local KB)
  196.  
  197. 60$:    WTLO$S    0,#<em.loc!em.rem>    ; Wait for a character on either
  198.     RDAF$S    #efbuf            ; Read the event flags
  199.  
  200.     movb    remios    ,r5        ; Get the status of the read
  201.     call    iocheck            ; Insure that it worked
  202.     bcs    100$            ; No good, DIE
  203.     call    xkin            ; Check for XK driver input
  204.     bcs    100$            ; Something went wrong
  205.     call    ttin            ; Check for TT1 input
  206.     bcc    60$            ; Next if all was well
  207.  
  208. 100$:    call    rsxrst            ; Restore terminal settings
  209.     call    setcc            ; Insure control C trap is correct
  210.     call    drpprv            ; Drop privs
  211.     return
  212.  
  213.     .dsabl    lsb            ; Please
  214.  
  215.  
  216. rsxabo:    call    rsxrst            ; called via requested exit
  217.     SREX$S                ; disable further exits
  218.     EXIT$S                ; bye
  219.  
  220.  
  221. rsxrst:    SREX$S                ; Don't keep reentering
  222.     QIOW$S    #IO.KIL,#LUN.XK,#EF.REM    ; Kill incoming I/O
  223.     QIOW$S    #IO.KIL,#LUN.CO,#EF.LOC    ; Kill incoming I/O
  224.     QIOW$S    #SF.SMC,#LUN.XK,#EF.REM,,,,<#savxk,#sxklen>
  225.     QIOW$S    #SF.SMC,#LUN.CO,#EF.LOC,,,,<#savtt,#sttlen>
  226.     QIOW$S    #IO.DET,#LUN.XK,#EF.REM    ; De-Attach remote line
  227.     return
  228.  
  229.  
  230.  
  231.  
  232.     .sbttl    Process input from the XK/XT port
  233.  
  234. ;     We do a rather odd thing here to  improve  the  interactive
  235. ;    response  of the console terminal at high XK port speeds. It
  236. ;    turns out the the XK driver can buffer so much data that  at
  237. ;    high  speeds  we  may  NEVER  be able to get a control C out
  238. ;    from the console through the XK port. Thus  at  high  speeds
  239. ;    we  do  EXACTLY  what  one would not normally do, that it we
  240. ;    CUT the read sizes down in order to give the TTDVR a  chance
  241. ;    to  read  TT1:  input  and  get  it out the XK port via that
  242. ;    driver. We won;t loose data, the  XK  driver  is  very  good
  243. ;    about   buffering  and  flow  control.  Of  course,  another
  244. ;    possibility would be to place  the  TI:  read  at  a  higher
  245. ;    priority. 
  246.  
  247.  
  248. xkin:    bit    #em.rem,efbuf+0        ; Anything coming in?
  249.     beq    100$            ; (no)
  250.                     ;
  251.     DIR$    #remtest        ; More in typeahead?
  252.     clr    r0            ; XK may have a lot ready to get
  253.     bisb    rtab+1,r0        ; R0 = number of chars in typeahead
  254.     beq    20$            ; Nothing at all in typeahead
  255.     cmpb    xkspd+1,#S.2400        ; Are we going fast today?
  256.     blos    10$            ; No
  257.     cmp    r0    ,#40        ; Yes, should we drop size of read?
  258.     blos    10$            ; No, we expect that control C's
  259.     mov    #40    ,r0        ; can make it out. Otherwise drop it
  260. 10$:    mov    r0,remtab+q.iopl+2    ; Set the number to read to drain
  261.     DIR$    #remtab            ; Read whats sitting around
  262.                     ;
  263. 20$:    inc    r0            ; R0 = total number of chars to show
  264.     clrb    rembf(r0)        ; Make it .asciz for mapping code
  265.     mov    r0    ,-(sp)        ; No, clear out the high bit
  266.     mov    #rembf    ,r1        ; For the entire buffer
  267.     mov    #tempbf    ,r4        ; /50/ Make a copy of the buffer
  268. 30$:    movb    (r1)+    ,(r4)        ; /50/ Copy the data
  269.     tst    con8bit            ; /50/ Clear the high bit off?
  270.     bne    40$            ; /50/ No, leave as is
  271.     bicb    #200    ,(r4)        ; /50/ Simple to do
  272. 40$:    inc    r4            ; /50/ dst++
  273.     sob    r0    ,30$        ; Next please
  274.     mov    (sp)+    ,r0        ; Restore the byte count now
  275.                     ;
  276.     mov    r0    ,locwri+q.iopl+2; Write out this many
  277.     mov    #tempbf    ,r2        ; /50/ We moved the data around a bit
  278.     mov    r2    ,locwri+q.iopl+0; /50/ Reset corrected buffer address
  279.     DIR$    #remread        ; /50/ Re-issue read
  280.                     ;
  281. 50$:    movb    (r2)    ,r1        ; Now dump to the logging file
  282.     call    dumplo            ; If logging is currently enabled
  283.     cmpb    (r2)    ,#'S&37        ; /48/ Xoffs are not to be suffered
  284.     bne    60$            ; /48/ Not an XOFF
  285.     clrb    (r2)            ; /48/ Xoff, convert it to a NULL
  286. 60$:    inc    r2            ; /48/ Next character please
  287.     sob    r0    ,50$        ; Next CH please
  288.     DIR$    #locwrite        ; Normal writes
  289. 100$:    clc                ; Success always
  290.     return                ; Exit
  291.  
  292.  
  293.     .sbttl    Check for input from TT1:
  294.  
  295.  
  296.  
  297. ttin:    mov    #cvtbuf    ,cvtadr        ; For converting pro/350 codes
  298.     clrb    cvtbuf            ; Nothing is there for now
  299.     clrb    cvtbuf+1        ; Ditto...
  300.     bit    #em.loc,efbuf+0        ; Anything typed locally?
  301.     beq    100$            ; No, just exit
  302.  
  303.     clr    r1            ; Pass 8bit ctls for pro/350
  304.     bisb    locbf    ,r1        ; R1 = just typed character
  305.     call    proesc            ; Is this a pro/350 ESC or BS?
  306.     bcs    10$            ; No
  307.     movb    @cvtadr    ,locbf        ; And setup send for first char
  308.     movb    @cvtadr    ,r1        ; Ditto
  309.     beq    80$            ; Nothing to do
  310.     inc    cvtadr            ; Point to the next character
  311. 10$:    bic    #^C177    ,r1        ; Drop bit 7 if mark set (BDN)
  312.     cmpb    r1    ,conesc        ; Console escape?
  313.     bne    20$            ; (no)
  314.     tst    eseen            ; Already seen one escape?
  315.     bne    30$            ; (yes, send this one)
  316.     inc    eseen            ; Yes, note it for now
  317.     br    40$            ; And go read again
  318.  
  319. 20$:    tst    eseen            ; Character following conesc?
  320.     beq    30$            ; (no, send it)
  321.     call    concmd            ; Yup, process it
  322.     clr    eseen            ; Clear the flag
  323.     tst    r0            ; Exit CONNECT mode?
  324.     bgt    110$            ; Yes, clean up etc
  325.     blt    40$            ; no, but it was a command
  326.  
  327. 30$:    clr    eseen            ; Clear the flag
  328.     setpar    locbf    ,locbf        ; Set correct outgoing parity
  329.     DIR$    #remwrite        ; Transmit character to remote
  330.     tst    duplex            ; IBM type things today?
  331.     beq    40$            ; No
  332.     DIR$    #locech            ; Need half duplex duplex ?
  333. 40$:    movb    @cvtadr    ,locbf        ; Anymore conversion chars to
  334.     beq    80$            ; To transfer over?
  335.     inc    cvtadr            ; No, get the next one please
  336.     br    30$            ; Next please
  337. 80$:    DIR$    #locread        ; Re-issue local read
  338.     mov    #cvtbuf    ,cvtadr        ; Reset conversion address
  339.     clrb    @cvtadr            ; Insure .asciz
  340.  
  341. 100$:    clc                ; Success
  342.     return                ; Exit
  343.  
  344. 110$:    sec                ; Failure or EXIT CONNECT
  345.     return
  346.  
  347.  
  348.  
  349.  
  350.     .sbttl     map pro/350 codes to vt100 codes
  351.     .dsabl    lsb
  352.  
  353. ;    Following code added edit 2.39 /39/
  354. ;
  355. ;
  356. ;     The following code, to  (1)  intercept  'DECID'  and  return  a
  357. ;    VT100   term   type  instead  of  P/OS's  mess  that  few  execs
  358. ;    recognize, and (2) to map some of the upper  row  LK201  Pro/350
  359. ;    function  keys  into useable characters were made at the request
  360. ;    of   Bernie   Eiben   of   DEC   LDP   (eiben@dec-marlboro.arpa,
  361. ;    eiben%lsmvax.dec@decwrl.arpa).  Currently,  the  mapping  is  as
  362. ;    follows (as of 18-NOV-1985 14:08)
  363. ;
  364. ;    F5  (break)    --> send a 'real' break ala IO.BRK for XKdriver
  365. ;    F6  (interupt) --> send \03  (control C)
  366. ;    F10 (exit)     --> send \032 (control Z)
  367. ;    F11 (ESC)      --> send \033 (esc)
  368. ;    F12 (BS)       --> send \010 (backspace)
  369. ;    
  370. ;    Since these settings may intfere with some editor functions keys
  371. ;    they can be disabled via the SET TER VT200 command.  The mapping
  372. ;    of F11 is notable to TOPS20 users for command completion.  In my
  373. ;    opinion, the mods were well worth it, though mapping F10 to \032
  374. ;    does present  some difficulties.  A future  version of this code
  375. ;    would most likely access a global data structure to map settable
  376. ;    codes (with defaults) to specified character sequences.  Ie,  we
  377. ;    may end up rewritting PRO/COMM functionality for Kermit-11/POS.
  378.  
  379.  
  380.     .save
  381.     .psect    mapdata    ,rw,d,lcl,rel,con
  382.  
  383. ;     In the list  specified  in  MAPSEQ,  the  translation  of  P/OS
  384. ;    escape  sequences  from  the upper row function keys is normally
  385. ;    an ascii character string. The exceptions are (1) if  the  first
  386. ;    character  is  a  \0377 then the next character is assumed to be
  387. ;    the argument of a connect mode 'escape'  command,  such  as  ^\B
  388. ;    for  sending  a  break,  or perhaps a possible mapping of F8 (or
  389. ;    F7) (\033[19\0176  and  \033[18\0176)  to  a  ^\C  command.  The
  390. ;    mapping  or  a  sequence  to  a NULL tells the mainline emulator
  391. ;    code to do nothing (a NOP).  INSEQ is  simply the P/OS generated
  392. ;    ecsape sequences.
  393.  
  394.  
  395. mapseq:    .word    10$,20$,30$,40$,50$,60$,70$,80$,90$
  396.     .word    100$,110$,120$
  397.     .word    0
  398. 10$:    .byte    10,0            ; return for F10
  399. 20$:    .byte    33,0            ; return for F11
  400. 30$:    .byte    3,0            ; return for F6
  401. 40$:    .byte    'Z&37,0            ; return for F10
  402. 50$:    .byte    377,'b,0        ; fake ^\b break cmd
  403. 60$:    .asciz    <33>/[?1;0c/        ; vt101 response
  404. 70$:    .asciz    <33>/[?1;0c/        ; vt101 response
  405. 80$:    .asciz    <33>/[?1;0c/        ; vt101 response
  406. 90$:    .asciz    <33>/[?1;0c/        ; vt101 response
  407. 100$:    .asciz    <33>/[?1;0c/        ; vt101 response
  408. 110$:    .asciz    <33>/[?1;0c/        ; vt101 response
  409. 120$:    .asciz    <33>/[?1;0c/        ; vt101 response
  410.     .even
  411. inseq:    .word    10$,20$,30$,40$,50$,60$,70$,80$,90$
  412.     .word    100$,110$,120$
  413.     .word    0
  414. 10$:    .byte    '2,'4,176,0        ; generated code for BS  (10)
  415. 20$:    .byte    '2,'3,176,0        ; generated code for ESC (33)
  416. 30$:    .byte    '1,'7,176,0        ; generated code for INT (3)
  417. 40$:    .byte    '2,'1,176,0        ; exit key
  418. 50$:    .byte    '1,'5,176,0        ; break
  419. 60$:    .asciz    /?21;0;0;/        ; part of response to DECID
  420. 70$:    .asciz    /?21;1;0;/        ; part of response to DECID
  421. 80$:    .asciz    /?21;2;0;/        ; part of response to DECID
  422. 90$:    .asciz    /?21;0;0;8;0c/        ; baseline p/os 2.0 system
  423. 100$:    .asciz    /?21;1;0;8;0c/        ; baseline p/os 2.0 system
  424. 110$:    .asciz    /?21;2;0;8;0c/        ; baseline p/os 2.0 system
  425. 120$:    .asciz    /?21;3;0;8;0c/        ; baseline p/os 2.0 system
  426.     .even
  427. inid:    .word    10$,40$            ; host strings to return ID
  428.     .word    0            ; DECID is 'not recommended'
  429. 10$:    .byte    33,'Z&137,0        ; but intil 52's are gone...
  430. 40$:    .byte    33,'Z&137,15,0        ; just in case
  431.     .even
  432. outid:    .asciz    <33>/[?1;0c/        ; vt101 response
  433.     .even
  434. iosb:    .word    0,0            ; a QIOW$S i/o status block
  435. smallb:    .word    0            ; a QIOW$S buffer
  436. cvtbuf:    .blkb    30            ; copy translated codes to
  437. cvtadr:    .word    cvtbuf            ; a pointer to it
  438.     .even
  439.     .restore
  440.  
  441.     
  442.  
  443.     .sbttl    DECID and PRO esc seq conversion code, continued...
  444.  
  445.  
  446.  
  447.     .mcall    mrkt$s    ,cmkt$s    ,astx$s    ,wtse$s
  448.  
  449. mapid:    save    <r0,r1,r2,r3>        ; save register please
  450.     tst    proflg            ; really on a pro/350?
  451.     beq    100$            ; no
  452.     cmpb    vttype    ,#VT100        ; iif we think we are a vt100
  453.     bne    100$            ; no
  454.     cmpb    @r2    ,#33        ; ESC ?
  455.     bne    100$            ; no
  456. 5$:    strlen    r2            ; is there enough to look for?
  457.     dec    r0            ; well ?
  458.     bne    20$            ; yes, go ahead with checks
  459.     mrkt$s    #20,#12,#1,#200$    ; time the read to be very short
  460.     QIOW$S    #IO.RAL!TF.RNE,#LUN.XK,,,#iosb,,<#smallb,#1>
  461.     cmkt$s    #20,#200$        ; kill the timed read
  462.     cmpb    iosb    ,#IS.SUC    ; successfull read?
  463.     bne    100$            ; no, exit on error
  464.     inc    locwrite+q.iopl+2    ; fix i/o count up
  465.     movb    smallb    ,1(r2)        ; yes, append the character now
  466.     clrb    2(r2)            ; insure asciz
  467. 20$:    clr    r3            ; yes    
  468. 30$:    tst    inid(r3)        ; done looking ?
  469.     beq    100$            ; yes
  470.     strcmp    r2    ,inid(r3)    ; check
  471.     tst    r0            ; found it?
  472.     bne    40$            ; no
  473.     strlen    #outid            ; yes
  474.     QIOW$S    #IO.WAL,#LUN.XK,,,,,<#outid,r0>
  475.     br    90$            ; exit
  476. 40$:    tst    (r3)+            ; not found, check again
  477.     br    30$            ; next
  478. 90$:    sec                ; say we sent a response
  479.     br    110$            ; exit
  480. 100$:    clc                ; say we never sent response
  481. 110$:    unsave    <r3,r2,r1,r0>        ; exit
  482.     return                ; bye
  483.  
  484.  
  485. 200$:    QIOW$S    #IO.KIL,#LUN.XK        ; abort the qio if timeout
  486.     astx$s                ; exit marktime ast
  487.  
  488.  
  489.  
  490.  
  491.     .sbttl    Map keyboard codes to something reasonable
  492.  
  493. proesc:    save    <r1,r2,r3,r4>        ; save a register please
  494.     cmpb    vttype    ,#VT100        ; not is we really want pro
  495.     bne    90$            ; exit
  496.     mov    #cvtbuf    ,r4        ; get address of conversion buf
  497.     clrb    @r4            ; assume failure
  498.     cmpb    r1    ,#233        ; escape character typed 8bit?
  499.     beq    10$            ; yes
  500.     cmpb    r1    ,#33        ; escape w/o bit 7 set
  501.     bne    90$            ; no, exit with C set
  502. 10$:    mrkt$s    #20,#2,#1        ; insure we wait long enough
  503.     wtse$s    #20            ; to get all the data input
  504.     QIOW$S    #SF.GMC,#LUN.CO,,,,,<#ltab,#2> ;/ 39/  yes, get typeahead count
  505.     movb    ltab+1    ,r2        ; check for typeahead count
  506.     beq    90$            ; nothing to do
  507.     QIOW$S    #IO.RAL!TF.RNE,#LUN.CO,,,,,<r4,r2>
  508.     clrb    cvtbuf(r2)        ; insure .asciz
  509.     mov    r4    ,r3        ; get address of data read
  510.     cmpb    @r3    ,#'[        ; esc [ or CSI ?
  511.     bne    15$            ; must be CSI
  512.     inc    r3            ; must be ESC [
  513. 15$:    clr    r2            ; look for a matching esc seq
  514. 20$:    tst    inseq(r2)        ; all done
  515.     beq    90$            ; exit with C set
  516.     strcmp    r3    ,inseq(r2)    ; did we get a pro/350 esc seq?
  517.     tst    r0            ; ...
  518.     bne    30$            ; no
  519.     mov    mapseq(r2),r3        ; yes, get the translation
  520.     cmpb    @r3    ,#377        ; fake emulator command?
  521.     bne    25$            ; no
  522.     inc    eseen            ; say we have a ctrl\
  523.     movb    1(r3)    ,(r4)+        ; yes, return 1 char code
  524.     clrb    (r4)+            ; insure .asciz
  525.     br    100$            ; exit success
  526. 25$:    strcpy    r4    ,r3        ; yes, copy the mapped string
  527.     br    100$            ; and exit
  528. 30$:    add    #2    ,r2        ; not done, next please
  529.     br    20$            ;
  530.  
  531. 90$:    sec                ; failure
  532.     br    110$            ; exit
  533. 100$:    clc                ; success
  534. 110$:    unsave    <r4,r3,r2,r1>        ; pop regs and exit
  535.     return
  536.  
  537.  
  538. conast:    QIOW$S    #IO.WAL,#LUN.XK,,,,,<#cc,#1>
  539.     tst    (sp)+
  540.     astx$s
  541.  
  542.  
  543.     .save
  544.     .psect    condat
  545. cc:    .byte    3,0
  546.     .restore
  547.  
  548.  
  549.  
  550.     .sbttl    check for allowable i/ o errors for RSX/ M+ and P/ OS
  551.  
  552.  
  553.  
  554. iocheck:mov    r0    ,-(sp)        ; insure this is saved
  555.     tstb    r5            ; sucessesful read qio ?
  556.     bpl    180$            ; yes
  557.     scan    r5    ,#errs        ; allowable error code ?
  558.     tst    r0            ; well
  559.     bne    180$            ; yes, let it through
  560.     neg    r5            ; make > 0 for direrr macro
  561.     direrr    r5            ; simple
  562.     sec                ; failure, exit to command level
  563.     br    190$            ; bye
  564. 180$:    clc                ; success, stay in connect code
  565. 190$:    mov    (sp)+    ,r0        ; restore old r0 please
  566.     return
  567.  
  568.     .save
  569.     .psect    condat
  570. errs:    .byte    IE.BCC    ,IE.DAO    ,IE.IES    ,IE.NOD    ,IE.PES    ,IE.VER    ,IE.ABO ,0
  571.     .even
  572.     .restore
  573.  
  574.     global    <conesc    ,ttcons    ,ttname    ,lun.co    ,lun.xk>
  575.  
  576.     .dsabl    lsb
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.     .sbttl    concmd    terminal emulation escape commands
  586.     .enabl    lsb
  587.  
  588. concmd:    save    <r1>
  589.     bicb    #^C177    ,r1
  590.     scan    r1,#200$        ; look for a match here
  591.     tst    r0            ; if no match, return 0
  592.     beq    100$            ; ok
  593.     asl    r0            ; word offsets
  594.     jsr    pc    ,@210$(r0)    ; dispatch to the correct routine
  595.     tst    r0            ; if not set then set to -1
  596.     bne    100$            ; already set
  597.     dec    r0            ; set to -1
  598. 100$:    unsave    <r1>            ; pop r1 and exit
  599.     return
  600.  
  601.  
  602.     .save
  603.     .psect    condat
  604. 200$:    .byte    'C&137    ,'c!40        ; drop connection ctrl \ C
  605.     .byte    'I&137    ,'i!40        ; init the line
  606.     .byte    'Q&137    ,'q!40        ; quit logging but leave file open
  607.     .byte    'R&137    ,'r!40        ; resume logging if file is open
  608.     .byte    'X&137    ,'X!40        ; control Q and then thats all
  609.     .byte    'B&137    ,'b!40
  610.     .byte    '?    ,177        ; help, rub for send break
  611.     .byte    'H&137    ,'h!40
  612.     .byte    0
  613.     .even
  614.  
  615. 210$:    .word    con.$            ; unknown escape command
  616.     .word    con.c    ,con.c        ; drop connection
  617.     .word    con.i    ,con.i        ; get modems attention
  618.     .word    con.q    ,con.q        ; turn console logging off
  619.     .word    con.r    ,con.r        ; turn it back on please
  620.     .word    con.x    ,con.x        ; send XON
  621.     .word    con.br    ,con.br        ; break
  622.     .word    con.hl    ,con.br        ; print out commands
  623.     .word    con.hl    ,con.hl        ; help
  624. .beep:    .byte    'G&37
  625. .xon:    .byte    'Q&37,0
  626.     .even
  627.     .restore
  628.     .dsabl    lsb
  629.  
  630.  
  631. con.$:    calls    binwri    ,<#.beep,#1,#lun.co>    ; beep at user
  632.     clr    r0
  633.     return
  634.  
  635.  
  636.  
  637. con.c:    mov    #1    ,r0        ; set flag to exit connect code
  638.     return                ; simple
  639.  
  640.  
  641. con.i:    calls    ttydtr    ,<#ttname>    ; try to force DTR up on the line
  642.     clr    r0
  643.     return
  644.  
  645.  
  646. con.q:    bic    #log$co    ,trace        ; turn off console logging
  647.     clr    r0
  648.     return
  649.  
  650.  
  651. con.r:    bit    #log$op    ,trace        ; if the file is open do it
  652.     beq    100$            ; no
  653.     bis    #log$co    ,trace        ; yes, enable this
  654. 100$:    clr    r0
  655.     return
  656.  
  657.  
  658. con.x:    QIOW$S    #IO.WAL,#LUN.XK,,,,,<#.xon,#1>
  659.     calls    ttxon    ,<#ttname>
  660.     clr    r0
  661.     return
  662.  
  663.  
  664. con.br:    QIOW$S    #IO.KIL,#LUN.XK        ; Abort the read qio
  665.     QIOW$S    #IO.BRK,#LUN.XK,,,,,<#0>; Get XK driver to do it
  666.     DIR$    #remread        ; Re-prime the read
  667.     clr    r0            ; Success
  668.     return
  669.  
  670.  
  671.     .enabl    lsb
  672.  
  673. con.hl:    strlen    #200$
  674.     calls    binwri    ,<#200$,r0,#lun.co>
  675.     clr    r0
  676.     return
  677.  
  678.     .save
  679.     .psect    condat
  680. 200$:    .ascii    /B    Try to send a  break to the  remote/<cr><lf>
  681.     .ascii    /C    Connect back to the local Kermit-11/<cr><lf>
  682.     .ascii    /I    Drop  and raise DTR (for RSTS only)/<cr><lf>
  683.     .ascii    /Q    Quit console logging.   See SET LOG/<cr><lf>
  684.     .ascii    /R    Resume console logging. See SET LOG/<cr><lf>
  685.     .ascii    /X    Send XON and cancel any active XONs/<cr><lf>
  686.     .asciz    /RUBOUT    Try to fake a break to the remote/<cr><lf>
  687.     .ascii    /?    Print this message/<cr><lf>
  688.     .byte    0
  689.     .even
  690.     .restore
  691.     .dsabl    lsb
  692.  
  693.  
  694.  
  695.     .sbttl    dump i/o to a log file ?
  696.  
  697.  
  698. dumplo:    bit    #log$co    ,trace        ; is this enabled ?
  699.     beq    100$            ; no
  700.     bit    #log$op    ,trace        ; is it open
  701.     beq    100$            ; no
  702.     save    <r0,r1>            ; yes, save temps please
  703.     mov    r1    ,r0        ; call simple version
  704.     mov    #lun.lo    ,r1        ; unit number
  705.     call    putcr0            ; thats it folks
  706.     unsave    <r1,r0>
  707. 100$:    return
  708.  
  709.  
  710.  
  711. sxon:    tst    conflow
  712.     beq    100$
  713.     QIOW$S    #IO.WAL,#LUN.XK,,,,,<#xon,#1>
  714. 100$:    return
  715.  
  716. sxoff:    tst    conflow
  717.     beq    100$
  718.     QIOW$S    #IO.WAL,#LUN.XK,,,,,<#xoff,#1>
  719. 100$:    return
  720.  
  721.  
  722.     .save
  723.     .psect    $pdata
  724. xon:    .byte    'Q&37
  725. xoff:    .byte    'S&37
  726.     .even
  727.     .restore
  728.  
  729.  
  730.  
  731.     global    <lun.lo    ,putcr0    ,trace    ,conflow>
  732.  
  733.  
  734.  
  735.     .end
  736.