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

  1. ;*****************************************************************
  2. ;
  3. ;            MBYE (Modular 'BYE')
  4. ;          D. C. Hayes MicroModem ][ modem I/O 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 Apple ][ running with a MicroModem ][ card.
  12. ; It seems to work on those Apples that even APBYE barfed on.  The prob-
  13. ; lem was in the Carrier Detect routine, because the Microsoft Z80 card
  14. ; screws up on a double strobe type of I/O that they tried to use.  Any-
  15. ; way, that means the Answer Phone routine is a crock,  but the thing
  16. ; works...
  17. ;
  18. ; For the Apple, you should set BYELOW to YES. (??)
  19. ;
  20. ;-----------------------------------------------------------------------
  21. ;
  22. ; 02/07/84  Altered and renamed to work with MBYE    - Kim Levitt
  23. ; 11/27/83  Altered and renamed to work with BYE3    - Irv Hoff
  24. ; 08/04/83  Updated for use with ByeII version 1.6    - Paul Traina
  25. ; 04/16/83  General code cleanup and optimization.    - Paul Traina
  26. ; 03/09/83  Fixed a missing '$+OFFSET' in MDANSW
  27. ;        routine, also improved the "flip" logic
  28. ;        needed for checking carrier and ring.    - Paul Traina
  29. ; 10/04/82  Routines added, no fuss, mess, or frills.    - Paul Traina
  30. ;
  31. ;-----------------------------------------------------------------------
  32. ;
  33. ; The following define the slot address to use.
  34. ;
  35. BASE:    EQU    0E0A6H        ;This is the status port location
  36. ;                ;for slot #2
  37. ;
  38. ;***********************************************************************
  39. ;
  40. ; MMII Modem address equates
  41. ;
  42. SPORT:    EQU    BASE        ;Control/status port
  43. DPORT:    EQU    BASE+1        ;Data port
  44. RPORT:    EQU    BASE-1        ;Baud rate/modem status port
  45. CPORT:    EQU    BASE-1        ;Modem control port
  46. ;
  47. ; Switch hook and modem commands, output to SPORT
  48. ;
  49. BYE:    EQU    0        ;on hook or dial-break
  50. ORIG:    EQU    8EH        ;off hook originate
  51. ANSW:    EQU    8AH        ;off hook answer
  52. TSB:    EQU    8        ;2 stop bits
  53. NORM:    EQU    15H        ;8 bits, no parity, 1 stop bit
  54. F110:    EQU    11H        ;same w/2 stop bits
  55. ;
  56. ; Modem status input
  57. ;
  58. RDET:    EQU    80H        ;ring detect
  59. CTS:    EQU    4        ;carrier detect
  60. TBMT:    EQU    2        ;xmit buffer empty
  61. DAV:    EQU    1        ;data available
  62. ; Baud rate divisors
  63. ;
  64. B110:    EQU    0        ;110 bps
  65. B300:    EQU    1        ;300 bps
  66. ;
  67. ;
  68. ;***********************************************************************
  69. ;
  70. ; If any of your routines zaps anything other than the Accumulator, then
  71. ; you must preserve all other registers.
  72. ;
  73. ;***********************************************************************
  74. ;
  75. ; This routine should turn off everything on the modem, hang up the
  76. ; phone, and get it ready to wait for a ring.
  77. ;
  78. MDINIT:    XRA    A
  79.     STA    CPORT        ;Hang up phone
  80.     STA    SPORT        ;Turn of Xmit/Recv
  81.     RET
  82. ;
  83. ; The following is a routine to determine if there is a character wait-
  84. ; ing to be received.  If none are there, the Zero flag will be set,
  85. ; otherwise, 255 will be returned in register A.  Remember that the
  86. ; system will like you a little more if you also mask out framing,
  87. ; parity, and overrun errors.
  88. ;
  89. MDINST:    LDA    SPORT        ;Get modem status
  90.     ANI    DAV        ;Data available?
  91.     RZ            ;nope
  92.     ORI    0FFH        ;return true
  93.     RET
  94. ;
  95. ; The following is a routine to determine if the transmit buffer is
  96. ; empty.  If it is empty, it will return with the Zero flag clear.  If
  97. ; the transmitter is busy, then it will return with the Zero flag set.
  98. ;
  99. MDOUTST:LDA    SPORT        ;Get modem status
  100.     ANI    TBMT        ;mask out junk
  101.     RET
  102. ;
  103. ; The following is a routine that will check to make sure we still have
  104. ; carrier.  If there is no carrier it will return with the Zero flag set.
  105. ;
  106. MDCARCK:LDA    RPORT        ;The Z80 interface likes this dummy load...
  107.     LDA    SPORT        ;Get modem status
  108.     CMA            ;flip/flop the Zero flag
  109.     ANI    CTS        ;got a carrier?
  110.     RET
  111. ;
  112. ; The following routine will check to see if the phone is ringing, if it
  113. ; isn't, it will return with Zero set, otherwise Zero will be cleared.
  114. ;
  115. MDRING:    LDA    RPORT        ;get ring port status
  116.     CMA            ;flip/flop the proper bit
  117.     ANI    RDET        ;ringing?
  118.     RET
  119. ;
  120. ; The following is a routine that will input one character from the
  121. ; modem port.  If there is nothing there, it will return garbage... so
  122. ; use the MDINST routine first.
  123. ;
  124. MDINP:    LDA    DPORT        ;get character
  125.     ANI    7FH        ;strip parity and other garbage
  126.     RET
  127. ;
  128. ; The following is a routine that will output one character in register
  129. ; A to the modem.  REMEMBER, that is register A, not register C.
  130. ;
  131. ; **** Use MDOUTST first to see if buffer is empty ****
  132. ;
  133. MDOUTP:    STA    DPORT        ;send character
  134.     RET
  135. ;
  136. ; The following routine will make the modem answer the phone.  It should
  137. ; set baudrate to 300 baud.
  138. ;
  139. MDANSW:    MVI    A,ANSW        ;Answer phone
  140.     STA    CPORT
  141.     PUSH    D        ;save register pair DE
  142.     MVI    E,20        ;Wait for modem to turn on
  143. ;
  144. ALOP1:    CALL    DELAY
  145.     DCR    E
  146.     JNZ    ALOP1
  147.     POP    D        ;restore registers
  148.     CALL    SET300
  149.     PUSH    B        ;here is the crock I was telling you
  150.     MVI    B,30        ;  about,  I was beating my head for two
  151. ;
  152. ALOOP:    CALL    DELAY        ;  days trying to figure out why the
  153.     LDA    RPORT        ;  carrier detect routine was not work-
  154.     LDA    SPORT        ;  ing - it turns out this corck here
  155.     LDA    DPORT        ;  will get the modem to work properly.
  156.     LDA    DPORT
  157.     DCR    B
  158.     JNZ    ALOOP
  159.     POP    B
  160.     RET
  161. ;
  162. ; These next routines set the proper baud rates for the modem.  If you
  163. ; do not support the particular rate, then simply put in a JMP to SETINV.
  164. ; If the baud rate change was successful, make SURE the Zero flag is set.
  165. ;
  166. ; The following routine returns a 255 because we were not able to set to
  167. ; the proper baud rate because either the serial port or the modem can't
  168. ; handle it.
  169. ;
  170. SET110:                ;110 bps too slow to support
  171. SET450:                ;450 bps not supported
  172. SET600:                ;600 bps not supported
  173. SET710:                ;710 bps not supported
  174. SET1200                ;1200 bps not supported
  175. ;
  176. SETINV:    ORI    0FFH        ;make sure the Zero flag isn't set
  177.     RET
  178. ;
  179. ; Set speed to 110 baud.
  180. ;
  181. SET110:    MVI    A,B110+ANSW
  182.     STA    CPORT        ;Set 110 bps
  183.     MVI    A,F110
  184.     STA    SPORT        ;Set 8 bits, no parity, 2 stop bits
  185.     RET
  186. ;
  187. ; Set up for 300 bps
  188. ;
  189. SET300:    MVI    A,B300+ANSW
  190.     STA    CPORT        ;Set 300 bps
  191.     MVI    A,NORM
  192.     STA    SPORT        ;Set 8 bits, no parity, 1 stop bit
  193.     RET
  194. ;
  195. ; Ok, that's all of the modem dependent routines that MBYE uses, so if
  196. ; you patch this file into your copy of MBYE, then it should work out
  197. ; well.
  198. ;
  199. ;**********************************************************************
  200. ;
  201.