home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / appleii / appccs.m65 < prev    next >
Text File  |  2020-01-01  |  17KB  |  578 lines

  1. .TITLE    KERMIT-65 CCS 7710 com card - interupt driven
  2. .SBTTL    6502 version - Ted Medin
  3. ;    Thanks to Bill Rupp for the loan of his equipment and thus this driver
  4.  
  5. ;    Version 1.0
  6. ;    Warning interupts must be allowed by card.
  7.  
  8. ;    Based on the KERMIT Protocol.
  9.  
  10. ;    $Header: appccs.m65,v 1.11 88/12/22 09:22:13 medin Locked $
  11. .SBTTL    Define start address for assembly
  12.  
  13.        .=$1003            ;[39] Start assembly here
  14.  
  15. debug    =    0        ;[1] debug flag - when 0 will not add debug code
  16. .SBTTL    Revision History
  17.  
  18. ;
  19. ; Edit #    Description
  20. ; ------    -----------
  21. ;    
  22.  
  23. ;$Log:    appccs.m65,v $
  24. ;Revision 1.11  88/12/22  09:22:13  medin
  25. ;Use time constant for the wait routine,
  26. ;enlarge the input buffer to $900.
  27.  
  28. ;Revision 1.10  88/04/27  18:05:59  medin
  29. ; Dont allow interupts when you exit kermit.
  30.  
  31. ;Revision 1.9  88/03/28  13:31:35  medin
  32. ; Attempt to make the interupt routine faster.
  33.  
  34. ;Revision 1.8  88/01/15  08:42:30  medin
  35. ;New origin for 3.81
  36.  
  37. ;Revision 1.7  87/06/29  10:55:05  medin
  38. ; Change wait rtn to use apple nom rtn, change org for 3.78.
  39.  
  40. ;Revision 1.6  87/05/13  18:09:28  medin
  41. ; Change org to correspond with 3.76
  42.  
  43. ;Revision 1.5  87/02/20  23:57:07  medin
  44. ; Put the version number in the hearld so we can keep track of the com
  45. ;drivers also. Thanks Rhoda.
  46.  
  47. ; DONT FORGET TO UPDATE THE VERSION
  48. ;Revision 1.4  86/12/23  10:17:59  medin
  49. ; Protect ourselves from interupts during initialization and
  50. ;tattle that we cant set baud via software.
  51.  
  52. ;Revision 1.3  86/12/09  22:14:52  medin
  53. ; Acknowledge Bill Rupp for the loan of his equipment.
  54.  
  55. ;Revision 1.2  86/12/09  22:08:38  medin
  56. ; This is the interupt driven version of the ccs 7710 serial card.
  57.  
  58.  
  59. ;
  60. ;
  61. ;    Vector for com cards starts here 
  62. ;        location $1003 for data
  63. ;        location $1020 for routine jumps
  64. ;        location $1040 for main routines
  65. ;
  66. sscdbd:    .blkb    1  ;[54]contains baud index(ala super serial card) used by init
  67.             ;        6 - 300 baud
  68.             ;        7 - 600 
  69.             ;        etc
  70.     .blkb    1    ;
  71. crdnam:    .word    herld    ;[54] null terminated string of who we are
  72. kersli:    .blkb    1    ;[54] com slot $n0
  73. kerins:    .blkb    1    ;[54] force initialization flag-when 0
  74. endker:    .blkb    2    ;[54] address of end of main kermit
  75. flowfg:    .blkb    1    ;[57] flow flag for xon/xoff controll b7=1 yes
  76. tl0end    .word    endcom    ;[1.8] end of this routine
  77. timect    .blkb    1    ;[1.11] 1 ms delay via rom wait rtn
  78.     .=sscdbd+29        ;[54] future expansion
  79. tlinit:    jmp    tl2int        ;[54] initialize com card
  80. tl0cmd:    jmp    tl2cmd        ;[54] command in A reg
  81.             ;
  82.             ;[54] 0 - hang up 
  83.             ;[54] $0b - set baud
  84.             ;[54] $0c - set break on the line
  85.             ;[57] $91 - turn remote on (xon)
  86.             ;[57] $93 - turn remote off(xoff)
  87.             ;
  88.             ;[54] routine will return false(0) if unable
  89. tl0cp:    jmp    tl2cp        ;[54] check for input ch ready-0 false
  90. tl0gpc:    jmp    tl2gpc        ;[54] get input ch
  91. tl0ppc:    jmp    tl2ppc        ;[54] put output character
  92. tl0exi:    jmp    tl2exi        ;[54] reset card and restore initialized
  93.     .=sscdbd+29+32        ;[54] futures
  94. ;[1.7]wait:    .blkb    3    ;[54] wait routine-a reg contains milliseconds
  95. wait:    .blkb    3    ;[1.7] wait routine-apple rom rtn 220=125ms,198=100ms,25=2ms
  96. prstr:    .blkb    3    ;[54] print string x=lsb,y=msb x&y->null terminated string
  97. rdkey:    .blkb    3    ;[54] read keyboard
  98. prcrlf:    .blkb    3    ;[54] print cr and lf
  99. telcnc:    .blkb    3    ;[54] check for keyboard character
  100. telspa:    .blkb    3    ;[57] set character parity
  101. prbyte    =     $fdda          ; Routine - Print A-reg as 2 hex nibbles
  102.  
  103.     .=$7f00    ;[1.12][1.8][54] place to start com card assembly
  104. start    =    .        ;need a label at begining
  105. kr2pch    =    $c081        ;data port
  106. kr2pst    =    $c080        ;status port
  107. kr2pcr    =    $c080        ;command port
  108. kr2pcc    =    $c080        ;control port
  109. mncinb    =    $95    ; Control port command(8 bit,no par,1-stop,in int,16xbaud)
  110. mnminb    =    $3    ; Master port reset
  111. mssinb    =    $1    ; status bit for input ready
  112. mssoub    =    $2    ;status bit for output busy
  113. moutb    =    $60    ; break command on output
  114. moutnt    =    $b5    ; command to start input & output with interupts
  115. ;    ACIA commands
  116. ;    xxxx xx00    clock 1x baud rate
  117. ;    xxxx xx01    clock 16x baud
  118. ;    xxxx xx10    clock 64x baud 
  119. ;    xxxx xx11    acia master reset
  120. ;    xxx0 00xx    7data + even parity + 2 stop bits
  121. ;    xxx0 01xx    7data + odd par     + 2 stop
  122. ;    xxx0 10xx    7data + even par    + 1 stop
  123. ;    xxx0 11xx    7data + odd par     + 1 stop
  124. ;    xxx1 00xx    8data + no par      + 2 stop
  125. ;    xxx1 01xx    8data + no par      + 1 stop
  126. ;    xxx1 10xx        8data + even par    + 1 stop
  127. ;    xxx1 11xx    8data + odd par     + 1 stop
  128. ;    x00x xxxx    set   CTS, disable xmit interupts
  129. ;    x01x xxxx    set   CTS, enable xmit interupts
  130. ;    x10x xxxx    clear CTS, disable xmit interupts
  131. ;    x11x xxxx    set   CTS, disable xmit interups, xmit break on xmit data
  132. ;    0xxx xxxx    disable receive interrupts
  133. ;    1xxx xxxx    enable receive interrupts on rec full,rec overrun,DTR signal inactive
  134. ;    STATUS bits
  135. ;    .... ...x    receive data reg full when x=1
  136. ;    .... ..x.    xmit reg ready for data
  137. ;    .... .x..    DTR inactive - dont send
  138. ;    .... x...    RTS inactive - dont send
  139. ;    ...x ....    rec data improper frame
  140. ;    ..x. ....    rec data overrun
  141. ;    .x.. ....    parity error in rec data
  142. ;    x... ....    ACIA-generated xmit or rec interupt
  143. inptr    .byte    0    ;[51] input q pointer
  144. pinptr    .byte    0    ;[51] p "
  145. outptr    .byte    0    ;[51] output q pointer
  146. poutpt    .byte    0    ;[51] p "
  147. hdirq    .word        ;[51] hold area for dos IRQ
  148. xon:    .byte    0    ;[57] flow controll
  149. xoff:    .byte    0    ;[57] "
  150. xofcnt    .byte    0    ;count of times buffer overran
  151. kwrk01    .byte    0    ;[1.11]
  152.     .ifne    debug    ;[1] conditional assembly
  153. cixon    .byte    0    ;[1] count of input xon request
  154. cixoff    .byte    0    ;[1]         "      xoff  "
  155. coxon    .byte    0    ;[1] count of ouput xon requests
  156. coxoff    .byte    0    ;[1]         "      xoff   "
  157. caixon    .byte    0    ;[1] count of actual input xon sent
  158. caixof    .byte    0    ;[1]         "             xoff "
  159.     .endc        ;[1]
  160. hxon    =    $91    ;^Q with high bit on
  161. hxoff    =    $93    ;^S  "
  162. ctrlq    =    $11    ;xon ^Q
  163. ctrls    =    $13    ;xoff ^S
  164. irqsva    =    $45    ;place dos saves a reg
  165. dirq    =    $3fe    ;[51] interupt address
  166. sscstp    =    $578    ;[47] +slot,bit 7 on turns off commands to ssc
  167. herld    nasc    <CCS 7710 V1.12> 1    ;tell who we are
  168. bad    nasc    <COM ROUTINES ASSEMBLED TOO LOW> 1
  169. nbaud   nasc    <CCS 7710 UNABLE TO SET BAUD> 1
  170. bcom    .byte   '<
  171.         nasc    <-- IS UNKNOWN COM CARD COMMAND> 1
  172.  
  173. ;
  174. ;    CCS 7710 Card I/O Device support - These routines support the
  175. ;        Apple CCS 7710 Card.
  176. ;
  177.  
  178. tl2rpt:         ;[51] a is already saved in irqsva
  179.     txa        ;[51] save x
  180.     pha        ;[51]
  181. tl2rpe            ;[67] enhanced // has all regs saved
  182. ;[1.9]    ldx    kersli    ;[51]
  183. ;[1.9]    lda    kr2pst,x    ;[51] get status
  184.     lda    kr2pst    ;[1.9] get status
  185.     bpl    tl2nts    ;[51] not our interupt
  186.     and    #mssinb    ;[51] look at input bit
  187.     bne    tl2inp    ;[51] this is input ready
  188.     bit    flowfg    ;[57] is flow controll on?
  189.     bpl    tl2out    ;[57] no
  190.     bvs    tl2noo    ;[59] yes, is output ctlr S on?, yes
  191.     lda    xoff    ;[57] have we given the ^S ?
  192.     beq    tl2ou0    ;[57] maybe
  193.     lda    xon    ;[57] yes
  194.     bne    tl2out    ;[57] is it time to give the xoff ?
  195.     .ifne    debug    ;[1]
  196.     inc    caixof    ;[1] bump count of actual input xoffs given
  197.     .endc        ;[1]
  198.     lda    #ctrls    ;[57] yes
  199.     sta    xon    ;[57] tatle
  200.     jmp    tl2ou2    ;[1][57] always jump
  201. tl2ou0:    lda    xon    ;[57] how about giving the xon ?
  202.     beq    tl2out    ;[57] no
  203.     .ifne    debug    ;[1]
  204.     inc    caixon    ;[1] bump count of actual input xons given
  205.     .endc        ;[1]
  206.     lda    #0    ;[57] turn off xoff
  207.     sta    xon    ;[57]
  208.     lda    #ctrlq    ;[57] now for the xon
  209. tl2ou2:    jsr    telspa    ;[57] set parity correctly
  210.  
  211. ;[1.9]    sta    kr2pch,x    ;[57] stop this flood
  212. tl2oup    sta    kr2pch    ;[1.9] stop this flood
  213.     jmp    tl2com    ;[1][57] always jump
  214. tl2out:
  215.     lda    outptr    ;[51] see if any to output
  216.     cmp    poutpt    ;[51]
  217.     beq    tl2noo    ;[51] no more to output
  218.     ldx    poutpt    ;[51] pointer to next ch to output
  219.     lda    outbuf,x    ;[51] get next ch
  220. ;[1.9]    ldx    kersli    ;[51] now for the port
  221. ;[1.9]    sta    kr2pch,x    ;[51] give it to card
  222. tl2rpp    sta    kr2pch    ;[1.9] give it to card
  223.     inc    poutpt    ;[51] bump to next ch to output
  224.     jmp    tl2com    ;[51] common return
  225. tl2nts:    pla        ;[51] restore x
  226.     tax        ;[51]
  227.     jmp    (hdirq)    ;[51] and pass it on sans a reg
  228. tl2noo:    lda    #mncinb    ;[51] turn off the output interupt
  229. ;[1.9]    sta    kr2pcr,x    ;[51]
  230. tl2no3    sta    kr2pcr    ;[1.9]
  231.     jmp    tl2com    ;[51] common return from interupt
  232. ;[1.9]tl2inp:    lda    kr2pch,x    ;[51] we have an input character
  233. tl2inp:    lda    kr2pch    ;[1.9] we have an input character
  234.     ldx    pinptr    ;[51] pointer to next input character
  235. store            ;[1.11]
  236.     sta    inbuf,x    ;[51] save ch
  237. ;[1.11]    inc    pinptr    ;[51] ready for next input
  238.     bit    flowfg    ;[57] are we flow controll
  239. ;[1.11]    bpl    tl2com    ;[57] no we may overun the buffers
  240.     bpl    tl2icm    ;[1.11] no we may overun the buffers
  241. ;[1.11]    lda    inbuf,x    ;[59] is host telling us stop ?
  242.     and    #$7f    ;[59] ignore parity
  243. ;    bvc    tl2in2    ;[59] are we already stoped?, yes
  244.     cmp    #ctrlq    ;[59] do we have a continue
  245.     bne    tl2in2    ;[59] no
  246.     lda    #$bf    ;[59] yes, now turn on flow
  247.     and    flowfg    ;[59]
  248.     sta     flowfg    ;[59]
  249.     .ifne    debug    ;[1]
  250.     inc    coxon    ;[1] bump count of output xons given
  251.     .endc        ;[1]
  252. ;[1.11]    dec    pinptr    ;[59] and ignore this character
  253.     jsr    tl2suo    ;[59] start up output
  254.     jmp    tl2com    ;[59] and carry on
  255. tl2in2    cmp    #ctrls    ;[59] do we have a stop?
  256.     bne    tl2in4    ;[59] 
  257.     .ifne    debug    ;[1]
  258.     inc    coxoff    ;[1] bump count of output xoffs given
  259.     .endc        ;[1]
  260.     lda    #$40    ;[59] yes tell all
  261.     ora    flowfg    ;[59] would you believe the remote
  262.     sta    flowfg    ;[59] has asked us to stop!
  263. ;[1.11]    dec    pinptr    ;[59] ignore this character
  264.     jmp    tl2com    ;[1] thats all
  265. tl2in4            ;[59] place to hang ones hat
  266. ;[1.11]    lda    xoff    ;[57] have we already asked for ^S ?
  267. ;[1.11]    bne    tl2com    ;[57] yes no need for another
  268. ;    inx        ;[57]
  269. ;    inx        ;[57]
  270. ;    inx        ;[57]
  271. ;    cpx    inptr    ;[57] are we about to overrun ?
  272. ;[1.11]    txa        ;[59] lets try stoping when half full
  273. ;[1.11]    clc        ;[59]
  274. ;[1]    adc    #126    ;[59]
  275. ;[1.11]    adc    #7    ;[1]
  276. ;[1.11]    cmp    inptr    ;[59] are we filling up ?
  277. ;[1.11]    bne    tl2com    ;[57] no
  278. ;[1.11]    jsr    tl2suo    ;[57] yes,start up output
  279. ;[1.11]    sta    xoff    ;[57] turn on xon(non 0)
  280. ;[1.11]    .ifne    debug    ;[1.11]
  281. ;[1.11]    inc    xofcnt    ;just for debug 
  282. ;[1.11]    .endc        ;[1.11]
  283. tl2icm    
  284.     inc    pinptr    ;[1.11] now bump the ptr
  285.     bne    tl2com    ;[1.11] thats all
  286.     ldx    store+2    ;[1.11] now for the msb
  287.     inx        ;[1.11]
  288.     cpx    #outbuf^    ;[1.11] too far?
  289.     bne    tl2ic0    ;[1.11] no
  290.     ldx    #inbuf^    ;[1.11] yes
  291. tl2ic0    stx    store+2    ;[1.11] update the msb
  292. tl2com:    pla        ;[51] get x
  293.     tax        ;[51]
  294. tl2eac    lda    irqsva    ;[51] get a
  295. tl2rti    rti        ;[51] return from interupt
  296.  
  297. tl2suo:
  298. ;[1.9]    ldx    kersli        ;[22] Get I/O location offset
  299.     lda    #moutnt        ;[51] turn on xmit and rec interupt
  300. ;[1.9]    sta    kr2pcr,x    ;[51] tell card about it
  301. tl2su3    sta    kr2pcr        ;[1.9] tell card about it
  302. tl2su0:    rts        ;
  303.  
  304. tl2int:    sei        ;lockout interupts just in case
  305. ;[1.11]    lda    hdirq    ;see if we already saved
  306. ;[1.11]    bne    init0    ;yes
  307.     lda    hdirq+1    ;maybe
  308.     bne    init0    ;sure thing
  309.     lda    dirq    ;[51] save dos IR for exit
  310.     sta    hdirq    ;[51]
  311.     lda    dirq+1    ;[51]
  312.     sta    hdirq+1    ;[51]
  313.     lda    #start^
  314.     cmp    endker+1    ;are we loaded above main
  315.     beq    dontno        ;cant tell yet
  316.     bcc    trble        ;yes we are in trouble
  317.     bcs    setnm        ;ok 
  318. dontno    lda    #start\        ;well lets check 16 bits
  319.     cmp    endker
  320. ;[1.11]    beq    setnm        ;whee just exactly right
  321.     bcs    setnm        ;ok
  322. trble    ldx    #bad\        ;got to tell someone
  323.     ldy    #bad^
  324.     jsr    prstr        ;print the message
  325.     jsr    prcrlf        ;and terminate it properly
  326. setnm:
  327. init0:    lda    kerins        ;[47] initialize slot
  328.     beq    .+5        ;hate to do this
  329.     jmp    tl2prr        ;[47] already initialized return
  330.  
  331. ;     apple machine id
  332. ;rom-->    $fbb3    $fbbf    $fbc0
  333. ; II    $38
  334. ; II+    $ea
  335. ; //e    $06        $ea
  336. ; //e+            $e0    enhanced
  337. ; //c    $06    $00    $00
  338. ;prodos-->    $bf98
  339. ; II,II+,//e    bit 3 = 0
  340. ; others    bit 3 = 1
  341. ; //c        bits 7,6 = 10
  342.  
  343.     lda    $fbc0        
  344.     cmp    #$e0        ; is this an enhanced 2e?
  345.     beq    setenh        ; yes
  346.     cmp    #0        ; no, how about a 2c?
  347.     bne    init3        ; no
  348.     lda    $fbbf        ; yes, how about an enhanced 2c?
  349.     bne    init3        ; no
  350. setenh    lda    tl2rti        ; yes
  351.     sta    tl2com
  352.     lda    #$ea        ; a nop
  353.     sta    tl2nts        ; this keeps the stack straight
  354.     sta    tl2nts+1    ; incase there are mult interups
  355.      lda    #tl2rpe\    ;[67][51]
  356.     sta    dirq    ;[67][51] setup inturpt address
  357.     lda    #tl2rpe^    ;[67][51]
  358.     sta    dirq+1    ;[67][51]
  359.     ldx    #0        ; now set up the ram banks for interupts
  360.     bit    $c011
  361.     bmi    .+4        ;hate to do this
  362.     ldx    #8
  363.     bit    $c012
  364.     bpl    .+4        ;ssigh!
  365.     inx
  366.     inx
  367.     bit    $c081
  368.     bit    $c081
  369.     phx            ;save the current state for later
  370. ;    .byte    $da
  371.     lda    $c016        ;how about it
  372.     asl    a
  373.     ldy    #1
  374. tl2ilp    lda    $fffe,y
  375.     sta    $c009        ;set alt card
  376.     sta    $fffe,y
  377.     sta    $c008        ;now for main ram
  378.     sta    $fffe,y
  379.     dey
  380.     bpl    tl2ilp
  381.     bcc    .+5        ;have we switch out the wrong one?
  382.     sta    $c009        ;yes
  383.     plx
  384. ;    .byte    $fa
  385.     bit    $c081,x
  386. ;    .byte    $3c,$81,$c0
  387.     bit    $c081,x
  388. ;    .byte    $3c,$81,$c0
  389.     jmp    init4        ;[67]
  390. init3
  391.      lda    #tl2rpt\    ;[67][51]
  392.     sta    dirq    ;[67][51] setup inturpt address
  393.     lda    #tl2rpt^    ;[67][51]
  394.     sta    dirq+1    ;[67][51]
  395. init4            ;[67]
  396.     lda    #0    ;[51] clear pointers etc
  397.     sta    inptr    ;[51]
  398.     sta    pinptr    ;[51]
  399.     sta    outptr    ;[51]
  400.     sta    poutpt    ;[51]
  401.     lda    #inbuf^    ;[1.11] and the msb also
  402.     sta    store+2    ;[1.11]
  403.     sta    get+2    ;[1.11]
  404. ;[67]     lda    #tl2rpt\    ;[51]
  405. ;[67]    sta    dirq    ;[51] setup inturpt address
  406. ;[67]    lda    #tl2rpt^    ;[51]
  407. ;[67]    sta    dirq+1    ;[51]
  408.     ldx    kersli    ;[47] get slot number
  409.     stx    kerins    ;[67] tell weve been here
  410.     clc
  411.     lda    #kr2pst\    ;[1.9] status address
  412.     adc    kersli    ;[1.9] calculate proper address for status
  413.     sta    tl2rpe+1    ;[1.9] and set interupt rtn
  414.     sta    tl2su3+1    ;[1.9]
  415.     sta    tl2no3+1
  416.     clc
  417.     lda    #kr2pch\    ;[1.9] data port address
  418.     adc    kersli    ;[1.9] calulate proper address for ld & st
  419.     sta    tl2rpp+1    ;[1.9] and set interupt rtn
  420.     sta    tl2inp+1
  421.     sta    tl2oup+1
  422.     lda    #mnminb    ;[47] Master port init
  423.     sta    kr2pcr,x    ;[47] Com master port
  424.     lda    #mncinb    ;[47] Control port init
  425.     sta    kr2pcc,x    ;[47]
  426. tl2prr:    cli        ;[51] allow the interurpts to happen
  427.     rts            ;[22] Return
  428.  
  429.  
  430. tl2cp:    sei        ;[51] lockout inturpts
  431.     lda    inptr    ;[51] check input for chs
  432.     cmp    pinptr    ;[51]
  433.     bne    tl2cp3    ;[1.11] how about msb, no
  434.     lda    store+2    ;[1.11] yes check that also
  435.     cmp    get+2    ;[1.11]
  436. tl2cp3            ;[1.11]
  437.     cli        ;[51] allow interupts
  438.     rts            ;[22]        ...
  439.  
  440. tl2gpc:    sei        ;[51] lockout interupts
  441.     ldx    inptr    ;[51] get input character
  442. get            ;[1.11]
  443.     lda    inbuf,x    ;[51]
  444.     inc    inptr    ;[51] bump in pointer
  445.     bne    tl2gp0    ;[1.11]
  446.     ldy    get+2    ;[1.11] bump msb also
  447.     iny        ;[1.11]
  448.     cpy    #outbuf^    ;[1.11] too far?
  449.     bne    tl2gp7    ;[1.11] no
  450.     ldy    #inbuf^    ;[1.11] yes, circle those wagons
  451. tl2gp7    sty    get+2    ;[1.11] msb
  452. ;[1.11]    ldy    xon    ;[57] are we flow controlling ?
  453. ;[1.11]    beq    tl2gp0    ;[57] no
  454. ;[1.11]    inx        ;[57]
  455. ;[1.11]    inx        ;[57]
  456. ;[1.11]    inx        ;[57]
  457. ;[1.11]    cpx    pinptr    ;[57] have we about caught up ?
  458. ;[1.11]    bne    tl2gp0    ;[57] no
  459. ;[1.11]    pha        ;[57] save ch
  460. ;[1.11]    lda    #0    ;[57] turn off xon
  461. ;[1.11]    sta    xoff    ;[57]
  462. ;[1.11]    jsr    tl2suo    ;[57] now start up output with a ^Q
  463. ;[1.11]    pla        ;[57] restore ch
  464. tl2gp0:
  465.     cli        ;[51] allow interupts
  466. ;    ldx    parity        ;[22] Check parity
  467. ;    cpx    #nparit        ;[22] No parity
  468. ;    beq    tl2rtc        ;[22] Go return the character
  469. ;    and    #$7f        ;[22] There is parity, so strip it off
  470. tl2rtc:    rts            ;[22]    and return
  471.  
  472. tl2ppc:    pha            ;[22] Hold the byte to send
  473.     sei        ;[51] lockout interupts
  474.     jsr    tl2suo    ;[57] start up output
  475.     pla            ;[22] Fetch the data byte off the stack
  476. ;    jsr    telspa        ;[22] Go set the parity appropriately
  477.     ldx    outptr    ;[51] get output pointer
  478.     sta    outbuf,x    ;[51] save in buffer for interupt
  479.     inc    outptr    ;[51] ready for next output
  480.     cli        ;[51] allow interupts
  481.     rts            ;[22]    and return
  482.  
  483. tl2exi:    sei        ;lockout interupts
  484. ;[1.11]    lda    hdirq    ;have we alredy done this?
  485. ;[1.11]    bne    exit0    ;nope
  486.     lda    hdirq+1    ;maybe
  487.     beq    exit9    ;definitly
  488. exit0:    lda    hdirq    ;[51] restore dos IRQ address
  489.     sta    dirq    ;[51]
  490.     lda    hdirq+1    ;[51]
  491.     sta    dirq+1    ;[51]
  492.     lda    #0    ;tell we did this
  493. ;[1.11]    sta     hdirq
  494.     sta    hdirq+1
  495.     ldx    kersli    ;[47] get slot number
  496.     sta    kr2pcr,x    ;shut it down
  497. ;[1.10exit9:    cli        ;now allow them
  498. exit9:    ;[1.10]cli        ;now allow them
  499.     rts
  500. tl2cmd:            ;find out what command
  501.     beq    tl2rts    ;its drop line and we cant
  502.     cmp    #$0c
  503.     beq    break    ;its a break command
  504.     cmp    #$0b
  505.     beq    baud       ;its a set baud command
  506.     cmp    #hxon    
  507.     beq    txon    ;its a turn xon
  508.     cmp    #hxoff
  509.     beq    txoff    ;its a turn xoff
  510.     jsr    prbyte    ;print command
  511.     ldx    #bcom\    ;and tell all
  512.     ldy    #bcom^
  513. tl2prn    jsr    prstr
  514.     jsr    prcrlf
  515. tl2fls:            ;a false return
  516. tl2rts:            ;tell that we cant
  517.     lda    #0    ;unknown command
  518.     rts        
  519. baud            ; sorry we cant
  520.     ldx    #nbaud\    ;tell that we cant
  521.     ldy    #nbaud^    ;drop the line
  522.     jmp    tl2prn    ;and tell kermit we cant
  523. txon:    ;[1.9]bit    flowfg    ;do we have flow control
  524. ;[1.9]    bpl    tl2fls    ;no can do
  525.     sei        ;protect ourselves from interupts
  526.     jsr    tl2suo    ;[57] now start up output 
  527.     lda    #0    
  528.     sta    xoff    ;tell interupt to start up 
  529.     .ifne    debug    ;[1]
  530.     inc    cixon    ;[1] bump count of xon requests
  531.     .endc        ;[1]
  532.     cli
  533. ltxon    lda    xon    ;[1] got to wait for ch to be sent
  534.     bne    ltxon    ;[1] its called true syncronization
  535.     lda    #1    ;give a true return
  536.     rts
  537. txoff:    ;[1.9]bit    flowfg    ;do we have flow control ?
  538. ;[1.9]    bpl    tl2fls    ;no 
  539.     sei
  540.     jsr    tl2suo    ;[57] now start up output 
  541.     .ifne    debug    ;[1]
  542.     inc    cixoff    ;[1] bump count of xoff requests
  543.     .endc        ;[1]
  544.     lda    #1    ;we need xoff
  545.     sta    xoff    ;this also gives a true return
  546.     cli
  547. ltxoff    lda    xon    ;[1] wait for it to be sent
  548.     beq    ltxoff    ;[1] are we syncronized? no
  549.     rts
  550. break:
  551.     sei        ;lock out interupts
  552.     ldy    kersli        ; ss card routine is not on
  553.     lda    #moutb        ;
  554.     sta    kr2pcr,y    ; start the break
  555.     sta    kr2pch,y    ; start xmit
  556.     cli        ; allow others to go
  557. ;[1.7]    lda    #233        ; for 233 millseconds
  558. ;[1.7]    jsr    wait        ; the y reg is not clobered
  559. ;[1.11]    lda    #220        ;[1.7] for 125 millseconds
  560.     lda    #233        ;[1.11] for 233 millseconds
  561.     sta    kwrk01        ;[1.11]
  562. break3    lda    timect        ;[1.11] 1 ms at a time
  563.     jsr    wait        ;[1.7]
  564.     dec    kwrk01        ;[1.11]
  565.     bne    break3        ;[1.11]
  566. ;[1.11]    lda    #206        ;[1.7] for 108 millseconds
  567. ;[1.11]    jsr    wait        ;[1.7] which is a grand total of 223ms
  568.     lda    #moutnt        ; restore the commands
  569.     sei        ; see how nice one can be
  570.     sta    kr2pcr,y    ;
  571.     cli        ;allow interupts
  572.     lda    #1    ;return true
  573.     rts
  574. ;[1.11]inbuf    .blkb    256    ;input buffer
  575. inbuf    .blkb    $900    ;[1.11]input buffer ***** inbuf & outbuf no separations
  576. outbuf    .blkb    256    ;output buffer
  577. endcom            ;[1.8]
  578.