home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / bye3 / b3pmmi-4.aqm / B3PMMI-4.ASM
Encoding:
Assembly Source File  |  1985-12-09  |  7.0 KB  |  234 lines

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