home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / bye3 / b3xe-2.iqs / B3XE-2.INS
Encoding:
Text File  |  1985-11-17  |  3.0 KB  |  134 lines

  1. ; B3XE-2.INS  -  Xerox 820 insert for BYE3  -  08/01/85
  2. ;
  3. ;           Z80-SIO and CTC baudrate generator
  4. ;
  5. ;        Note:  This is an insert, not an overlay.
  6. ;
  7. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  8. ;
  9. DPORT    EQU    04H        ; Data port
  10. SPORT    EQU    DPORT+2        ; Modem control port
  11. BRPORT    EQU    00H        ; Baud rate generator port
  12. ;
  13. DAV    EQU    00000001B    ; Data available
  14. TBMT    EQU    00000100B    ; Transmit buffer empty
  15. DCD    EQU    00001000B    ; Data carrier detect
  16. ;
  17. ; Divisors for the 8116 baudrate generator
  18. ;
  19. BD300    EQU    5        ; 300 baud
  20. BD1200    EQU    7        ; 1200 bps
  21. BD2400    EQU    10        ; 2400 bps
  22. ;
  23. ;-----------------------------------------------------------------------
  24. ;
  25. ; See if we still have a carrier - if not, return with the zero flat set
  26. ;
  27. MDCARCK:MVI    A,10H        ; Reset status
  28.     OUT    SPORT
  29.     IN    SPORT        ; Get status
  30.     ANI    DCD        ; Check for carrier
  31.     RET
  32. ;
  33. ; Disconnect and wait for an incoming call
  34. ;
  35. MDINIT:    MVI    A,0        ; Setup to write register 0
  36.     OUT    SPORT
  37.     MVI    A,18H        ; Reset channel
  38.     OUT    SPORT
  39. ;
  40.     MVI    A,4        ; Setup to write register 4
  41.     OUT    SPORT
  42.     MVI    A,44H        ; Set 16x, 1 stop bit, no parity
  43.     OUT    SPORT
  44. ;
  45.     MVI    A,3        ; Setup to write register 3
  46.     OUT    SPORT
  47.     MVI    A,0C1H        ; 8 bits, Rx enable
  48.     OUT    SPORT
  49. ;
  50.     MVI    A,5        ; Setup to write register 5
  51.     OUT    SPORT
  52.     MVI    A,68H        ; DTR off
  53.     OUT    SPORT
  54. ;
  55.     PUSH    B        ; Save in case it's being used elsewhere
  56.     MVI    B,20        ; 2 second delay to drop any carrier
  57. OFFTI:    CALL    DELAY        ; 1 second delay
  58.     DCR    B
  59.     JNZ    OFFTI        ; Keep looping until finished
  60.     POP    B        ; Restore 'BC'
  61. ;
  62.     MVI    A,5        ; Setup to write register 5
  63.     OUT    SPORT
  64.     MVI    A,0E8H        ; Turn DTR back on
  65.     OUT    SPORT
  66. ;
  67.      IF    IMODEM        ; If using an intellegent modem
  68.     CALL    IMINIT        ; Go initialize it now
  69.      ENDIF            ; IMODEM
  70. ;
  71.     RET
  72. ;
  73. ; Input a character from the modem port
  74. ;
  75. MDINP:    IN    DPORT        ; Get character
  76.     RET
  77. ;
  78. ; Check the status to see if a character is available.  If not, return
  79. ; with the zero flag set.  If yes, use 0FFH to clear the flag.
  80. ;
  81. MDINST:    IN    SPORT        ; Get status
  82.     ANI    DAV        ; Got a character
  83.     RZ            ; Return if none
  84.     ORI    255        ; Otherwise set the proper flag
  85.     RET
  86. ;
  87. ; Send a character to the modem
  88. ;
  89. MDOUTP:    OUT    DPORT        ; Send it
  90.     RET
  91. ;
  92. ; See if the output is ready for another character
  93. ;
  94. MDOUTST:IN    SPORT        ; Get status
  95.     ANI    TBMT        ; Ready for a character?
  96.     RZ
  97.     ORI    255
  98.     RET
  99. ;
  100. ; Reinitialize the modem and hang up the phone by dropping DTR and
  101. ; leaving it inactive.
  102. ;
  103. MDQUIT:     IF    IMODEM
  104.     CALL    IMQUIT
  105.      ENDIF            ; IMODEM
  106. ;
  107. ;
  108. ; Called by the main program after caller types BYE
  109. ;
  110. MDSTOP:    MVI    A,5        ; Setup to write register 5
  111.     OUT    SPORT
  112.     MVI    A,68H        ; Turn off DTR until next time
  113.     OUT    SPORT
  114.     RET
  115. ;
  116. ; The following routine sets the baud rate.  BYE3 asks for the maximum
  117. ; speed you have available.
  118. ;
  119. SET300:    MVI    A,BD300
  120.     JMP    SETBAUD
  121. ;
  122. SET1200:MVI    A,BD1200
  123.     JMP    SETBAUD
  124. ;
  125. SET2400:MVI    A,BD2400
  126. ;
  127. ; Sets the baudrate
  128. ;
  129. SETBAUD:OUT    BRPORT
  130.     XRA    A        ; Say baudrate is ok
  131.     RET
  132. ;                   end
  133. ;------------------------------------------------------------------------
  134.