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 / TRS-80 / BY2PSMAN.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  7KB  |  213 lines

  1. ;******************************************************************************
  2. ;               D. C. HAYES SMARTMODEM 300/1200 'Modem Control'
  3. ;                          BY2SMDM.ASM BY Don Brown
  4. ;                           version 1.1   04/24/83
  5. ;
  6. ; These routines may be used along with the more specific modem/usart
  7. ; routines commonly found in BYE11.LBR.
  8. ;
  9. ; These routines are specific to the needs of the Smartmodem 300/1200
  10. ; when used with BYEII and are not intended to override or preempt any
  11. ; function that is already performed by that software.
  12. ;
  13. ; This code is intended to be appended just after your own BYEII usart
  14. ; code, in BYEII.
  15. ;
  16. ;******************************************************************************
  17. ;
  18. ; Modification History (in reverse order):
  19. ;
  20. ; 07/23/84: Added BYE2FIX from Dave Crane. This fix will
  21. ;           reinitialize the Smartmodem in the event of a failure
  22. ;           caused by a ring at the same time the modem is being
  23. ;        initialized.                    <Ed Richter>
  24. ;
  25. ; 07/13/84: Modified and renamed to include the necessary code to allow  
  26. ;           use of the Anchor Signalman Mark XII also.      <Ed Richter>     
  27. ;
  28. ; 07/14/83: Modified the ring count to 2 instead of 3 (for S0=x). Other
  29. ;           modems would be timing out just as connection was being made.
  30. ;                                                               <pst>
  31. ;
  32. ; 04/24/83: Moved the smartmodem command bytes to reset the smartmodem
  33. ;           register S0, (answer on the nth ring), to the end of the
  34. ;           command string. Increase the number of rings stored in S0 from
  35. ;           1 to 3. Reduced the number of seconds stored in the S7 register
  36. ;           (number of seconds to wait for carrier before hang-up), from
  37. ;           30 to 11. Added additional comments. Assigned version 1.1
  38. ;                                                      <Don Brown>
  39. ;
  40. ; To use this code, the BYE2 routines for your usart must be modified:
  41. ;           SMODEM   EQU   TRUE      ;True, Hays Smartmodem 300/1200
  42. ;                                    ;or Anchor Mark XII
  43. ;          After all usart and baud rate instructions have been executed
  44. ;          and immediately after dtr has been set logic true, (dtr=on for
  45. ;          Smartmodem to receive commands), add the following:
  46. ;
  47. ;          IF SMODEM
  48. ;          CALL SMINIT
  49. ;          ENDIF        ;SMODEM
  50. ;
  51. ; The following hardware configuration is assumed.
  52. ;
  53. ;          DTR  (Pin 20)    true
  54. ;          DCD  (Pin  8)    true
  55. ;          RI   (Pin 22)    not true (Mark XII supports true or false)
  56. ;
  57. ; The following software (BYEII) configuration is assumed.
  58. ;         CWAIT    EQU     10
  59. ;         CLOSS    EQU      5
  60. ;
  61. ;         NORING   EQU     TRUE  (Mark XII supports true or false)
  62. ; There are no external switches for the Mark XII
  63. ;
  64. ;
  65. ; The following smartmodem default switches are assumed:
  66. ;  A. Switches not controlled by software:
  67. ;     1=up, 6=up, 7=up, 8=down
  68. ;
  69. ;  B. Switches controlled by software
  70. ;     2=up, 3=down, 4=down, 5=down
  71. ;
  72. ; Notes:
  73. ;     Smartmodem and Anchor will automatically set itself to the speed 
  74. ;     of the calling modem, if the speed is 300 or 1200. This relieves 
  75. ;     us of the need to set modem speed (still have to check and set the 
  76. ;     usart/baud), via software. 110 baud is not supported because the 
  77. ;     Smartmodem will not differentiate between 300 and 110 baud. You 
  78. ;     need to modify your usart routines to handle only 300/1200 baud.
  79. ;
  80. ;    BYEII drops DTR in order to hang up the phone. When DTR goes false
  81. ;    the Smartmodem will automatically drop the line and go to the local
  82. ;    command state. The Anchor Mark XII will not do this and must be reset
  83. ;    using software commands and the escape code. Because of this the
  84. ;    smartmodem can be "hung-up" if DTR goes true while the phone is 
  85. ;    ringing. Consequently it is extremely important that the register (S0)
  86. ;    be set to at least 2 and possibly 3 rings, and the command string ATZ
  87. ;    be executed immediately after DTR is set.
  88. ;
  89. ; Commands sent to the Smartmodem:
  90. ;    a.  'ATZ'    Attention and reset to default values
  91. ;    b.  The meaning of the 2nd command string is as follows:
  92. ;        'AT'     Attention
  93. ;        'Q1'     No result codes sent
  94. ;        'E0'     Do not echo commands
  95. ;        'M0'     Speaker off (not Mark XII)
  96. ;        'S0=128' Disable escape codes (not Mark XII)
  97. ;        'S7=11'  Seconds to wait for carrier (not Mark XII)
  98. ;        'S9=6'   Wait 6 seconds after carrier (not Mark XII)
  99. ;        'S10=60' Time to wait after carrier loss (not Mark XII)
  100. ;        'S0=2'   Answer on 2 rings. (should be last item in command string)
  101. ;
  102. ;******************************************************************************
  103. ;
  104. ; Initialize the Smartmodem.
  105. ; DTR must be logic true for the smartmodem to receive a command.
  106. ; The S0 register should be set to not less than 2 and should be the last
  107. ; string in the command.
  108. ;...
  109. ;
  110. RINGS    EQU    '2'
  111. ;
  112. ;...
  113. ;
  114. SMINIT     EQU    $+OFFSET
  115.     IF    ANCHOR
  116.     CALL    SMDELAY            ;1 second delay for the Mark XII      
  117.     CALL    SMSEND             ;send escape code           
  118.     DB    '+++',0
  119.     CALL    SMDELAY             ;1 second delay for Mark XII
  120.         CALL    SMSEND
  121.     DB    'ATZS0=0',CR,0        ;hang up and no-auto answer
  122.     CALL    SMDELAY            ;1 second delay for disconnect
  123.     CALL    SMSEND
  124.     DB    'ATE0Q1S0='        ;initialize no echo, no result codes
  125.     DB    RINGS            ;and answer on 2nd ring
  126.     DB    CR,0
  127.     CALL    SMDELAY
  128.     ENDIF    ;ANCHOR
  129. ;...
  130.     IF    NOT ANCHOR
  131.     CALL    SMSEND
  132.     DC    'ATZ',CR,0        ;Hayes default reset
  133.     CALL    SMDELAY            ;1 second needed by Smartmodem
  134.     CALL    SMDELAY            ;1 to stop erratic loads
  135.     CALL    SMSEND
  136.     DB    'ATQ1E0M0S2=128S7=11S9=6S10=60S0='
  137.     DB    RINGS
  138.     DB    CR,0            ;end message
  139.     CALL    SMDELAY            ;1 second needed by Smartmodem
  140.     ENDIF    ;IF NOT ANCHOR
  141. ;...
  142.     CALL    SMSEND            ;Look for error in S0
  143.     DB    'ATS0?',CR,0
  144. ;...
  145. SMCHK    EQU    $+OFFSET
  146.     CALL    SMGET
  147.     CPI    CR
  148.     JZ    SMCHK            ;Ignore CR and LF
  149.     CPI    LF
  150.     JZ    SMCHK            ;Ignore
  151.     CALL    SMGET            ;Skip 2nd zero
  152.     CALL    SMGET            ;Look at third digit
  153.     CPI    RINGS            ;This better be it
  154.     RZ                ;OK
  155.     JMP    SMINIT            ;Retry
  156. ;...
  157. SMGET    EQU    $+OFFSET
  158.     CALL    MDINST
  159.     CPI    0            ;Reply ??
  160.     JNZ    SMRDOK
  161.     LHLD    RDCNT            ;RDCNT is designed to keep us
  162.     INX    H            ;from hanging in a loop waiting
  163.     SHLD    RDCNT            ;for a modem that doesn't 
  164.     XRA    A            ;respond
  165.     CMP    H
  166.     JNZ    SMGET
  167.     CMP    L
  168.     JNZ    SMGET
  169.     JMP    SMRDNOK            ;Oh, Oh. Modem isn't going to speak
  170. ;...
  171. SMRDOK    EQU    $+OFFSET
  172.     CALL    MDINP            ;read
  173. ;...
  174. SMRDNOK    EQU    $+OFFSET
  175.     PUSH    A
  176.     XRA    A
  177.     STA    RDCNT            ;Counter reset
  178.     STA    RDCNT+1
  179.     POP    A
  180.     RET
  181. ;
  182. RDCNT    EQU    $+OFFSET
  183.     DB    0,0
  184. ;
  185. SMDELAY    EQU    $+OFFSET
  186.     PUSH    B              ;In case it is used
  187.     MVI    B,10
  188. DLP1    EQU    $+OFFSET
  189.     CALL    DELAY
  190.     DCR    B            ;Delay 1 second
  191.     JNZ    DLP1
  192.       POP    B            ;Done restore BC
  193.     RET
  194. ;
  195. SMSEND    EQU    $+OFFSET
  196.      XTHL    
  197.     PUSH    B            ;Get address of message
  198. SMPLP    EQU    $+OFFSET
  199.     CALL    MDOUTST            ;Modem status
  200.     JZ    SMPLP            ;Not ready, try again
  201.     MOV    A,M            ;Get character
  202.     CALL    MDOUTP            ;Send character
  203.     INX    H
  204.     MOV    A,M            ;Next character
  205.     ORA    A            ;0= All sent
  206.     JNZ    SMPLP            ;No get another
  207.     POP    B            ;Done restore BC
  208.     XTHL                ;Restore HL, get return address
  209.     RET
  210. ;
  211. ;End of Smartmodem overlay for BYEII
  212. ;******************************************************************************
  213.