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 / MODEMS / MODEM7 / M7MMP4.AQM / M7MM+4.ASM
Assembly Source File  |  2000-06-30  |  38KB  |  1,355 lines

  1. ; M7MM+4.ASM     v4.0       Micromodem ][ overlay file for MDM717.  1/18/84
  2. ;
  3. ; rev 4.0 -    1/18/84      - Revised and renamed to M7MM+4.ASM.  Updated
  4. ;                for use with MDM717.COM.  Fixed bug in dial
  5. ;                retry reporting present in M7MM+3. - mah
  6. ;
  7. ;    *********************************************************
  8. ;    *            C A U T I O N            *
  9. ;    *                            *
  10. ;    *    This overlay will only work with MDM717.COM    *
  11. ;    * Use of this overlay with previous or future revisions *
  12. ;    * of MDM7xx will not result in an executable file.    *
  13. ;    *********************************************************
  14. ;
  15. ; rev 3.0 -    1/16/84     - Revised and renamed to M7MM+3.ASM.  Updated
  16. ;               for use with MDM716.COM.  Added alternate
  17. ;               dialing capability for Micromodem ][/e.
  18. ;               Also added ability to abort during carrier
  19. ;               wait. - mah
  20. ;
  21. ; rev 2.0 -    1/8/84     - Renamed to M7MM+2.ASM.  Added Micromodem ][/e 
  22. ;               support.  Includes touch tone dialing.  Also 
  23. ;               fix auto-redial connect bug. - mah
  24. ;
  25. ; rev 1.4 -    1/8/84     - Changed bank select logic to technique
  26. ;               used by ALS Engineering.  This allowed
  27. ;               more interrupt windows, and compacted
  28. ;               code.  Overlay is now independent of ALS
  29. ;               card and/or BIOS revision - mah
  30. ;
  31. ; rev 1.3 -    12/2/83  - Fixed premature carrier tone problem on
  32. ;               originate call function. - mah
  33. ;
  34. ; rev 1.2 -     12/1/83  - Added conditional code for ALS Rev B Card - mah
  35. ;               Renamed to M712MM+.ASM
  36. ;
  37. ; rev 1.1 -    11/20/83 - Corrected timing in pulse dialing for CP/M 2.2 - mah
  38. ;
  39. ; rev 1.0 -    10/12/83 - Original version (M712MM.ASM)
  40. ;
  41. ;    Written by:    Mark A. Howard - SYSOP
  42. ;            CNY Technical RBBS-RCP/M
  43. ;            315-437-4890
  44. ;            319 Tower Ave
  45. ;            Syracuse, N.Y.  13206
  46. ;
  47. ;
  48. ; This overlay is similar to most of the other overlays available
  49. ; for MDM7xx, but differs in the respect that it not only modifies
  50. ; areas intended for overlays, but also overlays portions of the
  51. ; root program.  This was done to allow use of the logical and I/O
  52. ; procedures built into the program for use with the PMMI modem.
  53. ; The PMMI modem resembles the Micromodem in many respects, and
  54. ; most of the features are available on the Micromodem.
  55. ;
  56. ; It is for this reason that M7MM+4 will only work with MDM717, and
  57. ; further revisions of the root program will cause this overlay to
  58. ; be incompatible.
  59. ;
  60. ;=============================================================================
  61. ;
  62. ;    TO USE: First edit this file filling in answers for your own
  63. ;        equipment.  Also edit the phone number library, M7NM-3.ASM
  64. ;        if the phone directory is desired. Optionally, MDMNUM.COM
  65. ;        may be used to change phone numbers later.  Assemble these
  66. ;        files with ASM.COM or MAC.COM or equivalent assembler. 
  67. ;
  68. ;========================== ASSEMBLY WITH CP/M 2.2 ===========================
  69. ;
  70. ;        Use DDT to overlay the the results of these program(s)
  71. ;        to the original .COM file:
  72. ;
  73. ;        A>DDT MDM717.COM
  74. ;        DDT VERS 2.2
  75. ;        NEXT  PC
  76. ;        4580 0100
  77. ;        -IM7MM+4.HEX        (note the "I" command)
  78. ;        -R            ("R" loads in the .HEX file)
  79. ;        NEXT  PC
  80. ;        4580 0000
  81. ;          * -IM7NM-3.HEX        (get the optional phone library)
  82. ;          * -R
  83. ;          * NEXT  PC
  84. ;          * 4580 0000
  85. ;        -G0            (return to CP/M)
  86. ;        A>SAVE 69 MDM7.COM    (now have a modified .COM file)
  87. ;
  88. ;          * - This step is optional - however editing the number
  89. ;          library and overlaying it in this manner is the only
  90. ;          way to set or modify the alternate dialing strings.
  91. ;
  92. ;======================== ASSEMBLY WITH CP/M 3.0 =========================
  93. ;
  94. ;        Use SID to overlay the results of these program(s)
  95. ;        to the original .COM file:
  96. ;
  97. ;        A>SAVE            (load the CP/M 3.0 SAVE transient)
  98. ;                    (note no messages)
  99. ;        A>SID MDM717.COM    (load the original .COM file)
  100. ;        CP/M 3 SID - Version 3.0
  101. ;        NEXT MSZE  PC  END
  102. ;        4580 4580 0100 xxxx    (xxxx depends on your sys)
  103. ;        #RM7MM+4.HEX        (load overlay, note "R" command)
  104. ;        NEXT MSZE  PC  END
  105. ;        xxxx 4580 0100 xxxx    (xxxx's are insignificant)
  106. ;          * #RM7NM-3.HEX        (get the optional phone # overlay)
  107. ;          * NEXT MSZE  PC  END
  108. ;          * xxxx 4580 0100 xxxx
  109. ;        #G0            (exit SID)
  110. ;
  111. ;        CP/M 3 SAVE - Version 3.0
  112. ;        Enter file (Type return to exit) : MDM7.COM  (name new file)
  113. ;        Beginning hex address 100             (from PC above)
  114. ;        Ending hex address    457F             (MSZE - 1)
  115. ;
  116. ;        A>            (you now have modified .COM file)
  117. ;
  118. ;          * This step is optional - however see note above
  119. ;
  120. ;============================================================================
  121. ;
  122. YES:        EQU    0FFH
  123. NO:        EQU    0
  124. ;
  125. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  126. ;
  127. ; ---------------------> CUSTOMIZATION EQUATES <----------------------
  128. ;
  129. ; --->    Change the following information to match your equipment  <---
  130. ;
  131. CPM2        EQU    NO    ;Apple ][/][+/][/e with most CP/M cards
  132. ALSCARD        EQU    YES    ;Apple ][/][+/][/e with ALS CP/M Card
  133. ;
  134. MMIIE        EQU    NO    ;Yes if Micromodem ][/e
  135. ;
  136. SLOT        EQU    2    ;Micromodem slot (usually 2)
  137. ;
  138. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  139. ;
  140. ;        System equates
  141. ;
  142. FCB          EQU    5CH        ;system FCB area
  143. PRINT        EQU    9        ;print string function
  144. BDOS        EQU    5        ;BDOS jump location
  145. ;
  146. ;        Ascii equates
  147. ;
  148. BELL:        EQU    07H        ;bell
  149. CR:        EQU    0DH        ;carriage return
  150. ESC:        EQU    1BH        ;escape
  151. LF:        EQU    0AH        ;linefeed
  152. CANCEL:        EQU    'X'-040H    ;cancel character
  153. ;
  154. ;        Performance equates
  155. ;
  156. WAITCD        EQU    250        ;secs * 10 to wait for carrier detect
  157. ;                     after dialing phone number
  158. WAITRD        EQU    30        ;secs * 10 to wait between continuous
  159. ;                     redial retries
  160. ;
  161. SLOTNUM    EQU    SLOT*16            ;offset to slot base address
  162. ;
  163.         IF    CPM2
  164. ;
  165. SLOTBAS        EQU    0E085H        ;I/O memory for most CP/M cards
  166. ;
  167.         ENDIF            ;CPM2
  168. ;
  169.         IF    ALSCARD
  170. ;
  171. SLOTBAS        EQU    0C085H        ;I/O memory for ALS CP/M Card
  172. ;
  173.         ENDIF            ;ALSCARD
  174. ;
  175. ;
  176. ;====================== MICROMODEM SPECIFIC EQUATES ======================
  177. ;
  178. ;
  179. ;        MODEM I/O EQUATES
  180. ;
  181. MODCTL2        EQU    SLOTBAS+SLOTNUM        ;IN RI, OUT CR2
  182. MODCTL1        EQU    MODCTL2+1        ;IN STATUS, OUT CR1
  183. MODDATP        EQU    MODCTL1+1        ;IN/OUT DATA
  184. ;
  185.         IF    MMIIE
  186. ;
  187. MODCTL3        EQU    MODCTL2-2        ;SPKR, TOUCH TONE REG
  188. ;
  189.         ENDIF            ;MMIIE
  190. ;
  191. ;        BIT MASKS FOR MODCTL1 INPUT
  192. ;
  193. MODSNDB        EQU    2        ;bit to test for send status
  194. MODSNDR        EQU    2        ;value when ready
  195. MODRCVB        EQU    1        ;bit to test for receive status
  196. MODRCVR        EQU    1        ;value when ready
  197. CARBIT        EQU    4        ;carrier detect* bit
  198. ;
  199. ;        BIT MASKS FOR MODCTL1 OUTPUT
  200. ;
  201. INITBITS    EQU    03H        ;the first time
  202. BRKBITS        EQU    60H        ;break signal bits
  203. D8NP2SB        EQU    11H        ;8 bit data, no parity, 2 stop
  204. D8NP1SB        EQU    15H        ;8 bit data, no parity, 1 stop
  205. D8EP1SB        EQU    19H        ;8 bit data, even parity, 1 stop
  206. D8OP1SB        EQU    1DH        ;8 bit data, odd parity, 1 stop
  207. ;
  208. ;        BIT MASK FOR MODCTL2 INPUT
  209. ;
  210. RNGBIT        EQU    80H        ;ring indicator* bit
  211. ;
  212. ;        BIT MASKS FOR MODCTL2 OUTPUT
  213. ;
  214. MODBIT        EQU    4        ;mode bit in cr2 (1=org 0=ans)
  215. SETBIT        EQU    8        ;set bit in cr2 (always 1)
  216. OFFBIT        EQU    80H        ;off hook bit in cr2 (0=hungup)
  217. TXEBIT        EQU    2        ;transmit enable bit (1=enable)
  218. NOTTXE        EQU    0FDH        ;not(txebit) for and mask
  219. BAUDBIT        EQU    1        ;baud rate bit (0=110 1=300)
  220. ;
  221. ;        SETUP WORDS FOR MODCTL2 OUTPUT
  222. ;
  223. ORIGMOD        EQU    MODBIT+OFFBIT+SETBIT
  224. ANSWMOD        EQU    OFFBIT+SETBIT
  225. ;
  226.         IF    MMIIE
  227. ;
  228. ;        BIT MASKS FOR MODCTL3 OUTPUT
  229. ;
  230. SPKRBIT        EQU    20H        ;1=speaker on
  231. TONEBIT        EQU    10H        ;1=tone on
  232. ;
  233.         ENDIF            ;MMIIE
  234. ;
  235. ;
  236. ;======================== ROOT PROGRAM ADDRESSES =========================
  237. ;
  238. ;    THESE ARE FIXED ADDRESSES OF ROUTINES AND VARIABLES REFERENCED
  239. ;    IN THE ROOT FROM THIS OVERLAY, AND ARE ONLY VALID FOR MDM712.
  240. ;
  241. KEYIN          EQU    27A4H        ;address of "keyin:" in root
  242. CRLF          EQU    278CH        ;address of "crlf:" in root
  243. TYPE          EQU    27B8H        ;address of "type:" in root
  244. STAT        EQU    2799H        ;address of "stat:" in root
  245. ERXIT          EQU    285AH        ;address of "erxit:" in root
  246. MOVE        EQU    28B2H        ;address of "move:" in root
  247. MOVER        EQU    2CFEH        ;address of "mover:" in root
  248. NEWLINE        EQU    4362H        ;address of "newline:" in root
  249. SPACES        EQU    436BH        ;address of "spaces:" in root
  250. CLRTST        EQU    43C5H        ;address of "clrtst:" in root
  251. KBDCHR        EQU    27C5H        ;address of "kbdchr:" on root
  252. MENU        EQU    2EF6H        ;address of "menu:" in root
  253. RETURN        EQU    15E2H        ;address of "return:" in root
  254. DECOUT        EQU    27D8H        ;address of "decout:" in root
  255. FIXCNT        EQU    28CBH        ;address of "fixcnt:" in root
  256. ;
  257. ALTDIAL1    EQU    0CDFH        ;address of alt dial string 1
  258. ALTDIAL2    EQU    0CF7H        ;address of alt dial string 2
  259. CMDBUF        EQU    4508H        ;address of command line buffer
  260. BUFFER        EQU    4A00H        ;address of data buffer
  261. NUMBLIB        EQU    0D0FH        ;address of phone number library
  262. LIBLEN        EQU    22H        ;length of a library line
  263. RBWAIT        EQU    50        ;wait 5 sec before redial
  264. ANSWFLG        EQU    44B2H        ;answer mode request flag
  265. ORIGFLG        EQU    44B6H        ;originate mode request flag
  266. CRFLAG        EQU    44F5H        ;continuous redial flag
  267. RINGBKFL    EQU    4504H        ;ringback flag
  268. DIALCT        EQU    44EAH        ;no. of dials attempted
  269. OPARITY          EQU    44BEH        ;odd parity flag in option table
  270. EPARITY          EQU    44BDH        ;even parity flag in option table
  271. MODCTLB        EQU    44FFH        ;storage byte for MODCTL1 word
  272. UARTCTLB    EQU    4506H        ;storage byte for current control word
  273. ;
  274. ;============================= OVERLAY CODE ===============================
  275. ;
  276.         ORG    100H
  277. ;
  278.         DS    3    ;(for  "JMP   START" instruction)
  279. ;
  280. PMMIMODEM:    DB    YES    ;but not really, just did this to get
  281.                 ;correct logic decisions made in root    103H
  282. SMARTMODEM:    DB    NO    ;yes=HAYES Smartmodem, no=non-PMMI    104H
  283. TOUCHPULSE:    DB    'T'    ;T=touch, P=pulse (Smartmodem-only)    105H
  284. ;
  285. ; ---------->     Note:    The clock speed for most CP/M Cards usually
  286. ;            works out to be 2 mhz.  Change the equate below
  287. ;            to adjust timing for program.
  288. ;
  289. CLOCK:        DB    20    ;clock speed in MHz x10, as above
  290. ;
  291. MSPEED:        DB    1    ;0=110 1=300 2=450 3=600 4=710 5=1200   107H
  292.                 ;6=2400 7=4800 8=9600 9=19200 default
  293. ;
  294. ; ------------>    Note:    The following equates affect default program
  295. ;            parameters.  The following configuration is what
  296. ;            is usually used, change any of the following if
  297. ;            different operation is desired.
  298. ;
  299. BYTDLY:        DB    5    ;0=0 delay  1=10ms  5=50 ms - 9=90 ms   108H
  300.                 ;default time to send character in ter-
  301.                 ;minal mode file transfer for slow BBS.
  302. CRDLY:        DB    5    ;0=0 delay 1=100 ms 5=500 ms - 9=900 ms 109H
  303.                 ;default time for extra wait after CRLF
  304.                 ;in terminal mode file transfer
  305. NOOFCOL:    DB    5    ;number of DIR columns shown        10AH
  306. SETUPTST:    DB    YES    ;yes=user-added Setup routine        10BH
  307. SCRNTEST:    DB    YES    ;Cursor control routine         10CH
  308. ACKNAK:        DB    YES    ;yes=resend a record after any non-ACK    10DH
  309.                 ;no=resend a record after a valid-NAK
  310. BAKUPBYTE:    DB    NO    ;yes=change any file same name to .BAK    10EH
  311. CRCDFLT:    DB    YES    ;yes=default to CRC checking        10FH
  312. TOGGLECRC:    DB    YES    ;yes=allow toggling of CRC to Checksum    110H
  313. CONVBKSP:    DB    NO    ;yes=convert backspace to rub        111H
  314. TOGGLEBK:    DB    YES    ;yes=allow toggling of bksp to rub    112H
  315. ADDLF:        DB    NO    ;no=no LF after CR to send file in    113H
  316.                 ;terminal mode (added by remote echo)
  317. TOGGLELF:    DB    YES    ;yes=allow toggling of LF after CR    114H
  318. TRANLOGON:    DB    YES    ;yes=allow transmission of logon    115H
  319.                 ;write logon sequence at location LOGON
  320. SAVCCP:        DB    YES    ;yes=do not overwrite CCP        116H
  321. LOCONEXTCHR:    DB    NO    ;yes=local command if EXTCHR precedes    117H
  322.                 ;no=external command if EXTCHR precedes
  323. TOGGLELOC:    DB    YES    ;yes=allow toggling of LOCONEXTCHR    118H
  324. LSTTST:        DB    YES    ;yes=printer available on printer port    119H
  325. XOFFTST:    DB    NO    ;yes=checks for XOFF from remote while    11AH
  326.                 ;sending a file in terminal mode
  327. XONWAIT:    DB    NO    ;yes=wait for XON after CR while    11BH
  328.                 ;sending a file in terminal mode
  329. TOGXOFF:    DB    YES    ;yes=allow toggling of XOFF checking    11CH
  330. IGNORCTL:    DB    YES    ;yes=CTL-chars above ^M not displayed    11DH
  331. EXTRA1:        DB    0    ;for future expansion            11EH
  332. EXTRA2:        DB    0    ;for future expansion            11FH
  333. BRKCHR:        DB    '@'-40H    ;^@ = Send 300 ms. break tone        120H
  334. NOCONNCT:    DB    'N'-40H    ;^N = Disconnect from the phone line    121H
  335. LOGCHR:        DB    'L'-40H    ;^L = Send logon            122H
  336. LSTCHR:        DB    'P'-40H    ;^P = Toggle printer            123H
  337. UNSAVE:        DB    'R'-40H    ;^R = Close input text buffer        124H
  338. TRANCHR:    DB    'T'-40H ;^T = Transmit file to remote        125H
  339. SAVECHR:    DB    'Y'-40H    ;^Y = Open input text buffer        126H
  340. EXTCHR:        DB    '^'-40H    ;^^ = Send next character        127H
  341. ;
  342. ;
  343.         DS    2        ;                128H
  344. ;
  345. IN$MODCTL1:    JMP    LDACTLP        ;in modem control port             12AH
  346.         DS    7        ;( IN STATUS )
  347. OUT$MODDATP:    JMP    STADATP     ;out modem data port        134H
  348.         DS    7        ;( OUT DATA  )
  349. IN$MODDATP:    JMP    LDADATP     ;in modem data port        13EH
  350.         DS    7        ;( IN DATA   )
  351. ANI$MODRCVB:    ANI    MODRCVB    ! RET    ;bit to test for receive ready    148H
  352. CPI$MODRCVR:    CPI    MODRCVR    ! RET    ;value of rcv. bit when ready    14BH
  353. ANI$MODSNDB:    ANI    MODSNDB    ! RET    ;bit to test for send ready    14EH
  354. CPI$MODSNDR:    CPI    MODSNDR    ! RET    ;value of send bit when ready    151H
  355. IN$MODCTL2:    JMP    LDACTL2        ;in modem control port #2    154H
  356.                     ;( IN RI     )
  357. OUTDUMMY:    DB    0,0,0        ;dummy old "out baudrp"        157H
  358. OUT$MODCTL1:    JMP    STACTLP        ;out modem control port #1    15AH
  359.                     ;( OUT CR1   )
  360. OUT$MODCTL2:    JMP    STACTL2        ;out modem control port #2    15DH
  361.                     ;( OUT CR2   )
  362. LOGONPTR:    DW    LOGON        ;for user message.        160H
  363. JMP$DIAL:    JMP    DIAL        ;called from RESTART:        162H
  364. JMP$DISCONNT:    JMP    DISCONNT    ;called from DONETCD: after...  165H
  365. JMP$GOODBYE:    JMP    GOODBYE        ;called from DONETCD:        168H
  366. JMP$INITMOD:    JMP    INITMOD        ;jump to from INITADR: for ret    16BH
  367. JMP$NEWBAUD:    JMP    NEWBAUD        ;called frm NOLST: for baud chg 16EH
  368. JMP$NOPARITY:    JMP    NOPARITY    ;called from DONETCB:        171H
  369. JMP$PARITY:    JMP    PARITY        ;called from RCVFIL: & SENDFIL: 174H
  370. JMP$SETUPR:    JMP    SETUPR        ;if SETUPTST true & not PMMI    177H
  371. JMP$SPCLMENU:    JMP    SPCLMENU    ;implements Micromodem menu    17AH
  372. JMP$SYSVER:    JMP    SYSVER        ;version message        17DH
  373. JMP$BREAK:    JMP    SENDBRK        ;if PMMI not true        180H
  374. ;
  375. ;
  376. ; Do not change the following six lines. These are jumps to specific
  377. ; subroutines in root program.
  378. ;
  379. JMP$ILPRT:    DS    3        ;print inline string until 0    183H
  380. JMP$INBUF    DS    3        ;same as CP/M func 10 but no ^C    186H
  381. JMP$INLNCOMP:    DS    3        ;compare inline string to (DE)    189H
  382. JMP$INMODEM    DS    3        ;modem input, timeout = 100 ms    18CH
  383. JMP$NXTSCRN:    DS    3        ;"hit any key to continue"    18FH
  384. JMP$TIMER    DS    3        ;wait .1 sec for (B reg)    192H
  385. ;
  386. ; Routine to clear to end of screen.  If using CLREOS and CLRSCRN, set
  387. ; SCRNTEST to YES at 010AH (above).
  388. ;
  389. CLREOS:        CALL    JMP$ILPRT    ;                195H
  390.         DB    'K'-040H    ;for Apple ][ 80 col card    198H
  391.         DB    0,0,0,0        ;
  392.         RET            ;                19DH
  393. ;
  394. CLRSCRN:    CALL    JMP$ILPRT    ;                19EH
  395.         DB    'L'-040H    ;for Apple ][ 80 col card    1A1H
  396.         DB    0,0,0,0        ;                
  397.         RET            ;                1A6H
  398.     
  399. ;
  400. SYSVER:        CALL    JMP$ILPRT    ;                1A7H
  401.         DB    'Version for '
  402. ;
  403.         IF    ALSCARD
  404. ;
  405.         DB    'ALS CP/M Card '
  406.         DB    CR,LF,'and '
  407. ;
  408.         ENDIF            ;ALSCARD
  409. ;
  410.         DB    'Micromodem ]['
  411. ;
  412.         IF    MMIIE
  413. ;
  414.         DB    '/e'
  415. ;
  416.         ENDIF            ;MMIIE
  417. ;
  418.         DB    ' as of 1/8/84'
  419.         DB    CR,LF,0
  420.         RET
  421. ;
  422. ;========================= BAUD RATE ROUTINES =============================
  423. ;
  424. ;......
  425. ;
  426. ;     Change baudrate on-the-fly with CTL-B (while in terminal mode)
  427. ;
  428. ;
  429. NEWBAUD:      CALL    JMP$ILPRT
  430.           DB    CR,LF,'Enter new Baudrate: ',0
  431.           LXI    H,FCB+9
  432.           MVI    M,' '        
  433. ;
  434. NEWBAUD1:     CALL    KEYIN        
  435.           CPI    CR        
  436.           CZ    CRLF        
  437.           JZ    FIXBAUD        
  438. ;.....
  439. ;
  440. ;
  441. NEWBAUD2:     CPI    '0'        
  442.           JC    NEWBAUD1
  443.           CPI    '9'+1
  444.           JNC    NEWBAUD1    
  445.           MOV    M,A        
  446.           CALL    TYPE        
  447.           INX    H        
  448.           JMP    NEWBAUD1    
  449. ;
  450.         ORG    024FH        ;"setbaud:" is called from within
  451.                     ;the root, so this address is fixed
  452. ;
  453. SETBAUD:    LDA    UARTCTLB    ;called from "restart0:"
  454.         ORI    BAUDBIT        ;set for default 300 baud
  455.         STA    UARTCTLB    ;
  456.         CALL    OUT$MODCTL2    ;
  457.         DB    00H        ;to fill in old routine
  458. ;
  459. FIXBAUD:    CALL    GETBAUD        ;c = baud rate
  460.         LDA    UARTCTLB    ;get current mode word
  461.         ANI    0FEH        ;strip old baud rate bit
  462.         ORA    C        ;setup new word
  463.         STA    UARTCTLB    ;update current mode word
  464.         MOV    A,C        ;
  465.         STA    MSPEED        ;update current modem speed
  466. ;
  467. OFFHOOK:    PUSH    B        ;save the used registers
  468.         PUSH    H        ;
  469.         LXI    H,7500        ;
  470. ;
  471. OFFDLY:        DCR    L        ;delay needed for modem
  472.         JNZ    OFFDLY        ;
  473.         DCR    H        ;
  474.         JNZ    OFFDLY        ;
  475.         POP    H        ;restore hl
  476.         LDA    UARTCTLB    ;get the current status
  477.         MOV    B,A        ;save current mode word in B
  478.         LDA    ANSWFLG        ;answer mode?
  479.         ORA    A        ;
  480.         JNZ    ORGCHEK        ;no - originate?
  481.         MVI    A,0FBH        ;yes - zap the mode bit for answer
  482.         ANA    B        ;
  483.         JMP    UPDATE        ;and update the modem
  484. ORGCHEK:    LDA    ORIGFLG        ;check for originate mode
  485.         ORA    A        ;
  486.         JZ    ORGMOD        ;yes, set originate
  487.         MOV    A,B        ;otherwise retain old status
  488.         JMP    UPDATE        ;and tell the modem
  489. ORGMOD:        MVI    A,MODBIT    ;
  490.         ORA    B        ;set the mode bit
  491. UPDATE:        ORI    OFFBIT        ;set the offhook bit
  492.         STA    UARTCTLB    ;update storage word
  493.         CALL    OUT$MODCTL2    ;go offhook in requested mode & baud
  494.         LDA    MODCTLB        ;update format register
  495.         CALL    OUT$MODCTL1    ;just in case
  496.         XRA    A        ;
  497.         POP    B        ;restore bc
  498.         RET            ;
  499. ;
  500. GETBAUD:    LDA    FCB+9        ;
  501.         ORA    A        ;
  502.         JZ    NOBAUD        ;no baud rate change
  503.         CPI    ' '        ;
  504.         JNZ    DOBAUD        ;
  505. NOBAUD:        POP    D        ;get rid of first ret addr
  506.         JMP    OFFHOOK        ;and go do offhook
  507. ;
  508. DOBAUD:        LXI    D,FCB+9        ;something's there, convert it
  509.         LXI    H,0        ;to binary and check validity
  510. ;
  511. DECLP:        LDAX    D        ;get a baud rate byte
  512.         INX    D        ;for the next time
  513.         CPI    ' '        ;skip spaces
  514.         JZ    DECLP        ;
  515.         CPI    '0'        ;check for numiscity
  516.         JC    BADRATE        ;c = non-numic
  517.         CPI    '9'+1        ;
  518.         JNC    BADRATE        ;nc = bad stuff
  519.         SUI    '0'        ;kill the ascii bias
  520.         MOV    B,H        ;put hl in bc
  521.         MOV    C,L        ;
  522.         DAD    H        ; x2
  523.         DAD    H        ; x4
  524.         DAD    B        ; x5
  525.         DAD    H        ; x10
  526.         ADD    L        ; now add value
  527.         MOV    L,A        ;
  528.         JNZ    DIGNC        ;
  529.         INR    H        ;
  530. ;
  531. DIGNC:        MOV    A,E        ;check for end of fcb
  532.         CPI    FCB+12        ;
  533.         JNZ    DECLP        ;nope, keep converting
  534.         MVI    C,0        ;now set c
  535.         PUSH    H        ;save binary baud rate
  536.         LXI    D,-110        ;for subtract
  537.         DAD    D        ;do it
  538.         MOV    A,H        ;
  539.         ORA    L        ;110 baud?
  540.         POP    H        ;restore baud rate
  541.         RZ            ;yes - with c = 0
  542.         INR    C        ;no, try 300
  543.         LXI    D,-300        ;
  544.         DAD    D        ;
  545.         MOV    A,H        ;
  546.         ORA    L        ;
  547.         RZ            ;yes, c = 1
  548. ;
  549. BADRATE        POP    H        ;(getbaud ret)
  550.         POP    H        ;(fixbaud/setbaud ret)
  551.         CALL    ERXIT        ;exit with error message
  552.         DB    '++ Invalid Baud Rate ++$'
  553. ;
  554. ;======================== PARITY ROUTINES ==============================
  555. ;
  556. ;.....
  557. ;
  558. PARITY:        LDA    OPARITY        ;check for odd parity flag
  559.         ORA    A        ;
  560.         JNZ    EVENPAR        ;not set, check for even
  561.         MVI    A,D8OP1SB    ;set odd parity
  562.         JMP    PARITY1        ;go do it
  563. ;
  564. EVENPAR:    LDA    EPARITY        ;check even parity flag
  565.         ORA    A        ;
  566.         RNZ            ;nop if neither set
  567.         MVI    A,D8EP1SB    ;set even parity
  568. ;
  569. PARITY1:    STA    MODCTLB        ;update current format word
  570.         JMP    OUT$MODCTL1    ;this will ret to caller
  571. ;
  572. NOPARITY:    MVI    A,D8NP2SB    ;2 stop bits for no parity
  573.         JMP    PARITY1        ;
  574.  
  575. ;
  576. ;
  577. ;=========================== DISCONNECT ROUTINE ============================
  578. ;
  579. ;.....
  580. ;
  581. GOODBYE:
  582. DISCONNT:    LDA    UARTCTLB    ;get the current mode word
  583.         ANI    07FH        ;
  584.         STA    UARTCTLB    ;hang up
  585.         CALL    OUT$MODCTL2    ;
  586. ;
  587.         IF    MMIIE
  588. ;
  589.         XRA    A        ;turn off the speaker
  590.         CALL    STACTL3        ;
  591. ;
  592.         ENDIF            ;MMIIE
  593. ;
  594.         PUSH    B        ;
  595.         MVI    B,10        ;wait a second
  596.         CALL    TIMER        ;
  597.         POP    B        ;
  598.         RET            ;
  599. ;
  600. ;=================== INITIALIZATION AND APPLE I/O ROUTINES =================
  601. ;
  602. ;.....
  603. ;
  604. INITMOD:    EQU    $        ;locate the routine
  605. ;
  606.         IF    ALSCARD
  607. ;
  608.         LHLD    1        ;pointer to cold boot vector in BIOS
  609.         LXI    D,60H        ;offset to ALS' special vectors
  610.         DAD    D        ;hl => APREAD vector
  611.         SHLD    APREAD+1    ;store address locally so we can use
  612.         INX    H        ;bump hl to point to APWRITE
  613.         INX    H        ;
  614.         INX    H        ;
  615.         SHLD    APWRITE+1    ;
  616. ;
  617.         ENDIF            ;ALSCARD
  618. ;
  619.         MVI    A,INITBITS    ;initialize the ACIA
  620.         CALL    OUT$MODCTL1    ;
  621.         MVI    A,D8NP2SB    ;set default format
  622.         STA    MODCTLB        ;
  623.         CALL    OUT$MODCTL1    ;
  624.         RET            ;from initmod:
  625. ;
  626. ;        Apple I/O subroutines
  627. ;
  628.         IF    CPM2
  629. ;
  630. STADATP:    STA    MODDATP        ;out DATA
  631.         RET            ;
  632. ;
  633. STACTLP:    STA    MODCTL1        ;out CR1
  634.         RET            ;
  635. ;
  636. STACTL2:    STA    MODCTL2        ;out CR2
  637.         RET            ;
  638. ;
  639. LDADATP:    LDA    MODDATP        ;in DATA
  640.         RET            ;
  641. ;
  642. LDACTLP:    LDA    MODCTL1        ;in STATUS
  643.         RET            ;
  644. ;
  645. LDACTL2:    LDA    MODCTL2        ;in RI
  646.         RET            ;
  647. ;
  648.         ENDIF            ;CPM2
  649. ;
  650.         IF    MMIIE AND CPM2
  651. ;
  652. STACTL3:    STA    MODCTL3        ;out CR3
  653.         RET            ;
  654. ;
  655.         ENDIF            ;MMIIE AND CPM2
  656. ;
  657.         IF    ALSCARD
  658. ;
  659. ;        ALS bank select Apple I/O output
  660. ;
  661. STADATP:    PUSH    H        ;save the reg about to be used
  662.         LXI    H,MODDATP    ;point to desired location
  663.         JMP    APWRT        ;go do the action
  664. ;
  665. STACTLP:    PUSH    H        ;
  666.         LXI    H,MODCTL1    ;out CR1
  667.         JMP    APWRT        ;
  668. ;
  669. STACTL2:    PUSH    H        ;
  670.         LXI    H,MODCTL2    ;out CR2
  671. ;
  672.         ENDIF            ;ALSCARD
  673. ;
  674.         IF    ALSCARD AND MMIIE
  675. ;
  676.         JMP    APWRT        ;to give STACTL2 a place to go
  677. STACTL3:    PUSH    H        ;
  678.         LXI    H,MODCTL3    ;out CR3
  679. ;
  680.         ENDIF            ;ALSCARD AND MMIIE
  681. ;
  682.         IF    ALSCARD
  683. ;
  684. APWRT:        PUSH    D        ;save the rest of the registers
  685.         PUSH    B        ;
  686. ;
  687. APWRITE:    CALL    $-$        ;INITMOD inits this CALL
  688. ;
  689.         POP    B        ;
  690.         POP    D        ;
  691.         POP    H        ;
  692.         RET            ;
  693. ;
  694. ;        ALS bank select Apple I/O input
  695. ;
  696. LDADATP:    PUSH    H        ;
  697.         LXI    H,MODDATP    ;
  698.         JMP    APRD        ;
  699. ;
  700. LDACTLP:    PUSH    H        ;
  701.         LXI    H,MODCTL1    ;in STATUS
  702.         JMP    APRD        ;
  703. ;
  704. LDACTL2:    PUSH    H        ;
  705.         LXI    H,MODCTL2    ;
  706. ;
  707. APRD:        PUSH    D        ;save the rest
  708.         PUSH    B        ;
  709. ;
  710. APREAD:        CALL    $-$        ;INITMOD inits this CALL
  711. ;
  712.         POP    B        ;
  713.         POP    D        ;
  714.         POP    H        ;
  715.         RET            ;
  716. ;
  717.         ENDIF            ;ALSCARD
  718. ;
  719. ;========================= DIAL ROUTINES =============================
  720. ;
  721. ;.....
  722. ;
  723. DIAL:        XRA    A        ;reset:
  724.         STA    CRFLAG        ;continuous redial flag
  725.         STA    RINGBKFL    ;ringback flag
  726.         LXI    H,0        ;reset:
  727.         SHLD    DIALCT        ;no. of dial attempts
  728.         LXI    H,CMDBUF+1    ;point to command buffer
  729.         MOV    A,M        ;get no. of char's
  730.         CPI    3+1        ;
  731.         JC    DIAL1        ;< 4?
  732. ;
  733. ; If there were only 3 characters, the CAL<ret> was typed, the user
  734. ; obviously expecting to get a phone number (or letter) from the
  735. ; library file.  If 4 or more, a number (or letter) was typed in from
  736. ; the menu command line, so move the characters down 4 to compensate.
  737. ; Needed for auto-redialing of menu command line entries.
  738. ;
  739.         MOV    C,A        ;
  740.         MVI    B,0        ;bc = num of chars
  741.         SUI    4        ;
  742.         MOV    M,A        ;subtract 4 from cmdbuf+1
  743.         INX    H        ;point to beginning of cmd line
  744.         XCHG            ;switch pointers
  745.         LXI    H,CMDBUF+6    ;
  746.         CALL    MOVER        ;
  747.         JMP    DIAL4        ;
  748. ;
  749. ; Comes here if no phone number was manually entered after "CAL" and if
  750. ; no phone library letter was entered.  Displays the phone number library
  751. ; then asks for an entry.
  752. ;
  753. DIAL1:        MVI    C,13        ;
  754.         LXI    H,NUMBLIB    ;point to library
  755.         LXI    D,BUFFER    ;
  756.         CALL    NEWLINE        ;
  757.         STAX    D        ;
  758.         INX    D        ;
  759. ;
  760. DIAL2:        MVI    B,LIBLEN    ;
  761.         CALL    MOVE        ;
  762.         CALL    SPACES        ;
  763.         MVI    B,LIBLEN    ;
  764.         CALL    MOVE        ;
  765.         CALL    NEWLINE        ;
  766.         DCR    C        ;
  767.         JNZ    DIAL2        ;
  768. ;
  769. DIAL3:        MVI    A,'$'        ;terminate the buffer
  770.         STAX    D        ;
  771.         CALL    CLRTST        ;clear the screen if appropriate
  772.         MVI    C,PRINT        ;
  773.         LXI    D,BUFFER    ;readdress the buffer
  774.         CALL    BDOS        ;print the library
  775.         CALL    JMP$ILPRT    ;
  776.         DB    CR,LF,'Enter library letter or phone number,',CR,LF
  777.         DB    'CTL-X quits while dialing or ringing : ',0
  778.         LXI    D,CMDBUF    ;point to command buffer
  779.         CALL    JMP$INBUF    ;go get user command
  780. ;
  781. ; You now have either a library letter or a manually entered phone number.
  782. ; These either came from the menu command line or from the library command
  783. ; line.  Next we see if a letter, if so, get the corresponding line with
  784. ; phone number from the library.  If a number we ignore the library look-
  785. ; up.  (Ringback numbers are valid in library, but cause a caution message
  786. ; to the user, as this is not possible with Micromodem.)
  787. ;
  788. DIAL4:        LXI    H,CMDBUF+1    ;point to no. of char's
  789.         MOV    A,M        ;
  790.         ORA    A        ;
  791.         JZ    DIALEXIT    ;if none, bomb out
  792.         INX    H        ;point to first char
  793.         PUSH    H        ;save the pointer
  794.         CALL    DIALBGN        ;begin the dialing sequence
  795.         POP    H        ;restore the pointer
  796.         MVI    B,'A'        ;first compare byte
  797.         MVI    E,0        ;corresponding library entry
  798.         MVI    C,26        ;no. of entries to check
  799.         MOV    A,M        ;get the first cmdbuf char
  800. ;
  801. DIAL5:        CMP    B        ;match?
  802.         JZ    DIAL6        ;yes
  803.         INR    B        ;no - increment compare byte
  804.         INR    E        ;and offset
  805.         DCR    C        ;decrement tries
  806.         JZ    DIAL10        ;0 means checked 'Z'
  807.         JMP    DIAL5        ;try again
  808. ;
  809. ; Now have a match between the requested letter and the one in the library.
  810. ; E register has the decimal equivalent (0-25) of the letter (A-Z)
  811. ;
  812. DIAL6:        LXI    H,NUMBLIB    ;point to library
  813.         LXI    B,LIBLEN    ;
  814.         MOV    A,E        ;number of entries to skip
  815.         ORA    A        ;0?
  816.         JZ    DIAL8        ;yes - hl points to selected entry
  817. ;
  818. DIAL7:        MOV    A,M        ;
  819.         ORA    A        ;null phone number?
  820.         JZ    DIALBAD        ;yes - do error routine
  821.         DAD    B        ;no - move to next entry
  822.         DCR    E        ;done skipping?
  823.         JNZ    DIAL7        ;no - do it again
  824. ;
  825. ; Now hl points to the line containing the phone number requested, so
  826. ; store that line at CMDBUF+1
  827. ;
  828. DIAL8:        MVI    B,LIBLEN    ;length of the line
  829.         LXI    D,CMDBUF+1    ;to pointer
  830.         XCHG            ;switch pointers
  831.         MOV    M,B        ;put length of line in cmdbuf+1
  832.         XCHG            ;switch pointers back
  833.         INX    D        ;de -> cmdbuf+2
  834.         CALL    MOVE        ;from hl to de b times
  835. ;
  836. ; Now have the full line including phone number in 'CMDBUF' area.
  837. ;
  838. DIAL10:        LXI    H,CMDBUF+1    ;address the command line
  839.         MOV    E,M        ;put the no. of chars in e
  840.         INX    H        ;point to first char
  841. ;
  842. DIAL11:        MOV    A,M        ;get a char
  843.         ORA    A        ;nulls cause an error
  844.         JZ    DIALBAD        ;
  845. ;
  846. ; Dial a digit, check keyboard for abort
  847. ;
  848.         CALL    DIALA        ;dial the digit in A
  849.         CALL    STAT        ;keyboard hit?
  850.         JZ    DIAL13        ;no - continue
  851.         CALL    KEYIN        ;yes - get the character
  852.         CPI    CANCEL        ;is it the cancel character?
  853.         JZ    DIALEXIT    ;yes - forget the whole idea
  854. DIAL13:        INX    H        ;point to the next digit
  855.         DCR    E        ;decrement char count
  856.         JNZ    DIAL11        ;more to dial
  857. ;
  858. ; Show number of dial attempts
  859. ;
  860.         CALL    JMP$ILPRT    ;
  861.         DB    ' -try #',0    ;
  862.         LHLD    DIALCT        ;get the attempt counter
  863.         INX    H        ;bump it first
  864.         SHLD    DIALCT        ;and update it
  865.         CALL    DECOUT        ;now type it
  866.         MVI    A,' '        ;and then a space
  867.         CALL    TYPE        ;
  868. ;
  869. ; Dialing is done
  870. ;
  871.         MVI    B,WAITCD    ;secs * 10 to wait for carrier
  872.         CALL    CARWT        ;go wait for carrier
  873.         JC    EXMENU        ;cy means operator cancelled
  874.         LDA    UARTCTLB    ;not detected, try answer mode
  875.         XRI    MODBIT        ;flip modem mode...
  876.         ORI    TXEBIT        ;enable the transmitter
  877.         STA    UARTCTLB    ;
  878.         CALL    OUT$MODCTL2    ;set modem
  879.         MVI    B,30        ;now wait for orig tone for 3 seconds
  880.         CALL    CARWT        ;
  881.         JC    EXMENU        ;cy if cancel requested
  882.         LDA    UARTCTLB    ;nope, connection failed
  883.         XRI    MODBIT        ;flip back to originate
  884.         ANI    NOTTXE        ;reset the transmit enable bit
  885.         STA    UARTCTLB    ;
  886.         CALL    OUT$MODCTL2    ;tell modem about it
  887. ;
  888. ; Connection not made, go see if a redial is desired
  889. ;
  890.         CALL    DISCONNT    ;disconnect the modem
  891. DIALAGN:    LDA    CRFLAG        ;continuous redial requested?
  892.         ORA    A        ;
  893.         JNZ    DIALAGN1    ;yes - skip the idle chatter
  894.         CALL    JMP$ILPRT    ;
  895.         DB    CR,LF,LF,'No answer. Redial? (Y,N,C) : ',0
  896.         CALL    KBDCHR        ;get a keyboard character
  897.         CALL    CRLF        ;for neatness
  898.         CPI    'N'        ;(N)o?
  899.         JZ    MENU        ;nope, go back to the menu
  900.         CPI    'Y'        ;(Y)es?
  901.         JZ    DIALAGN1    ;yup, do it again
  902.         CPI    'C'        ;(C)ontinuously redial?
  903.         JNZ    DIALAGN        ;none of these, try again for user
  904.         MVI    A,1        ;set the continuous redial flag
  905.         STA    CRFLAG        ;so we won't do this again
  906. ;
  907. DIALAGN1:    MVI    B,WAITRD    ;secs * 10 to wait until redial
  908.         CALL    TIMER        ;
  909.         CALL    CRLF        ;for display neatness
  910.         JMP    DIAL4        ;
  911. ;
  912. EXMENU:        CALL    DISCONNT    ;disconnect the modem
  913.         CALL    CRLF        ;
  914.         JMP    MENU        ;
  915. ;
  916. ; Come here when the connection has been made
  917. ;
  918. CONMADE:    EQU    $        ;
  919. ;
  920.         IF    MMIIE
  921. ;
  922.         XRA    A        ;turn off speaker now
  923.         CALL    STACTL3        ;
  924. ;
  925.         ENDIF            ;MMIIE
  926. ;
  927.         LDA    UARTCTLB    ;carrier detected ...
  928.         ORI    TXEBIT        ;enable the transmitter, if not already
  929.         STA    UARTCTLB    ;
  930.         CALL    OUT$MODCTL2    ;
  931.         CALL    SETBAUD        ;set the current baud rate
  932.         CALL    JMP$ILPRT    ;
  933.         DB    CR,LF,LF,'Connected.',BELL,0
  934.         LDA    CRFLAG        ;were we continuously redialing?
  935.         ORA    A        ;
  936.         JZ    RETURN        ;no - drop into terminal mode
  937.         CALL    JMP$ILPRT    ;yes - get the user's attention
  938.         DB    ' - hit any key ... ',0
  939. ;
  940. CONMADE2:    CALL    STAT        ;check for user
  941.         JZ    CONMADE3    ;
  942.         CALL    KEYIN        ;get the character typed
  943.         XRA    A        ;
  944.         JMP    RETURN        ;and drop into terminal mode
  945. ;
  946. CONMADE3:    MVI    B,10        ;1 second between bells
  947.         CALL    TIMER        ;
  948.         MVI    A,BELL        ;
  949.         CALL    TYPE        ;send the bell
  950.         CALL    IN$MODCTL1    ;check to see if distant modem gave up
  951.         ANI    CARBIT        ;
  952.         JZ    CONMADE2    ;no - keep trying to signal user
  953.         CALL    DISCONNT    ;disconnect the modem
  954.         CALL    JMP$ILPRT    ;distant modem gave up waiting
  955.         DB    CR,LF,LF,BELL,'++ Carrier lost, hit any key ++ ',0
  956. CONMADE4:    CALL    STAT        ;check for keyboard
  957.         JZ    CONMADE4    ;
  958.         CALL    KEYIN        ;get the character
  959.         XRA    A        ;
  960.         JMP    MENU        ;go back to menu
  961. ;
  962. ; Automatic dialing routine, prints the number being dialed
  963. ;
  964. DIALA:        CALL    TYPE        ;get that out of the way
  965.         CPI    'R'        ;ringback request?
  966.         JNZ    DIALA0        ;no - continue checking
  967.         PUSH    PSW        ;yes - is it really?
  968.         MOV    A,E        ;check character count
  969.         CPI    1        ;last one?
  970.         JZ    RINGBK        ;
  971.         POP    PSW        ;not really, keep checking
  972. DIALA0:        MOV    B,A        ;save char in B
  973.         CALL    DIALAD        ;check for alternate dialing request
  974.         MOV    A,B        ;restore char
  975. DIALADC:    CPI    ','        ;pause request?
  976.         JNZ    DIALA1        ;no - keep going
  977.         MVI    B,20        ;yes - wait 2 seconds and return
  978.         JMP    TIMER        ;this will return
  979. ;
  980. DIALA1:        CPI    '0'        ;check for dialability
  981.         RC            ;less than, so return
  982.         CPI    '9'+1        ;
  983.         RNC            ;greater than, so return
  984.         SUI    '0'        ;kill ascii bias
  985.         JNZ    DIALA2        ;if 1-9, go on
  986.         MVI    A,10        ;convert 0 to 10
  987. ;
  988. ; Dial the digit in the AC, determine the dialing method
  989. ;
  990. DIALA2:        MOV    C,A        ;put digit to be dialed in C
  991. ;
  992.         IF    MMIIE
  993. ;
  994.         LDA    TOUCHPULSE    ;get touch tone flag
  995.         CPI    'T'        ;
  996.         JNZ    DIALA2P        ;not a T, pulse dial
  997. ;
  998. ; Touch tone dialing routine, wait 100 ms, tone for 100 ms
  999. ;
  1000.         MVI    B,10        ;wait 100 ms
  1001.         CALL    MS10        ;
  1002.         MOV    A,C        ;get the digit to dial (0-10)
  1003.         ORI    TONEBIT+SPKRBIT    ;add speaker and tone bits
  1004.         CALL    STACTL3        ;output to modem
  1005.         MVI    B,10        ;for 100 ms
  1006.         CALL    MS10        ;
  1007.         MVI    A,SPKRBIT    ;turn off tone now
  1008.         JMP    STACTL3        ;digit dialed, STACTL3 will RET
  1009. ;
  1010. DIALA2P:    EQU    $        ;
  1011. ;
  1012.         ENDIF            ;MMIIE
  1013. ;
  1014.         MVI    B,60        ;wait 600 ms
  1015.         CALL    MS10        ;uses the local timing routine
  1016. DIALNXT:    LDA    UARTCTLB    ;get the current make word
  1017.         PUSH    PSW        ;put on the stack
  1018.         ANI    07FH        ;make the break word
  1019.         CALL    OUT$MODCTL2    ;*   break   *
  1020.         MVI    B,5        ;* for 56 ms *
  1021.         CALL    MS10        ;
  1022.         POP    PSW        ;get the make word
  1023.         CALL    OUT$MODCTL2    ;*   make    *
  1024.         MVI    B,4        ;* for 44 ms *
  1025.         CALL    MS10        ;
  1026.         DCR    C        ;done with digit?
  1027.         JNZ    DIALNXT        ;
  1028.         RET            ;digit dialed
  1029. ;
  1030. MS10:        PUSH    B        ;wait 10 ms * b register
  1031.         PUSH    H        ;save used registers
  1032. ;
  1033.         IF    ALSCARD    ;
  1034. ;
  1035.         LXI    H,064H        ;constant to wait
  1036. ;
  1037.         ENDIF            ;ALSCARD
  1038. ;
  1039.         IF    CPM2        ;
  1040. ;
  1041.         LXI    H,032H        ;because I/O faster
  1042. ;
  1043.         ENDIF            ;CPM2
  1044. ;
  1045.         CALL    FIXCNT        ;adjust for clock speed
  1046.         MOV    B,H        ;put in bc
  1047.         MOV    C,L        ;
  1048.         POP    H        ;restore one register
  1049. ;
  1050. MSLP:        DCX    B        ;decrement timeout count
  1051.         MOV    A,B        ;
  1052.         ORA    C        ;done yet?
  1053.         JNZ    MSLP        ;no - keep timing
  1054.         POP    B        ;restore the other register
  1055.         DCR    B        ;debump count
  1056.         JNZ    MS10        ;do it again
  1057.         RET            ;
  1058. ;
  1059. TIMER:        PUSH    B        ;wait 100ms * b register
  1060.         PUSH    H        ;
  1061. ;
  1062.         IF    ALSCARD        ;
  1063. ;
  1064.         LXI    H,03E8H        ;constant to wait
  1065. ;
  1066.         ENDIF            ;ALSCARD
  1067. ;
  1068.         IF    CPM2
  1069. ;
  1070.         LXI    H,01F4H        ;because clock slower
  1071. ;
  1072.         ENDIF            ;
  1073. ;
  1074.         CALL    FIXCNT        ;adjust for clock speed
  1075.         MOV    B,H        ;put in bc
  1076.         MOV    C,L        ;
  1077.         POP    H        ;restore one register
  1078. ;
  1079. MSLP2:        DCX    B        ;decrement timeout count
  1080.         MOV    A,B        ;
  1081.         ORA    C        ;done yet?
  1082.         JNZ    MSLP2        ;no - keep timing
  1083.         POP    B        ;restore the other register
  1084.         DCR    B        ;debump count
  1085.         JNZ    TIMER        ;do it again
  1086.         RET            ;
  1087. ;
  1088. ; Bad library number
  1089. ;
  1090. DIALBAD:    CALL    JMP$ILPRT    ;
  1091.         DB    CR,LF,'++ Bad library number called ++',CR,LF,0
  1092. ;
  1093. DIALEXIT:    CALL    DISCONNT    ;disconnect the modem
  1094.         CALL    CRLF        ;
  1095.         XRA    A        ;clear:
  1096.         STA    CRFLAG        ;the continuous redial flag
  1097.         CALL    JMP$INMODEM    ;clear any garbage
  1098.         JMP    MENU        ;
  1099. ;
  1100. DIALEXT2:    CALL    JMP$INMODEM    ;wait for a clear line
  1101.         JNC    DIALEXT2    ;
  1102.         CALL    JMP$GOODBYE    ;redundancy
  1103.         JMP    MENU        ;
  1104. ;
  1105. ; Disconnect from the line, wait 3 seconds, then pick up again
  1106. ;
  1107. DIALBGN:    CALL    DISCONNT    ;disconnect
  1108.         PUSH    B        ;
  1109.         MVI    B,20        ;because disconnt waits 1
  1110.         CALL    TIMER        ;
  1111.         POP    B        ;
  1112. ;
  1113.         IF    MMIIE
  1114. ;
  1115.         MVI    A,SPKRBIT    ;turn on MM][/e's speaker
  1116.         CALL    STACTL3        ;
  1117. ;
  1118.         ENDIF            ;MMIIE
  1119. ;
  1120.         CALL    OFFHOOK        ;go offhook again
  1121.         PUSH    B        ;
  1122.         MVI    B,20        ;
  1123.         CALL    TIMER        ;wait 2 seconds
  1124.         POP    B        ;
  1125.         RET            ;and return
  1126. ;
  1127. ; If Micromodem ][:
  1128. ;
  1129. ; Check for aternate dialing characters, message the user if detected
  1130. ;
  1131. ; If Micromodem ][/e:
  1132. ;
  1133. ; Does the alternate dialing request, allowing dialing mode switch
  1134. ; with T or P in alternate dialing string.   When done, leaves the modem 
  1135. ; in touch tone mode, as all long distance services require touch tone.
  1136. ;
  1137. DIALAD:        MOV    A,B        ;get the char
  1138.         CPI    '<'        ;altdial1?
  1139.         JZ    DIALAD2        ;
  1140.         CPI    '>'        ;altdial2?
  1141.         RNZ            ;
  1142. ;
  1143.         IF    MMIIE        ;
  1144. ;
  1145. DIALAD2:    LDA    TOUCHPULSE    ;alternate dialing requested
  1146.         CPI    'T'        ;check for touch tone
  1147.         JZ    DIALAD3        ;
  1148.         MVI    A,'T'        ;we're pulse dialing, switch for ad
  1149. DIALAD3:    STA    TOUCHPULSE    ;
  1150.         MOV    A,B        ;restore the char
  1151.         CPI    '>'        ;altdial1?
  1152.         JNZ    ALT2        ;no, must be altdial2
  1153. ;
  1154.         PUSH    H        ;save the used register
  1155.         LXI    H,ALTDIAL1    ;
  1156.         JMP    DIALAD4        ;
  1157. ;
  1158. ALT2:        PUSH    H        ;
  1159.         LXI    H,ALTDIAL2    ;
  1160. ;
  1161. DIALAD4:    CALL    TYPE        ;get that out of the way
  1162. DIALAD5:    MOV    A,M        ;get an alternate dialing char
  1163.         CPI    '$'        ;end of string?
  1164.         JZ    DIALAD6        ;
  1165.         CPI    'P'        ;dialing mode change?
  1166.         JZ    SETIT        ;
  1167.         CPI    'T'        ;
  1168.         JZ    SETIT        ;
  1169.         CALL    DIALADC        ;dial the character, if you can
  1170.         JMP    ADNEXT        ;
  1171. ;
  1172. SETIT:        STA    TOUCHPULSE    ;update the dialing method
  1173. ADNEXT:        INX    H        ;point to the next char
  1174.         JMP    DIALAD5        ;and do it all again
  1175. ;
  1176. DIALAD6:    MVI    A,' '        ;for display neatness
  1177.         CALL    TYPE        ;
  1178.         POP    H        ;remember?
  1179.         RET            ;        
  1180. ;
  1181.         ENDIF            ;MMIIE
  1182. ;
  1183.         IF    NOT MMIIE
  1184. ;
  1185. DIALAD2:    CALL    JMP$ILPRT    ;
  1186.         DB    CR,LF,BELL,'++ Alternate dialing not available for'
  1187.         DB    ' Micromodem ++',CR,LF,LF
  1188.         DB    '   Do you wish to continue ? (Y,N) : ',0
  1189.         CALL    KBDCHR        ;
  1190.         CALL    CRLF        ;
  1191.         CALL    CRLF        ;
  1192.         CPI    'N'        ;
  1193.         JNZ    DIALAD3        ;
  1194.         POP    H        ;justify stack
  1195.         JMP    MENU        ;
  1196. ;
  1197. DIALAD3:    CPI    'Y'        ;
  1198.         JNZ    DIALAD2        ;
  1199.         RET            ;
  1200. ;
  1201.         ENDIF            ;NOT MMIIE
  1202. ;
  1203. ; Ringback not possible, also messages user, but doesn't need ack
  1204. ;
  1205. RINGBK:        POP    PSW        ;justify stack
  1206.         CALL    JMP$ILPRT    ;just message the user
  1207.         DB    BELL,' - (Ringback not available)',0
  1208.         RET            ;from DIALA
  1209. ;
  1210. ; Waits for carrier, performs direct jump to "conmade:" if detected
  1211. ;
  1212. CARWT:        PUSH    B        ;save the count
  1213.         CALL    IN$MODDATP    ;updates status register
  1214.         CALL    IN$MODCTL1    ;check the modem status
  1215.         ANI    CARBIT        ;carrier detected?
  1216.         JNZ    CARWT1        ;no, time out
  1217.         POP    B        ;restore BC
  1218.         POP    PSW        ;get rid of return address
  1219.         JMP    CONMADE        ;and go do connect options
  1220. CARWT1:        CALL    STAT        ;check for keyboard cancel
  1221.         JZ    CARWT2        ;z = no char hit
  1222.         CALL    KEYIN        ;char hit, is it cancel?
  1223.         CPI    CANCEL        ;
  1224.         JNZ    CARWT2        ;no, ignore it
  1225.         STC            ;set cancel flag
  1226.         RET            ;
  1227. ;
  1228. CARWT2:        MVI    B,10        ;wait .1 seconds
  1229.         CALL    MS10        ;
  1230.         POP    B        ;restore the count
  1231.         DCR    B        ;
  1232.         JNZ    CARWT        ;keep waiting
  1233.         XRA    A        ;reset the cy
  1234.         RET            ;
  1235. ;
  1236. ;====================== MICROMODEM SPECIAL MENU ========================
  1237. ;
  1238. SPCLMENU:    CALL    JMP$NXTSCRN    ;
  1239.         CALL    JMP$ILPRT    ;
  1240.         DB    '    Additional commands for Micromodem'
  1241.         DB    CR,LF,LF
  1242.         DB    '  Modem control :',CR,LF,LF
  1243.         DB    '    A - Answer tone for S or R',CR,LF
  1244.         DB    '    O - Originate tone for S or R',CR,LF,LF
  1245.         DB    '  Parity options :',CR,LF,LF
  1246.         DB    '    1 - Set odd parity',CR,LF
  1247.         DB    '    0 - Set even parity',CR,LF,LF
  1248.         DB    '  Both ends must be capable of parity.  Only',CR,LF
  1249.         DB    '  available in R and S modes.  Parity check',CR,LF
  1250.         DB    '  will be part of transfer protocol.',CR,LF,LF
  1251.         DB    '  Note : Data format will be forced to 1 stop',CR,LF
  1252.         DB    '  bit as the Micromodem only supports parity',CR,LF
  1253.         DB    '  in this format.  Data format will be 2 stop',CR,LF
  1254.         DB    '  bits when parity is disabled (default).',CR,LF,LF,0
  1255.         CALL    JMP$NXTSCRN    ;
  1256.         CALL    JMP$ILPRT    ;
  1257.         DB    '    Additional commands for Micromodem'
  1258.         DB    CR,LF,LF
  1259.         DB    '  Speed options :',CR,LF,LF
  1260.         DB    '    Follow primary and secondary options with',CR,LF
  1261.         DB    '    baud rate as ".XXX".',CR,LF,LF
  1262.         DB    '  Speed option example :',CR,LF,LF
  1263.         DB    '    SBOT.110  will set modem for batch mode',CR,LF
  1264.         DB    '    send transfer at 110 baud, then drops',CR,LF
  1265.         DB    '    into terminal mode.',CR,LF,LF
  1266.         DB    '  110 and 300 baud are only rates available,',CR,LF
  1267.         DB    '  default is 300 baud.'
  1268.         DB    CR,LF,LF
  1269. ;
  1270.         IF    MMIIE
  1271. ;
  1272.         DB    '  SET command selects touch-tone or pulse dialing'
  1273.         DB    CR,LF,LF
  1274. ;
  1275.         ENDIF            ;MMIIE
  1276. ;
  1277.         DB    0        ;
  1278.         RET            ;
  1279. ;
  1280. ;=============================================================================
  1281. ;
  1282. SENDBRK:    RET            ;These functions disabled for PMMI
  1283. SETUPR:          EQU    $
  1284. ;
  1285.         IF    MMIIE
  1286. ;
  1287.         CALL    JMP$ILPRT    ;
  1288.         DB    CR,LF,'(T)ouch tone, or (P)ulse dialing ? : ',0
  1289.         CALL    KBDCHR        ;get the response
  1290.         CALL    CRLF        ;for neatness
  1291.         CALL    CRLF        ;
  1292.         CPI    'T'        ;touch tone?
  1293.         JZ    SETMD        ;
  1294.         CPI    'P'        ;pulse?
  1295.         JNZ    SETUPR        ;no, try again
  1296. SETMD:        STA    TOUCHPULSE    ;update flag
  1297. ;
  1298.         ENDIF            ;MMIIE
  1299. ;
  1300.         RET            ;
  1301. ;
  1302. ;-----------------------------------------------------------------------
  1303. ;
  1304. ;.....
  1305. ;
  1306. ; You can put in a message at this location which can be called up with
  1307. ; CTL-O if TRANLOGON has been set TRUE.  You can use several lines if
  1308. ; desired, as long as IGNORE$ERROR evaluates to less than 0B80H
  1309. ; Terminate message with a null.
  1310. ;
  1311. LOGON:        DB    CR,LF,0
  1312. ;
  1313. ;=============================================================================
  1314. ;
  1315. IGNORE$ERROR    EQU    $+1        ;! MUST BE <= 0B80H
  1316. ;
  1317.         ORG    117EH        ;in "optck:"
  1318. ;
  1319.         DB    0,0,0,0,0,0,0,0    ;disable uartctlb modification
  1320.         DB    0,0,0,0,0,0,0,0    ;at this level
  1321.         DB    0,0,0        ;
  1322. ;
  1323.         ORG    1CE9H        ;in "break:"
  1324. ;
  1325.         ORI    BRKBITS        ;
  1326. ;
  1327.         ORG    2733H        ;in "donetcd:"
  1328. ;
  1329.         DB    0,0,0,0,0,0,0    ;zap the multiple goodbye
  1330.         DB    0,0,0,0,0,0,0    ;for pmmi
  1331. ;
  1332.         ORG    3B70H        ;in "nxtopt0:"
  1333. ;
  1334.         JMP    PATCH        ;go do patch
  1335. ;
  1336.         ORG    3BABH        ;in "byebye:"
  1337. ;
  1338.         JMP    3BB9H        ;disable multiple goodbye
  1339. ;
  1340. PATCH        STA    CMDBUF+3    ;disable setting answflg during call
  1341.         JMP    3B7FH        ;now "doopt:"
  1342. ;
  1343.         DB    0,0,0,0,0    ;rest of byebye:
  1344. ;
  1345.         ORG    MODCTLB        ;
  1346. ;
  1347.         DB    D8NP2SB        ;default modem format
  1348. ;
  1349.         ORG    UARTCTLB    ;
  1350. ;
  1351.         DB    ORIGMOD        ;default modem mode word
  1352. ;
  1353.         END
  1354.