home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols200 / vol218 / mxm-pc10.asm < prev    next >
Assembly Source File  |  1994-07-13  |  10KB  |  315 lines

  1. ;    TITLE    'MEX POPCOM OVERLAY V1.3'
  2. ;
  3. ; (un-DELETE ABOVE TITLE LINE IF ASSEMBLING WITH mac)
  4. ;
  5. ; PopCom overlay for MEX: revision 1.0
  6. ; adapted from smartmodem overlay Written 04/16/84 by Ronald G. Fowler
  7. ;
  8. ; 10/25/84: adapted smartmodem rev 1.3 for compatability with PopCom
  9. ;        using numeric result codes exclusively. (Howard Vigorita)
  10. ; 07/16/84: Added equate NUMRES to enable/disable numeric result code 
  11. ;        interpretation.  Under TurboDos, the first digit of the 
  12. ;        phone number was being interpreted as a result code as it 
  13. ;        was echoed by the Anchor modem as it dialed.  Set NUMRES false
  14. ;        to disable numeric results. (Bob Puckett)
  15. ;
  16. ; 06/06/84: Fixed problem for Anchor users, where, when the modem returned
  17. ;        "DIAL TONE", the "N" in "TONE" was being regarded as a NO-CONNECT
  18. ;        code.  Now we flush the entire result line before reading another.
  19. ;        Also added code for numeric version of "CONNECT 1200".  --RGF
  20. ;
  21. ; Small bug repaired: (V1.1) 05/14/84 (Steve Grandi): Smartmodem was not being 
  22. ;    flushed after a dial string so that last digit of the phone number 
  23. ;    was being interpreted as a numeric result code causing the program, 
  24. ;    for certain numbers, to give up even as the modem merrily dialed away.
  25. ;
  26. ; This modules adapts MEX for the PopCom modem.
  27. ; The main function of this module is to pro-
  28. ; vide dialing capability; the disconnect vector is ancillary.
  29. ; You may use this module as a model to develop dialing routines
  30. ; for non-standard modems (e.g., the Racal-Vadic).  The only
  31. ; pertinent entry point is the DIAL routine; you'll find entry
  32. ; specs for that below.
  33. ;
  34. ; The only conditional you might want to change in this
  35. ; module is the DISC equate below -- if left on, MEX will
  36. ; use the Smartmodem's disconnect code.  If you prefer to
  37. ; provide your own in your overlay's DISCV vector (e.g.,
  38. ; by dropping DTR), then set DISC to FALSE and re-assemble.
  39. ; (If you don't understand this, then play it safe, and
  40. ; leave the equate set as it is).
  41. ;
  42. ; This overlay will work with any modem overlay that terminates
  43. ; prior to 0B00H
  44. ;
  45. FALSE    EQU    0
  46. TRUE    EQU    1
  47. ;
  48. NUMRES    EQU    TRUE        ; TRUE = INTERPRET NUMERIC RESULT CODES
  49.                 ; FALSE = IGNORE NUMERIC RESULT CODES
  50. ;
  51. DISC    EQU    TRUE        ;<<== CHANGE TO FALSE IF YOU DISC. WITH DTR
  52. ;
  53. ; SYSTEM CONSTANTS
  54. ;
  55. TPULSE    EQU    0105H        ;TONE/PULSE FLAG IN MODEM OVERLAY
  56. DIALV    EQU    0162H        ;LOCATION OF DIAL VECTOR IN OVERLAY
  57. DISCV    EQU    0165H        ;LOCATION OF DISCONNECT VECTOR IN OVERLAY
  58. DIALOC    EQU    0B00H        ;DIALING CODE GOES HERE
  59. MEX    EQU    0D00H        ;"CALL MEX"
  60. ;
  61. ; FOLLOWING ARE FUNCTION CODES FOR THE MEX SERVICE CALL PROCESSOR
  62. ;
  63. INMDM    EQU    255        ;RETURN CHAR FROM MDM IN A, CY=NO CHR IN 100MS
  64. TIMER    EQU    254
  65. TMDINP    EQU    253        ;B=# SECS TO WAIT FOR CHAR, CY=NO CHAR
  66. CHEKCC    EQU    252        ;CHECK FOR ^C FROM KBD, Z=PRESENT
  67. SNDRDY    EQU    251        ;TEST FOR MODEM-SEND READY
  68. RCVRDY    EQU    250        ;TEST FOR MODEM-RECEIVE READY
  69. SNDCHR    EQU    249        ;SEND A CHARACTER TO THE MODEM (AFTER SNDRDY)
  70. RCVCHR    EQU    248        ;RECV A CHAR FROM MODEM (AFTER RCVRDY)
  71. ;
  72. CR    EQU    13
  73. LF    EQU    10
  74. ;
  75. ;
  76. ;
  77.     ORG    DIALV        ;OVERLAY THE DIALING VECTOR
  78.     JMP    DIAL
  79. ;    
  80.     IF    DISC        ;IF PROVIDING DISCONNECT CODE
  81.     ORG    DISCV        ;OVERLAY THE VECTOR
  82.     JMP    DISCON
  83.     ENDIF
  84. ;
  85. ; This is the DIAL routine called by MEX to dial a digit. The digit
  86. ; to be dialed is passed in the A register.  Note that two special
  87. ; codes must be intercepted as non-digits: 254 (start dial sequence)
  88. ; and 255 (end-dial sequence).  Mex will always call DIAL with 254
  89. ; in the accumulator prior to dialing a number.  Mex will also call
  90. ; dial with 255 in A as an indication that dialing is complete. Thus,
  91. ; the overlay may use these values to "block" the number, holding it
  92. ; in a buffer until it is completely assembled (in fact, that's the
  93. ; scheme employed here for the Smartmodem).
  94. ;
  95. ; After the 254-start-dial sequence, MEX will call the overlay with
  96. ; digits, one-at-a-time.  MEX will make no assumptions about the dig-
  97. ; its, and will send each to the DIAL routine un-inspected (some modems,
  98. ; like the Smartmodem, allow special non-numeric characters in the
  99. ; phone number, and MEX may make no assumptions about these).
  100. ;
  101. ; After receiving the end-dial sequence (255) the overlay must take
  102. ; whatever end-of-dial actions are necessary *including* waiting for
  103. ; carrier at the distant end.  The overlay should monitor the keyboard
  104. ; during this wait (using the MEX keystat service call), and return
  105. ; an exit code to MEX in the A register, as follows:
  106. ;
  107. ;    0 - Carrier detected, connection established
  108. ;    1 - Far end busy (only for modems that can detect this condition)
  109. ;    2 - No answer (or timed out waiting for modem response)
  110. ;    3 - Keyboard abort (^C only: all others should be ignored)
  111. ;    4 - Error reported by modem
  112. ;
  113. ; <No other codes should be returned after an end-dial sequence>
  114. ;
  115. ; The overlay should not loop forever in the carrier-wait routine, but
  116. ; instead use either the overlay timer vector, or the INMDMV (timed 100
  117. ; ms character wait) service call routine.
  118. ;
  119. ; The DIAL routine is free to use any of the registers, but must return
  120. ; the above code after an end-dial sequence
  121. ;
  122.     ORG    DIALOC
  123. ;
  124. DIAL:    LHLD    DIALPT        ;FETCH POINTER
  125.     CPI    254        ;START DIAL?
  126.     JZ    STDIAL        ;JUMP IF SO
  127.     CPI    255        ;END DIAL?
  128.     JZ    ENDIAL        ;JUMP IF SO
  129. ;
  130. ; Not start or end sequence, must be a digit to be sent to the modem
  131. ;
  132.     MOV    M,A        ;PUT CHAR IN BUFFER
  133.     INX    H        ;ADVANCE POINTER
  134.     SHLD    DIALPT        ;STUFF PNTR
  135.     RET            ;ALL DONE
  136. ;
  137. ; Here on a start-dial sequence
  138. ;
  139. STDIAL:    LXI    H,DIALBF    ;SET UP BUFFER POINTER
  140.     SHLD    DIALPT
  141.     RET
  142. ;
  143. ; Here on an end-dial sequence
  144. ;
  145. ENDIAL:    MVI    M,CR        ;STUFF END-OF-LINE INTO BUFFER
  146.     INX    H        ;FOLLOWED BY TERMINATOR
  147.     MVI    M,0
  148.     LDA    TPULSE        ;GET OVERLAY'S TOUCH-TONE FLAG
  149.     STA    SMDIAL1        ;PUT INTO STRING
  150.     LXI    H,SMDIAL    ;POINT TO DIALING STRING
  151.     CALL    SMSEND        ;SEND IT
  152. WAITSM:    MVI    C,INMDM
  153.     CALL    MEX        ;CATCH ANY OUTPUT FROM THE MODEM
  154.     JNC    WAITSM        ;LOOP UNTIL NO MORE CHARACTERS
  155. ;
  156. ; THE FOLLOWING LOOP WAITS FOR A RESULT FROM THE MODEM (UP TO
  157. ; 60 SECONDS: YOU MAY CHANGE THIS VALUE IN THE FOLLOWING LINE).
  158. ; NOTE THAT THE SMARTMODEM HAS AN INTERNAL 30 SECOND TIMEOUT WHILE
  159. ; FOR A CARRIER ON THE OTHER END.  YOU CAN CHANGE BY PLAYING WITH THE
  160. ; S7 VARIABLE (I.E. SEND THE SMARTMODEM "AT S7=20" TO LOWER THE 30 SECOND
  161. ; WAIT TO 20 SECONDS).
  162. ;
  163. RESULT:    MVI    C,60        ;<<== MAXIMUM TIME TO WAIT FOR RESULT
  164. SMWLP:    PUSH    B
  165.     MVI    B,1        ;CHECK FOR A CHAR, UP TO 1 SEC WAIT
  166.     MVI    C,TMDINP    ;DO TIMED INPUT
  167.     CALL    MEX
  168.     POP    B
  169.     JNC    SMTEST        ;JUMP IF MODEM HAD A CHAR
  170.     PUSH    B        ;NO, TEST FOR CONTROL-C FROM CONSOLE
  171.     MVI    C,CHEKCC
  172.     CALL    MEX
  173.     POP    B
  174.     JNZ    SMNEXT        ;IF NOT, JUMP
  175.     MVI    B,CR        ;YES, SHUT DOWN THE MODEM
  176.     MVI    C,SNDCHR
  177.     CALL    MEX
  178.     call    discon        ;disconnect the modem & restore verbose results
  179.     MVI    A,3        ;RETURN ABORT CODE
  180.     RET
  181. SMNEXT:    DCR    C        ;NO
  182.     JNZ    SMWLP        ;CONTINUE
  183. ;
  184. ; ONE MINUTE WITH NO MODEM RESPONSE (OR NO CONNECTION)
  185. ;
  186. SMTIMO:    MVI    A,2        ;RETURN TIMEOUT CODE
  187.     RET
  188. ;
  189. ; MODEM GAVE US A RESULT, CHECK IT
  190. ;
  191. SMTEST:    ANI    7FH        ;IGNORE ANY PARITY
  192.     CALL    SMANAL        ;TEST THE RESULT
  193.     MOV    A,B        ;A=RESULT (CY SIGNIFICANT HERE TOO)
  194.     PUSH    PSW        ;SAVE IT
  195. SMTLP:    MVI    C,INMDM        ;FLUSH ANY REMAINING COMMAND LINE
  196.     CALL    MEX
  197.     JC    SMCHEK        ;JUMP IF NO INPUT
  198.     CPI    LF        ;GOT SOME ... WAITING FOR EOL
  199.     JNZ    SMTLP        ;EAT ANY IN-BETWEEN
  200. SMCHEK:    POP    PSW        ;A HAS MEX RETURN-CODE, CY=1 IF UNKNOWN
  201.     JC    RESULT        ;IF RESULT UNKNOWN, IGNORE IT
  202.     RET
  203. ;
  204. SMANAL:    MVI    B,0        ;PREP CONNECT CODE
  205. ;
  206. ;
  207.  
  208. ; PopCom numeric result code table:
  209. ;
  210. IF     NUMRES
  211.  
  212.     ; connection responses
  213.  
  214.     CPI    '1'    ! LXI d,Pop300    ! JZ SendMsg    ;300  baud
  215.     CPI    '5'    ! LXI d,Pop1200 ! JZ SendMsg    ;1200 baud
  216.  
  217.     INR    b    ; busy signal responses
  218.         ;    note that POPCOM "Voice" result placed here because
  219.         ;    many busy signals are observed to fall in it's
  220.         ;    voice frequency range & misinterpreted
  221.  
  222.     CPI    ':'    ! RZ    ;correct busy signal interpretation
  223.     CPI    ';'    ! LXI d,PopV    ! JZ SendMsg    ; voice frequency
  224.  
  225.    INR    b    ; no connection responses
  226.  
  227.     CPI    '3'    ! RZ                ; no connection
  228.     CPI    '2'    ! LXI d,Pop2    ! JZ SendMsg    ; local phone ringing
  229.     CPI    '6'    ! LXI d,Pop6    ! JZ SendMsg    ; remote set 1200
  230.     CPI    '7'    ! LXI d,Pop7    ! JZ SendMsg    ; remote set 300
  231.     CPI    '8'    ! LXI d,Pop8    ! JZ SendMsg    ; wierd continuous tone
  232.     CPI    '9'    ! LXI d,Pop9    ! JZ SendMsg    ; no tone
  233.     CPI    '='    ! LXI d,PopP    ! JZ SendMsg    ; local phone offhook
  234.     CPI    '<'    ! LXI d,PopR    ! JZ SendMsg    ; too many rings
  235.     CPI    '?'    ! LXI d,PopL    ! JZ SendMsg    ; line current no good
  236.  
  237.    INR    b    ; error response
  238.  
  239.     CPI    '4'    ! RZ
  240. ENDIF
  241.  
  242.  
  243.  
  244.  
  245.     STC            ;UNKNOWN...
  246.     RET
  247.  
  248. SendMsg:
  249.     MVI    c,9
  250.     CALL    MEX
  251.     RET
  252.  
  253. ;
  254. ; FOLLOWING ROUTINE DISCONNECTS THE MODEM USING SMARTMODEM
  255. ; CODES. ALL REGISTERS ARE AVAILABLE FOR THIS FUNCTION.
  256. ; NOTHING RETURNED TO CALLER.
  257. ;
  258.     IF    DISC
  259. ;
  260. DISCON:    MVI    B,20
  261.     MVI    C,TIMER        ;WAIT 2 SECONDS
  262.     CALL    MEX
  263.     LXI    H,SMATN        ;SEND '+++'
  264.     CALL    SMSEND
  265.     MVI    B,20        ;WAIT 2 MORE SECONDS
  266.     MVI    C,TIMER
  267.     CALL    MEX
  268. DISC2:    LXI    H,SMDISC    ;SEND 'ATH'
  269.     CALL    SMSEND
  270.     MVI    B,10        ;WAIT 1 SECOND
  271.     MVI    C,TIMER
  272.     CALL    MEX
  273.     RET
  274. ;
  275. SMATN:    DB    '+++',0
  276. SMDISC:    DB    'ATH0V1',CR,0    ;disconnect & switch to verbose responses
  277. ;
  278.     ENDIF
  279. ;
  280. ; SMARTMODEM UTILITY ROUTINE: SEND STRING TO MODEM
  281. ;
  282. SMSEND:    MVI    C,SNDRDY    ;WAIT FOR MODEM READY
  283.     CALL    MEX
  284.     JNZ    SMSEND
  285.     MOV    A,M        ;FETCH NEXT CHARACTER
  286.     INX    H
  287.     ORA    A        ;END?
  288.     RZ            ;DONE IF SO
  289.     MOV    B,A        ;NO, POSITION FOR SENDING
  290.     MVI    C,SNDCHR    ;NOPE, SEND THE CHARACTER
  291.     CALL    MEX
  292.     JMP    SMSEND
  293. ;
  294. ; DATA AREA
  295. ;
  296. SMDIAL: DB    'ATS18=0V0X2D'    ;Sw#18=Smartmodem protocol,numeric,PopCom resps
  297. SMDIAL1: DB    'T '
  298. DIALBF:    DS    52        ;2* 24 CHAR MAX, + CR + NULL + SLOP
  299. DIALPT:    DS    2        ;DIAL POSITION POINTER
  300. ;
  301.    ; additions to MEX responses
  302. Pop2:    DB    'Ring -  $'
  303. Pop6:    DB    'Set 1200 -  $'
  304. Pop7:    DB    'Set 300 -  $'
  305. Pop8:    DB    'Tone -  $'
  306. Pop9:    DB    'No Tone -  $'
  307. PopL:    DB    'Line -  $'
  308. PopR:    DB    'Remote Ring - $'
  309. PopP:    DB    'Phone -  $'
  310. Pop300: DB    '300 baud connection $',0
  311. Pop1200: DB    '1200 baud connection $',0
  312. PopV:    DB    'Voice or $'
  313.     END
  314.