home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / bye3 / b3ap-2.iqs / B3AP-2.INS
Text File  |  1985-11-17  |  4KB  |  163 lines

  1.  
  2. ; B3AP-2.INS - APPLE ][ with Mountain CPS Serial Card - 07/30/85
  3. ;
  4. ;        2651 with internal baudrate generator
  5. ;
  6. ;           NOTE: This is an insert, not an overlay.
  7. ;
  8. ; WARNING:  Carrier detect (DCD) from the modem must go to DSR input on
  9. ;        the 2651 to provide proper operation for both autodialing
  10. ;        and autoreceiving.    If you use the DCD input, it requires
  11. ;        voltage (normally unavailable) during dialing to allow
  12. ;        result codes to be used.
  13. ;
  14. ;    To build "a better modem cable", on the apple side of the cable,
  15. ;    hook the following pins together:
  16. ;        5, 8, 20    - this will force CTS and DCD high when
  17. ;                  DTR is on.
  18. ;        6        - tie the real DCD (pin 8 on the modem)
  19. ;                  to this pin.
  20. ;
  21. ;        This program assumes you use the DSR pin (80H) to check carrier
  22. ;    from the modem.
  23. ;
  24. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  25. ;
  26. ; 07/30/85  Restored original format            - pst
  27. ; 07/24/85  Fixed minor bug with 2400 baud setting    - pst
  28. ; 01/20/84  Created overlay using BY2-2651.ASM        - Norman Beeler
  29. ;
  30. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  31. ;
  32. ; Define the CPS card slot you are using (normally 1 or 2)
  33. ;
  34. SLOT    EQU    2        ; CPM card slot
  35. ;
  36. ;=======================================================================
  37. ;
  38. ; Modem port equates
  39. ;
  40. DPORT    EQU    0E0FAH+SLOT*100H ; Modem data port
  41. SPORT    EQU    0E0FBH+SLOT*100H ; Modem status port
  42. XPORT    EQU    0E0FEH+SLOT*100H ; Modem swap port
  43. ;
  44. ; Status port equates
  45. ;
  46. TBMT    EQU    00000001B    ; Transmit buffer empty
  47. DAV    EQU    00000010B    ; Data available
  48. DCD    EQU    10000000B    ; Data carrier detect
  49. ;
  50. ; Mode port equates
  51. ;
  52. EBASE    EQU    30H        ; Mode register 2 base
  53. B300    EQU    EBASE+5        ; 300 baud
  54. B1200    EQU    EBASE+7        ; 1200 bps
  55. B2400    EQU    EBASE+10    ; 2400 bps
  56. ;
  57. ;-----------------------------------------------------------------------
  58. ;
  59. ; See if we still have a carrier - if not, return with the zero flag set
  60. ;
  61. MDCARCK:LDA    SPORT        ; Read port
  62.     ANI    DCD        ; Check DSR for carrier (do not use DCD)
  63.     RZ
  64.     ORI    255
  65.     RET
  66. ;
  67. ; Disconnect and wait for an incoming call
  68. ;
  69. MDINIT:    MVI    A,80H        ; Open CPS command register
  70.     STA    XPORT        ; By storing 80H in XPORT
  71.     MVI    A,15H        ; Turn DTR off, modem will quit
  72.     STA    SPORT
  73.     MVI    B,20        ; 2 seconds to drop any carrier
  74. ;
  75. MDINIT1:CALL    DELAY        ; .1 second delay
  76.     DCR    B
  77.     JNZ    MDINIT1
  78.     MVI    A,17H        ; With DTR on, modem accepts commands
  79.     STA    SPORT
  80.     XRA    A        ; Close the command port
  81.     STA    XPORT        ; By storing 0 in XPORT
  82. ;
  83.      IF    IMODEM
  84.     CALL    IMINIT        ; Initialize smartmodem
  85.      ENDIF            ; IMODEM
  86. ;
  87.     RET
  88. ;
  89. ; Input a character from the modem port
  90. ;
  91. MDINP:    LDA    DPORT        ; Get character
  92.     RET
  93. ;
  94. ; Check the status to see if a character is available.    If not, return
  95. ; with the zero flag set.  If yes, use 0FFH to clear the flag.
  96. ;
  97. MDINST:    LDA    SPORT        ; Read port
  98.     ANI    DAV        ; Check receive ready bit
  99.     RZ            ; Nope, nothing there
  100.     ORI    255        ; We got something...
  101.     RET
  102. ;
  103. ; Send a character to the modem
  104. ;
  105. MDOUTP:    STA    DPORT        ; Send it
  106.     RET
  107. ;
  108. ; See if the output is ready for another character
  109. ;
  110. MDOUTST:LDA    SPORT        ; Read port
  111.     ANI    TBMT        ; Check transmit ready bit
  112.     RZ
  113.     ORI    255
  114.     RET
  115. ;
  116. ; Reinitialize the modem and hang up the phone by dropping DTR and
  117. ; leaving it inactive.
  118. ;
  119. MDQUIT:     IF    IMODEM
  120.     CALL    IMQUIT        ; Initialize modem to default settings
  121.      ENDIF            ; IF IMODEM
  122. ;
  123. ;
  124. ; Called by the main program after caller types BYE
  125. ;
  126. MDSTOP:    MVI    A,80H        ; Open CPS command register
  127.     STA    XPORT        ; By storing 80H in XPORT
  128.     XRA    A        ; Turn DTR off, modem will quit
  129.     STA    SPORT
  130.     CALL    DELAY        ; Let it stabilize
  131.     RET
  132. ;
  133. ; The following routine sets the baudrate.  BYE3 asks for the maximum
  134. ; speed you have available.
  135. ;
  136. SET300:    CALL    BSETUP
  137.     MVI    A,B300
  138.     JMP    FSETUP
  139. ;
  140. SET1200:CALL    BSETUP
  141.     MVI    A,B1200
  142.     JMP    FSETUP
  143. ;
  144. SET2400:CALL    BSETUP
  145.     MVI    A,B2400
  146.     JMP    FSETUP
  147. ;
  148. BSETUP:    MVI    A,80H
  149.     STA    XPORT
  150.     MVI    A,37H        ; Initialize the serial chip
  151.     STA    SPORT        ; By storing 37H in SPORT
  152.     MVI    A,4EH        ; 1 stop, 8 bits, no parity
  153.     STA    DPORT
  154.     XRA    A
  155.     RET
  156. ;
  157. FSETUP:    STA    DPORT
  158.     XRA    A
  159.     STA    XPORT        ; Close command port by storing 0
  160.     RET
  161. ;                   end
  162. ;-----------------------------------------------------------------------
  163.