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

  1. .TITLE    KERMIT-65 Microtek SV-622 serial com card
  2. .SBTTL    6502 version - Ted Medin
  3.  
  4. ;    Version 1.0
  5.  
  6. ;    Based on the KERMIT Protocol.
  7.  
  8. ;    $Header: appmsv.m65,v 1.9 90/10/15 14:25:50 medin Locked $
  9. .SBTTL    Define start address for assembly
  10.  
  11.        .=$1003            ; Start assembly at hex 1003
  12.  
  13. .SBTTL    Revision History
  14.  
  15. ;
  16. ; Edit #    Description
  17. ; ------    -----------
  18. ;
  19.  
  20. ;$Log:    appmsv.m65,v $
  21. Revision 1.9  90/10/15  14:25:50  medin
  22. new org of $7f00 for 3.87
  23. version 1.8
  24.  
  25. ;Revision 1.8  88/12/22  09:40:58  medin
  26. ;use time constant for the wait routine
  27.  
  28. ;Revision 1.7  88/08/16  16:20:30  medin
  29. ;fix break so it doesnt drop dtr
  30.  
  31. ;Revision 1.6  88/02/06  21:45:13  medin
  32. ; Change output routine to check for input character before exiting.
  33.  
  34. ;Revision 1.5  88/01/15  08:41:02  medin
  35. ;New origin for 3.81
  36.  
  37. ;Revision 1.4  87/06/29  10:05:13  medin
  38. ; Change wait rtn to use apple rom rtn, change origin to $7600
  39.  
  40. ;Revision 1.3  87/05/13  18:12:04  medin
  41. ; Change org to correspond with 3.76
  42.  
  43. ;Revision 1.2  87/02/21  00:05:40  medin
  44. ; Put the version in the hearld so we can keep track of
  45. ;the com drivers also. Thanks Rhoda
  46.  
  47. ; DONT FORGET TO UPDATE THE VERSION
  48. ;Revision 1.1  86/10/28  10:28:13  medin
  49. ;Initial revision
  50.  
  51. ;
  52. ;
  53. ;    Vector for com cards starts here 
  54. ;        location $1003 for data
  55. ;        location $1020 for routine jumps
  56. ;        location $1040 for main routines
  57. ;
  58. sscdbd:    .blkb    1  ;contains baud index(ala super serial card) used by init
  59.             ;        6 - 300 baud
  60.             ;        7 - 600 
  61.             ;        etc
  62.     .blkb    1    
  63. crdnam:    .word    herld    ; null terminated string of who we are
  64. kersli:    .blkb    1    ; com slot $n0
  65. kerins:    .blkb    1    ; force initialization flag-when 0
  66. endker:    .blkb    2    ; address of end of main kermit
  67. flowfg:    .blkb    1    ; flow flag for xon/xoff controll b7=1 yes
  68. tl0end    .word    endcom    ;[1.5] end of this routine
  69. timect    .blkb    1    ;[1.7] 1 ms delay via rom wait rtn
  70.     .=$1020        ; future expansion
  71. tlinit:    jmp    tl2int        ; initialize com card
  72. tl0cmd:    jmp    tl2cmd        ; command for ACIA in A
  73.             ;
  74.             ; 0 - hang up 
  75.             ; $0b - set baud
  76.             ; $0c - set break on the line
  77.             ; $91 - xon
  78.             ; $93 - xoff
  79.             ;
  80.             ; routine will return false(0) if unable
  81. tl0cp:    jmp    tl2cp        ; check for input ch ready-0 false
  82. tl0gpc:    jmp    tl2gpc        ; get input ch
  83. tl0ppc:    jmp    tl2ppc        ; put output character
  84. tl0exi:    jmp    tl2exi        ; reset card and restore initialized
  85.     .=$1040        ; futures
  86. ;[1.4]wait:    .blkb    3    ; wait routine-a reg contains milliseconds
  87. wait:    .blkb    3    ; rom wait rtn 220=125ms,206=108ms,25=2ms
  88. prstr:    .blkb    3    ; print string x=lsb,y=msb x&y->null terminated string
  89. rdkey:    .blkb    3    ; read keyboard
  90. prcrlf:    .blkb    3    ; print cr and lf
  91. telcnc:    .blkb    3    ; check for keyboard character
  92. telspa:    .blkb    3    ; set character parity
  93.  
  94. ;[1.4]    .=$7200    ; place to start com card assembly
  95.     .=$7f00        ;[1.8][1.5] place to start com card assembly
  96. start    =    .        ;need a label at begining
  97. kr2pch    =    $c088        ;data port
  98. kr2pst    =    $c089        ;status port
  99. kr2pcr    =    $c08a        ;command port
  100. kr2pcc    =    $c08b        ;control port
  101. mncinb    =    $18    ; Control port init(8 bit,no par,1-stop,1200 baud)
  102. mnminb    =    $b    ; Master port init(DTR, RTS, no interrupts)
  103. mssinb    =    $8    ; status bit for input ready
  104. mssoub    =    $10    ;status bit for output busy
  105. moutb    =    $c    ; mask for the output bits of command
  106. moutnt    =    $4    ; command to start output with interupts
  107. pinptr:    .byte        ; input buffer pointer
  108. inptr:    .byte        ; input buffer pointer for get
  109. poutpt    .byte        ;[59]  output buffer pointer
  110. outptr    .byte        ;[59]     "       "     "    for put
  111. kwrk01    .byte        ;[1.7]
  112. irqsva    =    $45    ;place dos saves a reg
  113. hctrlq    =    $91    ;^Q with high bit on
  114. hctrls    =    $93    ;^S "
  115. ctrlq    =    $11    ;[59] ^Q
  116. ctrls    =    $13    ;[59] ^S
  117. dirq    =    $3fe    ; interupt address
  118. sscstp    =    $578    ; +slot,bit 7 on turns off commands to ssc
  119. herld    nasc    <MICROTEK SV-622 V1.8> 1    ;tell who we are
  120. bad    nasc    <*****ERROR***** COM ROUTINES ASSEMBLED TOO LOW IN MEMORY> 1
  121.  
  122. ;
  123. ;    Microtek serial interface support - These routines support the
  124. ;        SV-622 card
  125. ;
  126.  
  127.  
  128. tl2int:
  129.     lda    #start^
  130.     cmp    endker+1    ;are we loaded above main
  131.     beq    dontno        ;cant tell yet
  132.     bcc    trble        ;yes we are in trouble
  133.     bcs    setnm        ;ok 
  134. dontno    lda    #start\        ;well lets check 16 bits
  135.     cmp    endker
  136.     beq    setnm        ;whee just exactly right
  137.     bcs    setnm        ;ok
  138. trble    ldx    #bad\        ;got to tell someone
  139.     ldy    #bad^
  140.     jsr    prstr        ;print the message
  141.     jsr    prcrlf        ;and terminate it properly
  142. setnm:
  143.     lda    kerins
  144.     bne    tl2prr    ; already initialized
  145.     lda    #0    ; clear pointers etc
  146.     sta    pinptr    ; buffer starts at 0
  147.     sta    inptr    ; buffer starts at 0
  148.     sta    poutpt    ;[59]    "
  149.     sta    outptr    ;[59]    "
  150.     ldx    kersli    ;now for the slot $n0
  151.     lda    #mnminb    ; Master port init
  152.     sta    kerins    ; tell weve been here
  153.     sta    kr2pst,x    ; Com port status
  154.     sta    kr2pcr,x    ; Com master port
  155.     lda    #mncinb    ; Control port init
  156.     and    #$f0    ; drop baud
  157.     ora    sscdbd    ; and add default baud
  158.     sta    kr2pcc,x    ;
  159. tl2prr:    rts            ; Return
  160.  
  161.  
  162. tl2cp:    ldx    kersli        ; Offset into I/O locations
  163. tl2cp1:    lda    kr2pst,x    ; Try for a character
  164.     and    #$08        ; Check for receive register full
  165.     beq    tl2cp7        ; no we dont have a ch
  166.     lda    kr2pch,x    ; yes get ch
  167.     ldy    pinptr        ; where to put it in buf
  168.     sta    inbuf,y        ; save it
  169.     inc    pinptr        ; ready for next ch
  170.     bit    flowfg        ;[59] how about flow control
  171.     bpl    tl2cp7        ;[59] no
  172.     lda    inbuf,y        ;[59] get input ch
  173.     and    #$7f        ;[59] drop parity etc
  174. ;    bvc    tl2cp4        ;[59] yes,how about ^S received?, no
  175.     cmp    #ctrlq        ;[59] is this continue(start up outputing)
  176.     bne    tl2cp4        ;[59] no, check for ^S
  177.     lda    flowfg        ;[59] tattle about the continue
  178.     and    #$bf        ;[59]
  179.     sta    flowfg        ;[59]
  180.     dec    pinptr        ;[59] forget about this character
  181. tl2cp2    ldy    outptr        ;[59] see if any to output
  182.     cpy    poutpt        ;[59] well?
  183.     beq    tl2cp7        ;[59] no more we have put all
  184. tl2cp3    lda    kr2pst,x    ;[59] check status for output
  185.     and    #$10        ;[59] ready?
  186.     beq    tl2cp3        ;[59] no, spin
  187.     lda    outbuf,y    ;[59] output ch
  188.     sta    kr2pch,x    ;[59] bye
  189.     inc    outptr        ;[59] ready for next
  190.     jmp    tl2cp2        ;[59] 
  191. tl2cp4    cmp    #ctrls        ;[59] is this stop?
  192.     bne    tl2cp7        ;[59] no
  193.     lda    #$40        ;[59] yes, tattle
  194.     ora    flowfg        ;[59]
  195.     sta    flowfg        ;[59] now everyone knows
  196.     dec    pinptr        ;[59] forget about the ^S character
  197. tl2cp7:
  198.     lda    pinptr
  199.     cmp    inptr
  200.     rts            ;return with false(0) or true(non 0)
  201.  
  202. tl2gpc:    ldx    inptr        ; get where it is in buf
  203.     lda    inbuf,x        ; get the ch
  204.     inc    inptr        ; ready for next get
  205. tl2rtc:    rts            ;    and return
  206.  
  207. tl2ppc:    pha            ; Hold the byte to send
  208.     ldx    kersli        ; Get I/O location offset
  209. tl2pp1:    lda    kr2pst,x    ; Get the status byte
  210.     and    #$10        ; Isolate the flag we want (TRE)
  211.     beq    tl2pp2        ; Transmit register is NOT empty, try again
  212.     bit    flowfg        ;[59] flow control?
  213.     bpl    tl2pp0        ;[59] no
  214.     bvc    tl2pp0        ;[59] should we stop outputing?,no
  215.     ldy    poutpt        ;[59] yes, save this ch in buffer
  216.     pla            ;[59]
  217.     sta    outbuf,y    ;[59]
  218.     inc    poutpt        ;[59] tell how many
  219. ;[1.6]    rts            ;[59] thats all
  220.     jmp    tl2cp1        ;[1.6] check for input and return
  221. tl2pp0                ;[59]
  222.     pla            ; Fetch the data byte off the stack
  223.     sta    kr2pch,x    ; Stuff it at the proper loc to send it
  224. ;[1.6]    rts            ;    and return
  225.     jmp    tl2cp1        ;[1.6] check for input and return
  226. tl2pp2:    jsr    tl2cp1        ; see if there is an input ch
  227.     jmp    tl2pp1        ;and try again
  228.  
  229. tl2exi:
  230.     lda    #0    ;tell we did this
  231.     sta    kerins        ;just in case init gets called
  232.     ldx    kersli    ; get slot number
  233.     sta    kr2pst,x    ;shut it down
  234.     sta    kr2pcr,x    
  235. exit9:    rts
  236. tl2cmd:            ;find out what command
  237.     beq    tl2rts    ;its drop line and we cant
  238.     cmp    #$0c
  239.     beq    break    ;its a break command
  240.     cmp    #$0b
  241.     beq    baud       ;its a set baud command
  242.     cmp    #hctrlq
  243.     beq    tl2sac    ;its a xon command
  244.     cmp    #hctrls
  245.     beq    tl2sac    ;its a xoff command
  246. tl2fls:    lda    #0    ;unknown command
  247. tl2rts:    rts        ;que passo ? return false(0)
  248. tl2sac:    ldx    flowfg    ;do we have flow control
  249.     bpl    tl2fls    ;no return false
  250.     and    #$7f    ;drop high bit and send the ch
  251.     jsr    telspa    ;set parity
  252.     jsr    tl2ppc    ;output the ch
  253.     lda    #1    ;set true return
  254.     rts
  255. baud:    ldx    kersli    ; get slot number
  256.     lda    kr2pcc,x    ; get com control 
  257.     and    #$f0    ; and clear baud
  258.     ora    sscdbd    ; enter
  259.     sta    kr2pcc,x    ; and set new baud rate
  260.     rts        ;return true(non 0)
  261. break:
  262.     ldy    kersli        ; ss card routine is not on
  263.     lda    kr2pcr,y    ; get current command
  264.     pha            ;
  265. ;[1.7]    lda    #$c        ;
  266.     ora    #$c        ;[1.7] keep dtr up???
  267.     sta    kr2pcr,y    ; start the break
  268. ;[1.4]    lda    #233        ; for 233 millseconds
  269. ;[1.4]    jsr    wait        ; the y reg is not clobered
  270. ;[1.7]    lda    #220        ;[1.4] 125ms
  271.     lda    #233        ;[1.7] 233 ms
  272.     sta    kwrk01        ;[1.7]
  273. break3    lda    timect        ;[1.7] 1 ms at a time    
  274.     jsr    wait        ;[1.4]
  275.     dec    kwrk01        ;[1.7]
  276.     bne    break3        ;[1.7]
  277. ;[1.7]    lda    #206        ;[1.4] 108ms
  278. ;[1.7]    jsr    wait        ;[1.4]
  279.     pla            ; restore command
  280.     sta    kr2pcr,y    ;
  281.     lda    #1    ;return true
  282.     rts
  283. inbuf    .blkb    256        ;input buffer
  284. outbuf    .blkb    256        ;[59] output  "
  285. endcom            ;[1.5]
  286.