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 / MBPMMI-1.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  7KB  |  249 lines

  1. ;***********************************************************************
  2. ;
  3. ;            MBYE (Modular 'BYE')
  4. ;       Potomic Micro Magic Incorporated modem routines
  5. ;           v1.0 (02/07/84) by Kim Levitt
  6. ;
  7. ; These routines will allow the easy patching of MBYE for any type of
  8. ; modem/serial port combination.  Certain routines must return status
  9. ; flags, so please be careful to set the flags as directed.
  10. ;
  11. ; This version is for the PMMI S100 modem card.
  12. ;
  13. ; Current revision history: (in reverse order to minimize reading time)
  14. ;
  15. ; 02/07/84  Altered and renamed to work with MBYE    - Kim Levitt
  16. ; 11/27/83  Altered and renamed to work with BYE3    - Irv Hoff
  17. ; 08/04/83  Updated for use with ByeII version 1.6    - Paul Traina
  18. ; 04/16/83  General code optimization & housecleaning    - Paul Traina
  19. ; 01/29/82  Removed check for framing and overrun errors
  20. ;        which get screwed when TSTBAUD'ing...    - Paul Traina
  21. ; 11/28/82  Fixed some conventions in file format,
  22. ;        cleaned up for distribution.        - Paul Traina
  23. ; 11/27/82  Fixed MDCARCK and MDRING routines to work 
  24. ;        with PMMI convention.  Corrected syntax
  25. ;        errors with 8bit.                - Frank Gaude
  26. ; 11/25/82  Routines added, no fuss, mess, or frills.    - Paul Traina
  27. ;
  28. ;***********************************************************************
  29. ;
  30. ; The following define the port address for the PMMI card.
  31. ;
  32. BASEP:    EQU    0C0H        ;Base port for PMMI modem
  33. ;
  34. ; Modem port equates
  35. ;
  36. TPORT:    EQU    BASEP        ;control port #1
  37. DPORT:    EQU    BASEP+1     ;data port
  38. RPORT:    EQU    BASEP+2     ;baud rate generator/modem status
  39. CPORT:    EQU    BASEP+3     ;modem control port
  40. ;
  41. ; Switch hook and modem commands, output to TPORT (port 0)
  42. ;
  43. BYE:    EQU    0        ;hang up
  44. ANSW:    EQU    2        ;off hook, answer mode
  45. BIT8:    EQU    0CH        ;8 data bits
  46. NOPY:    EQU    10H        ;no parity
  47. TSB:    EQU    40H        ;2 stop bits
  48. NORM:    EQU    BIT8+NOPY    ;normal, 8 bits, no parity
  49. P110:    EQU    BIT8+NOPY+TSB    ;same w/2 stop bits
  50. ;
  51. ; Modem status, input on RPORT (port 3)
  52. ;
  53. DTD:    EQU    1        ;dial tone detect
  54. RDET:    EQU    2        ;ring detect
  55. CTS:    EQU    4        ;CTS (carrier detect)
  56. CONN:    EQU    10H        ;connected? (0=yes, 1=modem hung up)
  57. ;
  58. ; Control port values for filter mask
  59. ;
  60. LE300:    EQU    7FH        ;less than or equal to 300 bps
  61. GT300:    EQU    5FH        ;greater than 300 bps
  62. ;
  63. ; PMMI modem status masks
  64. ;
  65. TBMT:    EQU    1        ;xmit buffer empty
  66. DAV:    EQU    2        ;data available
  67. OE:    EQU    10H        ;overrun error    
  68. FE;    EQU    20H        ;framing error
  69. ;
  70. ; Baud rate divisors
  71. ;
  72. B110:    EQU    142        ;110 bps
  73. B300:    EQU    52        ;300 bps
  74. B450:    EQU    35        ;450 bps
  75. B600:    EQU    26        ;600 bps
  76. B710:    EQU    22        ;710 bps
  77. ;
  78. ;
  79. ;***********************************************************************
  80. ;
  81. ; If any of your routines zaps anything other than the Accumulator, then
  82. ; you must preserve all other registers.
  83. ;
  84. ;***********************************************************************
  85. ;
  86. ; This routine should turn off everything on the modem, and get it ready
  87. ; to wait for a ring.  (Also hang it up.)
  88. ;
  89. MDINIT:
  90.     XRA    A        ;get disconnect value
  91.     OUT    TPORT        ;reset orig/answer
  92.     OUT    CPORT        ;turn off DTR, do break
  93.     RET
  94. ;
  95. ; The following is a routine to determine if there is a character wait-
  96. ; ing to be received,  if none are there,  the Zero flag will be set,
  97. ; otherwise, 255 will be returned in register A.  Remember that the
  98. ; system may like you a little more if you also mask out framing,
  99. ; parity, and overrun errors.  (On some modems, you can't because of
  100. ; problems with the baud rate selection.)
  101. ;
  102. MDINST:
  103.     IN    TPORT        ;get status
  104.     ANI    DAV        ;data available?
  105.     RZ            ;return if not ready
  106.     ORI    0FFH        ;we got something...
  107.     RET
  108. ;
  109. ; The following is a routine to determine if the transmit buffer is
  110. ; empty.  If it isn't, then it will return with the Zero flag set.  If
  111. ; the transmitter is not empty, it will return with Zero clear.
  112. ;
  113. MDOUTST:
  114.     IN    TPORT    ;get modem status
  115.     ANI    TBMT    ;transmit buffer empty
  116.     RET
  117. ;
  118. ; The following is a routine that will check to make sure we still have
  119. ; carrier.  If there is no carrier, it will return with the Zero flag
  120. ; set.
  121. ;
  122. MDCARCK:
  123.     IN    RPORT        ;get status of modem
  124.     CMA            ;reverse for pmmi convention
  125.     ANI    CTS        ;clear to send?
  126.     RET
  127. ;
  128. ; The following routine will check to see if the phone is ringing, if it
  129. ; isn't, ;it will return with Zero set, otherwise Zero will be cleared.
  130. ;
  131. MDRING:
  132.     IN    RPORT        ;get ring status
  133.     CMA            ;reverse for pmmi convention
  134.     ANI    RDET        ;mask all but ring
  135.     RET
  136. ;
  137. ; The following is a routine that will input one character from the
  138. ; modem port.  If there is nothing there, it will return garbage... so
  139. ; use the MDINST routine first.
  140. ;
  141. MDINP:
  142.     IN    DPORT        ;get character
  143.     ANI    7FH        ;strip parity and other garbage
  144.     RET
  145. ;
  146. ; The following is a routine that will output one character in register
  147. ; A to the modem.  REMEMBER, that is register A, not register C.
  148. ;
  149. ; **** Use MDOUTST first to see if buffer is empty ****
  150. ;
  151. MDOUTP:
  152.     OUT    DPORT        ;send it
  153.     RET
  154. ;
  155. ; The following routine will make the modem answer the phone.  It should
  156. ; also set baud rate to 300 bps.
  157. ;
  158. MDANSW:
  159.     MVI    A,LE300        ;filter value for 300 bps (DTR)
  160.     OUT    CPORT
  161.     CALL    DELAY        ;give time to turn on (.1 sec)
  162.     MVI    A,P110+ANSW    ;answer phone
  163.     OUT    TPORT
  164.     CALL    DELAY        ;give time for answer
  165.     IN    DPORT        ;clear modem port
  166.     IN    DPORT        ;make sure it's clear
  167.     CALL    SET300        ;set modem for 300 bps
  168.     RET
  169. ;
  170. ; These next routines set the proper baud rates for the modem.  If you
  171. ; do not support the particular rate, then simply put in a JMP to SETINV.
  172. ; If the baud rate change was successful, make SURE the Zero flag is set.
  173. ;
  174. ; The following routine returns a 255 because we were not able to set to
  175. ; the proper baud rate because either the serial port or the modem can't
  176. ; handle it.
  177. ;
  178. SET1200:            ;PMMI does not support 1200 bps
  179. ;
  180. SETINV:    ORI    0FFH        ;make sure the Zero flag isn't set
  181.     RET
  182. ;
  183. ; Set up for 110 bps
  184. ;
  185. SET110:
  186.     MVI    A,LE300        ;set filter value to less than 300 bps
  187.     OUT    CPORT
  188.     MVI    A,P110        ; 8 data bits, no parity, 2 stop bits
  189.     OUT    TPORT
  190.     MVI    A,B110        ; 110 bps
  191.     OUT    RPORT
  192.     XRA    A        ;return 110 as a valid rate
  193.     RET
  194. ;
  195. ; Set up for 300 bps
  196. ;
  197. SET300:
  198.     MVI    A,LE300        ;filter set to less than or = 300 bps
  199.     OUT    CPORT
  200.     MVI    A,NORM        ;set for 8 bits, no parity, 1 stop bit
  201.     OUT    TPORT
  202.     MVI    A,B300        ;set divisor to 300 bps
  203.     OUT    RPORT
  204.     XRA    A        ;return with 300 bps as a valid rate
  205.     RET
  206. ;
  207. ; Set up for 450 bps
  208. ;
  209. SET450:
  210.     MVI    A,GT300        ;set filter value for >300 bps
  211.     OUT    CPORT
  212.     MVI    A,NORM        ;set for 8 bits, no parity, 1 stop bit
  213.     OUT    TPORT
  214.     MVI    A,B450        ;set for 450 bps
  215.     OUT    RPORT
  216.     XRA    A        ;return saying 450 is ok
  217.     RET
  218. ;
  219. ; Set up for 600 bps
  220. ;
  221. SET600:
  222.     MVI    A,GT300        ;set filter value for >300 bps
  223.     OUT    CPORT
  224.     MVI    A,NORM        ;set for 8 bits, no parity, 1 stop bit
  225.     OUT    TPORT
  226.     MVI    A,B600        ;set for 600 bps
  227.     OUT    RPORT
  228.     XRA    A        ;return saying 600 bps is valid
  229.     RET
  230. ;
  231. ; Set up for 710 bps
  232. ;
  233. SET710:
  234.     MVI    A,GT300        ;set filter value for >300 bps
  235.     OUT    CPORT
  236.     MVI    A,NORM        ;set for 8 bits, no parity, 1 stop bit
  237.     OUT    TPORT
  238.     MVI    A,B710        ;set for 710 bps
  239.     OUT    RPORT
  240.     XRA    A        ;return saying 710 bps is valid
  241.     RET
  242. ;
  243. ; Ok, that's all of the modem dependant routines that MBYE uses, so if
  244. ; you patch this file into your copy of MBYE, then it should work out
  245. ; well.
  246. ;
  247. ;************************************************************************
  248. ;
  249.