home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / BBSING / MBBS / MBK484-1.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  7KB  |  252 lines

  1. ;***********************************************************************
  2. ;
  3. ;             MBYE (Modular 'BYE')
  4. ;        Overlay for Kaypro 4'84 Internal Modem
  5. ;            v1.0 (05/12/85) by Terry Carroll
  6. ;
  7. ; These routines will allow the easy patching of MBYE for the
  8. ; Kaypro 4'84 Internal Modem.  Certain routines must return status
  9. ; flags, so please be careful to set the flags as directed.
  10. ;
  11. ; NOTE: In the main MBYE program, be sure to set the following equates:
  12. ;
  13. ;          NORING:    EQU     NO
  14. ;       SINGLE:     EQU     YES
  15. ;       S300:      EQU     YES
  16. ;
  17. ;       Set all other baud rate equates to NO.
  18. ;       Set all modem equates to NO.
  19. ;
  20. ;-----------------------------------------------------------------------
  21. ;
  22. ; 05/12/85  Initial version    -----     Terry Carroll
  23. ;                     The Poor Man's RCP/M
  24. ;                     Bedford, Texas
  25. ;                     817-283-9167
  26. ;                     24 hours, 300/1200 Baud
  27. ;
  28. ;-----------------------------------------------------------------------
  29. ;
  30. ; Set base ports
  31. ;
  32. SIOBASEP:    EQU    0DH        ;Base port for SIO
  33. PIOBASEP:    EQU    21H        ;Base port for PIO
  34. BAUDRATE:    EQU    00H        ;Baud rate port
  35. ;
  36. ; The following define the port addresses to use.
  37. ;
  38. DPORT:        EQU    SIOBASEP    ;SIO Data port
  39. SPORT:        EQU    SIOBASEP+2    ;SIO Status/Control port
  40. PDPORT:        EQU    PIOBASEP    ;PIO Data port
  41. PSPORT:        EQU    PIOBASEP+2    ;PIO Status/Control port
  42. BPORT:        EQU    BAUDRATE    ;Baud rate port
  43. ;
  44. ;
  45. ; The following are SPORT commands (output these to SPORT)
  46. ;
  47. ; WR0:
  48. RESCHN:        EQU    00011000B    ;Reset channel
  49. RESSTA:        EQU    00010000B    ;Reset ext/status
  50. RESERR:        EQU    00110000B    ;Error reset
  51. ;
  52. WRREG1:        EQU    00000000B    ;WR1 - No interrupts
  53. WRREG3:        EQU    11000001B    ;WR3 - Rx 8 bits/char, Rx enable
  54. WRREG4:        EQU    01000100B    ;WR4 - 16x, 1 stop bit, no parity
  55. ;
  56. ; WR5:
  57. DTROFF:        EQU    01101000B    ;DTR off, Tx 8 bits, Tx enable, RTS off
  58. DTRON:        EQU    11101010B    ;DTR on, Tx 8 bits, Tx enable, RTS on
  59. ;
  60. ;
  61. ; The following are SPORT status masks
  62. ;
  63. ; RR0:
  64. DAV:        EQU    00000001B    ;Data available
  65. TBMT:        EQU    00000100B    ;Transmit buffer empty
  66. DCD:        EQU    00001000B    ;Data carrier detect
  67. RI:        EQU    00100000B    ;Ring Indicator
  68. ;
  69. ; RR1:
  70. OE:        EQU    00100000B    ;Overrun error
  71. FE:        EQU    01000000B    ;Framing error
  72. ERR:        EQU    OE+FE        ;Overrun and framing errors
  73. ;
  74. ; 8116 (on Kaypros at least) is initialized by system on cold boot,
  75. ; only need to set baud rate as single command to baud rate port.
  76. ; The Kaypro 4'84 only supports 300 baud; other values are included here
  77. ; for informational purposes.
  78. ;
  79. BD110:        EQU    02H
  80. BD300:        EQU    05H
  81. BD600:        EQU    06H
  82. BD1200:        EQU    07H
  83. BD2400:        EQU    0AH
  84. BD4800:        EQU    0CH
  85. BD9600:        EQU    0EH
  86. BD19K:        EQU    0FH
  87. ;
  88. ;
  89. ;***********************************************************************
  90. ;
  91. ; If any of your routines zap anything other than the Accumulator, then
  92. ; you must preserve all other registers.
  93. ;
  94. ;***********************************************************************
  95. ;
  96. ; This routine should turn off everything on the modem, hang it up, and
  97. ; get it ready to wait for a ring. (DTR off)
  98. ;
  99. MDINIT:
  100.     MVI    A,00001111B    ;PIO initialization
  101.     OUT    PSPORT
  102.     MVI    A,01011111B
  103.     OUT    PDPORT
  104.     MVI    B,10
  105.     CALL    DELAY
  106.     MVI    A,11011111B    
  107.     OUT    PDPORT
  108.     MVI    B,10
  109.     CALL    DELAY
  110.     MVI    A,01011111B
  111.     OUT    PDPORT
  112.     MVI    A,10000111B
  113.     OUT    PSPORT
  114.     MVI    A,10000110B
  115.     OUT    PSPORT
  116.     MVI    A,01000000B    ;Set modem on-hook (hang-up)
  117.     OUT    PDPORT
  118.     MVI    A,0
  119.     OUT    SPORT
  120.     MVI    A,RESCHN    ;Reset channel (DTR, RTS off)
  121.     OUT    SPORT
  122.     MVI    A,4        ;Setup to write register 4
  123.     OUT    SPORT
  124.     MVI    A,WRREG4    ;set 16x clock, 1 stop bit, no parity
  125.     OUT    SPORT
  126.     MVI    A,1        ;Setup to write register 1
  127.     OUT    SPORT
  128.     MVI    A,WRREG1    ;set no interrupts
  129.     OUT    SPORT
  130.     MVI    A,3        ;Setup to write register 3
  131.     OUT    SPORT
  132.     MVI    A,WRREG3    ;set Rx 8 bits, enable recv
  133.     OUT    SPORT
  134.     MVI    A,5        ;Setup to write register 5
  135.     OUT    SPORT
  136.     MVI    A,DTROFF    ;leave DTR OFF initially
  137.     OUT    SPORT
  138.     RET            ;Return
  139. ;
  140. ; This routine will check the Ring Indicator status,
  141. ; returning a non-zero value if the RI line is active.
  142. ;
  143. MDRING:
  144.     MVI    A,RESSTA    ;reset status latches
  145.     OUT    SPORT        ;to get CURRENT
  146.     IN    SPORT        ;status
  147.     ANI    RI        ;check RI status
  148.     RET
  149. ;
  150. ; The following routine will raise DTR. (and RTS)
  151. ;
  152. MDANSW:
  153.     MVI    A,5        ;address WR5
  154.     OUT    SPORT
  155.     MVI    A,DTRON        ;raise DTR, RTS
  156.     OUT    SPORT
  157.     MVI    A,00010000B    ;answer phone (off hook)
  158.     OUT    PDPORT
  159.     MVI    B,10
  160.     CALL    DELAY
  161.     RET            ;Return
  162. ;
  163. ; The following routine checks to make sure we still have carrier.  If
  164. ; there is no carrier, it will return with the Zero flag set.
  165. ;
  166. MDCARCK:
  167.     MVI    A,RESSTA    ;Reset status
  168.     OUT    SPORT
  169.     IN    SPORT        ;Get status
  170.     ANI    DCD        ;Check for data carrier
  171.     RET            ;Return
  172. ;
  173. ; The following routine determines if there is a character waiting to
  174. ; be received.  If no character is waiting, the Zero flag will be set,
  175. ; otherwise, 255 will be returned in register A. (Error conditions are
  176. ; checked, and, if present, the character is ignored.)
  177. ;
  178. MDINST:
  179.     IN    SPORT        ;Get status
  180.     ANI    DAV        ;Got a character?
  181.     RZ            ;Return if none
  182.     MVI    A,1        ;else, check error bits
  183.     OUT    SPORT        ;(address RR1)
  184.     IN    SPORT        ;read RR1
  185.     ANI    ERR        ;mask error bits
  186.     JZ    MDINST1        ;no error, ok
  187.     MVI    A,RESERR    ;else, reset error bits
  188.     OUT    SPORT
  189.     IN    DPORT        ;clear out garbage
  190.     XRA    A        ;say no data
  191.     RET            ;and return
  192. MDINST1:
  193.     ORI    0FFH        ;say we got one
  194.     RET            ;...and return
  195. ;
  196. ; The following is a routine that will input one character from the
  197. ; modem port.  If there is nothing there, it will return garbage... so
  198. ; use the MDINST routine first.
  199. ;
  200. MDINP:
  201.     IN    DPORT        ;Get character
  202.     ANI    7FH        ;Strip parity
  203.     RET            ;Return
  204. ;
  205. ; The following is a routine to determine if the transmit buffer is
  206. ; empty.  If it is empty, it will return with the Zero flag clear.  If
  207. ; the transmitter is busy, then it will return with the Zero flag set.
  208. ;
  209. MDOUTST:
  210.     IN    SPORT
  211.     ANI    TBMT        ;Mask it
  212.     RET            ;Return
  213. ;
  214. ; The following is a routine that will output one character in register
  215. ; A to the modem.  REMEMBER, that is register A, not register C.
  216. ;
  217. ; **** Use MDOUTST first to see if buffer is empty ****
  218. ;
  219. MDOUTP:
  220.     OUT    DPORT        ;Send it
  221.     RET            ;Return
  222. ;
  223. ; These next routines set the proper baud rates for the modem.  If you
  224. ; do not support the particular rate, then simply put the label in front
  225. ; of the ORI 0FFH / RET. If the baud rate change was successful, make
  226. ; SURE the Zero flag is set (XRA A).
  227. ;
  228. SET300:
  229.     MVI    A,BD300
  230. ;
  231. SETBAUD:
  232.     OUT    BPORT        ;set baud rate
  233.     XRA    A        ;say rate ok
  234.     RET            ;and return
  235. ;
  236. ; The following baud rates are not supported on the Kaypro 4'84
  237. ;
  238. SET110:
  239. SET450:
  240. SET600:
  241. SET710:
  242. SET1200:
  243. SET2400:
  244.     ORI    0FFH        ;say rate ng
  245.     RET
  246. ;
  247. ; Ok, that's all of the modem dependent routines that MBYE uses, so if
  248. ; you insert this file into your copy of MBYE, then it should work out
  249. ; well.
  250. ;
  251. ;***********************************************************************
  252.