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 / BYE5 / B5MM-1.IQS / B5MM-1.INS
Text File  |  2000-06-30  |  5KB  |  193 lines

  1.  
  2. ; B5MM-1.INS - BYE5 insert for MicroMint SB180 computer - 03/17/86
  3. ;
  4. ;        Note:  This is an insert, not an overlay.
  5. ;
  6. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  7. ;
  8. ; 03/17/86  Converted to 8080 source code, as BYE5 is not written in
  9. ;        Zilog Z80 mnemonics.  Can now be assembled with ASM.COM or
  10. ;        other 8080 assemblers.  Renamed to B5MM for "MicroMint" as
  11. ;        there is already a B5SB for the Super Brain computer.
  12. ;                    - Irv Hoff
  13. ;
  14. ; 10/08/85  Written for use with BYE5.    - Ken Davidson
  15. ;
  16. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  17. ;
  18. ; NOTE - There is an anomaly with the HD64180 chip that doesn't allow
  19. ;     the allow the use of its DCD input in a fashion useful to BYE5.
  20. ;     When the DCD input is inactive (false) the chip's receive
  21. ;     register is turned off.  Since the chip cannot receive any
  22. ;     characters with DCD off, it isn't possible to set up a Hayes
  23. ;     compatable modem.  A fix for this is to make a special modem
  24. ;     cable which has pins 5 and 8 reversed.  Assuming the modem's
  25. ;     CTS signal is always active, the chip's DCD line is always on.
  26. ;     The modem's DCD signal then enters the chip through CTS0/.
  27. ;     With CTS off, the chip can send and receive characters, and
  28. ;     the receive register full status works correctly.  However,
  29. ;     the transmit buffer empty status is turned off.  Therefore,
  30. ;     when setting up the modem with DCD off, a delay must be
  31. ;     inserted after each character is sent to ensure the next
  32. ;     character doesn't overrun it.    This fix is something of a
  33. ;     a kludge, but works and is the only way around the problem
  34. ;     without adding more hardware.    Of course, when a carrier is
  35. ;     present, the serial port works correctly.
  36. ;
  37. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  38. ;
  39. ;
  40. PORT    EQU    00H        ; Modem control port
  41. MDATIN    EQU    PORT+8        ; Data in port
  42. MDATOUT    EQU    PORT+6        ; Data out port
  43. MDCTL1    EQU    PORT+4        ; Modem status port
  44. ;
  45. MDRCV    EQU    80H        ; Modem receive ready bit
  46. MDSND    EQU    02H        ; Modem send ready bit
  47. MDDCD    EQU    20H        ; Data carrier detect
  48. ;
  49. CDSTAT    EQU    02H        ; Carrier detect status
  50. BRPORT    EQU    02H        ; Baud rate generator port
  51. ;
  52. IN0    EQU    38EDH        ; Special Hitachi op code pair
  53. OUT0    EQU    39EDH        ; Special Hitachi op code pair
  54. ;
  55. ;
  56. ; Divisors for the HD64180 baudrate generator
  57. ;
  58. BD300    EQU    13        ; 300 baud
  59. BD1200    EQU    11        ; 1200 bps
  60. BD2400    EQU    10        ; 2400 bps
  61. BD9600    EQU    8        ; 9600 bps
  62. ;
  63. ;
  64. ;-----------------------------------------------------------------------
  65. ;
  66. ; See if we still have a carrier - if not, return with the zero flat set
  67. ;
  68. MDCARCK:DW    IN0        ; Get the status
  69.     DB    CDSTAT
  70.     CMA
  71.     ANI    MDDCD        ; Check for carrier
  72.     RET
  73. ;.....
  74. ;
  75. ;
  76. ; Disconnect and wait for an incoming call
  77. ;
  78. MDINIT:    MVI    A,10H        ; Reset channel
  79.     DW    OUT0
  80.     DB    PORT
  81.     PUSH    B        ; Save in case it's being used elsewhere
  82.     MVI    B,20        ; 2 second delay to drop any carrier
  83. ;
  84. OFFTI:    CALL    DELAY        ; 1 second delay
  85.     DCR    B
  86.     JNZ    OFFTI        ; Keep looping until finished
  87.     POP    B        ; Restore 'BC'
  88.     MVI    A,64H        ; Turn DTR back on
  89.     DW    OUT0
  90.     DB    PORT
  91. ;
  92.      IF    IMODEM        ; If using an intellegent modem
  93.     CALL    IMINIT        ; Go initialize it now
  94.      ENDIF            ; IMODEM
  95. ;
  96.     RET
  97. ;.....
  98. ;
  99. ;
  100. ; Input a character from the modem port
  101. ;
  102. MDINP:    DW    IN0        ; Get the character
  103.     DB    MDATIN
  104.     RET
  105. ;.....
  106. ;
  107. ;
  108. ; Check the status to see if a character is available.    If not, return
  109. ; with the zero flag set.  If yes, use 0FFH to clear the flag.
  110. ;
  111. MDINST:    DW    IN0        ; Get the status
  112.     DB    MDCTL1
  113.     ANI    MDRCV        ; Got a character
  114.     RZ            ; Return if none
  115.     ORI    0FFH        ; Otherwise set the proper flag
  116.     RET
  117. ;.....
  118. ;
  119. ;
  120. ; Send a character to the modem
  121. ;
  122. MDOUTP:    DW    OUT0
  123.     DB    MDATOUT
  124.     RET
  125. ;.....
  126. ;
  127. ;
  128. ; See if the output is ready for another character
  129. ;
  130. MDOUTST:DW    IN0        ; Get the status
  131.     DB    CDSTAT
  132.     ANI    MDDCD        ; Check for carrier
  133.     JZ    MDST1        ; Jump if present
  134.     CALL    DELAY
  135.     ORI    0FFH
  136.     RET
  137. ;
  138. MDST1:    DW    IN0        ; Get the status
  139.     DB    MDCTL1
  140.     ANI    MDSND        ; Ready for a character?
  141.     RET
  142. ;.....
  143. ;
  144. ;
  145. ; Reinitialize the modem and hang up the phone by dropping DTR and
  146. ; leaving it inactive.
  147. ;
  148. MDQUIT:     IF    IMODEM
  149.     CALL    IMQUIT
  150.      ENDIF            ; IMODEM
  151. ;
  152. ;
  153. ; Called by the main program after caller types BYE
  154. ;
  155. MDSTOP:    MVI    A,74H        ; Turn off DTR until next time
  156.     DW    OUT0
  157.     DB    PORT
  158.     RET
  159. ;.....
  160. ;
  161. ;
  162. ; The following routine sets the baud rate.  BYE5 asks for the maximum
  163. ; speed you have available.
  164. ;
  165. SETINV:    ORI    0FFH        ; Make sure zero flag is not set
  166.     RET
  167. ;.....
  168. ;
  169. ;
  170. SET300:    MVI    A,BD300
  171.     JMP    SETBAUD
  172. ;
  173. SET1200:MVI    A,BD1200
  174.     JMP    SETBAUD
  175. ;
  176. SET2400:MVI    A,BD2400
  177.     JMP    SETBAUD
  178. ;
  179. SET9600:MVI    A,BD9600
  180. ;.....
  181. ;
  182. ;
  183. ; Sets the baudrate
  184. ;
  185. SETBAUD:DW    OUT0
  186.     DB    BRPORT
  187.     XRA    A        ; Say baudrate is ok
  188.     RET
  189. ;.....
  190. ;
  191. ;                   end
  192. ;-----------------------------------------------------------------------
  193.