home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / modem / mxo-fx15.180 < prev    next >
Encoding:
Text File  |  1994-09-02  |  36.1 KB  |  1,346 lines

  1. ; MXO-FX.180
  2. ;
  3. ;    MEX Overlay for the Micromint SB180FX and a Hayes-compatible
  4. ;    smart modem.
  5. ;
  6. ; Because HD64180 opcodes are used in this overlay, it must be assembled
  7. ; using the SLR180, ZMAC, or ZAS assemblers.
  8. ;
  9. Vers    equ    15        ; overlay revision level
  10. ;
  11. ; This overlay is for use with MEX Plus (the commercial version) on the
  12. ; Micromint SB180FX with a Hayes-compatible smart modem.  The overlay
  13. ; will probably not work with the public domain MEX version 1.14 without
  14. ; modification.  I doubt the DTR routine will work on an SB180 that is
  15. ; not an FX.
  16. ;
  17. ; To use:  Make any changes you prefer, to suit your taste.  Then
  18. ; assemble with SLR180 or ZAS.  Use MLOAD to patch the changes into MEX:
  19. ;
  20. ;    SLR180 MXO-FX15/h            ; assemble with SLR180
  21. ;    ZMAC MXO-FX15 h                ; or with ZMAC
  22. ;    MLOAD NEWMEX.COM=MEX.COM,MXO-FX1x.HEX    ; patch MEX with HEX file
  23. ;
  24. ; You have a number of choices to make before assembling this file and
  25. ; overlaying MEX Plus.  The options you will most likely want to change
  26. ; are marked by "***" in the code below.  You can use your editor's
  27. ; search routine to locate the three asterisks.  You may also have to
  28. ; modify the clear-screen strings at ClsMsg and EosMsg.
  29. ;
  30. ; Although this overlay has been completely redesigned, much of the code is
  31. ; based on routines in MXO-SBS4.Z80, an overlay for MEX 1.14, which was
  32. ; developed from 10/85 to 3/87 by Ken Davidson, Rob Milette, Al Hawley,
  33. ; and Steve Mendelson.  Those versions were, in turn, based on a Kaypro
  34. ; version.
  35. ;
  36. ; The dialing routines were taken, with minor modifications, from Ron
  37. ; Fowler's MXM-SM15.ASM smart modem overlay which uses Intel mnemonics.
  38. ; The DTR disconnect routine is from Rory Kestner's DTR.Z80.  The break
  39. ; key routine is from Irv Hoff's SB180 overlay for IMP (I2MM-4.Z80).
  40. ;
  41. ; The last section of code is from Ron Fowler's MEXPAT22.ASM and is
  42. ; copyright 1985 by Nightowl Software, Inc.  Ron Fowler recommends that
  43. ; the patch file be used only on a completely virgin copy of MEX, but I
  44. ; haven't found that necessary when it is included here.  Although it
  45. ; could be separated into a separate file, but the SSET routine must
  46. ; have it's entry address included at label SSETV.
  47. ;
  48. ; Version 1.5 -- June 18, 1991 -- Gene Pizzetta
  49. ;    Now stores MSPEED on exit in page zero and uses that speed, if
  50. ;    it exists, on re-entry.  Now shows current baud rate on entry.
  51. ;    Modem is not initialized until just before dialing, unless the
  52. ;    "SSET MODEM INIT" is issued.  I have been unable to get auto-
  53. ;    stepdown to work, so your modem may answer and MEX will be at
  54. ;    the wrong baud rate.  In previous versions parity was being set
  55. ;    at the port before setting the modem, which didn't work and made
  56. ;    the modem inoperable.
  57. ;
  58. ;    Changes in the SET routine:  Alternate keywords allowed -- MODE
  59. ;    or MODEM; LENGTH, LEN, or WORD; SPEED or BAUD.
  60. ;
  61. ;    Changes in SSET routine:  "MODEM INIT" added because modem is
  62. ;    only initialized before dialing.  To put the modem in auto-
  63. ;    answer mode, the "SSET MODEM ANSWER" command must be issued,
  64. ;    followed by "SSET MODEM INIT".  Alternate keywords allowed --
  65. ;    MODEM or MODE; ANSWER or ANS; ORIGINATE or ORIG; VOLUME or VOL;
  66. ;    MEDIUM or MED.
  67. ;
  68. ; Version 1.4 -- October 19, 1990 -- Gene Pizzetta
  69. ;    Changed some defaults (REPLY=0, SODELAY=ON, TRIGGER='', GLOBALS=T).
  70. ;
  71. ; Version 1.3 -- November 17, 1989 -- Gene Pizzetta
  72. ;    Modified screen display for SET and SSET.  No longer initializes
  73. ;    modem on entry (so MEX can be exited and re-entered while on line).
  74. ;    Since the modem is not initialized, the default configuration
  75. ;    must be stored in the modem's non-volatile memory using the "AT&W"
  76. ;    command, or you can enter any SSET command to send the initialization
  77. ;    string to the modem.
  78. ;
  79. ; Version 1.2 -- May 19, 1989 -- Gene Pizzetta
  80. ;    Modified SSET carrier wait routine.
  81. ;
  82. ; Version 1.1 -- May 17, 1989 -- Gene Pizzetta
  83. ;    Added Break key routine.
  84. ;
  85. ; Version 1.0 -- May 15, 1989 -- Gene Pizzetta
  86. ;    SET and SSET commands added.  SET deals with communication
  87. ;    protocols:  baud rate, parity, stop bits, and word length.
  88. ;    (The parity, stop bit, and word length routines are not tested.)
  89. ;    SSET deals with the modem:  mode (originate/auto-answer), dial
  90. ;    mode (tone/pulse), carrier wait time, speaker mode (off, on after
  91. ;    dialing, on during dialing), and speaker volume (low, medium,
  92. ;    high).  Dial mode can also be set by STAT, but I've included it
  93. ;    in SSET because I think it should logically be there.  SET ? and
  94. ;    SSET ? will give you the syntax.
  95. ;
  96. ; Version 0.9 -- May 10, 1989 -- Gene Pizzetta
  97. ;    It works.
  98. ;
  99. FALSE    equ    0
  100. TRUE    equ    not FALSE
  101. NO    equ    FALSE
  102. YES    equ    TRUE
  103. ;
  104. ; Set next two equates for your CPU speed.  Set only one TRUE; set the
  105. ; other FALSE ***
  106. ;
  107. CPU9    equ    TRUE        ; 9.216 MHz clock
  108. CPU6    equ    FALSE        ; 6.144 MHz clock
  109. ;
  110.   IF CPU6 AND CPU9
  111.     Choose either CPU9 or CPU6 -- Not both!
  112.   ENDIF
  113. ;
  114. WBoot    equ    0000h
  115. TPA    equ    0100h
  116. Bdos    equ    0005h
  117. CSpeed    equ    003Ch        ; baud rate storage in page 0
  118. ;
  119. ESC    equ    1Bh        ; escape
  120. CR    equ    0Dh        ; carriage return
  121. LF    equ    0Ah        ; linefeed
  122. TAB    equ    09h        ; tab
  123. BELL    equ    07h        ; bell
  124. ;
  125. ; HD64180 port definitions
  126. ;
  127. EXPORT    equ    00h        ; base external port
  128. EXTCTL    equ    EXPORT        ; external modem control port
  129. EXSTAT    equ    EXPORT+4    ; external modem status port
  130. EXDATO    equ    EXPORT+6    ; external modem data out port
  131. EXDATI    equ    EXPORT+8    ; external modem data in port
  132. BAUDRP    equ    EXPORT+2    ; external modem baud rate port
  133. ;
  134. ; HD64180 bit definitions
  135. ;
  136. MDRCVB    equ    80h        ; modem receive bit (DAV)
  137. MDRCVR    equ    80h        ; modem receive ready
  138. MDSNDB    equ    02h        ; modem send bit
  139. MDSNDR    equ    02h        ; modem send ready bit
  140. ;
  141. ; MEX Service Processor functions
  142. ;
  143. MEXLOC    equ    0D00h        ; MEX function entry
  144. INMDM    equ    255        ; get char from port to A, CY=no more in 100 ms
  145. TIMER    equ    254        ; delay 100ms * reg B
  146. TMDINP    equ    253        ; B=# secs to wait for char, cy=no char
  147. CHEKCC    equ    252        ; check for ^C from KBD, Z=present
  148. SNDRDY    equ    251        ; test for modem-send ready
  149. RCVRDY    equ    250        ; test for modem-receive ready
  150. SNDCHR    equ    249        ; send a character to the modem (after sndrdy)
  151. RCVCHR    equ    248        ; recv a char from modem (after rcvrdy)
  152. LOOKUP    equ    247        ; table search: see CMDTBL comments for info
  153. PARSFN    equ    246        ; parse filename from input stream
  154. BDPARS    equ    245        ; parse baud-rate from input stream
  155. SBLANK    equ    244        ; scan input stream to next non-blank
  156. EVALA    equ    243        ; evaluate numeric from input stream
  157. LKAHED    equ    242        ; get nxt char w/o removing from input
  158. GNC    equ    241        ; get char from input, cy=1 if none
  159. ILP    equ    240        ; inline print
  160. DECOUT    equ    239        ; decimal output
  161. PRBAUD    equ    238        ; print baud rate
  162. ;
  163. KBDIN    equ    1        ; keyboard input
  164. CONOUT    equ    2        ; simulated BDOS function 2: console char out
  165. PRINT    equ    9        ; simulated BDOS function 9: print string
  166. INBUF    equ    10        ; input buffer, same structure as BDOS 10
  167. KSTAT    equ    11        ; keyboard status
  168. ;
  169. DCONIO    equ    6        ; BDOS Direct Console IO function #
  170. DCONIN    equ    0FFh        ; BDOS DCONIO Flag for input
  171. ;
  172.     org    TPA        ; we begin
  173. ;
  174.     db    0C3h        ; jump required by load
  175.     ds    2        ; MEX JMP START
  176.     ds    2        ; not used by MEX
  177. TPULSE:    db    'T'        ; T=touch, P=pulse (Used by overlay) ***
  178.   IF CPU9            ; 9.216 MHz
  179. CLOCK:    db    92        ; clock speed x .1, up to 25.5 MHz
  180.   ENDIF
  181.   IF CPU6            ; 6.144 MHz
  182. CLOCK:    db    61        ; clock speed x .1, up to 25.5 MHz
  183.   ENDIF
  184. MSPEED:    db    6        ; sets default baud rate and default display
  185.                 ; ..time for sending a file ***
  186.                 ; .. 0=110, 1=300, 2=450, 3=600, 4=710,
  187.                 ; .. 5=1200, 6=2400, 7=4800, 8=9600, 9=19200
  188. BYTDLY:    db    5        ; default time to send character in
  189.                 ; ..terminal mode file transfer (0-9)
  190.                 ; ..0=0 delay, 1=10 ms, 5=50 ms, 9=90 ms
  191. CRDLY:    db    5        ; end-of-line delay after CRLF in terminal
  192.                 ; ..mode file transfer for slow BBS systems
  193.                 ; ..0=0 delay, 1=100 ms, 5=500 ms, 9=900 ms
  194. COLUMS:    db    5        ; number of directory columns
  195. SETFL:    db    YES        ; yes=user-defined SET command
  196. SCRTST:    db    YES        ; yes=if home cursor and clear screen    [10C]
  197.                 ; ..routine at CLRSCRN ***
  198.     db    0        ; was once ACKNAK, now spare
  199. BAKFLG:    db    YES        ; yes=make .BAK file ***
  200. CRCDFL:    db    YES        ; yes=default to CRC checking ***    [10F]
  201.                 ; ..no=default to Checksum checking
  202. TOGCRC:    db    YES        ; yes=allow toggling of Checksum to CRC    [110]
  203. CVTBS:    db    NO        ; yes=convert backspace to rub ***
  204. TOGLBK:    db    YES        ; yes=allow toggling of bksp to rub
  205. ADDLF:    db    NO        ; no=no LF after CR to send file in
  206.                 ; ..terminal mode (added by remote echo)
  207. TOGLF:    db    YES        ; yes=allow toggling of LF after CR
  208. TRNLOG:    db    NO        ; yes=allow transmission of LOGON (not used)
  209. SAVCCP:    db    YES        ; yes=do not overwrite CCP
  210. LOCNXT:    db    NO        ; yes=local cmd if EXTCHR precedes
  211.                 ; ..no=not local cmd if EXTCHR precedes
  212. TOGLOC:    db    YES        ; yes=allow toggling of LOCNXTCHR
  213. LSTTST:    db    YES        ; yes=allow toggling of printer on/off
  214.                 ; ..in terminal mode.  Set to no if using
  215.                 ; ..printer port for modem
  216. XOFTST:    db    NO        ; yes=allow testing of XOFF from remote
  217.                 ; ..while sending a file in terminal mode
  218. XONWT:    db    NO        ; yes=wait for XON after sending CR while
  219.                 ; ..transmitting a file in terminal mode
  220. TOGXOF:    db    YES        ; yes=allow toggling of XOFF testing
  221. IGNCTL:    db    YES        ; yes=do not send control characters
  222.                 ; ..above CTL-M to CRT in terminal mode ***
  223.                 ; ..no=send any incoming CTL-chars to CRT
  224. EXTRA1:    db    0        ; for future expansion
  225. EXTRA2:    db    0
  226. ; The following are space fillers and have no effect . . .
  227. BRKCHR:    db    '@'-40h        ; ^@ = send a 300 ms. break tone
  228. NOCONN:    db    'N'-40h        ; ^N = disconnect from phone line
  229. LOGCHR:    db    'L'-40h        ; ^L = send LOGON
  230. LSTCHR:    db    'P'-40h        ; ^P = toggle printer
  231. UNSVCH:    db    'R'-40h        ; ^R = close input text buffer
  232. TRNCHR:    db    'T'-40h        ; ^T = transmit file to remote
  233. SAVCHR:    db    'Y'-40h        ; ^Y = open input text buffer
  234. EXTCHR:    db    '^'-40h        ; ^^ = send next character        [127]
  235. ;
  236.     ds    2        ; to make addresses right
  237. ;
  238. ; Low-level modem I/O routines.
  239. ;
  240. INC:    in0    a,(EXSTAT)    ; in modem control port            [12A]
  241.     ret
  242.     db    0,0,0,0,0,0    ; spares if needed for non-PMMI
  243. ;
  244. OUTD:    out0    (EXDATO),a    ; in modem data port            [134]
  245.     ret
  246.     db    0,0,0,0,0,0    ; spares if needed for non=PMMI
  247. ;
  248. IND:    in0    a,(EXDATI)    ; out modem data port            [13E]
  249.     ret
  250.     db    0,0,0,0,0,0    ; spares if needed for non-PMMI
  251. ;
  252. ; Bit-test routines. 
  253. ;
  254. MASKR:    and    MDRCVB        ; bit to test for receive ready        [148]
  255.     ret
  256. TESTR:    cp    MDRCVR        ; value of receive bit when ready
  257.     ret
  258. MASKS:    and    MDSNDB        ; bit to test for send ready
  259.     ret
  260. TESTS:    cp    MDSNDR        ; value of send bit when ready
  261.     ret
  262. ;
  263. DCDTST:    ds    3        ; data carrier detect            [154]
  264. RNGDET:    ds    3        ; ring detect                [157]
  265.     db    0,0,0,0,0
  266. SSMDISC:
  267.     jp    DISCON        ; smartmodem disconnect            [15F]
  268. ;
  269. ; Special modem function jump table:  if your overlay cannot handle
  270. ; some of these, change the jump to "DS 3", so the code present in
  271. ; MEX will be retained.  Thus, if your modem can't dial, change the
  272. ; JMP PDIAL at DIALV to DS 3, and MEX will print a "not implemented"
  273. ; diagnostic for any commands that require dialing.
  274. ;
  275. DIALV:    jp    DIAL        ; dial digit in A            [162]
  276. DISCV:    jp    DRDTR        ; disconnect modem            [165]
  277. GOODBV:    jp    GOODBYE        ; called before exit to CP/M
  278. INMODV:    jp    NITMOD        ; initialization. Called at cold-start
  279. NEWBDV:    jp    PBAUD        ; set baud rate
  280. NOPARV:    jp    NOPARITY    ; set modem for no-parity
  281. PARITV:    jp    PARITY        ; set modem parity
  282. SETUPV:    jp    SETCMD        ; SET cmd: jump to a RET if you don't write SET
  283. SPMENV:    ds    3        ; not used with MEX
  284. VERSNV:    jp    SYSVER        ; overlay's voice in the sign-on message[17D]
  285. BREAKV:    jp    SBREAK        ; send a break                [180]
  286. ;
  287. ; MDM calls supported in MEX 1.0 but not recommended for use.
  288. ;
  289. ILPRTV:    ds    3        ; replace with MEX function 9
  290. INBUFV:    ds    3        ; replace with MEX function 10
  291. ILCMPV:    ds    3        ; replace with table lookup function 247
  292. INMDMV:    ds    3        ; replace with MEX function 255
  293. NXSCRV:    ds    3        ; not supported by MEX (returns w/no action)
  294. TIMERV:    ds    3        ; replace with MEX function 254
  295. ;
  296. ClrEos:    ld    de,EosMsg    ; clear to end of string routine    [195]
  297.     ld    c,PRINT
  298.     call    MEX
  299.     ret
  300. ;
  301. Cls:    ld    de,ClsMsg    ; clear screen routine            [19E]
  302.     ld    c,PRINT
  303.     call    MEX
  304.     ret
  305. ;-----------------------------------------------------------------------------
  306. ; end of fixed area
  307. ;=============================================================================
  308. ;
  309. ;    org    200h        ; area above is reserved
  310. ;
  311. EosMsg:    db    ESC,'Y','$'    ; clear to end of screen string ***
  312. ClsMsg:    db    ESC,'+','$'    ; clear screen string ***
  313. ;
  314. ; Print overlay version
  315. ;
  316. SYSVER:    ld    de,VerMsg
  317.     ld    c,PRINT
  318.     call    MEX
  319.     jp    BdSho
  320. ;    ret
  321. ;
  322. VerMsg:    db    'Micromint SB180FX Smart Modem DTR Version '
  323.     db    Vers/10+'0'
  324.     db    '.'
  325.     db    Vers mod 10+'0'
  326.     db    CR,LF
  327.     db    '$'
  328. ;
  329. ; Break, disconnect and goodbye routines
  330. ;  (The HD64180 doesn't support break transmit or receive.)
  331. ;
  332. GOODBYE:
  333.     ld    a,(MSPEED)
  334.     ld    (CSPEED),a
  335.     ret
  336. ;
  337. NOPARITY:
  338.     ret
  339. ;
  340. PARITY:    ret
  341. ;
  342. SBREAK:    ld    a,(MSPEED)    ; get current baud rate
  343.     push    af        ; ..and save it
  344.     ld    a,9        ; set for 19,200 bps
  345.     call    PBAUD
  346.     ld    de,575        ; take 300 ms
  347. SBrk1:    ld    c,SNDRDY    ; wait for modem ready
  348.     call    MEX
  349.     jr    nz,SBrk1
  350.     xor    a        ; ASCII NUL in A
  351.     ld    b,a        ; no, position for sending
  352.     ld    c,SNDCHR    ; nope, send the character
  353.     call    MEX
  354.     dec    de        ; count down
  355.     jr    nz,SBrk1    ; continue until zero
  356.     call    NitSio        ; clear port
  357.     pop    af        ; get back current baud rate
  358.     call    PBAUD        ; ..and reset it
  359.     ret
  360. ;
  361. ; Disconnect Routine
  362. ;
  363. DRDTR:    call    SetDTR        ; raise DTR
  364.     ld    b,1        ; delay 100ms
  365.     ld    c,TIMER
  366.     call    MEX
  367.     call    ResetDTR    ; then lower it
  368.     ret
  369. ;
  370. SetDTR:    call    Status
  371.     ld    a,01000000b    ; mask off desired bit
  372.     or    b        ; ..OR it
  373.     ld    b,a        ; ..put in A for BIOS
  374.     ld    a,0FFh        ; set up for write
  375.     jr    XBios
  376. ;
  377. ResetDTR:
  378.     call    Status
  379.     ld    a,10111111b
  380.     and    b        ; AND desired bit
  381.     ld    b,a
  382.     ld    a,0FFh
  383.     jr    XBios
  384. ;
  385. Status:    xor    a        ; set up for read function
  386. ;
  387. XBios:    ld    hl,(1)        ; get BIOS address
  388.     ld    l,3Fh        ; offset for latch routine
  389.     jp    (hl)        ; jump to BIOS and return
  390. ;
  391. ; Initialize RS-232 port
  392. ;
  393. NITMOD:    call    NitSio
  394.     ld    a,(CSPEED)    ; check page zero
  395.     or    a        ; anything there?
  396.     jr    z,Nitmd2    ; (no, do default)
  397.     cp    10        ; within range?
  398.     jr    nc,Nitmd2    ; (no, do default)
  399.     jr    PBAUD        ; yes, set chip but not modem
  400.  
  401. Nitmd2:    ld    a,(MSPEED)    ; get default baud rate
  402.     jr    PBAUD        ; ..and set it
  403. ;
  404. ; Initialize the HD64180 chip (clear errors)
  405. ;
  406. NitSio:    in0    a,(EXTCTL)
  407.     and    11101111b
  408.     or    01101000b
  409.     out0    (EXTCTL),a
  410.     ret
  411. ;
  412. ; This routine sets baud rate passed in A.
  413. ; Returns CY=1 if baud rate not supported.
  414. ;
  415. PBAUD:    push    hl        ; don't alter anything
  416.     push    de
  417.     push    bc
  418.     ld    e,a        ; MSPEED code to DE
  419.     ld    d,0
  420.     ld    hl,BaudTB    ; offset into table
  421.     add    hl,de
  422.     ld    a,(hl)        ; fetch code
  423.     cp    0FFh        ; FFh means unsupported code
  424.     scf            ; prep carry in case unsupported
  425.     jr    z,PBExit    ; exit if bad
  426. PBAUD2:    ld    b,a        ; save code in B
  427.     ld    a,(SmPar+6)
  428.     cp    '3'    
  429.     ld    a,b        ; get back code
  430.     jr    nz,PBAUD1    ; (nope)
  431.     or    00010000b    ; set bit 4 to preserve odd parity
  432. PBAUD1:    out0    (BaudRp),a    ; if OK, set it
  433.     ld    a,e        ; get MSPEED code back
  434.     ld    (MSPEED),a    ; set it
  435.     or    a        ; return (no errors)
  436. PBExit:    pop    bc
  437.     pop    de
  438.     pop    hl
  439.     ret
  440. ;
  441. ; Table of baud rate divisors for supported rates.  (nnn) are not
  442. ; supported.
  443. ;
  444.   IF CPU9            ; clock speed 9.216 MHz
  445. BaudTB:    db      0FFh,26h,0FFh,25h,0FFh    ; (110), 300, (450), 600, (710)
  446.     db    24h,23h,22h,21h,20h    ; 1200, 2400, 4800, 9600, 19200
  447.   ENDIF
  448. ;
  449.   IF CPU6            ; clock speed 6.144 MHz
  450. BaudTB:    db    0FFh,0Dh,0FFh,06h,0FFh    ; (110), 300, (450), 600, (710)
  451.     db    05h,04h,03h,02h,01h    ; 1200, 2400, 4800, 9600, 19200
  452.   ENDIF
  453. ;
  454. ; SET command implements setting baud rate, parity, stop bits, and word
  455. ; length.
  456. ;
  457. SETCMD:    ld    c,SBLANK    ; any arguments?
  458.     call    MEX
  459.     jr    c,SetSho    ; if not, display defaults
  460.     ld    de,SetTbl
  461.     ld    c,LOOKUP
  462.     call    MEX        ; parse the argument
  463.     push    hl        ; save any parsed arguments
  464.     ret    nc        ; ..and return to it
  465.     pop    hl        ; not found
  466. SetErr:    ld    de,SetEms
  467.     ld    c,PRINT
  468.     call    MEX
  469.     ret
  470. ;
  471. SetEms:    db    BELL,'  SET syntax error -- "SET ?" for help',CR,LF,'$'
  472. ;
  473. SetTbl:    dc    '?'        ; help
  474.     dw    StHelp
  475.     dc    'SPEED'        ; set baud
  476.     dw    StBaud
  477.     dc    'BAUD'        ; alternate set baud
  478.     dw    StBaud
  479.     dc    'PARITY'    ; set parity
  480.     dw    StPrty
  481.     dc    'STOP'        ; set stop bits
  482.     dw    StStop
  483.     dc    'LENGTH'    ; set word length
  484.     dw    StWord
  485.     dc    'LEN'        ; alternate set word length
  486.     dw    StWord
  487.     dc    'WORD'        ; alternate set word length
  488.     dw    StWord
  489.     db    0        ; end of table
  490. ;
  491. ; SET with no arguments, prints current settings.
  492. ;
  493. SetSho:    call    SCRLF
  494.     call    BdSho
  495.     call    PrSho
  496.     call    StSho
  497.     call    WdSho        ; fall through to SCRLF
  498. ;
  499. ; Print carriage return and linefeed
  500. ;
  501. SCRLF:    call    SILP
  502.     db    ' ',CR,LF,0
  503.     ret
  504. ;
  505. ; SET with "?" print help message
  506. ;
  507. StHelp:    call    SILP
  508.     db    '  SET Options:',CR,LF
  509.     db    '    SPEED     300, 600, 1200, 2400, 4800, 9600, 19200',CR,LF
  510.     db    '    PARITY    ODD, EVEN, NONE                (parity)',CR,LF
  511.     db    '    STOP      1, 2              (number of stop bits)',CR,LF
  512.     db    '    LEN{GTH}  7, 8     (number of bits per character)',CR,LF
  513.     db    0
  514.     ret
  515. ;
  516. ; Set baud rate
  517. ;
  518. StBaud:    ld    c,BDPARS    ; Parse baud rate
  519.     call    MEX
  520.     jp    c,SetErr    ; (no good)
  521.     call    PBaud        ; set it
  522.     jp    c,SetErr    ; (no good)
  523.     call    SCRLF
  524.     call    BdSho
  525.     jp    SCRLF        ; send CRLF and return
  526. ;
  527. BdSho:    call    SILP
  528.     db    'Modem Speed     : ',0
  529.     ld    a,(MSpeed)    ; get current rate
  530.     ld    c,PRBAUD    ; let MEX print it
  531.     call    MEX
  532.     jp    SCRLF        ; send CRLF and return
  533. ;
  534. ; Set parity -- parity is controlled by bit 1 of EXTCTL and bit 4 of
  535. ; BAUDRP:
  536. ;        BAUDRP b4    EXTCTL b1
  537. ;    None        -            0
  538. ;    Even        0            1
  539. ;    Odd        1            1
  540. ;
  541. StPrty:    ld    de,ParTbl    ; check syntax
  542.     jp    ADRTBL
  543. ;
  544. ParTbl:    dc    'NONE'        ; set parity none
  545.     dw    PrOff
  546.     dc    'EVEN'        ; set parity even
  547.     dw    PrEven
  548.     dc    'ODD'        ; set parity odd
  549.     dw    PrOdd
  550.     db    0
  551. ;
  552. PrOff:    ld    a,55        ; '55'
  553.     call    BinAsc
  554.     ld    (SmPar+6),hl
  555.     ld    hl,SmPar
  556.     call    SMSEND
  557.     in0    a,(EXTCTL)
  558.     and    11111101b    ; reset bit 1
  559.     jr    ParTb1
  560. ;
  561. PrEven:    ld    a,7        ; '07'
  562.     call    BinAsc
  563.     ld    (SmPar+6),hl
  564.     ld    hl,SmPar
  565.     call    SMSEND
  566.     in0    a,(EXTCTL)
  567.     or    00000010b    ; set bit 1
  568.     jr    ParTb1
  569. ;
  570. PrOdd:    ld    a,39        ; '39'
  571.     call    BinAsc
  572.     ld    (SmPar+6),hl
  573.     ld    hl,SmPar
  574.     call    SMSEND
  575.     in0    a,(EXTCTL)
  576.     or    00000010b    ; set bit 1
  577.     push    af        ; save mask
  578.     ld    a,(BAUDRP)
  579.     or    00010000b    ; set bit 4
  580.     ld    (BAUDRP),a
  581.     pop    af        ; recover mask and fall through
  582. ;
  583. ParTb1:    out0    (EXTCTL),a    ; set parity/no parity
  584.     ld    a,(MSPEED)
  585.     call    PBAUD
  586.     call    SCRLF
  587.     call    PrSho
  588.     jp    SCRLF        ; send CRLF and return
  589. ;
  590. PrSho:    call    SILP        ; print the result
  591.     db    'Parity          : ',0
  592.     in0    a,(EXTCTL)
  593.     and    00000010b    ; test bit 1
  594.     jr    nz,ParSh1
  595.     call    SILP
  596.     db    'None',CR,LF,0
  597.     ret
  598. ;
  599. ParSh1:    in0    a,(BAUDRP)
  600.     and    00010000b    ; test bit 4
  601.     jr    z,ParSh2
  602.     call    SILP
  603.     db    'Odd',CR,LF,0
  604.     ret
  605. ;
  606. ParSh2:    call    SILP
  607.     db    'Even',CR,LF,0
  608.     ret
  609. ;
  610. ; Set stop bits -- number of stop bits is controlled by bit 0 of
  611. ; EXTCTL:
  612. ;        EXTCTL b0
  613. ;    1 bit        0
  614. ;    2 bits      1
  615. ;
  616. StStop:    ld    de,StpTbl    ; check syntax
  617.     jp    ADRTBL
  618. ;
  619. StpTbl:    dc    '1'        ; set 1 stop bit
  620.     dw    Stop1
  621.     dc    '2'        ; set 2 stop bits
  622.     dw    Stop2
  623.     db    0
  624. ;
  625. Stop1:    in0    a,(EXTCTL)    ; get control register
  626.     and    11111110b    ; reset bit 0
  627.     jr    StStp1
  628. ;
  629. Stop2:    in0    a,(EXTCTL)
  630.     or    00000001b    ; set bit 0
  631. ;
  632. StStp1:    out0    (EXTCTL),a
  633.     call    SCRLF
  634.     call    StSho
  635.     jp    SCRLF        ; send CRLF and return
  636. ;
  637. StSho:    call    SILP        ; print result
  638.     db    'Stop bits       : ',0
  639.     in0    a,(EXTCTL)
  640.     and    00000001b    ; test bit 0
  641.     jr    nz,StSho2    ; (if bit 0 = 1 then 2 stop bits)
  642.     call    SILP
  643.     db    '1',CR,LF,0
  644.     ret
  645. ;
  646. StSho2:    call    SILP
  647.     db    '2',CR,LF,0
  648.     ret
  649. ;
  650. ; Set word length -- number of bits per character is controlled by
  651. ; bit 2 of EXTCTL:
  652. ;        EXTCTL b2
  653. ;    7 bits        0
  654. ;    8 bits        1
  655. ;
  656. StWord:    ld    de,WrdTbl    ; check syntax
  657.     jp    ADRTBL
  658. ;
  659. WrdTbl:    dc    '7'        ; set 7-bit word length
  660.     dw    Word7
  661.     dc    '8'        ; set 8-bit word length
  662.     dw    Word8
  663.     db    0
  664. ;
  665. Word7:    in0    a,(EXTCTL)
  666.     and    11111011b    ; reset bit 2
  667.     jr    StWrd2
  668. ;
  669. Word8:    in0    a,(EXTCTL)
  670.     or    00000100b    ; set bit 2
  671. ;
  672. StWrd2:    out0    (EXTCTL),a
  673.     call    SCRLF
  674.     call    WdSho
  675.     jp    SCRLF        ; send CRLF and return
  676. ;
  677. WdSho:    call    SILP
  678.     db    'Word Length     : ',0
  679.     in0    a,(EXTCTL)
  680.     and    04h        ; test bit 2
  681.     ld    a,'7'
  682.     jr    z,WdSho7    ; (if bit 2 = 0 then 7-bit word)
  683.     ld    a,'8'
  684. WdSho7:    ld    (WdMsg),a
  685.     call    SILP
  686. WdMsg:    db    '8 bits/char',CR,LF,0
  687.     ret
  688. ;
  689. SSTCMD:    ld    c,SBLANK    ; any arguments?
  690.     call    MEX
  691.     jr    c,SstSho    ; if not, display defaults
  692.     ld    de,SstTbl
  693.     ld    c,LOOKUP
  694.     call    MEX        ; parse the argument
  695.     push    hl        ; save any parsed arguments
  696.     ret    nc        ; ..and return to it
  697.     pop    hl        ; not found
  698. SstErr:    ld    de,SstEms
  699.     ld    c,PRINT
  700.     call    MEX
  701.     ret
  702. ;
  703. SstEms:    db    BELL,'  SSET syntax error -- "SSET ?" for help',CR,LF,'$'
  704. ;
  705. SstTbl:    dc    '?'        ; help
  706.     dw    SstHlp
  707.     dc    'MODEM'        ; set modem mode
  708.     dw    SsMode
  709.     dc    'MODE'        ; alternate set modem mode
  710.     dw    SsMode
  711.     dc    'DIAL'        ; set dial mode
  712.     dw    SsDial
  713.     dc    'WAIT'        ; set carrier wait
  714.     dw    SsWait
  715.     dc    'SPEAKER'    ; set speaker mode
  716.     dw    SsSpkr
  717.     dc    'VOLUME'    ; set speaker volume
  718.     dw    SsVol
  719.     dc    'VOL'        ; alternate set speaker volume
  720.     dw    SsVol
  721.     db    0        ; end of table
  722. ;
  723. ; SSET with no arguments, prints current settings.
  724. ;
  725. SstSho:    call    SCRLF
  726.     call    MdSho
  727.     call    DlSho
  728.     call    Wtsho
  729.     call    SkSho
  730.     call    VlSho
  731.     jp    SCRLF        ; send CRLF and return
  732. ;
  733. ; SSET with "?" print help message
  734. ;
  735. SstHlp:    call    SILP
  736.     db    '  SSET Options:',CR,LF
  737.     db    '    MODE{M}   ORIG{INATE}, ANS{WER}, INIT (modem mode)',CR,LF
  738.     db    '    DIAL      PULSE, TONE                  (dial mode)',CR,LF
  739.     db    '    WAIT      number of seconds     (wait for carrier)',CR,LF
  740.     db    '    SPEAKER   ON, DIAL, OFF             (speaker mode)',CR,LF
  741.     db    '    VOL{UME}  LOW, MED{IUM}, HIGH     (speaker volume)',CR,LF
  742.     db    0
  743.     ret
  744. ;
  745. ; Set modem mode
  746. ;
  747. SsMode:    ld    de,MdTbl
  748.     jp    ADRTBL
  749. ;
  750. MdTbl:    dc    'ORIG'        ; set originate mode
  751.     dw    MdOrig
  752.     dc    'ORIGINATE'    ; alternate set originate mode
  753.     dw    MdOrig
  754.     dc    'ANS'        ; set answer mode
  755.     dw    MdAns
  756.     dc    'ANSWER'    ; alternate set answer mode
  757.     dw    MdAns
  758.     dc    'INIT'        ; initialize modem
  759.     dw    MdInit
  760.     db    0
  761. ;
  762. MdOrig:    ld    a,'0'
  763.     ld    (SmMode+3),a
  764.     jr    MdSend
  765. ;
  766. MdAns:    ld    a,'1'
  767.     ld    (SmMode+3),a
  768. ;
  769. MdSend:    call    SCRLF
  770.     call    MdSho
  771.     jp    SCRLF        ; send CRLF and return
  772. ;
  773. MdSho:    call    SILP
  774.     db    'Modem Mode      : ',0
  775.     ld    a,(SmMode+3)
  776.     cp    '0'
  777.     jr    z,MdSho2
  778.     call    SILP
  779.     db    'Auto-Answer',0
  780.     jp    SCRLF        ; send CRLF and return
  781. ;
  782. MdSho2:    call    SILP
  783.     db    'Originate',0
  784.     jp    SCRLF        ; send CRLF and return
  785. ;
  786. ; Initialize modem
  787. ;
  788. MdInit:    call    SCRLF
  789.     call    NitSio        ; clear port
  790.     call    JUSTRT        ; send initialization string
  791.     call    SILP
  792.     db    'Modem Initialized',CR,LF,0
  793.     jp    SCRLF        ; send CRLF and return
  794. ;
  795. ; Set dial mode
  796. ;
  797. SsDial:    ld    de,DialTb
  798.     jp    ADRTBL
  799. ;
  800. DialTb:    dc    'PULSE'        ; pulse dialing
  801.     dw    DialP
  802.     dc    'TONE'        ; tone dialing
  803.     dw    DialT
  804.     db    0
  805. ;
  806. DialP:    ld    a,'P'
  807.     ld    (TPULSE),a
  808.     jr    DialT1
  809. ;
  810. DialT:    ld    a,'T'
  811.     ld    (TPULSE),a
  812. ;
  813. DialT1:    call    SCRLF
  814.     call    DlSho
  815.     jp    SCRLF        ; send CRLF and return
  816. ;
  817. DlSho:    call    SILP
  818.     db    'Dial Mode       : ',0
  819.     ld    a,(TPULSE)
  820.     cp    'P'
  821.     jr    z,DlSho2
  822.     call    SILP
  823.     db    'Tone',CR,LF,0
  824.     ret
  825. ;
  826. DlSho2:    call    SILP
  827.     db    'Pulse',CR,LF,0
  828.     ret
  829. ;
  830. ; Set ring and carrier wait
  831. ;
  832. SsWait:    ld    c,EVALA
  833.     call    MEX        ; get binary numeric
  834.     ld    a,h        ; validate
  835.     or    a
  836.     jp    nz,SstErr
  837.     ld    a,l
  838.     ld    (WtFlg),a    ; set new rate
  839.     call    BinAsc        ; convert to ASCII
  840.     ld    (SmWait+3),hl    ; store in S7 string
  841.     call    SCRLF
  842.     call    WtSho
  843.     jp    SCRLF        ; send CRLF and return
  844. ;
  845. WtSho:    call    SILP
  846.     db    'Carrier Wait    : ',0
  847.     ld    a,(WtFlg)    ; get rate
  848.     ld    l,a
  849.     ld    h,0
  850.     ld    c,DECOUT
  851.     call    MEX        ; print in decimal
  852.     call    SILP
  853.     db    ' Seconds',CR,LF,0
  854.     ret
  855. ;
  856. ; Convert of binary in A (less than 63h) to 2 ASCII digits in hl,
  857. ; MSD in L and LSD in H
  858. ;
  859. BinAsc:    ld    hl,00FFh    ; L = -1
  860. BinAs2:    inc    l
  861.     sbc    a,10        ; subtract 10
  862.     jr    nc,BinAs2    ; if no borrow, one more time
  863.     add    a,10        ; too much, add 10 back
  864.     or    030h        ; remainder into ASCII
  865.     ld    h,a        ; LSD to H
  866.     ld    a,l        ; get quotient
  867.     or    030h        ; ..into ASCII
  868.     ld    l,a        ; MSD to L
  869.     ret
  870. ;
  871. ; Set speaker mode
  872. ;
  873. SsSpkr:    ld    de,SkTbl
  874.     jp    ADRTBL
  875. ;
  876. SkTbl:    dc    'ON'        ; speaker on after dialing
  877.     dw    SkOn
  878.     dc    'DIAL'        ; speaker on during dialing
  879.     dw    SkDl
  880.     dc    'OFF'        ; speaker off
  881.     dw    SkOf
  882.     db    0
  883. ;
  884. SkOn:    ld    a,'3'
  885.     ld    (SmSpkr+1),a
  886.     jr    SkSend
  887. ;
  888. SkDl:    ld    a,'1'
  889.     ld    (SmSpkr+1),a
  890.     jr    SkSend
  891. ;
  892. SkOf:    ld    a,'0'
  893.     ld    (SmSpkr+1),a
  894. ;
  895. SkSend:    call    SCRLF
  896.     call    SkSho
  897.     jp    SCRLF        ; send CRLF and return
  898. ;
  899. SkSho:    call    SILP
  900.     db    'Speaker Mode    : ',0
  901.     ld    a,(SmSpkr+1)
  902.     cp    '0'
  903.     jr    z,SkSho2
  904.     cp    '1'
  905.     jr    z,SkSho3
  906.     call    SILP
  907.     db    'On after dialing',CR,LF,0
  908.     ret
  909. ;
  910. SkSho2:    call    SILP
  911.     db    'Off',CR,LF,0
  912.     ret
  913. ;
  914. SkSho3:    call    SILP
  915.     db    'On during Dialing',CR,LF,0
  916.     ret
  917. ;
  918. ; Set speaker volume
  919. ;
  920. SsVol:    ld    de,VlTbl
  921.     jp    ADRTBL
  922. ;
  923. VlTbl:    dc    'LOW'        ; speaker low volume
  924.     dw    VlLow
  925.     dc    'MEDIUM'    ; speaker medium volume
  926.     dw    VlMed
  927.     dc    'MED'        ; alternate medium volume
  928.     dw    VlMed
  929.     dc    'HIGH'        ; speaker high volume
  930.     dw    VlHi
  931.     db    0
  932. ;
  933. VlLow:    ld    a,'1'
  934.     ld    (SmVol+1),a
  935.     jr    VlSend
  936. ;
  937. VlMed:    ld    a,'2'
  938.     ld    (SmVol+1),a
  939.     jr    VlSend
  940. ;
  941. VlHi:    ld    a,'3'
  942.     ld    (SmVol+1),a
  943. ;
  944. VlSend:    call    SCRLF
  945.     call    VlSho
  946.     jp    SCRLF        ; send CRLF and return
  947. ;
  948. VlSho:    call    SILP
  949.     db    'Speaker Volume  : ',0
  950.     ld    a,(SmVol+1)
  951.     cp    '1'
  952.     jr    z,VlSho2
  953.     cp    '2'
  954.     jr    z,VlSho3
  955.     call    SILP
  956.     db    'High',CR,LF,0
  957.     ret
  958. ;
  959. VlSho2:    call    SILP
  960.     db    'Low',CR,LF,0
  961.     ret
  962. ;
  963. VlSho3:    call    SILP
  964.     db    'Medium',CR,LF,0
  965.     ret
  966. ;
  967. ; Set up and check command table
  968. ;
  969. ADRTBL:    push    de
  970.     ld    c,SBLANK
  971.     call    MEX
  972.     pop    de        ; get table address
  973.     jp    c,SetErr    ; ..or print error
  974.     ld    c,LOOKUP
  975.     call    MEX
  976.     push    hl        ; match found, do it
  977.     ret    nc
  978.     pop    hl        ; fix stack
  979.     jp    SetErr        ; ..and print error
  980. ;
  981. ; In-line print routine (calls MEX)
  982. ;
  983. SILP:    ld    c,ILP
  984.     jp    MEX
  985. ;
  986. ; Smart modem dialing code
  987. ;
  988. DIAL:    ld    hl,(DIALPT)    ; fetch pointer
  989.     cp    254        ; start dial?
  990.     jp    z,STDIAL    ; ..jump if so
  991.     cp    255        ; end dial?
  992.     jp    z,ENDIAL    ; ..jump if so
  993. ;
  994. ; Not start or end sequence, must be a digit to be sent to the modem
  995. ;
  996.     ld    (hl),a        ; put char in buffer
  997.     inc    hl        ; ..advance pointer
  998.     ld    (DIALPT),hl    ; stuff pntr
  999.     ret            ; all done
  1000. ;
  1001. ; Here on a start-dial sequence
  1002. ;
  1003. STDIAL:    ld    hl,DIALBF    ; set up buffer pointer
  1004.     ld    (DIALPT),hl
  1005.     ret
  1006. ;
  1007. ; Here on an end-dial sequence
  1008. ;
  1009. ENDIAL:    ld    (hl),CR        ; stuff end-of-line into buffer
  1010.     inc    hl        ; ..followed by terminator
  1011.     ld    (hl),0
  1012.     ld    a,(TPULSE)    ; get overlay's touch-tone flag
  1013.     ld    (SMDIAL+3),a    ; put into string
  1014.     call    JUSTRT        ; initialize modem
  1015.     ld    b,10        ; delay 1 sec
  1016.     ld    c,TIMER
  1017.     call    MEX
  1018.     ld    hl,SMDIAL    ; point to dialing string
  1019.     call    SMSEND        ; send it
  1020. WAITSM:    ld    c,INMDM
  1021.     call    MEX        ; catch any output from the modem
  1022.     jr    nc,WAITSM    ; ..loop until no more characters
  1023. ;
  1024. ; The following loop waits for a result from the modem (up to 60 seconds).
  1025. ; You may change this value below, but note that the smart modem
  1026. ; has an internal 30 second timeout while waiting for a carrier on the
  1027. ; other end.  You can change by playing with the S7 variable (i.e., send
  1028. ; the smart modem "AT S7=20" to lower the 30 second wait to 20 seconds).
  1029. ;
  1030. RESULT:    ld    c,60        ; <= maximum time to wait for result
  1031. SMWLP:    push    bc
  1032.     ld    b,1        ; check for a char, up to 1 sec wait
  1033.     ld    c,TMDINP    ; do timed input
  1034.     call    MEX
  1035.     pop    bc
  1036.     jr    nc,SMTEST    ; ..jump if modem had a char
  1037.     push    bc        ; no, test for control-C from console
  1038.     ld    c,KSTAT        ; check for keypress
  1039.     call    MEX
  1040.     or    a
  1041.     pop    bc
  1042.     jr    z,SMNEXT    ; ..jump if no keypress
  1043.     push    bc        ; get keypress
  1044.     ld    c,KBDIN
  1045.     call    MEX
  1046.     pop    bc
  1047.     cp    'C'-40h        ; is it ^C?
  1048.     jr    nz,NOCC        ; ..jump if not
  1049.     ld    a,3        ; prep return code
  1050.     push    af        ; ..save it
  1051. ABCOM:    ld    b,CR        ; yes, shut down the modem
  1052.     ld    c,SNDCHR
  1053.     call    MEX
  1054.     pop    af        ; ..return abort code
  1055.     ret
  1056. ;
  1057. NOCC:    cp    ' '        ; space bar?
  1058.     jr    nz,SMNEXT    ; ..ignore all others
  1059.     ld    a,1        ; prep return code
  1060.     push    af        ; ..
  1061.     jr    ABCOM        ; ..finish in common code
  1062. SMNEXT:    dec    c        ; no
  1063.     jr    nz,SMWLP    ; ..continue
  1064. ;
  1065. ; One minute with no modem response (or no connection)
  1066. ;
  1067. SMTIMO:    ld    a,2        ; return timeout code
  1068.     ret
  1069. ;
  1070. ; Modem gave us a result, check it
  1071. ;
  1072. SMTEST:    and    7Fh        ; ignore any parity
  1073.     call    SMANAL        ; test the result
  1074.     ld    a,b        ; A=result (CY significant here too)
  1075.     push    af        ; save it
  1076. SMTLP:    ld    c,INMDM        ; flush any remaining command line
  1077.     call    MEX
  1078.     jr    c,SMCHEK    ; ..jump if no input
  1079.     cp    LF        ; got some ... waiting for EOL
  1080.     jr    nz,SMTLP    ; ..eat any in-between
  1081. SMCHEK:    pop    af        ; A has MEX return-code, CY=1 if unknown
  1082.     jr    c,RESULT    ; ..if result unknown, ignore it
  1083.     ret
  1084. ;
  1085. SMANAL:    ld    b,0        ; prep connect code
  1086.     cp    'C'        ; "CONNECT"?
  1087.     ret    z        ; \R1\
  1088.     cp    '1'        ; numeric version of "CONNECT"
  1089.     ret    z        ; \R1\
  1090.     cp    '5'        ; numeric version of "CONNECT 1200"
  1091.     ret    z        ; \R1\
  1092. SMAN2:    cp    '9'        ; numeric version of "CONNECT 600"
  1093.     ret    z        ; \R1\
  1094.     inc    b        ; prep busy code B=1
  1095.     cp    'B'
  1096.     ret    z        ; \R1\
  1097.     cp    '7'        ; numeric version of "BUSY"
  1098.     ret    z
  1099.     inc    b        ; prep NO CONNECT msg B=2
  1100.     cp    'N'        ; N=no connect
  1101.     ret    z        ; \R1\
  1102.     cp    '3'        ; numeric version of "NO CONNECT"
  1103.     ret    z        ; \R1\
  1104.     cp    '6'        ; numeric version of "NO DIALTONE"
  1105.     ret    z
  1106.     ld    b,4        ; prep modem error
  1107.     cp    'E'        ; E=error
  1108.     ret    z        ; \R1\
  1109.     cp    '4'        ; numeric version of "ERROR"
  1110.     ret    z        ; \R1\
  1111.     scf            ; unknown...
  1112. R1:    ret
  1113. ;
  1114. ; Following routine disconnects the modem using smart modem codes.
  1115. ; All registers are available for this function.  Nothing returned
  1116. ; to caller.
  1117. ;
  1118. DISCON:    ld    b,20
  1119.     ld    c,TIMER        ; wait 2 seconds
  1120.     call    MEX
  1121.     ld    hl,SMATN    ; send '+++'
  1122.     call    SMSEND
  1123.     ld    b,20        ; wait 2 more seconds
  1124.     ld    c,TIMER
  1125.     call    MEX
  1126.     ld    hl,SMDISC    ; send 'ATH'
  1127.     call    SMSEND
  1128.     ld    b,1        ; wait 1 second
  1129.     ld    c,TIMER
  1130.     call    MEX
  1131.     ret
  1132. ;
  1133. SMATN:    db    '+++',0
  1134. SMDISC:    db    'ATH',CR,0
  1135. ;
  1136. ; Smart modem utility routine:  Send string to modem
  1137. ;
  1138. SMSEND:    ld    c,SNDRDY    ; wait for modem ready
  1139.     call    MEX
  1140.     jr    nz,SMSEND    ; ..
  1141.     ld    a,(hl)        ; fetch next character
  1142.     inc    hl        ; ..
  1143.     or    a        ; end?
  1144.     ret    z        ; \R1\ done if so
  1145.     ld    b,a        ; no, position for sending
  1146.     ld    c,SNDCHR    ; nope, send the character
  1147.     call    MEX
  1148.     jr    SMSEND        ; ..
  1149. ;
  1150. ; Data area
  1151. ;
  1152. WtFlg:    db    30        ; seconds wait while ringing ***
  1153. SMDIAL:    db    'ATDT '
  1154. DIALBF:    ds    52        ; 2* 24 CHAR MAX, + CR + NULL + SLOP
  1155. DIALPT:    ds    2        ; dial position pointer
  1156. ;
  1157. ; Initialize modem
  1158. ;
  1159. JUSTRT:    ld    hl,SmAtt    ; send initial string
  1160.     call    SMSEND
  1161.     ret
  1162. ;
  1163. ; Modem initialization string ***
  1164. ;
  1165. SmAtt:    db    'AT'        ; modem initialization
  1166. SmEcho:    db    'E1'        ; command echo - 0=off, 1=on
  1167. SmCode:    db    'Q0'        ; result codes - 0=enabled, 1=disabled
  1168. SmRslt:    db    'X4'        ; type of result - 0, 1, 2, 3, 4
  1169. SmType:    db    'V1'        ; code type - 0=numeric, 1=verbal
  1170. SmDTR:    db    '&D2'        ; DTR - 0=ignore, 1=command state,
  1171.                 ; .. 2=disconnect & command state
  1172. SmSpkr:    db    'M1'        ; speaker - 0=off, 1=off w/carrier,
  1173.                 ; .. 3=off w/carrier and dialing
  1174. SmWait:    db    'S7=30'        ; wait for carrier (seconds)
  1175. SmMode:    db    'S0=0'        ; mode - 0=originate, 1=answer
  1176. SmVol:    db    'L2'        ; speaker volume - 1, 2, 3
  1177.     db    CR,0        ; must end with CR and NUL
  1178. ;
  1179. ; Set modem parity mode
  1180. SmPar:    db    'ATS23=55',CR,0    ; parity: 7=even, 39=odd, 48=none
  1181.  
  1182. ;
  1183. JUEND:    ret            ; modem deinit
  1184. ;
  1185. ; MEX PATCH version 2.2
  1186. ; Current as of 07/25/85 (rgf).
  1187. ; Copyright (c) 1985 by NightOwl Software, Inc.
  1188. ; All Rights Reserved
  1189. ;
  1190. ; (Note that the patch revision number bears no relation to the version
  1191. ; of MEX being patched).
  1192. ;
  1193. ; This is the patch file for MexPlus(tm) (the commercial version).  Code
  1194. ; for the public domain versions has been removed for this overlay.  This
  1195. ; version supercedes all previous patch files (although previous patch
  1196. ; files should still work, if you update the two lines starting at RESTT,
  1197. ; below).
  1198. ;
  1199. ; Be sure to use a completely virgin copy of MEX to make these changes.
  1200. ; We no longer recommend placing this code in your overlay file.
  1201. ;
  1202. ; The order of the patch variables supported here will not change from
  1203. ; version to version (i.e., new items will be added on to the end).
  1204. ;
  1205.     org    MEXLOC        ; location of patch variables
  1206. ;
  1207. ; The following line defines the MEX service call entry point, and
  1208. ; is not meant to be changed by the user
  1209. ;
  1210. MEX:    ds    3        ; MEX service call processor
  1211.     ds    3        ; (reserved)
  1212.     ds    1        ; (reserved)
  1213. ;
  1214. ; The following line contains the initial free-memory pointer for
  1215. ; MEX.  Sophisticated modem overlays requiring additional space may change
  1216. ; this pointer (ie, move it higher), and thus "protect" an area of RAM.
  1217. ;
  1218. MEMRY:    DS    2        ; first free memory pointer
  1219. ;
  1220. ; Following are the lowest-level vectors for console and list I/O used
  1221. ; by MEX.  These normally point to routines that save the registers and
  1222. ; vector to the appropriate BIOS routines.  Complex applications may
  1223. ; need to intercept (or even replace) these routines.  If you do this,
  1224. ; be sure to preserve DE, HL and BC.
  1225. ;
  1226. STSVEC:    ds    2        ; console status vector
  1227. INVEC:    ds    2        ; console input vector
  1228. OUTVEC:    ds    2        ; console output vector
  1229. LVEC:    ds    2        ; list output vector
  1230. LSTVEC:    ds    2        ; list status vector
  1231. ;
  1232. ; The following line defines the location of the default MEX prompt.
  1233. ; If you'd like to provide your own initial prompt, add a DW statement
  1234. ; pointing to a prompt buffer structured as follows:
  1235. ;
  1236. ;        DB <max size of buffer>
  1237. ;        DB <length of actual prompt>
  1238. ;        DB <prompt string>
  1239. ;
  1240. ; <maxsize> and <length> may be equal (especially if you disable the
  1241. ; ID command by setting CHGPMT, below to 0); the ID command will, if
  1242. ; left enabled, be limited to the <max size> value.
  1243. ;
  1244. PROMPT:    ds    2        ; prompt location
  1245.     ds    1        ; reserved
  1246. TYPLIN:    db    23        ; for TYPE command: # lines/screen ***
  1247. PAUSFL:    db    1        ; for TYPE cmd: 1=pause 0=no pause ***
  1248. SEPCHR:    db    '|'        ; multiple command-line separator
  1249.                 ; ..(default is ";") ***
  1250. ;
  1251. ; Following five for SENDOUT command
  1252. ;
  1253. SOWAIT:    db    4        ; # seconds waiting for a sendout echo
  1254. SOREPL:    db    0        ; # seconds waiting for initial reply
  1255. SOTRIG:    db    0        ; SENDOUT trigger char from remote
  1256. CANCHR:    db    'X'-64        ; SENDOUT char to cancel line to remote
  1257.                 ; ..(default 'U'-64) ***
  1258. SORTRY:    db    6        ; SENDOUT # retries
  1259. ;
  1260. ;
  1261. HEXFLG:    db    0        ; hex/decimal mode
  1262. ESCCHR:    db    ESC        ; terminal mode escape char (default 0Ah:
  1263.                 ; ..linefeed) ***
  1264. NOBELL:    db    0        ; set to 1 to disable bell
  1265. ;
  1266. ; Buffer variables.  See BUFFERS.DOC for setup information
  1267. ;
  1268. PSIZE:    db    1        ; printer buffer size
  1269. ASIZE:    db    255        ; "big" capture buffer
  1270. XSIZE:    db    16        ; 16K transfer buffer
  1271. NSIZE:    db    1        ; 1K for 85 batch files
  1272. PRELEN:    db    40        ; maximum length of PREFIX string
  1273. SUFLEN:    db    40        ; maximum length of SUFFIX string
  1274. ;
  1275. ; Misc. stuff
  1276. ;
  1277. CDOSFL:    db    0        ; non-zero for CDOS
  1278. WTECHO:    db    0        ; non-zero sets "wait-for-echo"
  1279. KYSIZE:    dw    400        ; size of keystring area, in bytes
  1280. ; CompuServe A protocol is not very useful nowadays . . .
  1281. CISFLG:    db    0        ; non-zero allows CIS file transfers***
  1282. CISOK:    db    0        ; non zero allows STAT CIS ON or OFF***
  1283. CHGPMT:    db    0FFh        ; non-zero allows ID (prompt chg) command
  1284. ERRID:    db    0FFh        ; non-zero prints ID msg in err msgs
  1285. ;
  1286. ; By setting the following DB to 0, you can disable the HELP
  1287. ; command, freeing up space used by the help file index.
  1288. ;
  1289. HELPOK:    db    0FFh        ; non-zero allows HELP command
  1290. MEXDU:    db    14        ; user 0-15 \/  alt area for READ,LOAD,INI.MEX ***
  1291.     db    0        ; drive 0=A /\  & HELP.MEX (if SEARCH <>0) ***
  1292. DEBUG:    db    0        ; debugging in term-mode if non-zero
  1293. EXCLSY:    db    0FFh        ; non-0 excludes $SYS from batchsend, dir
  1294. INIMEX:    db    0        ; non-zero runs INI.MEX (if present) at startup ***
  1295. RTIMER:    db    1        ; receiver wait: # seconds [Plouff patch]
  1296. PQSIZE:    dw    150        ; size of the modem-port queue
  1297. PHSIZE:    db    30        ; phone library size (# entries)
  1298. SILENT:    db    0        ; 0=silence multi-line & READ cmd echo ***
  1299. ALERT:    db    255        ; alert-bell count on CALL complete
  1300. EXTEND:    db    0        ; non-zero: unknown commands goto READ processor ***
  1301. SPLIT:    db    0FFh        ; non-zero: splits phonelib printout, shows baud
  1302. SEARCH:    db    2        ; search mode 0,1,2,3 ***
  1303. ;
  1304. ; Following is the GLOBAL secondary options table.  To
  1305. ; set an option to global, change its ASCII character to a 0. ***
  1306. ;
  1307. ;         ABDEKLQRSTVX
  1308. RESTT:    DB    'ABDEKLQRS',0,'VX'
  1309.     DS    7        ;room for option expansion
  1310. ;
  1311. ; Added on release 1.10:
  1312. ;
  1313. Queue:    db    1        ; 1=allow queueing, 0=no
  1314. TimBas:    dw    567        ; MexPlus timing constant
  1315. Mode:    db    0        ; mode of modem I/O
  1316. SmInit:    dw    JUSTRT        ; smart modem INIT routine adrs
  1317. SSetV:    dw    SSTCMD        ; SSET command: defaulted off
  1318. SmExit:    dw    JUEND        ; smart modem EXIT routine adrs
  1319.     ds    4        ; (internal to MEX)
  1320. SodFlg:    db    1        ; 1=tie SENDOUT to time delay if no WTECHO
  1321. AutoSv:    db    1        ; 0=initial term mode, save off
  1322. TabFlg:    db    0FFh        ; non-zero=expand tabs within MEX
  1323. ;
  1324. ;------------------------------------------------------------
  1325. ;
  1326. ; Additional area used by MexPlus (not valid in MEX 1.12 or 1.14)
  1327. ;
  1328. SmFlag:    db    0        ; 0FFh=default to software disconnect ***
  1329.     ds    1        ; (for 8086 only)
  1330. RValue:    dw    0        ; RVALUE variable kept here        [0D64]
  1331. RVSave:    dw    0        ; stacked RVALUE here            [0D66]
  1332.     ds    12        ; (internal stuff)
  1333. ExiMex:    db    0        ; 0FFh=run EXI.MEX on exit ***        [0D74]
  1334.     ds    8        ; (internal use only)
  1335. ;
  1336. M7Val:    db    0        ; non-zero, protocol xfer affects VALUE    [0D7D]
  1337.     ds    8        ; (internal use only)
  1338. ;
  1339. ; Additional (unofficial) patch points
  1340. ;
  1341.     org    0DEFh
  1342. ;
  1343. XFCls:    db    0        ; non-zero to clear screen before file Xfer***
  1344. ;
  1345.     end
  1346.