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 / MEX / MXM-CM11.AQM / MXM-CM11.ASM
Assembly Source File  |  2000-06-30  |  8KB  |  246 lines

  1.     TITLE    'MEX Cermetek Infomate 212a overlay V1.1'
  2. ;
  3. ; (DELETE ABOVE TITLE LINE IF ASSEMBLING WITH ASM)
  4. ;
  5. ; Cermetek overlay for MEX: revision 1.1
  6. ; Written 08/22/84 by Paul Traina with grateful thanks to Ronald G. Fowler
  7. ; Last revision: 08/24/84 (PST)
  8. ;
  9. ; This modules adapts MEX for the Cermetek Infomate 212a Intelligent Modem.
  10. ; The main function of this module is to provide dialing capability; the
  11. ; disconnect vector is ancillary.
  12. ;
  13. ;----------------------------------------------------------------
  14. ;
  15. ; 08/24/84    Updated for MEX version 1.1        -- Paul Traina
  16. ;
  17. ; 08/22/84    This is based upon original work by RGF.  I can take
  18. ;        no credit for the intelligence needed to make this module,
  19. ;        but if there is some blame for it malfunctioning, I'll take
  20. ;        that, because I was the one who performed the cut-job.
  21. ;                            -- Paul Traina
  22. ;
  23. ;----------------------------------------------------------------
  24. ;
  25. ; This overlay will work with any modem overlay that terminates
  26. ; prior to 0900H
  27. ;
  28. ; System Constants
  29. ;
  30. DIALV    EQU    0162H        ; Location of DIAL vector in overlay
  31. DISCV    EQU    0165H        ; Location of DISCONNECT vector in overlay
  32. DIALOC    EQU    0900H        ; Dialing code goes here
  33. MEX    EQU    0D00H        ; "CALL MEX"
  34. ;
  35. ; Following are function codes for the MEX service call processor
  36. ;
  37. INMDM    EQU    255        ; Return char form MDM in A, CY=no chr in 100ms
  38. TIMER    EQU    254        ; Wait B*100ms
  39. TMDINP    EQU    253        ; B=# secs to wait for char, CY=no char
  40. CHEKCC    EQU    252        ; Check for ^C from kbd, Z=present
  41. SNDRDY    EQU    251        ; Test for modem-send ready
  42. RCVRDY    EQU    250        ; Test for modem-receive ready
  43. SNDCHR    EQU    249        ; Send a character to the modem (after SNDRDY)
  44. RCVCHR    EQU    248        ; Recv a char from modem (after RCVRDY)
  45. ILP    EQU    240        ; Inline print routine
  46. ;
  47. CR    EQU    13        ; Ascii carriage-return
  48. LF    EQU    10        ; Ascii line-feed
  49. APPOS    EQU    027H        ; Ascii appostrophe
  50. ;
  51.     ORG    DIALV        ; Overlay the dialing vector
  52.     JMP    DIAL
  53. ;
  54. ; This is the DIAL routine called by MEX to dial a digit. The digit
  55. ; to be dialed is passed in the A register.  Note that two special
  56. ; codes must be intercepted as non-digits: 254 (start dial sequence)
  57. ; and 255 (end-dial sequence).    Mex will always call DIAL with 254
  58. ; in the accumulator prior to dialing a number.  Mex will also call
  59. ; dial with 255 in A as an indication that dialing is complete. Thus,
  60. ; the overlay may use these values to "block" the number, holding it
  61. ; in a buffer until it is completely assembled (in fact, that's the
  62. ; scheme employed here for the Smartmodem).
  63. ;
  64. ; After the 254-start-dial sequence, MEX will call the overlay with
  65. ; digits, one-at-a-time.  MEX will make no assumptions about the dig-
  66. ; its, and will send each to the DIAL routine un-inspected (some modems,
  67. ; like the Smartmodem, allow special non-numeric characters in the
  68. ; phone number, and MEX may make no assumptions about these).
  69. ;
  70. ; After receiving the end-dial sequence (255) the overlay must take
  71. ; whatever end-of-dial actions are necessary *including* waiting for
  72. ; carrier at the distant end.  The overlay should monitor the keyboard
  73. ; during this wait (using the MEX keystat service call), and return
  74. ; an exit code to MEX in the A register, as follows:
  75. ;
  76. ;    0 - Carrier detected, connection established
  77. ;    1 - Far end busy (only for modems that can detect this condition)
  78. ;    2 - No answer (or timed out waiting for modem response)
  79. ;    3 - Keyboard abort (^C only: all others should be ignored)
  80. ;    4 - Error reported by modem
  81. ;    5 - No ring detected (only for modems that can detect this condition)
  82. ;    6 - No dial tone (only for modems that can detect this condition)
  83. ;
  84. ; <No other codes should be returned after an end-dial sequence>
  85. ;
  86. ; The overlay should not loop forever in the carrier-wait routine, but
  87. ; instead use either the overlay timer vector, or the INMDMV (timed 100
  88. ; ms character wait) service call routine.
  89. ;
  90. ; The DIAL routine is free to use any of the registers, but must return
  91. ; the above code after an end-dial sequence
  92. ;
  93.     ORG    DIALOC
  94. ;
  95. DIAL:    LHLD    DIALPT        ; Fetch pointer
  96.     CPI    254        ; Start dial?
  97.     JZ    STDIAL        ; Jump if so
  98.     CPI    255        ; End dial?
  99.     JZ    ENDIAL        ; Jump if so
  100. ;
  101. ; Not start or end sequence, must be a digit to be sent to the modem
  102. ;
  103.     MOV    M,A        ; Put char in buffer
  104.     INX    H        ; Advance pointer
  105.     SHLD    DIALPT        ; Stuff pointer
  106.     RET            ; All done
  107. ;
  108. ; Here on a start-dial sequence
  109. ;
  110. STDIAL:    LXI    H,DIALBF    ; Set up buffer pointer
  111.     SHLD    DIALPT
  112.     RET
  113. ;
  114. ; Here on an end-dial sequence
  115. ;
  116. ENDIAL:    MVI    M,0        ; Terminate buffer
  117.     CALL    IMLRN        ; Learn new baud rate
  118.     LXI    H,IMDIAL    ; Point to dialing string
  119.     CALL    IMSEND        ; Send it
  120.     LXI    H,IMEND        ; Point to terminal part of string
  121.     CALL    IMSEND
  122.     MVI    C,INMDM
  123.     CALL    MEX        ; Catch any output from the modem
  124. ;
  125. ; The following loop waits for a result from the modem (up to
  126. ; 60 seconds: You may change this value in the following line)
  127. ;
  128. RESULT:    MVI    C,60        ; <<== MAXIMUM TIME TO WAIT FOR RESULT
  129. IMWLP:    PUSH    B
  130.     MVI    B,1        ; Check for a char, up to 1 sec wait
  131.     MVI    C,TMDINP    ; Do timed input
  132.     CALL    MEX
  133.     POP    B
  134.     JNC    IMTEST        ; Jump if modem had a char
  135.     PUSH    B        ; No, test for ^C from console
  136.     MVI    C,CHEKCC
  137.     CALL    MEX
  138.     POP    B
  139.     JNZ    IMNEXT        ; If not, jump
  140.     CALL    DISCV        ; Disconnect for 1 second if possible
  141.     LXI    H,IMABRT    ; Send abort string
  142.     CALL    IMSEND
  143. WTABRT:    MVI    C,INMDM        ; Wait for any garbage
  144.     CALL    MEX
  145.     JNC    WTABRT
  146.     MVI    A,3        ; Return abort code
  147.     RET
  148. IMNEXT:    DCR    C        ; No
  149.     JNZ    IMWLP        ; Continue
  150. ;
  151. ; One minute with no modem response
  152. ;
  153. IMTIMO:    MVI    A,4        ; Return with modem error
  154.     RET
  155. ;
  156. ; Modem gave us a result, check it
  157. ;
  158. IMTEST:    ANI    127        ; Ignore any parity
  159.     CALL    IMANAL        ; Test the result
  160.     JC    RESULT        ; Go try again if unknown response
  161.     MOV    A,B        ; A=result
  162.     PUSH    PSW        ; Save it
  163. IMTLP:    MVI    C,INMDM        ; Eat any additional chars from modem
  164.     CALL    MEX
  165.     JNC    IMTLP        ; Until 100ms of quiet time
  166.     POP    PSW        ; Return the code
  167.     RET
  168. ;
  169. IMANAL:    MVI    B,0        ; Prep connect code         B=0
  170.     CPI    'A'        ; Answer?
  171.     RZ
  172.     MVI    B,1        ; Prep busy code         B=1
  173.     CPI    'B'        ; Busy?
  174.     RZ
  175.     MVI    B,2        ; Prep no connect message     B=2
  176.     CPI    'N'        ; No answer?
  177.     RZ
  178.     MVI    B,4        ; Prep error             B=4
  179.     CPI    'W'        ; Wrong baud rate?
  180.     RZ
  181.     MVI    B,6        ; Prep no dial tone         B=6
  182.     CPI    'X'        ; No phone connected?
  183.     RZ
  184. ;
  185.     CPI    'V'        ; Voice (which mex does not support)
  186.     JNZ    WTCR        ; Error
  187.     PUSH    D        ; Message
  188.     PUSH    H
  189.     MVI    C,ILP
  190.     CALL    MEX
  191.     DB    'VOICE ',0
  192.     POP    H
  193.     POP    D
  194. ;
  195. ; Unknown response, return carry to caller, do not flush unknown response
  196. ;
  197. WTCR:    STC            ; Set flag if so
  198.     RET
  199. ;
  200. ; Utility routine, learn baud rate
  201. ;
  202. IMLRN:    LXI    H,IMLERN
  203. IMLRN1:    MVI    C,SNDRDY    ; Wait for modem ready
  204.     CALL    MEX
  205.     JNZ    IMLRN1
  206.     PUSH    H        ; Wait 200ms
  207.     MVI    B,2
  208.     MVI    C,TIMER
  209.     CALL    MEX
  210.     POP    H
  211.     MOV    A,M        ; Fetch next character
  212.     INX    H
  213.     ORA    A        ; End?
  214.     RZ            ; Done if so
  215.     MOV    B,A        ; No, position for sending
  216.     MVI    C,SNDCHR    ; Nope, send the character
  217.     CALL    MEX
  218.     JMP    IMLRN1
  219. ;
  220. ; Utility routine: send string to modem
  221. ;
  222. IMSEND:    MVI    C,SNDRDY    ; Wait for modem ready
  223.     CALL    MEX
  224.     JNZ    IMSEND
  225.     MOV    A,M        ; Fetch next character
  226.     INX    H
  227.     ORA    A        ; End?
  228.     RZ            ; Done if so
  229.     MOV    B,A        ; No, position for sending
  230.     MVI    C,SNDCHR    ; Nope, send the character
  231.     CALL    MEX
  232.     JMP    IMSEND
  233. ;
  234. ; DATA AREA
  235. ;
  236. IMDIAL:    DB    CR,'N'-40H,'N ~',CR,CR,CR ; Init to new attn character
  237.     DB    '~U 1',CR,CR,CR    ; Unlisten
  238.     DB    '~D ',APPOS    ; ~D 'num'^M
  239. DIALBF:    DS    52        ; 2* 24 char max,+cr+null+slop
  240. DIALPT:    DS    2        ; Dial position pointer
  241. IMEND:    DB    APPOS,CR,0    ; End part of dial string
  242. IMABRT:    DB    '~',CR,'~',CR,CR,0 ; Abort string
  243. IMLERN:    DB    '  XY',CR,0    ; Learn baud rate
  244. ;
  245.     END
  246.