home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols200 / vol216 / mdm840.a86 < prev    next >
Text File  |  1994-07-13  |  184KB  |  8,066 lines

  1.     pagesize 51
  2. VERSION EQU    840            ;MDM840a(10/27/84)  --    CP/M MODEM PROGRAM  *
  3. ;
  4. ;                MDM841.A86
  5. ;
  6. ;
  7. ; 840A 10/27/84       -   Fixed Timing Loops           Alex Soya
  8. ; 840  10/23/84       -   Added stuff from MDM740           Dennis Vallianos
  9. ; 830           -   Translation from MDM730           Alex Soya
  10. ;------------------------------------------------------------------------
  11. ;       Translation of MDM740.ASM for CPM86 and MPM86.
  12. ;
  13. ;    This translation follows the same principle of using overlays
  14. ;    to adapt MDM8xx to different hardware environments as was so
  15. ;    successfully done with MDM7xx.
  16. ;
  17. ;    The procedure to adapt MDM8xx to specific hardware has changed
  18. ;    somewhat due to the facts that DDT86 can not be used to overlay
  19. ;    H86 (HEX) files and no SAVE command beeing available in CPM86.
  20. ;
  21. ;    The Procedure is now as follows:
  22. ;
  23. ;        Required Files:      MDM8xx.H86   (xx is Version Number)
  24. ;                           The Main Program in Hex Form.
  25. ;
  26. ;                  M8GP.A86     (The General None Specific
  27. ;                        Overlay.
  28. ;                         or
  29. ;                        One of the available Overlays
  30. ;                        for your hardware.)
  31. ;
  32. ;
  33. ;
  34. ;    After Editing your Overlay Source File to conform to your
  35. ;    Hardware environment, proceed as follows:
  36. ;
  37. ;
  38. ;        ASM86 M8GP             (Assemble the Overlay File )
  39. ;        PIP MDM.H86=MDM840.H86,M8GP.H86     (Append the Overlay to the
  40. ;                          main program)
  41. ;        GENCMD MDM 8080 CODE[MFF0] ( Run GENCMD to produce MDM.CMD )
  42. ;
  43. ;        Now you can run MDM.CMD
  44. ;
  45. ;
  46. ;
  47. ;    The Translation was MAINLY done be hand as XLT86 ( DRs 8080 -> 8086 translator)
  48. ;    is virtualy useless with large files.
  49. ;    Various routines had to be changed to work properly with CPM86 and MPM86
  50. ;    When making mods to MDM8xx keep in mind that they should work on CPM86 as
  51. ;    well as MPM86, so dont use BIOS calls and stuff as such...
  52. ;
  53. ;                    Alex Soya
  54. ;                    Sysop Melbourne RCPM
  55. ;
  56. ;                    P.O. Box 121
  57. ;                    Melbourne Beach
  58. ;                    Fl. 32951
  59. ;
  60. ;
  61. ;    MDM8xx    COPYRIGHTED 1984 BY ALEX K. SOYA
  62. ;    MDM7xx    COPYRIGHTED 1984 BY IRVIN M. HOFF
  63. ;
  64. ; THIS TELEPHONE MODEM PROGRAM USES THE CHRISTENSEN PROTOCOL.  IT HAS
  65. ; BOTH 'CRC' AND CHECKSUM CAPABILITY FOR ERROR-DETECTION. IT SUPPORTS
  66. ; DIALING AND AUTO-REDIALING FOR THE ANCHOR AUTOMATION SIGNALMAN MARK
  67. ; XII, US ROBOTICS MODEMS, THE HAYES SMARTMODEM 300 AND 1200 AND PMMI
  68. ; S-100 MODEMS.     IT SUPPORTS UP TO TWO ALTERNATE DIALING SYSTEMS SUCH
  69. ; AS 'MCI', 'SPRINT', ETC.  IT IS COPYRIGHTED TO DETER COMMERCIALISM.
  70. ;
  71. ; OTHER EXTERNAL MODEMS MAY BE READILY USED, ALTHOUGH  MANUAL DIALING
  72. ; MAY BE NECESARY.  OVERLAYS HAVE BEEN MADE ALLOWING RAPID ADAPTATION
  73. ; TO VARIOUS COMPUTERS.     THE PROGRAM CONFORMS READILY TO NUMEROUS I/O
  74. ; DEVICES INCLUDING THE 2661, 8250, 8251, Z80-SIO, ETC.
  75. ;
  76. ;
  77. ;***********************************************************************
  78. ;
  79. ;   GENERAL INTEREST:  When transferring files modem-to-modem, the batch
  80. ;   mode is extremely useful.  It allows automatic transmission of nu-
  81. ;   merous files while the operator at the receiving end does virtually
  82. ;   nothing.  It can be used for single files or with wildcards.  With
  83. ;   normal single program transfer, the receiving end switches from CRC
  84. ;   to checksum in one minute and times out completely in 120 seconds.
  85. ;   (In batch mode it times out in 3 minutes for receive.)  This offers
  86. ;   ample opportunity to transfer programs between individuals.
  87. ;
  88. ;
  89. ;      M8LIB.CMD  can be used to very easily and very quickly change
  90. ;         any of the telephone overlay numbers.
  91. ;
  92. ;      M8FNK.CMD can be used to quickly and easily change any of the
  93. ;         10 function key assignments (or the function key intercept
  94. ;         character itself, which is currently the '^' character.
  95. ;
  96. ;
  97. ;    This program may be used freely for any non-commercial purpose,
  98. ;    provided that the user does not remove or alter this notice or
  99. ;    the copyright statement.  It is not covered by a warranty either
  100. ;    express or implied.  No changes or alterations are authorized.
  101. ;    If desirious of modifying the program for national release, it
  102. ;    may be used for such purposes only if the name is changed and
  103. ;    credit given where appropriate.
  104. ;
  105. ;    Many people have contributed in the past to make MODEM7 what it
  106. ;    was when I renamed the program to MDM700 and began this series.
  107. ;    Their achievements range from modest changes to significant ma-
  108. ;    jor additions:
  109. ;
  110. ;         Ward Christensen, Jim Mills, Mark Zeigler, Keith Petersen,
  111. ;         Paul Kelly, Bruce Ratoff, Ron Fowler, Rich Berg, Bob Clyne,
  112. ;         Bill Earnest, Ben Bronson, Paul Hansknecht, John Mahr, Bob
  113. ;         Plouffe, Sigi Kluger, Frank Gaude' and others.
  114. ;
  115. ;    I do not mean to slight anyone, and hope I have included those
  116. ;    who made the most significant advancements to the program.
  117. ;                    - Irv Hoff W6FFC
  118. ;
  119. ;***********************************************************************
  120. ;
  121. ;
  122. PORT    EQU    0C0H            ;your base port (data or status)
  123. ;
  124. MODCTL1 EQU    PORT            ;modem control port
  125. MODDATP EQU    PORT+1            ;modem data port
  126. MODRCVB EQU    02H            ;modem receive bit (DAV)
  127. MODRCVR EQU    02H            ;modem receive ready
  128. MODSNDB EQU    01H            ;modem send bit
  129. MODSNDR EQU    01H            ;modem send ready bit
  130. ;
  131. ;
  132. ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  133. ;             SPECIAL EQUATES FOR PMMI
  134. ;
  135. MODCTL2     EQU    PORT+3            ;modem status port
  136. ;
  137. BAUDRP     EQU    PORT+2            ;modem baud rate port
  138. BRKMSK     EQU    0FBH            ;mask to set break
  139. EVPARMSK EQU    20H            ;mask to set even parity
  140. NOPARMSK EQU    10H            ;mask to reset to no parity
  141. ODPARMSK EQU    0CFH            ;mask to set odd parity
  142. ;
  143. ANSWMOD     EQU    1EH            ;answer mode
  144. ORIGMOD     EQU    1DH            ;originate mode
  145. WAITCTS     EQU    150            ;number of seconds (x5) to wait for the
  146.                     ;computer to answer after PMMI auto-dial
  147.                     ;100=20 sec, 150=30 sec, 255=51 sec.
  148.                     ;any number 0-255 acceptable
  149. ;
  150. ;          (END OF SPECIAL PMMI EQUATES)
  151. ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  152. ;
  153. ;
  154. YES    EQU    0FFH
  155. NO    EQU    0
  156. ;
  157. ;
  158. BUFSIZ    EQU    16            ;buffer size in Kbytes for ASCII capture to disk
  159.                     ;(16k is one file extent)
  160. XFRSIZ    EQU    4            ;file transfer buffer in Kbytes.  Do not make
  161.                     ;any larger than BUFSIZ.  16k works fine on all
  162.                     ;but very slowest systems
  163. ;
  164. BDNMCH    EQU    75H            ;bad name match
  165. ERRLIM    EQU    10            ;maximum allowable consecutive errors
  166. ERRCRC    EQU    6            ;CRC tries, then switches to CHECKSUM
  167. LIBLEN    EQU    34            ;length of each phone library entry
  168. SHOWHEX EQU    NO            ;yes, show both decimal and hex record counts
  169.                     ;no, show just standard decimal record count
  170. RUB    EQU    7FH            ;rub
  171. CRC    EQU    'C'            ;requests 'CRC' instead of 'CKSUM'
  172. ESC    EQU    '['-40H            ;^[ = escape
  173. SOH    EQU    'A'-40H            ;^A = start of header
  174. EOT    EQU    'D'-40H            ;^D = end of text
  175. EXITCHR EQU    'E'-40H            ;^E = exit character
  176. ACK    EQU    'F'-40H            ;^F = acknowledge
  177. OKNMCH    EQU    'F'-40H            ;^F = ok name match
  178. BELL    EQU    'G'-40H            ;^G = bell character
  179. BKSP    EQU    'H'-40H            ;^H = backspace
  180. LF    EQU    'J'-40H            ;^J = linefeed
  181. CR    EQU    'M'-40H            ;^M = carriage return
  182. XON    EQU    'Q'-40H            ;^Q = XON character
  183. XOFF    EQU    'S'-40H            ;^S = XOFF character
  184. NAK    EQU    'U'-40H            ;^U = not acknowledge
  185. CANCEL    EQU    'X'-40H            ;^X = cancel send or receive
  186. EOFCHAR EQU    'Z'-40H            ;^Z = end of file
  187. ;
  188. ;
  189.     ORG    0100H
  190. ;
  191. ;
  192.     JMP    START            ;skip the data area below
  193. ;
  194. ;
  195. ;
  196. ; THESE ROUTINES AND EQUATES ARE AT THE BEGINNING OF THE PROGRAM SO
  197. ; THEY CAN BE PATCHED BY A MONITOR OR OVERLAY FILE WITHOUT RE-ASSEMBLING
  198. ; THE PROGRAM.
  199. ;
  200. PMMIMODEM    DB    YES        ;yes=PMMI modem
  201. AUTODIAL    DB    NO        ;yes=Hayes-type autodial modem
  202. TOUCHPULSE    DB    'T'        ;T=touch, P=pulse (autodial-only)
  203. ;
  204. CLOCK        DB    40        ;clock speed in MHz x 10, 25.5 MHz max.
  205.                     ;2 MHz=20, 3.68 MH=37, 4 MHz=40, etc.
  206. MSPEED        DB    1        ;sets display time for sending a file
  207.                     ;0=110    1=300  2=450  3=600  4=710
  208.                     ;5=1200 6=2400 7=4800 8=9600 9=19200
  209. BYTDLY        DB    5        ;0=0 delay  1=10 ms  5=50 ms - 9=90 ms
  210.                     ;defaut time to send character in ter-
  211.                     ;minal mode file transfer for slow BBS
  212. CRDLY        DB    5        ;0=0 delay 1=100 ms 5=500 ms - 9=900 ms
  213.                     ;default time for extra wait after CRLF
  214.                     ;in terminal mode file transfer
  215. NOOFCOL        DB    5        ;number of directory columns
  216. SETUPTST    DB    NO        ;yes=non-PMMI setup routine
  217. SCRNTEST    DB    NO        ;yes=if home cursor and clear screen
  218.                     ;routine at CLRSCRN
  219. RETRY        DB    YES        ;yes=reset the error limit to try again
  220.                     ;no=abort after 10 consecutive errors
  221.                     ;(ARPANET users should select yes)
  222. BAKUPBYTE    DB    NO        ;yes=make .BAK file
  223. CRCDFLT        DB    YES        ;yes=default to CRC checking
  224.                     ;no=default to Checksum checking
  225. TOGGLECRC    DB    YES        ;yes=allow toggling of Checksum to CRC
  226. CONVRUB        DB    YES        ;yes=convert rub to backspace
  227. TOGGLERUB    DB    YES        ;yes=allow toggling of rub to backspace
  228. ADDLF        DB    NO        ;no=no LF after CR to send file in
  229.                     ;terminal mode (added by remote echo)
  230. TOGGLELF    DB    YES        ;yes=allow toggling of LF after CR
  231. TRANLOGON    DB    NO        ;yes=allow transmission of logon
  232.                     ;write logon sequence at location LOGON
  233. RESERVED    DB    NO        ;Reserved for Future releases
  234. LOCNXTCHR    DB    NO        ;yes=local cmd if EXTCHR precedes
  235.                     ;no=not local cmd if EXTCHR precedes
  236. TOGGLELOC    DB    YES        ;yes=allow toggling of LOCNXTCHR
  237. LSTTST        DB    YES        ;yes=allow toggling of printer on/off
  238.                     ;in terminal mode. Set to no if using
  239.                     ;the printer port for the modem
  240. XOFFTST        DB    NO        ;yes=allow testing of XOFF from remote
  241.                     ;while sending a file in terminal mode
  242. XONWAIT        DB    NO        ;yes=wait for XON after sending CR while
  243.                     ;transmitting a file in terminal mode    
  244. TOGXOFF        DB    YES        ;yes=allow toggling of XOFF testing
  245. IGNORCTL    DB    YES        ;yes=do not send control characters
  246.                     ;above CTL-M to CRT in terminal mode
  247.                     ;no=send any incoming CTL-char to CRT
  248. EXTRA1        DB    0        ;for future expansion
  249. EXTRA2        DB    0        ;for future expansion
  250. BRKCHR        DB    '@'-40H        ;^@ = Send a 300 ms. break tone
  251. NOCONNCT    DB    'N'-40H        ;^N = Disconnect from phone line
  252. LOGCHR        DB    'L'-40H        ;^L = Send logon
  253. LSTCHR        DB    'P'-40H        ;^P = Toggle printer
  254. UNSAVECHR    DB    'R'-40H        ;^R = Close input text buffer
  255. TRANCHR        DB    'T'-40H        ;^T = Transmit file to remote
  256. SAVECHR        DB    'Y'-40H        ;^Y = Open input text buffer
  257. EXTCHR        DB    '^'-40H        ;^^ = Send next character
  258. ;
  259. ;
  260. ; Equates used only by PMMI routines grouped together here.
  261. ;
  262. PULSERATE    DB    250        ;125=20pps dialing, 250=10pps
  263. CHGBAUD        DB    'B'-40H        ;^B = Used with PMMIMODEM in terminal
  264.                     ;mode to change baud rate on fly
  265. PMMIPORT    DB    MODCTL1        ; Pmmi Port location
  266. ;
  267. ; Handles in/out ports for data and status
  268. ;
  269. IN_MODCTL1:    IN   AL,MODCTL1 ! RET
  270.         DB    0,0,0,0,0,0,0        ;spares if needed for non-PMMI
  271. OUT_MODDATP:    OUT MODDATP,AL    ! RET        ;out modem data port
  272.         DB    0,0,0,0,0,0,0        ;spares if needed for non=PMMI
  273. IN_MODDATP:    IN   AL,MODDATP ! RET        ;in modem data port
  274.         DB    0,0,0,0,0,0,0        ;spares if needed for non-PMMI
  275. ANI_MODRCVB:    AND AL,MODRCVB    ! RET        ;bit to test for receive ready
  276. CPI_MODRCVR:    CMP AL,MODRCVR    ! RET        ;value of receive bit when ready
  277. ANI_MODSNDB:    AND AL,MODSNDB    ! RET        ;bit to test for send ready
  278. CPI_MODSNDR:    CMP AL,MODSNDR    ! RET        ;value of send bit when ready
  279. ;
  280. ;
  281. ;====================== SPECIAL PMMI PORTS =============================
  282. ;
  283. IN_BAUDRP:    IN    AL,BAUDRP ! RET        ;in baudrate port
  284. OUT_BAUDRP:    OUT    BAUDRP,AL ! RET        ;out baudrate port
  285. OUT_MODCTL1:    OUT    MODCTL1,AL! RET        ;out modem control port #1
  286. OUT_MODCTL2:    OUT    MODCTL2,AL! RET        ;out modem control port #2
  287. ;
  288. ;================== END OF SPECIAL PMMI PORTS ==========================
  289. ;
  290. ;
  291. LOGONPTR    DW    (Offset LOGON)
  292. JMP_DIAL:    JMP    DIAL
  293. JMP_DISCONNT:    JMP    DISCONNT
  294. JMP_GOODBYE:    JMP    GOODBYE
  295. JMP_INITMOD:    JMP    INITMOD
  296. JMP_NEWBAUD:    JMP    NEWBAUD
  297. JMP_NOPARITY:    JMP    NOPARITY
  298. JMP_PARITY:    JMP    PARITY
  299. JMP_SETUPR:    JMP    SETUPR
  300. JMP_SPCLMENU:    JMP    SPCLMENU
  301. JMP_SYSVER:    JMPS    SYSVER
  302. JMP_BREAK:    JMP    SENDBRK
  303. ;
  304. ;
  305. ; NEXT EIGHT LINES SHOULD NOT BE CHANGED BY USER OVERLAY AS THESE GO TO
  306. ; SPECIFIC LOCATIONS IN THE MAIN PROGRAM, NOT IN THE OVERLAY.
  307. ;
  308. JMP_ILPRT:    JMP    ILPRT
  309. JMP_INBUF:    JMP    INBUF
  310. JMP_INLNCOMP:    JMP    INLNCOMP
  311. JMP_INMODEM:    JMP    INMODEM
  312. JMP_NXTSCRN:    JMP    NXTSCRN
  313. JMP_TIMER:    JMP    TIMER
  314. JMP_CTYPE:    JMP    CTYPE
  315. JMP_KEYIN:    JMP    KEYIN
  316. ;
  317. ;
  318. ; Clear sequences are for Televideo, Lear Siegler, etc.     Change to match
  319. ; your terminal.  (Heath uses ESC 4AH for clear to end of screen, ESC 45H
  320. ; to clear screen.  Lear Siegler and others use ESC 79H for clear to end
  321. ; of screen and ESC 3AH to clear screen.)  Room allowed for four bytes.
  322. ; (Last zero needed for stopping the string display.  Any extra 0's just
  323. ; act as NOP's.)
  324. ;
  325. CLREOS:        CALL    ILPRT
  326.         DB    ESC,79H,0,0,0
  327.         RET
  328. ;.....
  329. ;
  330. ;
  331. CLRSCRN:    CALL    ILPRT
  332.         DB    ESC,3AH,0,0,0
  333.         RET
  334. ;.....
  335. ;
  336. ;
  337. ;======================= SIGN-ON MESSAGE ============================== 
  338. ;
  339. ; Send version number and date
  340. ;
  341. SYSVER: MOV    AL,Byte Ptr PMMIMODEM    ;using the PMMI S-100 modem?
  342.     OR    AL,AL
  343.     JZ    SYSVER1            ;go if not
  344.     CALL    ILPRT
  345.     DB    'Version for PMMI S-100 modem starting at port: ',0
  346.     MOV    AL,Byte Ptr PMMIPORT
  347.     CALL    HEXO            ; put in PMMI control port number
  348.     CALL    ILPRT
  349.     DB    'H',CR,LF,0
  350.     RET
  351. ;.....
  352. ;
  353. ;
  354. SYSVER1:CALL    ILPRT            ;if not using the PMMI S-100 board
  355.     DB    'Version for Non-PMMI modem',CR,LF,0
  356.     RET
  357. ;.....
  358. ;
  359. ;
  360. ;==================== LOGON MESSAGE (IF ANY) ===========================
  361. ;
  362. ; Insert your logon message here.  End with a 0 (for"CALL ILPRT").
  363. ; PMMIusers have 59 bytes available, non-PMMI users have approximately
  364. ; 2K bytes available as they can overwrite all the following PMMI rou-
  365. ; tines if they wish.  This method allows the external overlays to have
  366. ; plenty of room.  It keeps the phone number library at a fixed location.
  367. ;
  368. LOGON    RB    59            ;up to 59 characters allowed
  369.     DB    0            ;to terminate the logon message
  370. ;.....
  371. ;
  372. ;
  373. ;=============== NON-PMMI INITIALIZATION (IF ANY) ======================
  374. ;
  375. ; Insert your initialization routine here if needed.  Can replace the
  376. ; following special PMMI area to set speed and auto-dial.  Over 950
  377. ; bytes are available for this purpose.     (End your routine with a RET.)
  378. ;
  379. ;
  380. INITMOD:    RET
  381. ;
  382. ;========== NON-PMMI SETUP (SPEED CHANGE, ETC.) IF ANY ==============
  383. ;
  384. ; Insert your speed change and/or auto-dialing routines here.
  385. ; Over 950 bytes are available (INCLUDING INITMOD, above).
  386. ; End your routine with a RET.
  387. ;
  388. SETUPR:        RET
  389. ;
  390. ;
  391. ; Not needed if using the PMMI board, as it has its own break routine
  392. ;
  393. SENDBRK:    RET
  394. ;
  395. ;
  396. ;**************** START OF SPECIAL PMMI ROUTINES **********************
  397. ;
  398. ;
  399. ;=======================================================================
  400. ;
  401. ;            SETS THE BAUD RATE
  402. ;
  403. ;=======================================================================
  404. ;
  405. ;
  406. SETBAUD:MOV    AL,Byte Ptr ANSWFLG    ;if 'O' or 'A' not requested and
  407.     OR    AL,AL            ;   baudrate not specified, returns
  408.     JZ    FIXBAUD            ;   with current mode and rate
  409.     MOV    AL,Byte Ptr ORIGFLG    ;if option requested, a blank returns
  410.     OR    AL,AL            ;   with current mode and rate
  411.     JZ    FIXBAUD
  412.     RET                ;no change if neither 'O' or 'A' shown
  413. ;
  414. FIXBAUD:CALL    GETBAUD            ;calculate PMMI baud rate divisor
  415.     CALL    SETMSPD            ;set the file time transfer value
  416.     CALL    OUT_BAUDRP        ;set the PMMI board to that baudrate
  417.     CMP    AL,52
  418.     MOV    AL,5FH            ;DTR (filter for over 300 baud)
  419.     JB    GT300            ;yes, greater than
  420.     MOV    AL,7FH            ;DTR (filter for 300 and less baud)
  421. ;
  422. GT300:    CALL    OUT_MODCTL2
  423.     MOV    Byte Ptr MODCTLB,AL    ;save modem control byte
  424. ;
  425. OFFHOOK:MOV    BX,7500            ;throw in some delay
  426. ;
  427. OFFDLY: DEC    BL
  428.     JNZ    OFFDLY
  429.     DEC    BH
  430.     JNZ    OFFDLY
  431.     MOV    AL,Byte Ptr UARTCTLB   ;UART control byte for 'A' or 'O'
  432.     CALL    OUT_MODCTL1        ;now set to answer or originate
  433.     MOV    AL,CL
  434.     MOV    Byte Ptr MSPEED,AL    ;set the file transfer time value
  435.     XOR    AL,AL            ;clear the flags
  436.     RET
  437. ;.....
  438. ;
  439. ;
  440. ;=======================================================================
  441. ;         CALCULATES THE BAUD RATE DIVISOR
  442. ;
  443. ; Returns with current baud rate intact if a blank or null in the speed
  444. ; field (extent area).
  445. ;
  446. GETBAUD:MOV    AL,Byte Ptr FCB+9      ;get 1st digit of requested baudrate
  447.     CMP    AL,' '            ;if a space, return with current speed
  448.     MOV    AL,Byte Ptr CURRENT
  449.     JNZ    LA14
  450.     RET
  451. LA14:
  452.     MOV    AL,Byte Ptr FCB+9
  453.     OR    AL,AL            ;if a null, return with current speed
  454.     MOV    AL,Byte Ptr CURRENT
  455.     JNZ    LA15
  456.     RET
  457. LA15:
  458. ;
  459.     MOV    DX, FCB+9      ;get the requested speed
  460.     MOV    BX,0
  461. ;
  462. DECLP:    MOV    SI,DX            ;get the ASCII digit
  463.     MOV    AL,[SI]
  464.     INC    DX
  465.     CMP    AL,' '
  466.     JZ    DECLP
  467.     CMP    AL,'0'            ;numerals are 0-9
  468.     JB    BADRATE
  469.     CMP    AL,'9'+1
  470.     JNB    BADRATE
  471.     SUB    AL,'0'
  472.     MOV    CH,BH
  473.     MOV    CL,BL
  474.     SHL    BX,1
  475.     SHL    BX,1
  476.     ADD    BX,CX
  477.     SHL    BX,1
  478.     ADD    AL,BL
  479.     MOV    BL,AL
  480.     JNZ    DIGNC
  481.     INC    BH
  482. ;
  483. DIGNC:    MOV    AL,DL
  484.     CMP    AL,FCB+12
  485.     JNZ    DECLP
  486.     MOV    AL,BH
  487.     NOT    AL
  488.     MOV    DH,AL
  489.     MOV    AL,BL
  490.     NOT    AL
  491.     MOV    DL,AL
  492.     INC    DX
  493.     MOV    BX,15625        ;250000/16
  494.     MOV    CX,-1
  495. ;
  496. DIVLP:    INC    CX
  497.     ADD    BX,DX
  498.     JB    DIVLP
  499.     MOV    AL,CH
  500.     OR    AL,AL
  501.     MOV    AL,CL
  502.     MOV    Byte Ptr CURRENT,AL    ;can use this the next time by default
  503.     JNZ    BADRATE
  504.     RET
  505. ;
  506. BADRATE:CALL    ERXIT
  507.     DB    '++ INVALID BAUDRATE ++$'
  508. ;.....
  509. ;
  510. ;
  511. ;=======================================================================
  512. ;            SETS 'MSPEED' TO BAUD RATE
  513. ;
  514. ;
  515. SETMSPD:MOV    CL,0            ;changes PMMI mspeed for 110-710 baud
  516.     CMP    AL,100            ;<300 baud
  517.     JNAE    LA17
  518.     RET
  519. LA17:
  520.     INC    CL            ;c=1 for 300 baud
  521.     CMP    AL,40            ;<450 baud
  522.     JNAE    LA18
  523.     RET
  524. LA18:
  525.     INC    CL            ;c=2 for 450 baud
  526.     CMP    AL,30            ;<600 baud
  527.     JNAE    LA19
  528.     RET
  529. LA19:
  530.     INC    CL            ;c=3 for 600 baud
  531.     CMP    AL,24            ;<710 baud
  532.     JNAE    LA20
  533.     RET
  534. LA20:
  535.     INC    CL            ;c=4 for 710 baud
  536.     RET
  537. ;.....
  538. ;
  539. ;    
  540. ; Change baudrate on-the-fly with CTL-B (while in terminal mode)
  541. ;
  542. NEWBAUD:MOV    AL,Byte Ptr PMMIMODEM
  543.     OR    AL,AL
  544.     JNZ    LA21
  545.     RET
  546. LA21:
  547.     CALL    ILPRT
  548.     DB    CR,LF,'Enter new Baudrate: ',0
  549.     MOV    BX, FCB+9
  550.     MOV    Byte ptr [BX],' '    ;keep current baud if none included
  551. ;
  552. NEWBAUD1:
  553.     CALL    KEYIN            ;get the baud rate
  554.     CMP    AL,CR            ;carriage ret finishes baud rate entry
  555.     JNZ    LA22
  556.     CALL    CRLF            ;if a 'CR', baud rate has been entered
  557. LA22:
  558.     JNZ    LA23
  559.     JMP    FIXBAUD            ;go change the baud rate
  560. LA23:
  561. ;.....
  562. ;
  563. ;
  564. NEWBAUD2:
  565.     CMP    AL,'0'            ;numerals are 0-9
  566.     JB    NEWBAUD1
  567.     CMP    AL,'9'+1
  568.     JNB    NEWBAUD1        ;if not a numeral, ignore, ask again
  569.     MOV    Byte Ptr [BX],AL    ;store answer starting at FCB+9
  570.     CALL    STYPE             ;show the numeral on the CRT
  571.     INC    BX            ;next storage location in FCB
  572.     JMPS    NEWBAUD1        ;get the next numeral
  573. ;.....
  574. ;
  575. ;
  576. ;======================= PARITY ROUTINES ===============================
  577. ;
  578. ;--->PARITY: Routine to setup PMMI for odd/even parity.
  579. ;
  580. PARITY: MOV    AL,Byte Ptr PMMIMODEM    ;is modem a PMMI?
  581.     OR    AL,AL            ;set flags
  582.     JNZ    LA24
  583.     RET                ;no, return
  584. LA24:
  585.     MOV    AL,Byte Ptr OPARITY    ;get odd parity request byte
  586.     OR    AL,AL            ;set flags
  587.     JNZ    EVENPAR            ;if not odd see if it is even
  588.     MOV    AL,Byte Ptr UARTCTLB   ;get uart/modem control byte
  589.     AND    AL,ODPARMSK
  590.     JMPS    PARITY1
  591. ;...
  592. ;
  593. ;
  594. EVENPAR:MOV    AL,Byte Ptr EPARITY    ;get even parity request byte
  595.     OR    AL,AL            ;set flags
  596.     JZ    LA25
  597.     RET                ;if even parity not specified return
  598. LA25:
  599.     MOV    AL,Byte Ptr UARTCTLB   ;get uart/modem control byte
  600.     AND    AL,ODPARMSK        ;set for parity
  601.     OR    AL,EVPARMSK        ;now set for even parity
  602. ;
  603. PARITY1:MOV    Byte Ptr UARTCTLB,AL
  604.     JMP    OUT_MODCTL1        ;send to PMMI -
  605. ;                ;when OUT$MODCTL1 does return, it
  606. ;.....                ;will go back to calling routine
  607. ;
  608. ;
  609. NOPARITY:
  610.     MOV    AL,Byte Ptr PMMIMODEM
  611.     OR    AL,AL
  612.     JNZ    LA26
  613.     RET
  614. LA26:
  615.     MOV    AL,Byte Ptr UARTCTLB   ;get UART/modem control byte
  616.     OR    AL,NOPARMSK        ;reset parity bit on PMMI
  617.     JMP    OUT_MODCTL1
  618. ;.....
  619. ;
  620. ;
  621. ;==================== END OF PARITY ROUTINES ===========================
  622. ;
  623. ;
  624. ;=======================================================================
  625. ;
  626. ;           HAYES/PMMI DIALING ROUTINES
  627. ;
  628. ;=======================================================================
  629. ;
  630. ;
  631.     RB    640            ;FOR EXPANSION
  632. ;    
  633. ; Modem control command words
  634. ;
  635. BRKMASK EQU    0            ;tele line on hook (break while dialing)
  636. CLEAR    EQU    3FH            ;idle mode
  637. DTMSK    EQU    1            ;dial tone mask
  638. MAKEM    EQU    1            ;tele line make (off hook)
  639. RBLMT    EQU    35            ;7 seconds to wait til no-ring-heard msg
  640. RBWAIT    EQU    50            ;5 second delay before redialing PMMI
  641. SMRWAIT EQU    15            ;1.5 sec delay before redialing HAYES
  642. TMPUL    EQU    80H            ;timer pulses mask bit
  643. TRATE    EQU    250            ;value for 0.1 second
  644. ;.....
  645. ;
  646. ;
  647. ; Dialing routine
  648. ;
  649. DIAL:    MOV    AL,Byte Ptr PMMIMODEM    ;using a PMMI modem?
  650.     OR    AL,AL
  651.     JNZ    DIAL1
  652.     MOV    AL,Byte Ptr AUTODIAL
  653.     OR    AL,AL
  654.     JNZ    LA29
  655.     RET                ;return if neither modem
  656. LA29:
  657.     CALL    SMNOISEY        ;make sure autodial modem speaker is on
  658. ;
  659. DIAL1:    XOR    AL,AL
  660.     MOV    BYTE PTR AUTODIR,AL    ;zero the direct to terminal mode flag
  661.     MOV    BYTE PTR AUTOFL,AL    ;zero the auto-linking flag
  662.     MOV    Byte Ptr CRFLAG,AL     ;zero the continuous dial flag
  663.     MOV    BX,0
  664.     MOV    Word Ptr DIALCT,BX    ;zero the dial count
  665.     MOV    BX, Offset CMDBUF+1    ;point to the number of characters in..
  666.     MOV    AL, Byte Ptr [BX]    ;..the buffer, then get the number
  667.     CMP    AL,3+1            ;anything typed after 'CAL'?
  668.     JB    DIAL2            ;if not, go through library routine
  669. ;
  670. ;
  671. ; If there were only 3 characters, then "CAL<RET>" was typed -- the user
  672. ; obviously expecting to get a phone number (or letter) from the library
  673. ; file.     If 4 or more, a number (or letter) was typed in from the menu
  674. ; command line, so move the characters down 4 to compensate.  Needed for
  675. ; auto-redialing of menu command line entries.
  676. ;
  677.     MOV    CL,AL            ;put into the 'C' reg.
  678.     MOV    CH,0            ;will move original number down 4
  679.     SUB    AL,4            ;eliminate the 'CAL' portion
  680.     MOV    Byte Ptr [BX],AL    ;store new count at cmdbuf+1
  681.     INC    BX            ;CMDBUF+2 (first character of string)
  682.     XCHG    BX,DX            ;'DE' now has CMDBUF+2
  683.     MOV    BX, Offset CMDBUF+6    ;point to number (or letter) to dial
  684.     CALL    MOVER            ;move the group down 4 places
  685.     JMP    DIAL4            ;check if library number, then dial
  686. ;...
  687. ;
  688. ;
  689. ; Comes here if no phone number was manually entered after 'CAL' and if
  690. ; no phone library code was entered.  Displays the phone number library
  691. ; then asks for an entry.
  692. ;
  693. DIAL2:    MOV    CL,18            ;number of lines to move
  694.     MOV    BX, Offset NUMBLIB    ;start of phone number library
  695.     MOV    DX, Offset BUFFER    ;buffer add. to store them temporarily
  696.     CALL    NEWLINE            ;start with CR/LF
  697.     MOV    SI,DX            ;+LF
  698.     MOV    [SI],AL
  699.     INC    DX            ;and bump it
  700. ;
  701. DIAL3:    MOV    CH,LIBLEN        ;number of bytes to move
  702.     CALL    MOVE            ;move to buffer
  703.     CALL    SPACES            ;2 entries + 3 spaces = 71 characters
  704.     PUSH    BX            ;save source address
  705.     PUSH    DX            ;save destination address
  706.     MOV    DX,(17*LIBLEN)        ;get offset of 17 times entry length
  707.     ADD    BX,DX            ;add it to source address
  708.     POP    DX            ;restore destination address
  709.     MOV    CH,LIBLEN        ;get length of library entry
  710.     CALL    MOVE            ;move another entry
  711.     POP    BX            ;restore source address
  712.     CALL    NEWLINE
  713.     DEC    CL            ;one less line to print
  714.     JNZ    DIAL3            ;if not zero, print another
  715.     MOV    AL,'$'            ;BDOS print routine terminate character
  716.     MOV    SI,DX            ;store in buffer
  717.     MOV    [SI],AL
  718.     CALL    CLRTST
  719.     MOV    CL,PRINT
  720.     MOV    DX, Offset BUFFER    ;print the library on the CRT
  721.     INT    224
  722.     CALL    JMP_ILPRT        ;ask which one is wanted
  723.     DB    CR,LF,'Enter library code or phone number,',CR,LF
  724.     DB    'Hit RET to abort this function now or',CR,LF
  725.     DB    'CTL-X quits while dialing or ringing: ',0
  726.     MOV    DX, Offset CMDBUF
  727.     CALL    INBUF            ;get the answer from the keyboard
  728. ;
  729. ;
  730. ; You now have either a library code or a manually entered phone num-
  731. ; ber.    These either came from the menu command line or from the library
  732. ; command line.     Next we see if a code, if so, get the corresponding
  733. ; line with phone number from the library.  If a number greater than
  734. ; one digit, we ignore the library look-up.  (Ringback numbers must end
  735. ; with letter 'R'.)
  736. ;
  737. DIAL4:    MOV    BX,Offset CMDBUF+1    ;number of characters in buffer
  738.     MOV    AL,Byte ptr [BX]
  739.     OR    AL,AL            ;null means CR was typed
  740.     JNZ    LA30
  741.     JMP    DIALEXIT2        ;abort dialing, return to menu
  742. LA30:
  743.     MOV    Byte Ptr NUMBER,AL
  744.     MOV    BX,OFFSET CMDBUF+3
  745.     MOV    AL,BYTE PTR [BX]    ;see if at least two chars. entered
  746.     CMP    AL,'/'            ;slash for linking, direct to terminal.
  747.     JNZ    LA30A
  748.     CALL    AUTO            ;..mode on answer
  749. LA30A:    CMP    AL,','            ;comma used for linking
  750.     JNZ    DIAL5
  751.     CALL    AUTO1            ;if so, set it up for auto-linking
  752. ;
  753. ;
  754. ; Check to see how many characters were typed.    If more than one, then
  755. ; was a hand-entered phone number, so exit.
  756. ;
  757. DIAL5:    CALL    DIALBGN            ;disconnect, reconnect, wait for tone
  758.     MOV    AL,BYTE PTR AUTOFL    ;auto-link flag set?
  759.     OR    AL,AL
  760.     JZ    LA30B
  761.     JMP    AUTO2            ;if yes, exit
  762.  
  763. LA30B:    MOV    AL,BYTE PTR NUMBER    ;number of chars. in buffer
  764.     MOV    BX,OFFSET CMDBUF+1
  765.     MOV    BYTE PTR [BX],AL    ;reset the character count, if needed
  766.     CMP    AL,1            ;more than 1 character
  767.     JNA    LA32
  768.     JMP    DIAL14            ;if more than one, hand-entered number
  769. LA32:
  770.     MOV    BX, Offset CMDBUF+2    ;first character in phone number line
  771. ;
  772. ;
  773. ; If just one character entered, see if a (A-Z) letter
  774. ;
  775. DIAL6:    MOV    AL,Byte ptr [BX]
  776.     MOV    CH,'A'            ;first letter of alphabet
  777.     MOV    DL,0            ;counts number of letters to match
  778.     MOV    CL,26            ;number of letters in alphabet
  779. ;
  780. DIAL7:    CMP    AL,CH            ;letter from table?
  781.     JNZ    LA33
  782.     JMP    DIAL9            ;if yes, get phone number, else
  783. LA33:
  784.     INC    CH            ;make next letter (A-Z)
  785.     INC    DL            ;count up
  786.     DEC    CL            ;count down
  787.     JNZ    DIAL7            ;try next one in (A-Z) table
  788. ;
  789. ;
  790. ; If not (A-Z) then should be (0-9)
  791. ;
  792.     MOV    CH,'0'            ;first digit to check
  793.     MOV    DL,26            ;point past alpha codes
  794.     MOV    CL,10            ;number of digits in table
  795. ;
  796. DIAL8:    CMP    AL,CH            ;number from table?
  797.     JZ    DIAL9            ;if yes, go dial, else
  798.     INC    DL            ;make next table line number
  799.     INC    CH            ;make next digit to compare
  800.     DEC    CL            ;count down - loop counter
  801.     JNZ    DIAL8            ;loop
  802.     JMP    DIALBAD            ;error if not a number or a letter
  803. ;
  804. ;
  805. ; Now have a match between the requested code and one in the library.
  806. ; E-reg. holds the library line number (1-36) that matches the requested
  807. ; code (A-Z or 0-9).
  808. ;
  809. DIAL9:    MOV    BX,(Offset NUMBLIB)    ;phone number library
  810.     MOV    CX,LIBLEN        ;length of library entry
  811.     MOV    AL,DL            ;number of times to library length to BX
  812.     OR    AL,AL            ;set flags
  813.     JZ    DIAL11
  814. ;
  815. DIAL10: MOV    AL,Byte Ptr [BX]    ;get first char of selected lib entry
  816.     OR    AL,AL            ;set flags
  817.     JNZ    LA2
  818.     JMP    DIALBAD            ;send bad library msg and abort
  819. LA2:
  820.     ADD    BX,CX            ;increment 'BX' by library length
  821.     DEC    DL            ;countdown
  822.     JNZ    DIAL10            ;not there yet, loop
  823. ;
  824. ;
  825. ; Now have the line in the phone number library matching the requested
  826. ; letter so store that line starting at 'CMDBUF+1'
  827. ;
  828. DIAL11: MOV    CH,LIBLEN        ;number of characters to get from table
  829.     MOV    DX, Offset CMDBUF+1    ;point to buffer
  830.     XCHG    BX,DX            ;'BX' points to CMDBUF+1
  831.     MOV    Byte Ptr [BX],CH    ;length of each table entry
  832.     XCHG    BX,DX            ;restore the registers
  833.     INC    DX            ;point to first char position in buffer
  834.     CALL    MOVE            ;move the table entry to the buffer
  835. ;
  836. ;
  837. ; Now have the full line including phone number in 'CMDBUF' area.  Scan
  838. ; past the descriptive portion of library entry - terminate scan at the
  839. ; first '.'  This allows commas and numbers to be part of the text, such
  840. ; as:
  841. ;         'A=DataTech, Node 7..1-408-238-9621'
  842. ;
  843. DIAL12: MOV    AL,Byte Ptr AUTODIAL   ;using a Hayes-type modem?
  844.     OR    AL,AL
  845.     JZ    DIAL12A
  846.     CALL    SMINIT            ;if yes, initialize
  847. ;
  848. DIAL12A:
  849.     MOV    BX, Offset CMDBUF+1
  850.     MOV    DL,Byte Ptr [BX]    ;number of chars in buffer
  851.     INC    BX            ;point to 1st character in buffer
  852. ;
  853. DIAL13: MOV    AL,Byte ptr [BX]    ;get next character
  854.     CALL    STYPE            ;show it
  855.     INC    BX            ;bump pointer
  856.     DEC    DL            ;decrement count
  857.     JNZ    L2A4
  858.     JMP    DIALEXIT        ;exit if no '.' (bad lib entry)
  859. L2A4:
  860.     CMP    AL,'.'            ;dot?
  861.     JZ    DIAL15            ;yes, go dial the phone
  862.     JMPS    DIAL13            ;no, loop for next character
  863. ;.....
  864. ;
  865. ;
  866. ; There is a user entered phone number in 'CMDBUF' area
  867. ;
  868. DIAL14: MOV    AL,Byte Ptr AUTODIAL   ;using a Hayes-type modem?
  869.     OR    AL,AL
  870.     JZ    L2A5
  871.     CALL    SMINIT            ;if yes, initialize
  872. L2A5:
  873.     MOV    BX, Offset CMDBUF+1
  874.     MOV    DL,Byte Ptr [BX]    ;get number of chars in buffer
  875.     INC    BX            ;point to 1st character to dial
  876. ;.....
  877. ;
  878. ;
  879. ; Loop to dial the phone number pointed to by 'BX', character count in
  880. ; the 'DL' register.
  881. ;
  882. DIAL15: MOV    AL,Byte Ptr [BX]    ;get first number from the buffer
  883.     OR    AL,AL            ;set flags
  884.     JNZ    L2A6
  885.     JMP    DIALBAD            ;bad number if a null
  886. L2A6:
  887. ;
  888. ;
  889. ; Dial a digit, check keyboard for abort
  890. ;
  891.     CALL    DIALA            ;dial a digit, show on CRT
  892.     CALL    STAT            ;keypress?
  893.     JZ    DIAL17            ;if not, exit
  894.     CALL    KEYIN            ;yes, go get it
  895.     CMP    AL,CANCEL        ;CTL-X?
  896.     JNZ    DIAL17            ;if not, exit
  897.     MOV    AL,Byte Ptr AUTODIAL   ;using a Hayes-type modem?
  898.     OR    AL,AL
  899.     JNZ    L2A7
  900.     JMP    DIALEXIT        ;if not, exit now, otherwise clear line
  901. L2A7:
  902. ;
  903. ;
  904. ; If using an autodial modem, backspace 30 times to make sure the entire
  905. ; number plus "DT" part of "ATDT" is erased.
  906. ;
  907.     MOV    CL,30
  908. ;
  909. DIAL16: MOV    CH,BKSP
  910.     CALL    SENDCHR            ;send to the modem to cancel call
  911.     DEC    CL
  912.     JNZ    DIAL16            ;if not zero, do another
  913.     MOV    CH,CR
  914.     CALL    SENDCHR
  915.     MOV    AL,' '
  916.     CALL    STYPE             ;show on CRT
  917.     JMP    DIALEXIT        ;now go abort
  918. ;
  919. DIAL17: INC    BX            ;bump pointer
  920.     DEC    DL            ;one less character to go
  921.     JNZ    DIAL15            ;if not done, send the next digit
  922. ;
  923. ;
  924. ; Show the number of dial attempts
  925. ;
  926.     CALL    JMP_ILPRT
  927.     DB    ' - try #',0
  928.     MOV    BX,Word Ptr DIALCT     ;increment the dial count
  929.     INC    BX
  930.     MOV    Word Ptr DIALCT,BX
  931.     CALL    DECOUT            ;show number of attempts so far
  932.     MOV    AL,' '            ;extra space to position cursor
  933.     CALL    STYPE
  934.     MOV    AL,Byte Ptr AUTODIAL   ;using a Hayes-type modem?
  935.     OR    AL,AL
  936.     JZ    DIAL19            ;if not, exit
  937.     MOV    CH,CR            ;tells the modem the number is done
  938.     CALL    SENDCHR            ;just have one character to send
  939. ;
  940. DIAL18: CALL    JMP_INMODEM        ;catch any output from the modem
  941.     JNB    DIAL18
  942.     JMP    SMRESULT        ;number sent to modem, now get results
  943. ;
  944. ;
  945. ; Dialing is all done, this section is PMMI-only
  946. ;
  947. DIAL19: MOV    AL,07FH            ;turn on PMMI 'DTR'
  948.     CALL    OUT_MODCTL2        ;timer rate?
  949.     MOV    CH,1            ;0.1 second per interval
  950.     CALL    JMP_TIMER        ;wait for modem to turn on 'DTR'
  951.     MOV    AL,5DH            ;2 stop bits, no parity, 8 data bits
  952.     CALL    OUT_MODCTL1
  953.     MOV    DH,4            ;clear to send mask
  954.     MOV    CL,WAITCTS        ;wait time for CTS
  955.     CALL    WAIT            ;..(30 seconds, can set 'WAITCTS' for
  956.                     ;..up to 51 seconds for European use)
  957. ;
  958. ; If PMMI connection made, go get options for starting communications
  959. ;
  960.     JNAE    L2A8
  961.     JMP    CONMADE            ;connection made
  962. ;
  963. ;
  964. ; Connection not made, see if a redial is desired
  965. ;
  966. L2A8:
  967. ;    CALL    DISCONNT        ;hang-up so we can redial if desired
  968. ;
  969. DIALAGN:MOV    SP,OFFSET STACK        ;reset the stack to normal, just in case
  970.     MOV    AL,Byte Ptr CRFLAG     ;continuous redial flag
  971.     OR    AL,AL
  972.     JZ    L2A9
  973.     JMP    DIALAGN2        ;if already set, go dial again
  974. L2A9:
  975. L2A10:
  976.     CALL    JMP_ILPRT        ;see if we should keep trying
  977.     DB    CR,LF,CR,LF,'     Redial? (C/Y/N/Q): ',BELL,0
  978.     CALL    KBDCHR
  979.     PUSH    AX
  980.     CALL    CRLF            ;turn up a line
  981.     POP    AX
  982.     CMP    AL,'Y'            ;redial?
  983.     JZ    DIALAGN2        ;yes, redial
  984.     CMP    AL,'C'            ;continuous redial?
  985.     JZ    DIALAGN1        ;if yes, set continuous redial flag
  986.     CMP    AL,'Q'            ;kill the Hayes-type modem speaker?
  987.     JZ    L2A11
  988.     JMP    DIALEXIT1        ;none of these, quit
  989. L2A11:
  990.     CALL    SMQUIET            ;strangle speaker
  991. ;
  992. DIALAGN1:
  993.     MOV    AL,1
  994.     MOV    Byte Ptr CRFLAG,AL     ;continuous redial flag
  995. ;
  996. DIALAGN2:
  997.     MOV    AL,Byte Ptr AUTODIAL   ;using a Hayes-type modem?
  998.     OR    AL,AL
  999.     JNZ    DIALAGN3        ;if yes, exit
  1000.     MOV    CH,RBWAIT        ;wait for PMMI reset (or busy)
  1001.     CALL    JMP_TIMER        ;or busy tone may be sensed as dialtone
  1002.     JMPS    DIALAGN4
  1003. ;
  1004. DIALAGN3:
  1005.     MOV    CH,SMRWAIT
  1006.     CALL    JMP_TIMER
  1007. ;
  1008. DIALAGN4:
  1009.     CALL    CRLF            ;start a new line
  1010.     JMP    DIAL5            ;redial entry point
  1011.  
  1012.  
  1013. ;.....
  1014. ;
  1015. ;
  1016. ; Connection has been made
  1017. ;
  1018. CONMADE:
  1019.     MOV    AL,BYTE PTR PMMIMODEM
  1020.     OR    AL,AL
  1021.     JZ    CONMADE1    
  1022.     MOV    AL,Byte Ptr CURRENT    ;get current baud rate
  1023.     CALL    OUT_BAUDRP        ;set baudrate
  1024. ;
  1025. CONMADE1:
  1026.     MOV    CH,2
  1027.     CALL    JMP_TIMER
  1028.     CALL    JMP_ILPRT
  1029.     DB    BELL,CR,LF,CR,LF,'     CONNECTED',0
  1030.     MOV    AL,BYTE PTR AUTODIR    ;going direct to terminal mode?
  1031.     OR    AL,AL
  1032.     JZ    CONMADE1A
  1033.     JMP    RETURN
  1034. ;
  1035. CONMADE1A:
  1036.     MOV    AL,BYTE PTR CRFLAG    ;in continuous redial or first time try?
  1037.     OR    AL,AL
  1038.     JNZ    CONMADE1B
  1039.     JMP    RETURN            ;go to terminal mode if first time
  1040. ;
  1041. CONMADE1B:
  1042.     CALL    JMP_ILPRT
  1043.     DB    ' - any key for terminal mode ',0
  1044. ;
  1045. CONMADE2:
  1046.     MOV    DL,10
  1047. CONMADE3:
  1048.     CALL    STAT            ;keypress?
  1049.     JZ    CONMADE4        ;exit if no keys pressed
  1050.     CALL    KEYIN
  1051.     XOR    AL,AL
  1052.     JMP    RETURN            ;key pressed, go to terminal mode
  1053. ;
  1054. CONMADE4:
  1055.     MOV    CH,1            ;wait 0.1 second
  1056.     CALL    JMP_TIMER
  1057.     DEC    DL            ;one less loop to make
  1058.     JNZ    CONMADE3        ;see if a keyboard character yet
  1059.     MOV    AL,BELL            ;sound a bell
  1060.     CALL    STYPE
  1061.     JMPS    CONMADE2
  1062. ;.....
  1063. ;
  1064. ;
  1065. ; Automatic dialing routine, prints the number being dialed.  If we find
  1066. ; 'R', it either has to be the final character for ringback or toss it.
  1067. ;
  1068. DIALA:    CALL    STYPE             ;print whatever character, dashes, etc.
  1069.     CMP    AL,'R'            ;could it be a ringback character?
  1070.     JNZ    DIALA1            ;if not, probably a number so exit
  1071.     MOV    AL,DL            ;get the character count.  Is this "r"..
  1072.     CMP    AL,1            ;..the last character in the string?
  1073.     JNZ    L2A13
  1074.     JMP    RINGBK            ;yes, must be ringback char, do ringback
  1075. L2A13:
  1076.     RET                ;if not, ignore the 'r'
  1077. ;
  1078. DIALA1: MOV    CH,AL            ;store the character for now
  1079.     CALL    DIALAD            ;check for alternate dialing like 'MCI'
  1080.     MOV    AL,CH            ;get the original character back
  1081. DIALA2: CMP    AL,'*'            ;* is a valid dial digit
  1082.     JZ    DIALA3
  1083.     CMP    AL,'#'            ;# is a valid dial digit
  1084.     JZ    DIALA3
  1085.     CMP    AL,','            ;comma indicates a short delay-time
  1086.     JZ    DIALA3
  1087.     CMP    AL,'0'            ;digits are (0-9)
  1088.     JNB    L2A14
  1089.     RET                ;exit less than ASCII '0'
  1090. L2A14:
  1091.     CMP    AL,'9'+1
  1092.     JNAE    L2A15
  1093.     RET                ;exit if more than ASCII '9'
  1094. L2A15:
  1095.     SUB    AL,'0'            ;strip ASCII - could also do 'ANI 0FH'
  1096.     JNZ    DIALA3
  1097.     MOV    AL,10            ;convert zero to 10 pulses
  1098. ;
  1099. ;
  1100. ; Sends the digit to the modem.     Waits 100 ms. after each digit to in-
  1101. ; sure it gets to the modem ok.
  1102. ;
  1103. DIALA3: MOV    CL,AL
  1104.     MOV    AL,Byte Ptr PMMIMODEM    ;using a PMMI?
  1105.     OR    AL,AL
  1106.     JNZ    DIALA4            ;if yes, exit
  1107.     CALL    SENDCHR            ;character is already in the 'B' reg.
  1108.     MOV    CH,1            ;slight delay to let modem settle down
  1109.     JMP    JMP_TIMER
  1110. ;
  1111. DIALA4:
  1112.     MOV    AL,Byte Ptr PULSERATE
  1113.     CALL    OUT_BAUDRP
  1114. ;
  1115. DIALA5: CALL    IN_BAUDRP
  1116.     AND    AL,TMPUL
  1117.     JNZ    DIALA5
  1118. ;
  1119. DIALA6: CALL    IN_BAUDRP
  1120.     AND    AL,TMPUL
  1121.     JZ    DIALA6
  1122. ;
  1123. DIALA7: MOV    AL,MAKEM
  1124.     CALL    OUT_MODCTL1
  1125. ;
  1126. DIALA8: CALL    IN_BAUDRP
  1127.     AND    AL,TMPUL
  1128.     JNZ    DIALA8
  1129.     MOV    AL,BRKMASK
  1130.     CALL    OUT_MODCTL1
  1131. ;
  1132. DIALA9: CALL    IN_BAUDRP
  1133.     AND    AL,TMPUL
  1134.     JZ    DIALA9
  1135.     DEC    CL
  1136.     JNZ    DIALA7
  1137.     MOV    AL,MAKEM
  1138.     CALL    OUT_MODCTL1
  1139.     MOV    CH,2
  1140.     JMP    JMP_TIMER
  1141. ;.....
  1142. ;
  1143. ; Print bad library number message and abort if a null is encountered.
  1144. ;
  1145. DIALBAD:
  1146.     CALL    JMP_ILPRT
  1147.     DB    CR,LF,CR,LF,'++ Bad library number called ++',CR,LF,0
  1148. ;
  1149. DIALEXIT:
  1150.     CALL    CRLF            ;turn up a new line
  1151. ;
  1152. DIALEXIT1:
  1153.     MOV    SP,OFFSET STACK        ;make sure the stack is normal again
  1154.     CALL    JMP_GOODBYE        ;user routine to disable DTR, if any
  1155.     CALL    DISCONNT        ;hang up the phone and reset the modem
  1156. ;
  1157. DIALEXIT2:
  1158.     MOV    BYTE PTR CRFLAG,0    ;reset the continuous redial flag
  1159.     JMP    MENU
  1160. ;.....
  1161. ;
  1162. ;
  1163. ; Disconnect from the line, reconnect and wait for the dialtone.
  1164. ;
  1165. DIALBGN:MOV    AL,Byte Ptr AUTODIAL   ;Hayes-type modem?
  1166.     OR    AL,AL
  1167.     JZ    DIALBG1
  1168.     RET                ;if yes, finished
  1169. ;
  1170. DIALBG1:MOV    AL,MAKEM        ;go off-hook
  1171.     CALL    OUT_MODCTL1
  1172.     MOV    DH,DTMSK        ;dial tone mask
  1173.     MOV    CL,50            ;waits up to 10 sec. for dial tone
  1174.     CALL    WAIT            ;wait for dial tone
  1175. ;
  1176. ;
  1177. ; Wait subroutine will return with carry set if unable to get dialtone.
  1178. ; If carry is not set, the dialtone was received.
  1179. ;
  1180.     JNAE    L2A18
  1181.     RET                ;if dial tone within 10 seconds
  1182. L2A18:
  1183.     CALL    JMP_ILPRT        ;otherwise print error message
  1184.     DB    CR,LF,CR,LF,'++ NO DIAL TONE ++',BELL,0
  1185.     POP    BX            ;restore the stack to normal
  1186.     JMP    DIALEXIT        ;forget it.
  1187. ;.....
  1188. ;
  1189. ;
  1190. ; Do any alternate dialing such as 'MCI' or 'SPRINT'
  1191. ;
  1192. DIALAD: MOV    AL,Byte Ptr AUTODIAL   ;using a Hayes-type modem?
  1193.     OR    AL,AL
  1194.     JNZ    L2A19
  1195.     RET                ;if not, exit
  1196. L2A19:
  1197.     MOV    AL,Byte Ptr TOUCHPULSE ;using touch tone dialing?
  1198.     CMP    AL,'T'
  1199.     JZ    L2A20
  1200.     RET                ;if not, ignore
  1201. L2A20:
  1202.     MOV    AL,CH            ;get the character back
  1203.     CMP    AL,'<'            ;alternate dialing system #1 (MCI?)
  1204.     JNZ    DIALAD1            ;if not, exit
  1205.     PUSH    BX            ;save the current values
  1206.     MOV    BX,(Offset ALTDIAL1)    ;alternate dialing area
  1207.     JMPS    DIALAD2
  1208. ;
  1209. DIALAD1:CMP    AL,'>'            ;alternate dialing system #2 (Sprint?)
  1210.     JZ    L2A21
  1211.     RET                ;if neither, exit
  1212. L2A21:
  1213.     PUSH    BX            ;save the current values
  1214.     MOV    BX,(Offset ALTDIAL2)
  1215. ;
  1216. DIALAD2:MOV    AL,Byte Ptr [BX]
  1217.     CMP    AL,'$'            ;ready to terminate?
  1218.     JZ    DIALAD3            ;if yes, exit
  1219. ;
  1220. ;
  1221. ; Move the semicolons up one line if you do not want to see the SPRINT
  1222. ; number dialed.
  1223. ;
  1224.     CALL    STYPE            ;display the character
  1225.     MOV    CH,AL            ;need the char. in 'CH' to send to modem
  1226.     CALL    DIALA2            ;send proper characters to the modem
  1227.     INC    BX            ;next location
  1228.     CALL    STAT            ;keypress?
  1229.     JZ    DIALAD2            ;if not, do the next character
  1230.     CALL    KEYIN            ;yes, go get it
  1231.     CMP    AL,CANCEL        ;ctl-x?
  1232.     JNZ    DIALAD2            ;if not, handle the next character
  1233.     POP    BX            ;if yes, reset the stack
  1234.     JMP    DIALEXIT        ;if yes, exit
  1235. ;
  1236. DIALAD3:MOV    AL,' '
  1237.     MOV    CH,AL            ;clears 'CH' from last digit sent
  1238.     CALL    STYPE             ;separate from the main number     
  1239.     POP    BX            ;restore the stack
  1240.     RET
  1241. ;.....
  1242. ;
  1243. ;
  1244. ; Disconnect the autodial modem from the phone line.  Sends 'I, CR' to
  1245. ; the Racal-Vadic to return to idle mode.
  1246. ;
  1247. GOODBYE:
  1248. DISCONNT:
  1249.     MOV    AL,Byte Ptr AUTODIAL   ;using a Hayes-type autodial modem?
  1250.     OR    AL,AL
  1251.     JNZ    DISCONN1        ;if yes, skip PMMI section
  1252.     XOR    AL,AL
  1253.     CALL    OUT_MODCTL1        ;hang up
  1254.     CALL    OUT_MODCTL2        ;clear DAV, ESD, etc.
  1255.     PUSH    CX
  1256.     MOV    CH,10            ;1 second for PMMI to disconnect
  1257.     CALL    JMP_TIMER
  1258.     POP    CX
  1259.     RET    
  1260. ;...
  1261. ;    
  1262. ;
  1263. ; Disconnect the autodial modem from the phone line
  1264. ;
  1265. DISCONN1:
  1266.     MOV    CH,12            ;wait 1.2 seconds pause
  1267.     CALL    JMP_TIMER
  1268.     MOV    BX,(Offset SM_DISC)    ;get into command mode
  1269.     CALL    SENDOUT
  1270.     MOV    CH,12            ;another 1.2 seconds pause
  1271.     CALL    JMP_TIMER
  1272.     MOV    AL,' '            ;space character
  1273. ;
  1274. ; If printing +++ and ATH, ATD, etc. move the three semicolons up one
  1275. ; line to include a space on the crt to look better.
  1276. ;
  1277.     DB    90H,90H,90H
  1278. ;;;    CALL    STYPE            ;show on local crt only
  1279.     MOV    BX,(Offset SM_DISC1)    ;now disconnect the modem
  1280.     CALL    SENDOUT
  1281. ;
  1282. DISCONN2:
  1283.     CALL    JMP_INMODEM        ;wait 0.1 seconds after last char.
  1284.     JNB    DISCONN2
  1285.     RET
  1286. ;...
  1287. ;
  1288. ;
  1289. ; Hayes Stuff
  1290. ;
  1291. SMQUIET:
  1292.     MOV    AL,Byte Ptr SPKRFLG    ;speaker flag set to quiet?
  1293.     OR    AL,AL
  1294.     JZ    L2A23
  1295.     RET                ;if yes, forget it
  1296. L2A23:
  1297.     MOV    AL,YES
  1298.     MOV    BYTE PTR SPKRFLG,AL    ;flip the flag to quiet, now
  1299.     MOV    BX,(Offset SM_SPKOFF)
  1300.     CALL    SENDOUT
  1301.     MOV    CH,6
  1302.     JMP    JMP_TIMER        ;time for an 'ok' from modem and return
  1303. ;.....
  1304. ;
  1305. ;
  1306. SMNOISEY:
  1307.     MOV    AL,Byte Ptr SPKRFLG    ;speaker already turned on?
  1308.     OR    AL,AL
  1309.     JNZ    L2A24
  1310.     RET                ;if yes, forget it
  1311. L2A24:
  1312.     MOV    AL,NO            ;set for noisey, now
  1313.     MOV    BYTE PTR SPKRFLG,AL
  1314.     MOV    BX,(Offset SM_SPKON)
  1315.     CALL    SENDOUT
  1316.     MOV    CH,6
  1317.     JMP    JMP_TIMER
  1318. ;.....
  1319. ;
  1320. ;
  1321. ; Hayes-like autodial modem control codes
  1322. ;
  1323. SM_DIAL        DB    'ATDT $'    ;set for touch (or pulse) dialing
  1324. SM_DISC        DB    '+++$'        ;puts the modem in local command mode
  1325. SM_DISC1    DB    'ATH0',CR,'$'     ;disconnects the modem
  1326. SM_SPKOFF    DB    'ATM0',CR,'$'    ;turns the speaker off
  1327. SM_SPKON    DB    'ATM1',CR,'$'    ;turns the speaker on
  1328. SPKRFLG        DB    0        ;0 = speaker has not been silenced
  1329. ;.....
  1330. ;
  1331. ;
  1332. ; Set the autodial modem for pulse dialing
  1333. ;
  1334. SMINIT: MOV    AL,Byte Ptr TOUCHPULSE ;touch or pulse dialing for autodial?
  1335.     MOV    Byte Ptr SM_DIAL+3,AL    ;store
  1336.     MOV    BX,(Offset SM_DIAL)
  1337.     CALL    SENDOUT
  1338. ;
  1339. SMINIT1:CALL    JMP_INMODEM        ;wait for modem to finish, if needed
  1340.     JNB    SMINIT1
  1341.     RET
  1342. ;.....
  1343. ;
  1344. ;
  1345. ; Send the string pointed to by 'BX' to both the CRT and the modem.
  1346. ;
  1347. SENDOUT:CALL    SENDNOW            ;wait until modem is ready
  1348.     MOV    AL,Byte Ptr [BX]    ;get the character
  1349.     CMP    AL,'$'
  1350.     JNZ    L2A29
  1351.     RET                ;if yes, finished
  1352. L2A29:
  1353.     MOV    AL,Byte Ptr [BX]
  1354.     CALL    OUT_MODDATP        ;send to modem
  1355. ;
  1356. ;
  1357. ; If you want to print the +++ ATD, etc. from Hayes-type units, move the
  1358. ; three semicolons down one line.
  1359. ;
  1360. ;;;    CALL    STYPE             ;show on CRT
  1361.     DB    90H,90H,90H
  1362.     INC    BX
  1363.     JMPS    SENDOUT
  1364. ;.....    
  1365. ;
  1366. ;
  1367. ; Checks for answer from Hayes-type autodial modem
  1368. ;
  1369. SMRESULT:
  1370.     CALL    RCVREADY        ;see if any incoming character yet
  1371.     JZ    SMRESUL1        ;if yes, exit and look at it
  1372.     CALL    STAT            ;else see if want to abort ringing
  1373.     JZ    SMRESULT        ;if neither, wait for one of them
  1374.     CALL    KEYIN            ;get character from keyboard
  1375.     CMP    AL,CANCEL        ;CTL-X to terminate dialing?
  1376.     JNZ    SMRESULT        ;if not, keep going
  1377.     MOV    CH,CR
  1378.     CALL    SENDCHR            ;tells the modem to hang up right away
  1379.     JMP    DIALEXIT        ;abort dialing routine
  1380. ;
  1381. SMRESUL1:
  1382.     CALL    IN_MODDATP           ;get the character, then
  1383.     AND    AL,7FH            ;remove any parity
  1384.     MOV    CH,AL            ;store for 'GIVLF' area if needed
  1385.     CMP    AL,'B'            ;'BUSY' (for Anchor modems, etc.)
  1386.     JZ    BUSY            ;if busy, flush string and retry
  1387.     CMP    AL,'0'            ;'OK' single digit result code
  1388.     JZ    SMRESUL1        ;ok, loop for next response
  1389.     CMP    AL,'O'            ;'ok' verbose digit result code
  1390.     JZ    SMRESUL1        ;ok loop for next response
  1391.     CMP    AL,'1'            ;'CONNECT', single digit result code
  1392.     JNZ    L2A30
  1393.     JMP    ON_LINE            ;connected, reset redial flags
  1394. L2A30:
  1395.     CMP    AL,'C'            ;'CONNECT', verbose result code
  1396.     JNZ    L2A31
  1397.     JMP    ON_LINE            ;connected, reset redial flags
  1398. L2A31:
  1399.     CMP    AL,'3'            ;'NO CARRIER', single digit result code
  1400.     JZ    NO_CARRIER        ;no carrier, flush string and retry
  1401.     CMP    AL,'N'            ;'NO CARRIER', verbose result code
  1402.     JZ    NO_CARRIER        ;no carrier, flush string and retry
  1403.     CMP    AL,'4'            ;'ERROR', single digit result code
  1404.     JNZ    L2A32
  1405.     JMP    FAILED            ;error, go display
  1406. L2A32:
  1407.     CMP    AL,'E'            ;'ERROR', verbose result code
  1408.     JNZ    L2A33
  1409.     JMP    FAILED            ;error, go display
  1410. L2A33:
  1411.     CMP    AL,'5'            ;'CONNECT 1200' single digit result code
  1412.     JNZ    SMDM1
  1413.     JMP    ON_1200            ;connected, reset redial flags
  1414. ;
  1415. SMDM1:    CMP    AL,LF            ;<LF> is end-of-line for verbose mode
  1416.     JZ    SMRESULT        ;yes, go get the next response
  1417.     CMP    AL,CR            ;<CR> may precede digit in digit mode
  1418.     JZ    SMRESULT        ;yes, go get the next response
  1419. ;
  1420.     CALL    STAT            ;else, see if want to abort ringing
  1421.     JZ    SMDM1A            ;if not, get next character
  1422.     CALL    KEYIN            ;else, get character from keyboard
  1423.     CMP    AL,CANCEL        ;CTL-X to terminate dialing?
  1424.     JNZ    SMDM1A            ;if not, keep going
  1425.     MOV    CH,CR
  1426.     CALL    SENDCHR            ;tells the modem to hang up right away
  1427.     JMP    DIALEXIT        ;abort dialing routine
  1428. ;
  1429. SMDM1A: CALL    JMP_INMODEM        ;get next character
  1430.     JMPS    SMDM1            ;loop until end of response encountered
  1431. ;
  1432. ;
  1433. ; The Anchor modem gives a busy result code, although still waits the
  1434. ; normal time-out period to do it.
  1435. ;
  1436. BUSY:    CALL    JMP_ILPRT
  1437.     DB    'busy! ',0
  1438.     JMP    DIALAGN
  1439. ;.....
  1440. ;
  1441. ;
  1442. ; Failed call is usually caused by continuous ringing with no answer.
  1443. ; The modem times out (can be set to either 30 seconds or 60 seconds.
  1444. ;
  1445. FAILED: CALL    JMP_ILPRT
  1446.     DB    'abort ',0
  1447.     JMP    DIALAGN
  1448. ;.....
  1449. ;
  1450. ;
  1451. NO_CARRIER:
  1452.     CALL    JMP_ILPRT
  1453.     DB    'no carrier ',0
  1454.     JMP    DIALAGN
  1455. ;.....
  1456. ;
  1457. ;
  1458. ON_LINE:
  1459.     CALL    JMP_ILPRT
  1460.     DB    'on line',0
  1461.     JMP    CONMADE
  1462. ;.....
  1463. ;
  1464. ;
  1465. ON_1200:
  1466.     CALL    JMP_ILPRT
  1467.     DB    'on at 1200',0
  1468.     JMP    CONMADE
  1469. ;.....
  1470. ;
  1471. ;        END OF SPECIAL HAYES-LIKE HANDLING
  1472. ;------------------------------------------------------------------------
  1473. ;
  1474. ; Handles the special ringback numbers.     Dials, lets it ring only once,
  1475. ; hangs up and then redials.
  1476. ;
  1477. RINGBK: MOV    AL,Byte Ptr AUTODIAL   ;using a Hayes-type modem?
  1478.     OR    AL,AL
  1479.     JNZ    RINGBK2            ;if yes, ringback not possible
  1480.     MOV    AL,Byte Ptr CMDBUF+1   ;get the number of chars. in the buffer
  1481.     DEC    AL            ;subtract 1 to avoid the ringback char
  1482.     MOV    Byte Ptr CMDBUF+1,AL   ;store the new value
  1483.     MOV    DH,DTMSK        ;load tone detect mask
  1484.     MOV    CL,RBLMT        ;waits up to 7 seconds for a ring
  1485.     CALL    WAIT
  1486.     JB    RINGBK0            ;if no ring detected, pretend we got one
  1487.     JMP    RINGBK1            ;hangup, redial, & listen for carrier
  1488. ;
  1489. RINGBK0:
  1490.     MOV    CH,25            ;got a ring, wait 2.5 sec
  1491.     CALL    TIMER
  1492.     CALL    IN_BAUDRP        ;is tone still present?
  1493.     AND    AL,DH
  1494.     JNZ    RINGBK1
  1495.     JMP    DIALAGN            ;yes, must be busy, do a normal redial
  1496. ;.....
  1497. ;
  1498. ;
  1499. ; Hang up, redial and listen for dial tone
  1500. ;
  1501. RINGBK1:CALL    HANGUP            ;hang up the phone
  1502.     CALL    JMP_ILPRT
  1503.     DB    'ringback set, first ring ',0
  1504.     MOV    CH,RBWAIT        ;wait 5 seconds before redialing..
  1505.     CALL    JMP_TIMER        ;..for line to clear, etc.
  1506.     CALL    DIALBGN            ;disconnect, reconnect, wait for tone
  1507.     JNB    L2A38
  1508.     JMP    DIALEXIT        ;go redial number
  1509. L2A38:
  1510.     MOV    AL,BYTE PTR NUMBER    ;number of characters in buffer
  1511.     CMP    AL,1+1            ;more than one character?
  1512.     JNB    L2A38A
  1513.     JMP    DIAL12            ;go redial for the table ringback number
  1514. ;
  1515. L2A38A: JMP    DIAL14            ;if more than one, hand-entered number
  1516. ;.....
  1517. ;
  1518. ;
  1519. RINGBK2:CALL    JMP_ILPRT
  1520.     DB    CR,LF,'++ No ringback for autodial modem ++',0
  1521.     POP    BX            ;reset the stack
  1522.     JMP    DIALEXIT
  1523. ;.....
  1524. ;
  1525. ;
  1526. HANGUP: MOV    AL,CLEAR
  1527.     CALL    OUT_MODCTL2
  1528.     XOR    AL,AL
  1529.     JMP    OUT_MODCTL1        ;turn off DTR, originate/answer tones
  1530. ;.....
  1531. ;
  1532. ;
  1533. ; This is the auto-linking area.  Up to 32 numbers may be linked, each
  1534. ; should have a comma for a separator, such as:
  1535. ;
  1536. ;    B>>COMMAND: CAL A,F,3,A,G,A,H
  1537. ;
  1538. AUTO:    MOV    BYTE PTR AUTODIR,AL    ;direct to terminal mode on answer
  1539. ;
  1540. AUTO1:    MOV    BYTE PTR AUTOFL,0FFH    ;set the auto-linking flag
  1541.     MOV    BYTE PTR CRFLAG,0FFH    ;set the continuous redial flag
  1542.     MOV    CH,64            ;maximum number of characters to move
  1543.     MOV    BX,OFFSET CMDBUF+1    ;start with number in the string
  1544.     MOV    DX,OFFSET CMDBUF+65    ;move to aft part of buffer
  1545.     JMP    MOVE    
  1546. ;.....
  1547. ;
  1548. ;
  1549. ; Linking routine
  1550. ;
  1551. AUTO2:    MOV    AL,BYTE PTR AUTOFL    ;increment the flag for each new try
  1552.     INC    AL
  1553.     INC    AL
  1554.     MOV    BYTE PTR AUTOFL,AL
  1555.     MOV    CL,AL            ;hold momentarily
  1556.     MOV    CH,0
  1557.     MOV    AL,BYTE PTR CMDBUF+65    ;see how many characters typed
  1558.     CMP    AL,CL
  1559.     JNB    AUTO3
  1560.     MOV    AL,1            ;reset the flag to start over
  1561.     MOV    CL,AL
  1562.     MOV    BYTE PTR AUTOFL,AL
  1563. ;
  1564. AUTO3:    MOV    BX,OFFSET CMDBUF+65
  1565.     ADD    BX,CX
  1566.     JMP    DIAL6            ;go to work
  1567. ;.....
  1568. ;
  1569. ;
  1570. AUTODIR DB    0            ;direct to terminal mode on answer
  1571. AUTOFL    DB    0            ;auto-linking flag
  1572. NUMBER    DB    0            ;number of characters in CMDBUF
  1573.  
  1574. ;.....
  1575. ;
  1576. ;
  1577. ; Time-out routine.  Must be called with mask in 'D' reg. for input at
  1578. ; relative port 2 and number of seconds (times 10) in 'C' reg.
  1579. ;
  1580. WAIT:    MOV    CH,2
  1581.     CALL    TIMER            ;wait for timer to go high then low
  1582.     CALL    IN_BAUDRP        ;PMMIADDR+2 (modem status port)
  1583.     AND    AL,DH            ;(CTS or dialtone mask)
  1584.     JNZ    L2A39
  1585.     RET                ;active low, so return on 0
  1586. L2A39:
  1587.     PUSH    CX            ;save..
  1588.     PUSH    DX            ;..active registers
  1589.     CALL    STAT            ;keypress?
  1590.     JZ    WAIT1            ;if not, exit
  1591.     CALL    KEYIN            ;yes, get char
  1592.     CMP    AL,CANCEL        ;CTL-X to intentionally abort?
  1593.     JZ    WAIT2            ;yes, disconnect, jmp to menu
  1594. ;
  1595. WAIT1:    POP    DX            ;restore..
  1596.     POP    CX            ;..registers
  1597.     DEC    CL            ;count-down
  1598.     JNZ    WAIT
  1599.     STC                ;set carry to indicate mask not set
  1600.     RET
  1601. ;.....
  1602. ;
  1603. ;
  1604. WAIT2:    POP    DX            ;reset..
  1605.     POP    CX            ;..stack
  1606.     JMP    DONETCD            ;disconnect
  1607. ;.....
  1608. ;
  1609. ;           (END OF HAYES/PMMI DIALING ROUTINE)
  1610. ;=======================================================================
  1611. ;            SPECIAL PMMI MENU
  1612. ;
  1613. SPCLMENU:
  1614.     MOV    AL,Byte Ptr PMMIMODEM
  1615.     OR    AL,AL
  1616.     JNZ    L2A40
  1617.     RET
  1618. L2A40:
  1619.     CALL    JMP_NXTSCRN
  1620.     CALL    ILPRT
  1621.     DB    '        Additional Subcommands for PMMI Modems'
  1622.     DB    CR,LF,LF
  1623.     DB    '  Modem control:',CR,LF
  1624.     DB    '    A - Answer tone for send or receive',CR,LF
  1625.     DB    '    O - Originate tone for send or receive',CR,LF,LF
  1626.     DB    '  Parity option:',CR,LF
  1627.     DB    '    1 - Set and check for odd parity',CR,LF
  1628.     DB    '    0 - Set and check for even parity',CR,LF
  1629.     DB    '           Both ends must be capable of these options'
  1630.     DB    CR,LF
  1631.     DB    '           which are available only in R and S modes.'
  1632.     DB    CR,LF
  1633.     DB    '           The parity checking will be part of the'
  1634.     DB    CR,LF
  1635.     DB    '           file transfer protocol.',CR,LF,LF
  1636.     DB    '  Speed Options:',CR,LF
  1637.     DB    '        After entering your primary and secondary '
  1638.     DB    'options,',CR,LF
  1639.     DB    '        you can set the modem speed by placing a '
  1640.     DB    ' "." after',CR,LF
  1641.     DB    '        the options followed by the speed e.g., '
  1642.     DB    '300, 600.',CR,LF,LF
  1643.     DB    '        EXAMPLE:  SBO.600 will set the modem for '
  1644.     DB    '600 baud',CR,LF,0
  1645.         RET            ;all done
  1646. ;.....
  1647. ;            (END OF PMMI MENU)
  1648. ;=======================================================================
  1649. ;
  1650. ;
  1651. ; Timer routine.  Waits 0.1 seconds for each unit in 'B' reg.
  1652. ;
  1653. TIMER:    PUSH    BX
  1654. ;
  1655. TIMER1: PUSH    CX
  1656. ;
  1657. TIMER2: CALL    JMP_INMODEM        ;100 ms. delay per loop
  1658.     JNB    TIMER2
  1659.     POP    CX
  1660.     DEC    CH
  1661.     JNZ    TIMER1
  1662.     POP    BX
  1663.     RET
  1664. ;.....
  1665. ;
  1666. ;
  1667. ;
  1668. ;************** END OF SPECIAL HAYES/PMMI ROUTINES *********************
  1669. ;
  1670. ;
  1671. ;=======================================================================
  1672. ;
  1673.     ORG    ((offset $+255+50)/256*256)-50 ;even page for 'NUMLIB'
  1674. ;
  1675. ;
  1676. ;
  1677. CRITE:    CALL    JMP_ILPRT
  1678.     DB    'for Menu)',CR,LF,'Copyright (c) '
  1679.     DB    '1984 - Irvin M. Hoff',CR,LF
  1680.     DB    'Translation to CPM-86 - Alex K. Soya',CR,LF,0
  1681.     RET
  1682. ;.....
  1683. ;
  1684. ;            END OF SPECIAL PATCH AREA
  1685. ;=======================================================================
  1686. ;
  1687. ; Long distance alternate dialing such as MCI, SPRINT, etc.  Must end
  1688. ; with a '$', use as many commas (2 seconds delay, each) as needed to
  1689. ; let the alternate dialing code return with a new dial tone.  Fill in
  1690. ; any character (periods are fine) after the $ to keep number of columns
  1691. ; to 24, i.e.,    '1234567,,,,12345,,$.....'   --      the first group is the
  1692. ; MCI or SPRINT access number, the second group is the user number.  A
  1693. ; small delay is usually required after the billing number also.
  1694. ;
  1695. ALTDIAL1 DB    'xxxxxxx,,,,,,xxxxxxxx,,$'    ;accessed by a < character
  1696. ;
  1697. ALTDIAL2 DB    'xxxxxxx,,,,,,xxxxxxxx,,$'    ;accessed by a > character
  1698. ;
  1699. ;=======================================================================
  1700. ;
  1701. HEXSHOW DB    SHOWHEX            ;can easily change SHOWHEX via DDT
  1702. ;
  1703. SAVSIZ    DB    XFRSIZ*8        ;can easily change buffer size for file
  1704.                     ;transfers with DDT for "NUMBLIB-1" ad-
  1705.                     ;dress.     Normally 4k (32 records or 4k).
  1706. ;
  1707. ;=======================================================================
  1708. ;
  1709. ; Phone number library table for auto-dialing.    Each number must be as
  1710. ; long as"LIBLEN" (EQU at start of program).  Some areas require extra
  1711. ; characters such as:    1-313-846-7127.     Room is left for those.  Use
  1712. ; a (<) for alternate dialing system #1, and a (>) for alternate dialing
  1713. ; System #2.  Either would preceed the actual number, for example:
  1714. ;
  1715. ;    DB    'A=Alan Alda..........<123-456-7890'    ;'A'
  1716. ;
  1717. ; -    -     -        -      -    -     -        -      -    -     -        -
  1718. ;
  1719. ; NOTE: At least one dot (.) MUST precede the actual phone number
  1720. ;
  1721. ;        '----5---10---15---20---25---30--34'
  1722. NUMBLIB DB    'A=Bob Robesky.......1-209-227-2083'    ;'A'
  1723.     DB    'B=Byron McKay.......1-415-965-4097'    ;'B'
  1724.     DB    'C=Bruce Jorgens.....1-509-255-6324'    ;'C'
  1725.     DB    'D=Phil Cary.........1-505-522-8856'    ;'D'
  1726.     DB    'E=Bill Earnest......1-215-398-3937'    ;'E'
  1727.     DB    'F=Chuck Forsberg....1-503-621-3193'    ;'F'
  1728.     DB    'G=Ron Fowler........1-414-563-9932'    ;'G'
  1729.     DB    'H=Charlie Hoffman...1-813-831-7276'    ;'H'
  1730.     DB    'I=Jack Kinn.........1-817-547-8890'    ;'I'
  1731.     DB    'J=Walt Jung.........1-301-661-2175'    ;'J'
  1732.     DB    'K=Sigi Kluger.......1-915-598-1668'    ;'K'
  1733.     DB    'L=Keith Petersen....1-313-759-6569'    ;'L'
  1734.     DB    'M=Wayne Masters.....1-408-378-7474'    ;'M'
  1735.     DB    'N=Dick Mead.........1-213-799-1632'    ;'N'
  1736.     DB    'O=Al Mehr...........1-408-238-9621'    ;'O'
  1737.     DB    'P=Pasadena RBBS.....1-213-577-9947'    ;'P'
  1738.     DB    'Q=Mark Pulver.......1-312-789-0499'    ;'Q'
  1739.     DB    'R=Bruce Ratoff......1-201-272-1874'    ;'R'
  1740.     DB    'S=Ken Stritzel......1-201-584-9227'    ;'S'
  1741.     DB    'T=TCBBS, Dearborn...1-313-846-6127'    ;'T'
  1742.     DB    'U=AnaHUG RCPM.......1-714-774-7860'    ;'U'
  1743.     DB    'V=Dave Austin.......1-707-257-6502'    ;'V'
  1744.     DB    'W=Paul Bagdonovitch.1-201-747-7301'    ;'W'
  1745.     DB    'X=Kirk De Haan......1-408-296-5078'    ;'X'
  1746.     DB    'Y=Byron Kantor......1-619-273-4354'    ;'Y'
  1747.     DB    'Z=Chuck Metz........1-408-354-5934'    ;'Z'
  1748.     DB    '0=Bill Parrott......1-913-682-3328'    ;'0'
  1749.     DB    '1=Larry Snyder......1-305-671-2330'    ;'1'
  1750.     DB    '2=Alex Soya.........1-305-259-7955'    ;'2'
  1751.     DB    '3=Tony Stanley......1-912-929-8728'    ;'3'
  1752.     DB    '4=Ed Svoboda........1-408-732-9190'    ;'4'
  1753.     DB    '5=Tampa Bay Bandit..1-813-937-3608'    ;'5'
  1754.     DB    '6=Thousand Oaks.....1-805-492-5472'    ;'6'
  1755.     DB    '7=Bill Wood.........1-619-256-3914'    ;'7'
  1756.     DB    '8=Spare.............1-xxx-xxx-xxxx'    ;'8'
  1757.     DB    '9=Spare.............1-xxx-xxx-xxxx'    ;'9'
  1758.     DB    0                    ;end
  1759. ;        '----5---10---15---20---25---30--34'
  1760. ;
  1761. ;-----------------------------------------------------------------------
  1762. ;
  1763. ; This is the storage area for the ten function keys.  The M7FNK.COM
  1764. ; program dynamically allocates the storage for the keys.  Thus, no
  1765. ; function key is limited to so-and-so many characters.     Rather, the
  1766. ; total number of bytes in the function key library (including flags)
  1767. ; is 256.
  1768. ;
  1769. INTCPT    DB    '^'            ;intercept character (prefix)
  1770. ;
  1771. FNCTBL    DB    0,'DIR ',CR,0
  1772.     DB    1,'DIR *.* $U0AD ',CR,0
  1773.     DB    2,'XMODEM S ',0
  1774.     DB    3,'XMODEM R ',0
  1775.     DB    4,'BYE ',CR,0
  1776.     DB    5,'RBBS ',CR,0
  1777.     DB    6,'(vacant)',0
  1778.     DB    7,'(vacant)',0
  1779.     DB    8,'(vacant)',0
  1780.     DB    9,'Nice chatting, see you again soon... ',CR,0
  1781.     RS    256-((Offset $)-(Offset FNCTBL))
  1782. ;
  1783. ;
  1784. ;
  1785. ;***********************************************************************
  1786. ;
  1787. ;
  1788. ; P - R - O - G - R - A - M    S - T - A - R - T - S      H - E - R - E
  1789. ;
  1790. ;
  1791. ;***********************************************************************
  1792. ;
  1793. ;
  1794. START:    MOV    AX,CS            ; stack resides in the Code Segment
  1795.     MOV    SS,AX
  1796.     MOV    SP, Offset STACK    ;start local stack
  1797. ;
  1798. ;
  1799. ; The 'FIXCNT' calculations are done here and the values stored so the
  1800. ; overhead of doing the calculation is not incurred in the RECV routine
  1801. ; where it is desired to pick up a character from the modem data port as
  1802. ; quickly as possible.
  1803. ;
  1804.     MOV    BX,590            ;adjust to get 1 second time intervals
  1805.     CALL    FIXCNT
  1806.     MOV    Word Ptr TIMVAL,BX
  1807.     MOV    BX,36            ;should be 1/16 of above value
  1808.     CALL    FIXCNT
  1809.     MOV    Word Ptr QUIKTIM,BX
  1810. ;
  1811. ;
  1812. ; Now display the program name and version number and we are under way
  1813. ;
  1814.     CALL    ILPRT
  1815.     DB    CR,LF,'MDM',VERSION/100+'0',VERSION MOD 100/10+'0'
  1816.     DB    VERSION MOD 10+'0',' modem pgm (type M ',0
  1817.     CALL    CRITE
  1818.     CALL    JMP_SYSVER        ;give configuration message
  1819.     CALL    CRCGEN            ;generate tables for fast 'CRC' check
  1820.     CALL    INITADR            ;initialize addresses
  1821.     CALL    INTERCEPT        ;establish the function key intercept
  1822.     CALL    PROCOPT            ;process any options
  1823.     MOV    AL,Byte Ptr OPTION     ;any options on the command line?
  1824.     CMP    AL,' '+1
  1825.     JNB    RESTART
  1826.     JMP    MENU            ;if not, show the menu
  1827. ;
  1828. ;
  1829. ; Comes here from menu once the options have been set
  1830. ;
  1831. RESTART:MOV    SP, Offset STACK    ;make sure we have a clean stack
  1832.     CALL    CKCHAR            ;catch any garbage characters left over
  1833.     MOV    AL,Byte Ptr PMMIMODEM
  1834.     OR    AL,AL
  1835.     JNZ    RESTART1        ;if yes, accept 'C' or 'D'
  1836.     MOV    AL,Byte Ptr AUTODIAL   ;using a Hayes-type modem?
  1837.     OR    AL,AL
  1838.     JZ    RESTART2        ;exit if neither modem-type
  1839. ;
  1840. RESTART1:
  1841.     MOV    AL,Byte Ptr OPTION     ;get the option
  1842.     CMP    AL,'C'            ;call (dial) function?
  1843.     JNZ    L3A2
  1844.     JMP    JMP_DIAL        ;yes, go to it
  1845. L3A2:
  1846.     MOV    AL,Byte Ptr PMMIMODEM
  1847.     OR    AL,AL
  1848.     JZ    RESTART2
  1849.     CALL    SETBAUD            ;just the PMMI has to check each time
  1850. ;
  1851. RESTART2:
  1852.     CALL    MOVEFCB
  1853.     MOV    AL,Byte Ptr OPTION     ;get main option
  1854.     CMP    AL,'D'            ;disconnect?
  1855.     JNZ    L3A4
  1856.     JMP    DONETCD            ;yes, disconnect then back to the menu
  1857. L3A4:
  1858.     CMP    AL,'M'            ;menu asked for?
  1859.     JNZ    L3A5
  1860.     JMP    MENU2            ;go display the menu
  1861. L3A5:
  1862.     CMP    AL,'R'            ;want to receive a file?
  1863.     JNZ    L3A6
  1864.     JMP    RCVFIL            ;exit if yes
  1865. L3A6:
  1866.     CMP    AL,'S'            ;want to send a file?
  1867.     JNZ    L3A7
  1868.     JMP    SENDFIL            ;exit if yes
  1869. L3A7:
  1870.     CMP    AL,'T'            ;want terminal mode?
  1871.     JNZ    RESTART3        ;if not, exit
  1872.     XOR    AL,AL
  1873.     MOV    Byte Ptr ECHOFLG,AL    ;reset echo flag
  1874.     MOV    Byte Ptr LOCFLG,AL     ;reset local flag
  1875.     JMP    DSKSAVE            ;exit if yes
  1876. ;
  1877. RESTART3:
  1878.     CMP    AL,'E'            ;want echo mode?
  1879.     JNZ    NOECHO            ;if not, exit
  1880.     MOV    Byte Ptr ECHOFLG,AL    ;set the echo flag
  1881.     XOR    AL,AL
  1882.     MOV    Byte Ptr LOCFLG,AL     ;reset local flag
  1883.     JMP    DSKSAVE
  1884. ;
  1885. NOECHO: CMP    AL,'L'            ;want local echo mode?
  1886.     JNZ    NOLOCAL            ;if not, exit
  1887.     MOV    Byte Ptr LOCFLG,AL     ;set the local flag
  1888.     XOR    AL,AL
  1889.     MOV    Byte Ptr ECHOFLG,AL    ;reset echo flag
  1890.     JMP    DSKSAVE
  1891. ;    
  1892. NOLOCAL:CALL    NTVLDMSG        ;say not a valid option
  1893.     JMP    MENU            ;then go back to the command mode
  1894. ;....
  1895. ;
  1896. ;
  1897. INITADR:CALL    GETUSER            ;get current user number
  1898.     MOV    Byte Ptr OLDUSER,AL    ;save to restore upon exit
  1899.     CALL    GETMAX            ;find maximum ram for printer use
  1900.     JMP    JMP_INITMOD        ;initialize non-PMMI systems if needed
  1901. ;.....
  1902. ;
  1903. ;
  1904. ; Get the function key intercept character and put in appropriate places
  1905. ;
  1906. INTERCEPT:
  1907.     MOV    AL,Byte Ptr INTCPT    ;get the function key intercept char.
  1908.     AND    AL,07FH            ;strip off any parity
  1909.     MOV    Byte Ptr FNCKY,AL    ;store 
  1910.     CMP    AL,' '            ;printing character?
  1911.  
  1912.     JNB    INTER2            ;if yes, exit
  1913.     ADD    AL,40H            ;change to printing character
  1914.     JMP    FIXFNK            ;fix-patch area of extra bytes
  1915. ;
  1916. INTER1: MOV    AL,'^'
  1917.     MOV    BYTE PTR MENU3,AL    ;store the "control-" character
  1918.     RET
  1919. ;
  1920. INTER2: MOV    Byte Ptr MENU3+1,AL
  1921.     RET
  1922. ;.....
  1923. ;
  1924. ;
  1925. ; Process any options - put 0 in appropriate place in option table if
  1926. ; option is selected
  1927. ;
  1928. PROCOPT:MOV    DX,Offset FCB+1
  1929.     MOV    SI,DX
  1930.     MOV    AL,[SI]
  1931.     MOV    Byte Ptr OPTION,AL
  1932.     CMP    AL,' '            ;exit if no options
  1933.     JNZ    OPTLP
  1934.     RET
  1935. ;
  1936. OPTLP:    INC    DX
  1937.     MOV    SI,DX
  1938.     MOV    AL,[SI]
  1939.     CMP    AL,' '
  1940.     JZ    ENDOPT
  1941.     MOV    BX, Offset OPTBL
  1942.     MOV    CH, (Offset OPTBE)-(Offset OPTBL)
  1943. ;
  1944. OPTCK:    CMP    AL,Byte Ptr [BX]
  1945.     JNZ    OPTNO
  1946.     CMP    AL,'O'            ;want originate tones?
  1947.     MOV    CH,AL            ;store momentarily
  1948.     MOV    AL,ORIGMOD
  1949.     JZ    OPTCK1
  1950.     MOV    AL,CH            ;get the option back
  1951.     CMP    AL,'A'            ;want answer tones?
  1952.     JNZ    OPTCK2            ;if not, exit
  1953.     MOV    AL,ANSWMOD
  1954. ;
  1955. OPTCK1: MOV    Byte Ptr UARTCTLB,AL
  1956. ;
  1957. OPTCK2: MOV    Byte Ptr [BX],0
  1958.     JMPS    OPTLP
  1959. ;
  1960. OPTNO:    INC    BX
  1961.     DEC    CH
  1962.     JNZ    OPTCK
  1963.     CALL    NTVLDMSG
  1964.     POP    BX            ;preserve stack
  1965.     JMP    MENU
  1966. ;
  1967. ENDOPT: MOV    AL,Byte Ptr VSEEFLG
  1968.     OR    AL,AL
  1969.     JNZ    CKOPTN
  1970.     MOV    Byte Ptr QFLG,AL       ;quiet mode for watching data items
  1971. ;
  1972. CKOPTN: MOV    AL,Byte Ptr OPTION     ;check on the primary option
  1973.     CMP    AL,'D'            ;going to disconnect?
  1974.     JNZ    L3A9
  1975.     RET
  1976. L3A9:
  1977.     CMP    AL,'E'            ;return if echo option
  1978.     JNZ    L3A10
  1979.     RET
  1980. L3A10:
  1981.     CMP    AL,'M'            ;return if help option
  1982.     JNZ    L3A11
  1983.     RET
  1984. L3A11:
  1985.     CMP    AL,'L'            ;return if local echo option
  1986.     JNZ    L3A12
  1987.     RET
  1988. L3A12:
  1989.     CMP    AL,'T'            ;return if terminal mode
  1990.     JNZ    L3A13
  1991.     RET
  1992. L3A13:
  1993.     MOV    CH,AL            ;save the primary option for a moment
  1994.     MOV    AL,Byte Ptr PMMIMODEM  ;PMMI modem?
  1995.     OR    AL,AL
  1996.     JNZ    CKOPTN0            ;if yes, accept 'C'
  1997.     MOV    AL,Byte Ptr AUTODIAL   ;using a Hayes-type modem?
  1998.     OR    AL,AL
  1999.     JZ    CKOPTN1            ;exit if neither
  2000. ;
  2001. CKOPTN0:MOV    AL,CH            ;get the character back 
  2002.     CMP    AL,'C'            ;going to call a number now?
  2003.     JNZ    L3A14
  2004.     RET
  2005. L3A14:
  2006. ;
  2007. CKOPTN1:MOV    AL,Byte Ptr NFILFLG    ;saving memory for disk file?
  2008.     OR    AL,AL
  2009.     JZ    CKOPTN2            ;if not, continue
  2010.     POP    BX            ;reset the stack from 'CALL PROCOPT'
  2011.     JMP    MENU0            ;go show the 'FILE OPEN' message
  2012. ;
  2013. CKOPTN2:MOV    AL,CH            ;get the option back    
  2014.     CMP    AL,'S'
  2015.     JZ    CKFILE
  2016.     CMP    AL,'R'
  2017.     JNZ    BDOPT            ;none of these, bad option
  2018.     MOV    AL,Byte Ptr BATCHFLG   ;see if the batch mode flag is set
  2019.     OR    AL,AL
  2020.     JNZ    CKFILE
  2021.     RET                ;if yes, exit
  2022. ;
  2023. CKFILE: MOV    AL,Byte Ptr FCB+17     ;'S' and 'R' need a file name
  2024.     CMP    AL,' '
  2025.     JZ    REENT
  2026.     RET                ;exit if a file name is present
  2027. ;
  2028. REENT:    CALL    ILPRT
  2029.     DB    '++ Enter primary option plus file name ++'
  2030.     DB    CR,LF,BELL,0
  2031.     POP    BX            ;reset stack from 'CALL SETFCB
  2032.     JMP    MENU            ;abort to command line
  2033. ;.....
  2034. ;
  2035. ;
  2036. BDOPT:    CALL    ILPRT
  2037.     DB    CR,LF,'++ Bad option ++',CR,LF,LF,0
  2038. ;.....
  2039. ;
  2040. ;
  2041. ; Check for any garbage characters on line - catch and ignore
  2042. ;
  2043. CKCHAR: CALL    RCVREADY        ;any characters ready to receive?
  2044.     JZ    L3A17
  2045.     RET                ;if not, return
  2046. L3A17:
  2047.     CALL    IN_MODDATP        ;otherwise get the character and ignore
  2048.     JMPS    CKCHAR            ;check for any additional characters
  2049. ;.....
  2050. ;
  2051. ;
  2052. ; Revised terminal routine allowing memory save.  First checks for bad
  2053. ; options, to prevent wiping out the disk with accidental memory save.
  2054. ;
  2055. DSKSAVE:MOV    AL,Byte Ptr BATCHFLG   ;batch flag set?
  2056.     OR    AL,AL
  2057.     JNZ    DSKSAVE1        ;if not set, everything is normal
  2058.     MOV    AL,'B'            ;if set, shouldn't be, so reset it
  2059.     MOV    Byte Ptr BATCHFLG,AL
  2060.     JMP    NOTVLD            ;if set, error for 'E', 'L' or 'T'
  2061. ;
  2062. DSKSAVE1:
  2063.     MOV    Byte Ptr XFLG,AL       ;will use the ASCII capture buffer size
  2064.     MOV    AL,Byte Ptr NFILFLG    ;already saving for a file?
  2065.     OR    AL,AL
  2066.     JZ    DSKSAVE2        ;exit if not, and open a file
  2067.     CALL    BUFMSG            ;tell if buffer if on or off
  2068.     JMPS    TERM
  2069. ;
  2070. DSKSAVE2:
  2071.     MOV    AL,Byte Ptr .FCB+1    ;first character of filename (if any)
  2072.     CMP    AL,' '            ;file specified?
  2073.     JNZ    GOODNM            ;yes, good name
  2074.     XOR    AL,AL
  2075.     MOV    Byte Ptr NFILFLG,AL    ;show no file being saved
  2076.     MOV    Byte Ptr SAVEFLG,AL    ;reset the flag to zero
  2077.     JMPS    TERM
  2078. ;...
  2079. ;
  2080. ;
  2081. GOODNM: CALL    ERASFIL
  2082.     MOV    BX, Offset FCB3
  2083.     CALL    INITFCB
  2084.     MOV    BX, Offset FCB        ;move the disk name into FCB3 area
  2085.     MOV    DX, Offset FCB3
  2086.     MOV    CH,12
  2087.     CALL    MOVE
  2088.     MOV    DX, Offset FCB3        ;now make a file from that name
  2089.     MOV    CL,MAKE
  2090.     INT    224
  2091.     MOV    DX, Offset FCB3        ;now open the file from FCB3
  2092.     MOV    CL,OPEN
  2093.     INT    224
  2094.     MOV    BX, offset BUFFER    ;reset pointers to start of buffer
  2095.     MOV    Word Ptr HLSAVE,BX
  2096.     MOV    AL,1
  2097.     MOV    Byte Ptr NFILFLG,AL    ;show now saving to memory for disk file
  2098.     CALL    BUFMSG2            ;show buffer is available
  2099. ;
  2100. TERM:    MOV    AL,Byte Ptr LSTTST     ;allowing the printer to be used?
  2101.     OR    AL,AL
  2102.     JZ    L3A18
  2103.     CALL    GOLIST            ;if yes, see if anything to print
  2104. L3A18:
  2105.     CALL    STAT            ;keyboard have a character?
  2106.     JNZ    L3A19
  2107.     JMP    TERML            ;if not, see if any incoming
  2108. L3A19:
  2109.     CALL    KEYIN            ;get character from keyboard
  2110.     MOV    CH,AL            ;save for now to protect 'A' reg.
  2111.     CMP    AL,RUB            ;test for rub
  2112.     JNZ    NOTRUB            ;exit if not
  2113.     MOV    AL,Byte Ptr CONVRUB    ;convert rub to backspace?
  2114.     OR    AL,AL
  2115.     JZ    NOTRUB            ;exit if no conversion
  2116.     MOV    CH,BKSP            ;call it a backspace
  2117.     JMP    NOTOG            ;go send a backspace
  2118. ;
  2119. NOTRUB: MOV    AL,Byte Ptr FNKFLG     ;get function key active flag
  2120.     OR    AL,AL
  2121.     JZ    NOF            ;if not set yet, exit
  2122.     MOV    AL,CH            ;get character
  2123.     CMP    AL,'0'
  2124.     JB    NOFNK1            ;ignore invalid key codes
  2125.     CMP    AL,'9'+1
  2126.     JNB    NOFNK1
  2127.     AND    AL,0FH            ;make 0..9
  2128.     JMP    SENDFK
  2129. ;
  2130. NOF:    MOV    AL,Byte Ptr INTCPT    ;check intercept character
  2131.     CMP    AL,CH
  2132.     JNZ    NOFNK1            ;skip if no function key
  2133.     MOV    Byte Ptr FNKFLG,AL     ;set the function flag
  2134.     JMP    TERML            ;do not send the intercept character
  2135. ;
  2136. NOFNK1: XOR    AL,AL            ;reset the flag
  2137.     MOV    Byte Ptr FNKFLG,AL
  2138.     MOV    AL,Byte Ptr EXACFLG
  2139.     OR    AL,AL            ;exact?
  2140.     MOV    AL,0            ;(cannot use 'XRA A' here)
  2141.     MOV    Byte Ptr EXACFLG,AL    ;clear for next time
  2142.     JZ    NTEXAFLG        ;go if EXACFLG not set 'YES'
  2143.     MOV    AL,Byte Ptr LOCNXTCHR
  2144.     OR    AL,AL            ;should we send on exacflg?
  2145.     JNZ    L3A20
  2146.     JMP    NOTOG            ;jump if LOCONEXTCHR 'NO'
  2147. L3A20:
  2148.     MOV    AL,Byte Ptr EXTCHR     ;we want to send EXTCHR in any case
  2149.     CMP    AL,CH
  2150.     JNZ    L3A21
  2151.     JMP    NOTOG            ;send if EXTCHR
  2152. L3A21:
  2153.     JMPS    LOCCHK            ;otherwise do local stuff
  2154. ;...
  2155. ;
  2156. ;
  2157. NTEXAFLG:
  2158.     MOV    AL,Byte Ptr EXTCHR     ;treat next character in special way?
  2159.     CMP    AL,CH            ;check against this control character
  2160.     JNZ    NTEXA1            ;yes, set exacflg for next character
  2161.     MOV    AL,1
  2162.     MOV    Byte Ptr EXACFLG,AL    ;set the flag
  2163.     JMP    TERM            ;do not send, get next character
  2164. ;
  2165. NTEXA1: MOV    AL,Byte Ptr LOCNXTCHR
  2166.     OR    AL,AL            ;should we send if not EXACFLG?
  2167.     JZ    LOCCHK
  2168.     JMP    NOTOG            ;jump if loconextchr 'YES'
  2169. ;
  2170. LOCCHK: CALL    EXITTST1        ;want to exit to menu?
  2171.     MOV    AL,Byte Ptr NOCONNCT   ;want to disconnect from line?
  2172.     CMP    AL,CH
  2173.     JNZ    L3A23
  2174.     JMP    DONETCD            ;if yes go disconnect
  2175. L3A23:
  2176.     MOV    AL,Byte Ptr TRANCHR    ;output text file to remote?
  2177.     CMP    AL,CH
  2178.     JNZ    L3A24
  2179.     JMP    TRANSFER
  2180. L3A24:
  2181.     MOV    AL,Byte Ptr TRANLOGON
  2182.     OR    AL,AL
  2183.     JZ    SKPLOGON
  2184.     MOV    AL,Byte Ptr LOGCHR     ;send logon?
  2185.     CMP    AL,CH
  2186.     JNZ    L3A25
  2187.     JMP    SENDLOG
  2188. L3A25:
  2189. ;
  2190. SKPLOGON:
  2191.     MOV    AL,Byte Ptr LSTTST     ;going to use the external printer?
  2192.     OR    AL,AL
  2193.     JZ    NOLST            ;if not, skip this area
  2194.     MOV    AL,Byte Ptr LSTCHR     ;get the printer control-character
  2195.     CMP    AL,CH            ;did we just ask for printer control?
  2196.     JNZ    NOLST            ;if not, exit
  2197.     MOV    AL,Byte Ptr LISTFLG    ;otherwise reset the printer toggle
  2198.     NOT    AL
  2199.     MOV    Byte Ptr LISTFLG,AL    ;and store
  2200.     CALL    CRLF
  2201.     CALL    CRLF
  2202.     CALL    LSTMSG            ;tell if printer is on or off now
  2203.     CALL    CRLF
  2204.     JMP    TERML            ;back to the terminal mode again
  2205. ;.....
  2206. ;
  2207. ;
  2208. NOLST:    MOV    AL,Byte Ptr BRKCHR     ;PMMI break?
  2209.     CMP    AL,CH
  2210.     JNZ    L3A26
  2211.     JMP    BREAK
  2212. L3A26:
  2213.     MOV    AL,Byte Ptr PMMIMODEM  ;using a PMMI board?
  2214.     OR    AL,AL
  2215.     JZ    NOLST1            ;if not, skip the next few lines
  2216.     MOV    AL,Byte Ptr CHGBAUD    ;PMMI change baud?
  2217.     CMP    AL,CH
  2218.     LAHF
  2219.     XCHG    AL,AH
  2220.     PUSH    AX
  2221.     PUSH    BX
  2222.     JNZ    L3A27
  2223.     CALL    JMP_NEWBAUD
  2224. L3A27:
  2225.     POP    BX
  2226.     POP    AX
  2227.     XCHG    AL,AH
  2228.     SAHF
  2229.     JNZ    NOLST1
  2230.     JMP    TERML
  2231. ;...
  2232. ;
  2233. ;
  2234. NOLST1: MOV    AL,Byte Ptr UNSAVECHR  ;close input buffer?
  2235.     CMP    AL,CH
  2236.     JZ    NOLST2            ;if yes, disable copy
  2237.     MOV    AL,Byte Ptr SAVECHR    ;open input buffer?
  2238.     CMP    AL,CH
  2239.     JZ    L3A29
  2240.     JMP    NOTOG
  2241. L3A29:
  2242.     MOV    AL,Byte Ptr NFILFLG    ;do not allow save if..
  2243.     OR    AL,AL
  2244.     JNZ    L3A30
  2245.     JMP    TERML            ;..this flag is set.
  2246. L3A30:
  2247.     JMPS    NOLST3
  2248. ;
  2249. NOLST2: XOR    AL,AL            ;stop copy into file
  2250. ;
  2251. NOLST3: MOV    Byte Ptr SAVEFLG,AL
  2252.     CALL    BUFMSG
  2253.     JMP    TERM            ;get next character
  2254. ;.....
  2255. ;
  2256. ;    
  2257. ;***********************************************************************
  2258. ;
  2259. ;             SEND A CP/M FILE
  2260. ;
  2261.  
  2262. ;***********************************************************************
  2263. ;
  2264. ;
  2265. SENDFIL:XOR    AL,AL            ;set to checksum initially on send
  2266.     MOV    Byte Ptr CRCFLAG,AL    ;..initially on send
  2267.     CALL    CKCHAR            ;catch any garbage characters
  2268. ;
  2269. SENDFIL1:
  2270.     MOV    AL,Byte Ptr BATCHFLG   ;check if multiple file..
  2271.     OR    AL,AL            ;..mode is set.
  2272.     JNZ    SENDC1
  2273.     CALL    ILPRT
  2274.     DB    'Ready to send in batch mode',CR,LF,0
  2275. ;
  2276. SENDFIL2:
  2277.     CALL    JMP_PARITY
  2278.     MOV    AL,YES            ;indicate send for batch mode
  2279.     MOV    Byte Ptr SENDFLG,AL
  2280.     MOV    AL,Byte Ptr FSTFLG     ;if first time through..
  2281.     OR    AL,AL            ;..scan the command line..
  2282.     JNZ    L3A31
  2283.     CALL    TNMBUF            ;..for multiple names.
  2284. L3A31:
  2285.     CALL    SENDFN            ;sends file name to receive
  2286.     LAHF
  2287.     XCHG    AL,AH
  2288.     PUSH    AX
  2289.     CALL    CRLF
  2290.     CALL    SHOWFIL
  2291.     MOV    AL,' '
  2292.     CALL    STYPE
  2293.     POP    AX
  2294.     XCHG    AL,AH
  2295.     SAHF
  2296.     JNB    SENDC2            ;carry set means no more files
  2297.     MOV    AL,'B'            ;stop batch
  2298.     MOV    Byte Ptr BATCHFLG,AL   ;mode option
  2299.     MOV    AL,EOT            ;final transfer end
  2300.     CALL    SEND
  2301.     JMP    DONE
  2302. ;
  2303. SENDC1: MOV    AL,Byte Ptr FCB+1
  2304.     CMP    AL,' '
  2305.     JNZ    SENDC2
  2306.     JMP    BLKFILE
  2307. ;
  2308. SENDC2: CALL    CNREC            ;get number of records
  2309.     CALL    OPENFIL
  2310.     MOV    DL,120            ;wait 2 minutes maximum
  2311.     CALL    WAITNAK
  2312. ;
  2313. SENDLP: CALL    CKABORT            ;want to terminate while sending file?
  2314.     CALL    RDRECD
  2315.     JB    SENDEOF
  2316.     CALL    INCRRNO
  2317.     MOV    AL,1
  2318.     MOV    Byte Ptr ERRCT,AL
  2319. ;
  2320. SENDRPT:CALL    CKABORT            ;want to terminate while sending file?
  2321.     CALL    SENDHDR
  2322.     CALL    SENDREC
  2323.     MOV    AL,Byte Ptr CRCFLAG
  2324.     OR    AL,AL
  2325.     JNZ    SNDCRC
  2326.     CALL    SENDCKS
  2327.     JMPS    SNDCONT
  2328. ;
  2329. SNDCRC: CALL    SENDCRC
  2330. ;
  2331. SNDCONT:CALL    GETACK
  2332.     JB    SENDRPT
  2333.     JMPS    SENDLP
  2334. ;.....
  2335. ;
  2336. ;
  2337. SENDEOF:MOV    AL,EOT
  2338.     CALL    SEND
  2339.     CALL    GETACK
  2340.     JB    SENDEOF
  2341.     JMP    DONE
  2342. ;.....
  2343. ;
  2344. ;
  2345. ;***********************************************************************
  2346. ;
  2347. ;               RECEIVE A CP/M FILE
  2348. ;
  2349. ;***********************************************************************
  2350. ;
  2351. ;
  2352. RCVFIL: MOV    AL,Byte Ptr CRCDFLT    ;get mode requested by operator
  2353.     MOV    Byte Ptr CRCFLAG,AL    ;store it
  2354. ;
  2355. RCVFIL1:CALL    JMP_PARITY
  2356.     MOV    AL,Byte Ptr BATCHFLG   ;check if multiple file mode
  2357.     OR    AL,AL
  2358.     JNZ    RCVC1            ;if not, exit
  2359.     MOV    AL,NO            ;flag where to return..
  2360.     MOV    Byte Ptr SENDFLG,AL    ;..for next file transfer
  2361.     CALL    GETFN            ;get the file name
  2362.     JNB    RCVC2            ;carry set means no more files
  2363.     MOV    AL,'B'            ;stop batch
  2364.     MOV    Byte Ptr BATCHFLG,AL   ;mode option
  2365.     JMP    DONE
  2366. ;
  2367. RCVC1:    MOV    AL,Byte Ptr FCB+1      ;make sure file is named
  2368.     CMP    AL,' '
  2369.     JNZ    L3A35
  2370.     JMP    BLKFILE
  2371. L3A35:
  2372.     JMPS    RCVC3
  2373. ;
  2374. RCVC2:    CALL    SHOWFIL            ;show the file name
  2375.     MOV    AL,' '
  2376.     CALL    STYPE
  2377.     CALL    SNDPRG            ;get progress and wait for quiet line
  2378.     CALL    CKCPM2
  2379.     CALL    CRLF
  2380.     CALL    CKBAKUP
  2381. ;
  2382. RCVC3:    CALL    ERASFIL
  2383.     CALL    MAKEFIL
  2384.     CALL    WAITQ1
  2385.     MOV    AL,Byte Ptr BATCHFLG   ;do not print message if in batch mode
  2386.     OR    AL,AL
  2387.     JZ    RCVFST
  2388.     CALL    ILPRTQ
  2389.     DB    'File open, ready to receive',CR,LF,0
  2390. ;
  2391. RCVFST: MOV    AL,Byte Ptr CRCFLAG
  2392.     OR    AL,AL
  2393.     JZ    RCVNAKM            ;if in 'CRC' mode
  2394.     CALL    ILPRTQ            ;then say so
  2395.     DB    'CRC in effect',CR,LF,0
  2396.     MOV    AL,CRC
  2397.     JMPS    RCVLP0
  2398. ;
  2399. RCVNAKM:CALL    ILPRTQ            ;else say 'CHECKSUM' mode
  2400.     DB    'Checksum in effect',CR,LF,0
  2401.     MOV    AL,NAK
  2402. ;
  2403. RCVLP0: LAHF
  2404.     XCHG    AL,AH
  2405.     PUSH    AX
  2406.     CALL    ILPRT
  2407.     DB    'Waiting.....',0
  2408. ;
  2409. NOPRG:    POP    AX
  2410.     XCHG    AL,AH
  2411.     SAHF
  2412.     CALL    SEND
  2413. ;
  2414. RCVLP:    CALL    RCVRECD
  2415.     JB    RCVEOT
  2416.     CALL    REPORT            ;show record received if not in quiet 
  2417.     CALL    WRRECD
  2418.     CALL    INCRRNO
  2419.     CALL    SENDACK
  2420.     JMPS    RCVLP
  2421. ;
  2422. RCVEOT:
  2423.     CALL    WRBLOCK
  2424.     CALL    SENDACK
  2425.     CALL    CLOSFIL
  2426.     JMP    DONE
  2427. ;
  2428. SENDACK:MOV    AL,ACK
  2429.     CALL    SEND
  2430.     RET
  2431. ;
  2432. ;.....
  2433. ;
  2434. ;
  2435. ;=================== FILE TRANSFER IN T-MODE ===========================
  2436. ;
  2437. ;
  2438. ; File transfer routine - called with CTL-T from terminal mode.     Trans-
  2439. ; fer may be cancelled while sending, by using CTL-X.
  2440. ;
  2441. TRANSFER:
  2442.     MOV    BX, Offset FCB4
  2443.     CALL    INITFCB            ;initializes FCBs pointed..
  2444.     MOV    BX, offset FCB+16    ;..to by 'BX' reg.
  2445.     CALL    INITFCB
  2446. ;
  2447. ;
  2448. ; Get name of file to send in "T" (terminal) mode
  2449. ;
  2450. GET:    CALL    ILPRT
  2451.     DB    CR,LF,'File name to send? (CR to abort): ',0
  2452.     MOV    DX, offset CMDBUF
  2453.     CALL    INBUF
  2454.     MOV    AL,Byte Ptr CMDBUF+2   ;was file entered?
  2455.     CMP    AL,' '
  2456.     JNZ    L3A36
  2457.     JMP    RETURN            ;if not probably wanted to quit
  2458. L3A36:
  2459.     MOV    DX, Offset CMDBUF
  2460.     MOV    BX, Offset FCB4
  2461.     CALL    CMDLINE
  2462.     MOV    DX, Offset FCB4
  2463.     MOV    CL,OPEN
  2464.     INT    224
  2465.     CMP    AL,0FFH            ;return with 0FFH means 'NO SUCH FILE'
  2466.     JNZ    L3A37
  2467.     JMP    TRANSL
  2468. L3A37:
  2469.     MOV    AL,Byte Ptr XONWAIT    ;waiting for X-on to send next line?
  2470.     OR    AL,AL
  2471.     JNZ    DLYSAV            ;if yes, skip additional delays
  2472. ;
  2473. ;
  2474. ; Choice of normal speed or delays between characters / lines
  2475. ;
  2476.     CALL    ILPRT
  2477.     DB    'Want to include time delays? (Y/N): ',0
  2478.     CALL    KBDCHR
  2479.     CMP    AL,'N'            ;if 'N' send normal speed
  2480.     JZ    DLYSAV
  2481.     XOR    AL,AL            ;otherwise use character/line delays
  2482. ;
  2483. DLYSAV: MOV    Byte Ptr DLYFLG,AL    ;store the decision
  2484.     CALL    CRLF
  2485.     MOV    DX, Offset CMDBUF+2        ;make sure cmdbuf has been selected
  2486.     MOV    CL,SETDMA
  2487.     INT    224
  2488. ;
  2489. ;
  2490. ; Get 128-byte record
  2491. ;
  2492. READMR: MOV    DX, Offset FCB4
  2493.     MOV    CL,READ
  2494.     INT    224
  2495.     OR    AL,AL            ;check for a good read
  2496.     JZ    READMR1
  2497.     DEC    AL            ;check for end of file to send
  2498.     JZ    RETURNS
  2499.     CALL    ERXIT            ;neither of those, was a read error
  2500.     DB    '++ DISK READ ERROR ++','$'
  2501. ;
  2502. ;
  2503. ; Successful read, so send the record
  2504. ;
  2505. READMR1:CALL    SEND80C            ;send one 128-char record
  2506.     CMP    AL,EOFCHAR        ;end of file - omit if object..
  2507.     JZ    RETURNS            ;..code is to be sent.
  2508.     CMP    AL,CANCEL        ;cancellation?
  2509.     JNZ    READMR
  2510. ;
  2511. RETURN: CALL    ILPRT
  2512.     DB    CR,LF,LF,'(in Terminal-mode now)',CR,LF,LF,0
  2513.     CALL    SENDNOW            ;insures last character is finished
  2514.     CALL    CKCHAR            ;catch any echo character on line
  2515.     JMP    TERM            ;finished, back to t-mode
  2516. ;.....
  2517. ;
  2518. ;
  2519. RETURNS:CALL    ILPRT
  2520.     DB    CR,LF,'[Transfer completed]',0
  2521.     JMPS    RETURN
  2522. ;.....
  2523. ;
  2524. ;
  2525. TRANSL: CALL    ILPRT
  2526.     DB    CR,LF,BELL,'++ FILE NAME ERROR ++ ',CR,LF,0
  2527.     JMP    GET
  2528. ;.....
  2529. ;
  2530. ;
  2531. ; Send one 128-byes record
  2532. ;
  2533. SEND80C:MOV    CH,128            ;will send a maximum of 128 character
  2534.     MOV    BX, Offset CMDBUF+2    ;they are in the cmdbuf area
  2535. ;
  2536. SENDCH1:PUSH    DX
  2537.     CALL    SPEED            ;0-90 ms. delay between characters
  2538.     POP    DX
  2539.     MOV    AL,Byte Ptr [BX]
  2540.     CMP    AL,EOFCHAR
  2541.     JNZ    L3A38
  2542.     RET
  2543. L3A38:
  2544.     CALL    MODOUT            ;send the character to modem
  2545.     CALL    STAT            ;test to see if
  2546.     OR    AL,AL            ;cancellation requested
  2547.     JZ    SKIP1
  2548.     CALL    KEYIN 
  2549.     CMP    AL,CANCEL
  2550.     JNZ    L3A39
  2551.     RET
  2552. L3A39:
  2553. ;
  2554. SKIP1:    INC    BX
  2555.     DEC    CH
  2556.     JNZ    SENDCH1
  2557.     RET
  2558. ;.....
  2559. ;
  2560. ;
  2561. ; Send the character to the output
  2562. ;
  2563. MODOUT: PUSH    AX            ; save character so we can use AX
  2564.     CMP    AL,LF
  2565.     JNZ    MODOUTL
  2566.     MOV    AL,Byte Ptr ADDLF      ;going to send the line feed to modem?
  2567.     OR    AL,AL
  2568.     JNZ    MODOUTL            ;if yes, exit
  2569.     POP    AX            ;get the char. back (a line feed)
  2570.     CALL    STYPE             ;show on CRT, do not send to modem
  2571.     RET
  2572. ;
  2573. MODOUTL:MOV    AL,Byte Ptr XOFFTST    ;waiting for X-off, X-on ?
  2574.     OR    AL,AL
  2575.     JZ    L3A40
  2576.     CALL    TXOFF            ;if yes, go check
  2577. L3A40:
  2578.     CALL    SENDRDY            ;wait until modem is ready to send
  2579.     JNZ    MODOUTL
  2580.     POP    AX            ;get the character back
  2581.     CALL    STYPE             ;send character to CRT
  2582.     CALL    OUT_MODDATP        ;send character to modem
  2583.     CMP    AL,CR            ;was it an end of line?
  2584.     JZ    MODOUTN
  2585.     RET                ;if yes, see if any delay is needed
  2586. ;
  2587. ;
  2588. ; Delay to allow slow BBS systems (most use BASIC) to enter the line.
  2589. ; Choice of 0-9 for about 100 ms. each, maximum of 900 ms.
  2590. ;
  2591. MODOUTN:MOV    AL,Byte Ptr XONWAIT    ;wait for X-on after CR?
  2592.     OR    AL,AL
  2593.     JZ    L3A42
  2594.     JMP    WAITXON            ;if yes, handle separately
  2595. L3A42:
  2596.     MOV    DH,10
  2597. ;
  2598. MODOUTT:PUSH    DX
  2599.     CALL    SPEED1            ;10 ms delay
  2600.     POP    DX
  2601.     DEC    DH
  2602.     JNZ    MODOUTT            ;10 loops for 100 ms.
  2603.     RET
  2604. ;.....
  2605. ;
  2606. ;
  2607. ; Add from 0 to 90 ms. delay between characters for slow (most use
  2608. ; BASIC) bulletin board systems.  Also used to add 0-900 ms. delay
  2609. ; between lines.
  2610. ;
  2611. SPEED:    MOV    AL,Byte Ptr BYTDLY     ;get delay between characters (0-9)
  2612.     JMPS    L3A43            ;1=10 ms, 5=50 ms, 9=90 ms, etc.
  2613. ;
  2614. SPEED1: MOV    AL,Byte Ptr CRDLY      ;get delay after crlf (0-9)
  2615. L3A43:
  2616.     OR    AL,AL            ;100 ms, 5=500 ms, 9=900 ms, etc.
  2617.     JNZ    L3A44
  2618.     RET                ;if no delay needed, return
  2619. L3A44:
  2620.     MOV    CL,AL            ;store number requested in c-reg.
  2621.     MOV    AL,Byte Ptr DLYFLG     ;want any delays this file?
  2622.     OR    AL,AL
  2623.     JZ    SPEED2
  2624.     RET                ;if not, skip this section
  2625. ;
  2626. SPEED2: CALL    SPEED3            ;outer loop
  2627.     DEC    CL
  2628.     JNZ    SPEED2
  2629.     RET                ;done whenever the c-reg. is zero
  2630. ;...
  2631. ;
  2632. ;
  2633. SPEED3: PUSH    BX            ;save current 'BX' value
  2634.     MOV    BX,20
  2635.     MOV    AL,Byte Ptr XOFFTST
  2636.     OR    AL,AL
  2637.     JZ    SPEED4
  2638.     MOV    BX,20            ;adjust for 'X-OFF' testing
  2639.     MOV    AL,Byte Ptr ECHOFLG
  2640.     OR    AL,AL
  2641.     JZ    SPEED4
  2642.     MOV    AL,Byte Ptr LOCFLG
  2643.     OR    AL,AL
  2644.     JZ    SPEED4
  2645.     MOV    BX,25            ;adjust for remote echo
  2646. ;
  2647. SPEED4: CALL    FIXCNT            ;multiply delay by clock speed
  2648.     XCHG    BX,DX            ;transfer delay to 'DE'
  2649.     POP    BX            ;restore current 'BX' from"speed3"
  2650. ;
  2651. SPEED5: DEC    DX            ;inner loop
  2652.     MOV    AL,Byte Ptr XOFFTST
  2653.     OR    AL,AL
  2654.     JZ    L3A46
  2655.     CALL    TXOFF
  2656. L3A46:
  2657.     MOV    AL,DL
  2658.     OR    AL,DH
  2659.     JNZ    SPEED5
  2660.     RET
  2661. ;...
  2662. ;
  2663. ;
  2664. TXOFF:    CALL    RCVREADY
  2665.     JZ    L3A47
  2666.     RET
  2667. L3A47:
  2668.     CALL    IN_MODDATP
  2669.     AND    AL,7FH
  2670.     CMP    AL,XOFF
  2671.     JNZ    L3A48
  2672.     CALL    WAITXON
  2673. L3A48:
  2674.     RET
  2675. ;.....
  2676. ;
  2677. ;
  2678. WAITXON:CALL    RCVREADY        ;have a character? (like x-on)
  2679.     JNZ    WTXON1            ;if no char. see if want to abort
  2680.     CALL    IN_MODDATP
  2681.     AND    AL,7FH            ;strip off any parity
  2682.     CMP    AL,XON            ;see if char. was x-on
  2683.     JNZ    WTXON1
  2684.     RET                ;if yes, keep going
  2685. ;
  2686. WTXON1: CALL    STAT            ;test to see if requesting cancellation
  2687.     JZ    WAITXON
  2688.     CALL    KEYIN            ;can abort if the x-on never comes
  2689.     CMP    AL,CANCEL        ;ctl-x to abort?
  2690.     JNZ    WAITXON            ;if not, keep going
  2691.     RET
  2692.  
  2693. ;.....
  2694. ;
  2695. ;================ END OF FILE TRANSFER IN T-MODE =======================
  2696. ;
  2697. ;
  2698. ;***********************************************************************
  2699. ;
  2700. ;               SUBROUTINES    
  2701. ;
  2702. ;***********************************************************************
  2703. ;
  2704. ; Returns with the zero flag set if retry requested.  If using multi-
  2705. ; file (batch) modem, then no questions asked, just quit.
  2706. ;
  2707. CKQUIT: MOV    AL,Byte Ptr BATCHFLG   ;using batch mode now?
  2708.     OR    AL,AL
  2709.     JNZ    CKQUIT1
  2710.     JMP    ABORT            ;quit if using batch mode
  2711. ;
  2712. CKQUIT1:MOV    AL,1
  2713.     MOV    Byte Ptr ERRCT,AL
  2714.     CALL    ILPRT
  2715.     DB    CR,LF,'Multiple errors encountered.',CR,LF
  2716.     DB    'Type Q to quit, R to retry:  ',BELL,0
  2717.     CALL    KEYIN
  2718.     LAHF
  2719.     XCHG    AL,AH
  2720.     PUSH    AX
  2721.     CALL    CRLF
  2722.     POP    AX
  2723.     XCHG    AL,AH
  2724.     CALL    UCASE            ;instead of 'ANI 5FH'
  2725.     CMP    AL,'R'
  2726.     JNZ    L3A52
  2727.     JMP    RCVRECD            ;if 'R' keep trying
  2728. L3A52:
  2729.     CMP    AL,'Q'
  2730.     JNZ    CKQUIT1
  2731.     JMP    ABORT
  2732. ;.....
  2733. ;
  2734. ;
  2735. ; Show the file name as stored in the FCB but in CP/M format
  2736. ;
  2737. SHOWFIL:MOV    AL, Byte Ptr QFLG
  2738.     OR    AL,AL
  2739.     JNZ    L4A1
  2740.     RET
  2741. L4A1:
  2742.     MOV    BX, Offset FCB+1
  2743. ;
  2744. SHOWNM: XOR    AL,AL
  2745.     MOV    Byte Ptr FTYCNT,AL
  2746.     MOV    CL,11
  2747. ;
  2748. PRNAM:    CALL    FTYTST
  2749.     INC    BX
  2750.     DEC    CL
  2751.     JNZ    PRNAM
  2752.     RET
  2753. ;.....
  2754. ;
  2755. ;
  2756. ; Give report of received records as they occur
  2757. ;
  2758. REPORT: MOV    AL,Byte Ptr QFLG
  2759.     OR    AL,AL
  2760.     JNZ    L4A2
  2761.     RET
  2762. L4A2:
  2763.     MOV    BX,Word Ptr RECDNO     ;get record number
  2764.     INC    BX
  2765.     CALL    ILPRT
  2766.     DB    CR,'Received # ',0
  2767.     CALL    DECOUT            ;print record number in decimal
  2768.     CALL    ILPRT
  2769.     DB    ' ',0
  2770. ;
  2771.     MOV    AL,Byte Ptr HEXSHOW
  2772.     OR    AL,AL
  2773.     JNZ    L4A3
  2774.     RET
  2775. L4A3:
  2776.     CALL    ILPRT
  2777.     DB    '(',0
  2778.     CALL    DHXOUT            ;16 bit hex conversion and output
  2779.     CALL    ILPRT
  2780.     DB    'H) ',0
  2781.     RET
  2782. ;.....
  2783. ;
  2784. ;
  2785. FTYTST: MOV    AL,Byte Ptr FTYCNT
  2786.     INC    AL
  2787.     MOV    Byte Ptr FTYCNT,AL
  2788.     CMP    AL,9            ;are we at the file type?
  2789.     JZ    SPCTST            ;go if so
  2790. ;
  2791. ENDSPT: MOV    AL,Byte PTr [BX]
  2792.     CMP    AL,' '            ;test for space
  2793.     JZ    L4A4
  2794.     CALL    STYPE             ;type if not
  2795. L4A4:    RET
  2796. ;.....
  2797. ;
  2798. ;
  2799. SPCTST: MOV    AL,Byte Ptr [BX]
  2800.     CMP    AL,' '            ;test for space in 1st file type byte
  2801.     JNZ    L4A5
  2802.     RET                ;do not output period if space
  2803. L4A5:    MOV    AL,'.'
  2804.     CALL    STYPE
  2805.     JMPS    ENDSPT            ;output 1st file type byte
  2806. ;.....
  2807. ;
  2808. ;
  2809. ; Get sender's progress report if it is present and wait for line to get
  2810. ; quiet
  2811. ;
  2812. SNDPRG: MOV    CH,5            ;wait up to 5 seconds
  2813.     CALL    RECV
  2814.     CALL    STYPE             ;show the progress report from sender
  2815.     JNB    SNDPRG
  2816.     RET
  2817. ;.....
  2818. ;
  2819. ;
  2820. SENDFN: CALL    ILPRTQ
  2821.     DB    'Awaiting name NAK',CR,LF,0
  2822.     CALL    GETACK
  2823.     JNB    SENDFN1
  2824.     CALL    SENDACK
  2825. SENDFN1:
  2826.     MOV    BX, Offset FILECT
  2827.     DEC    Byte Ptr [BX]
  2828.     JS    NOMRNM 
  2829.     MOV    BX,Word Ptr NBSAVE     ;get file name..
  2830.     MOV    DX, Offset FCB        ;..in FCB
  2831.     MOV    CH,12
  2832.     CALL    MOVE
  2833.     MOV    Word Ptr NBSAVE,BX
  2834.     CALL    SENDNM            ;send it
  2835.     OR    AL,AL            ;clear carry
  2836.     RET
  2837. ;.....
  2838. ;
  2839. ;
  2840. NOMRNM: MOV    AL,EOT
  2841.     CALL    SEND
  2842.     STC
  2843.     RET
  2844. ;.....
  2845. ;
  2846. ;
  2847. ; Wait for line to get quiet and gobble characters
  2848. ;
  2849. WAITQ1: MOV    CH,1
  2850.     CALL    RECV
  2851.     JNB    WAITQ1
  2852.     RET
  2853. ;.....
  2854. ;
  2855. ;
  2856. SENDNM: PUSH    BX
  2857. ;
  2858. SENDNM1:MOV    DH,11            ;count characters in name
  2859.     MOV    CL,0            ;initialize checksum
  2860.     MOV    BX, Offset FCB+1    ;address name
  2861. ;
  2862. NAMLPS: MOV    AL,Byte Ptr [BX]    ;send name
  2863.     AND    AL,7FH            ;strip high order bit so CP/M2..
  2864.     CALL    SEND            ;..will not send R/O file designation.
  2865. ;
  2866. ACKLP:    PUSH    CX            ;save checksum
  2867.     MOV    CH,5            ;wait for receiver to acknowledge..
  2868.     CALL    RECV            ;..getting the letter.
  2869.     POP    CX
  2870.     JB    SCKSER
  2871.     CMP    AL,ACK
  2872.     JNZ    ACKLP
  2873.     INC    BX            ;next character
  2874.     DEC    DH
  2875.     JNZ    NAMLPS
  2876.     MOV    AL,EOFCHAR        ;tell receiver the end of name
  2877.     CALL    SEND
  2878.     MOV    DH,CL            ;save checksum
  2879. ;
  2880. CKSMLP: MOV    CH,5            ;wait up to 5 seconds
  2881.     CALL    RECV            ;get checksum
  2882.     CMP    AL,DH
  2883.     JNZ    SCKSER            ;exit if bad name
  2884.     MOV    AL,OKNMCH        ;good name-tell receiver
  2885.     CALL    SEND
  2886.     POP    BX
  2887.     RET
  2888. ;.....
  2889. ;
  2890. ;
  2891. SCKSER: MOV    AL,BDNMCH        ;bad name-tell receiver
  2892.     CALL    SEND
  2893.     CALL    ILPRT
  2894.     DB    CR,LF,'++ ERROR sending name  ++',CR,LF,0
  2895.     MOV    DL,120            ;do handshaking over (2 minutes maximum)
  2896.     CALL    WAITNLP            ;don't print "WAITING READY SIGNAL" msg
  2897.     CALL    SENDACK
  2898.     JMP    SENDNM1
  2899. ;.....
  2900. ;
  2901. ;
  2902. ; This patch fixes a trivial problem with the display of the function
  2903. ; key group on the menu.  It uses some of the extra bytes available in
  2904. ; this area from the CKSMLP fix.
  2905. ;
  2906. FIXFNK: MOV    BYTE PTR MENU3+1,AL    ;store the character in the menu display
  2907.     CMP    AL,'['            ;'ESC' character, printed
  2908.     JNB    FIXFNK1            ;if 'ESC' or more, exit
  2909.     JMP    INTER1            ;otherwise include a '^'
  2910. ;
  2911. FIXFNK1:
  2912.     JMP    INTER2
  2913. ;
  2914. ; Patch to close FCB3 instead of FCB when in disk-capture mode.
  2915. ;
  2916. WRERRSP:CALL    WRTFIL2            ;close FCB3 file
  2917.     JMP    WRERR1            ;go write 'DISK FULL' message and quit
  2918. EXTRA    DB    '123456789 '        ;10 extras from CKSMLP (there were 27)
  2919. ;
  2920. ;
  2921. GETFN:    MOV    BX, FCB
  2922.     CALL    L4A6            ;does not initialize drive
  2923.     CALL    ILPRTQ
  2924.     DB    'Awaiting file name',CR,LF,0
  2925.     CALL    HSNAK
  2926.     CALL    GETNM            ;get the name
  2927.     CMP    AL,EOT            ;if EOT, then no more files
  2928.     JZ    NOMRNMG
  2929.     OR    AL,AL            ;clear carry
  2930.     RET
  2931. ;
  2932. NOMRNMG:STC
  2933.     RET
  2934. ;
  2935. ;
  2936. GETNM:    PUSH    BX
  2937. ;
  2938. GETNM1: MOV    AL,0FFH
  2939.     MOV    Byte Ptr FLTRFLG,AL
  2940.     MOV    CL,0            ;initialize checksum
  2941.     MOV    BX, FCB+1
  2942. ;
  2943. NAMELPG:MOV    CH,5
  2944.     CALL    RECV            ;get the character
  2945.     PUSH    CX
  2946.     LAHF
  2947.     XCHG    AL,AH
  2948.     PUSH    AX
  2949.     MOV    AL,0FFH
  2950.     MOV    Byte Ptr TIMFLG,AL
  2951.     MOV    CH,1
  2952.     CALL    RECV
  2953.     XOR    AL,AL
  2954.     MOV    Byte Ptr TIMFLG,AL
  2955.     POP    AX
  2956.     XCHG    AL,AH
  2957.     SAHF
  2958.     POP    CX
  2959.     JNB    GETNM3
  2960.     CALL    ILPRTQ
  2961.     DB    'Time out receiving filename',CR,LF,0
  2962.     JMP    GCKSER
  2963. ;
  2964. GETNM3: CMP    AL,EOT            ;if EOT, then no more files
  2965.     JNZ    L4A7
  2966.     JMP    GNRET
  2967. L4A7:
  2968.     CMP    AL,EOFCHAR        ;got end of name
  2969.     JZ    ENDNAME
  2970.     LAHF
  2971.     XCHG    AL,AH
  2972.     PUSH    AX
  2973.     PUSH    CX
  2974.     CALL    SENDACK
  2975.     POP    CX
  2976.     POP    AX
  2977.     XCHG    AL,AH
  2978.     MOV    Byte Ptr [BX],AL    ;put name in FCB
  2979.     INC    BX            ;get next character
  2980.     MOV    AL,BL            ;don not let noise cause overflow..
  2981.     CMP    AL,7FH            ;..into the program area.
  2982.     JZ    GCKSER
  2983.     JMP    NAMELPG
  2984. ;
  2985. ENDNAME:XOR    AL,AL
  2986.     MOV    Byte Ptr FLTRFLG,AL
  2987.     MOV    AL,CL            ;send checksum
  2988.     MOV    DH,CL
  2989.     CALL    SEND
  2990. ;
  2991. NMLP1:    MOV    CH,5            ;wait up to 5 second to see if..
  2992.     CALL    RECV            ;..the checksum is good
  2993.     CMP    AL,OKNMCH        ;yes if 'OKNMCH' sent
  2994.     JZ    GNRET
  2995.     CMP    AL,DH
  2996.     JZ    NMLP1            ;in case it is echo of send
  2997.     CMP    AL,CR
  2998.     JZ    NMLP1
  2999.     CMP    AL,LF
  3000.     JZ    NMLP1
  3001. ;
  3002. GCKSER: MOV    BX, FCB             ;clear FCB (except drive) since it..
  3003.     CALL    L4A6             ;..might be damaged.
  3004.     CALL    ILPRTQ
  3005.     DB    CR,LF,'**  Checksum error  **',CR,LF,0
  3006.     XOR    AL,AL
  3007.     MOV    Byte Ptr FLTRFLG,AL
  3008.     CALL    HSNAK            ;do handshaking over
  3009.     JMP    GETNM1
  3010. ;
  3011. GNRET:    LAHF
  3012.     XCHG    AL,AH
  3013.     PUSH    AX
  3014.     XCHG    AL,AH
  3015.     XOR    AL,AL
  3016.     MOV    Byte Ptr FLTRFLG,AL
  3017.     POP    AX
  3018.     XCHG    AL,AH
  3019.     SAHF
  3020.     POP    BX
  3021.     RET
  3022. ;
  3023. HSNAK:    MOV    DL,180            ;3 minute wait for file name
  3024.     XOR    AL,AL
  3025.     MOV    Byte Ptr FLTRFLG,AL
  3026. ;
  3027. HSNAK1: CALL    CKABORT            ;want to abort?
  3028.     MOV    AL,NAK            ;send 'NAK' until receiving 'ACK'
  3029.     CALL    SEND
  3030.     MOV    CH,1            ;wait up to 1 second for a character
  3031.     CALL    RECV
  3032.     CMP    AL,ACK            ;'ACK' is what we were waiting for
  3033.     JNZ    L4A8
  3034.     RET
  3035. L4A8:
  3036.     DEC    DL
  3037.     JNZ    HSNAK1
  3038.     JMP    ABORT            ;back to command line
  3039. ;
  3040. ;.....
  3041. ;
  3042. ;
  3043. TNMBUF: MOV    AL,1            ;call from 'SENDFIL' only once.
  3044.     MOV    Byte Ptr FSTFLG,AL
  3045.     XOR    AL,AL
  3046.     MOV    Byte Ptr FILECT,AL
  3047.     CALL    SCAN
  3048.     MOV    BX, Offset NAMEBUF
  3049.     MOV    Word Ptr NBSAVE,BX     ;save address of 1st name
  3050. ;
  3051. TNLP1:    CALL    TRTOBUF
  3052.     MOV    BX, Offset FCB
  3053.     MOV    DX, Offset FCBBUF
  3054.     CALL    CMDLINE            ;parse name to CP/M format
  3055. ;
  3056. TNLP2:    CALL    MFNAME            ;search for names (wildcard format)
  3057.     JB    NEXTNM
  3058.     MOV    AL,Byte Ptr FCB+10     ;if CP/M 2 $sys file..
  3059.     AND    AL,80H            ;..do not send
  3060.     JNZ    TNLP2
  3061.     MOV    BX,Word Ptr NBSAVE     ;get name
  3062.     MOV    DX, FCB            ;move it to FCB
  3063.     XCHG    BX,DX
  3064.     MOV    CH,12
  3065.     CALL    MOVE
  3066.     XCHG    BX,DX
  3067.     MOV    Word Ptr NBSAVE,BX     ;addressof next name
  3068.     MOV    BX, Offset FILECT    ;count files found
  3069.     INC    Byte Ptr [BX]
  3070.     JMPS    TNLP2
  3071. ;.....
  3072. ;
  3073. ;
  3074. NEXTNM: MOV    BX, Offset NAMECT    ;count names found
  3075.     DEC    Byte Ptr [BX]
  3076.     JNZ    TNLP1
  3077.     MOV    BX, Offset NAMEBUF    ;save start of buffer
  3078.     MOV    Word Ptr NBSAVE,BX
  3079.     MOV    AL,Byte Ptr FILECT
  3080.     CMP    AL,64+1            ;no more than 64 transfers
  3081.     JNB    L4A9
  3082.     RET
  3083. L4A9:
  3084.     MOV    AL,64            ;only transfer first 64
  3085.     MOV    Byte Ptr FILECT,AL
  3086.     RET
  3087. ;.....
  3088. ;
  3089. ;
  3090. ; Tells when buffer is opened/closed for memory save to write on disk
  3091. ;
  3092. BUFMSG: CALL    ILPRT
  3093.     DB    CR,LF,'** Memory buffer ',0
  3094.     MOV    AL,Byte Ptr SAVEFLG
  3095.     OR    AL,AL
  3096.     JZ    BUFMSG1
  3097.     CALL    ILPRT
  3098.     DB    'open **',CR,LF,LF,';',0
  3099.     RET
  3100. ;
  3101. BUFMSG1:CALL    ILPRT
  3102.     DB    'closed **',CR,LF,LF,0
  3103.     RET
  3104. ;
  3105. BUFMSG2:CALL    ILPRT
  3106.     DB    CR,LF,'** Memory buffer available **',CR,LF,0
  3107.     RET
  3108. ;.....
  3109. ;
  3110. ;
  3111. ; Clear the screen and return to the menu command
  3112. ;
  3113. EXITMENU:
  3114.     CALL    CRLF
  3115.     CALL    CLREOS            ;clear line to clean up any mess
  3116.     JMP    MENU0
  3117. ;.....
  3118. ;
  3119. ;
  3120. ; Checks to see if the modem has a character ready
  3121. ;
  3122. RCVREADY:
  3123.     CALL    IN_MODCTL1
  3124.     CALL    ANI_MODRCVB
  3125.     JMP    CPI_MODRCVR
  3126. ;.....
  3127. ;
  3128. ;
  3129. ; Checks to see if the modem is ready to receive a character
  3130. ;
  3131. SENDRDY:CALL    IN_MODCTL1
  3132.     CALL    ANI_MODSNDB
  3133.     JMP    CPI_MODSNDR
  3134. ;.....
  3135. ;
  3136. ;
  3137. SENDNOW:CALL    EXITTEST        ;see if want to quit now
  3138.     CALL    SENDRDY            ;ready to send a character?
  3139.     JNZ    SENDNOW            ;if not ready wait some more
  3140.     RET                ;exit if ready
  3141. ;.....
  3142. ;
  3143. ;
  3144. ; Send the log-on message when requested
  3145. ;
  3146. SENDLOG:MOV    BX,Word Ptr LOGONPTR   ;'BX' points to start of logon message
  3147.     CALL    LOGLP
  3148.     JMP    TERML
  3149. ;...
  3150. ;
  3151. ;
  3152. LOGLP:    CALL    SENDNOW            ;wait until modem is ready
  3153.     MOV    AL,Byte Ptr [BX]    ;get logon byte
  3154.     OR    AL,AL            ;last character in string is '0'
  3155.     JNZ    L4A10
  3156.     RET                ;return if finished
  3157. L4A10:
  3158.     CALL    OUT_MODDATP        ;otherwise send the character
  3159.     CALL    LOGLP1            ;check for echo character and display it
  3160.     LAHF                ;next location in message
  3161.     INC    BX
  3162.     SAHF
  3163.     JMPS    LOGLP            ;get next character
  3164. ;.....
  3165. ;
  3166. ;
  3167. LOGLP1: CALL    JMP_INMODEM        ;get the echo character
  3168.     JNB    L4A11
  3169.     CALL    JMP_INMODEM        ;if none, try once more
  3170. L4A11:
  3171.     JNB    L4A12
  3172.     RET                ;if no character don't try to print
  3173. L4A12:
  3174.     AND    AL,7FH            ;strip off any parity
  3175.     JMP    STYPE             ;display the character, then return     
  3176. ;.....
  3177. ;
  3178. ;
  3179. ; Check for exit character
  3180. ;
  3181. EXITTEST:
  3182.     CALL    STAT            ;anything on keyboard?
  3183.     JNZ    L4A13
  3184.     RET
  3185. L4A13:
  3186.     CALL    KEYIN            ;get it, then
  3187.     MOV    CH,AL            ;save to protect the 'A' reg.
  3188. ;
  3189. EXITTST1:
  3190.     MOV    AL,EXITCHR        ;exit character
  3191.     CMP    AL,CH            ;asking to exit to menu?
  3192.     JZ    L4A14
  3193.     RET                ;if not, back to work
  3194. L4A14:
  3195.     POP    BX            ;clear the stack from 'CALL'
  3196.     JMPS    EXITMENU        ;exit to the menu
  3197. ;.....
  3198. ;
  3199. ;
  3200. LSTMSG: CALL    ILPRT
  3201.     DB    'Printer buffer is ',0
  3202.     MOV    AL,Byte Ptr LISTFLG    ;see if printer should be on or off
  3203.     OR    AL,AL
  3204.     JZ    LSTMSG1
  3205.     CALL    ILPRT
  3206.     DB    'ON',CR,LF,0
  3207.     RET
  3208. ;...
  3209. ;
  3210. ;
  3211. LSTMSG1:CALL    ILPRT
  3212.     DB    'OFF',CR,LF,0
  3213.     RET
  3214. ;.....
  3215. ;
  3216. ;
  3217. ; Special function key handler.     This routine is entered with the
  3218. ; function key number (0..9) in A.  The corresponding function key is
  3219. ; then transmitted.
  3220. ;
  3221. SENDFK: PUSH    BX            ;save register
  3222.     MOV    BX, Offset FNCTBL        ;point to function key codes
  3223. ;
  3224. SFK1:    CMP    AL,Byte Ptr [BX]    ;this the one?
  3225.     LAHF                ;point to next byte
  3226.     INC    BX
  3227.     SAHF
  3228.     JNZ    SFK1            ;loop until found
  3229.     CALL    LOGLP            ;send the char
  3230.     POP    BX
  3231.     XOR    AL,AL            ;reset the function flag
  3232.     MOV    Byte Ptr FNKFLG,AL
  3233.     JMPS    TERML
  3234. ;.....
  3235. ;
  3236. ;
  3237. ; Send keyboard character to modem, also to console if "E" or "L".  If
  3238. ; "E", include a LF after a CR, if either, include a LF if toggle is set.
  3239. ;
  3240. NOTOG:    CALL    SENDCHR            ;send char. in 'B' to modem
  3241.     MOV    AL,Byte Ptr LOCFLG     ;using the local mode?
  3242.     OR    AL,AL
  3243.     JNZ    LTYPE            ;if yes, show the character
  3244.     MOV    AL,Byte Ptr ECHOFLG    ;in echo mode?
  3245.     OR    AL,AL
  3246.     JZ    TERML            ;if not, see if it was a 'CR'
  3247. ;
  3248. LTYPE:    MOV    AL,CH            ;get the char. back
  3249.     CALL    STYPE             ;show on the local CRT
  3250.     CALL    CHKSAVE            ;to store local if buffer open
  3251.     CALL    CHKPRNT            ;put on printer if running
  3252. ;
  3253. CHKCR:    MOV    AL,CR
  3254.     CMP    AL,CH
  3255.     JNZ    TERML            ;if not cr, all done
  3256.     MOV    AL,Byte Ptr ECHOFLG    ;in echo mode now?
  3257.     OR    AL,AL
  3258.     JNZ    CHKLF            ;if yes add a line feed
  3259.     MOV    AL,Byte Ptr ADDLF      ;going to add a line feed in 'L' mode?
  3260.     OR    AL,AL
  3261.     JNZ    CHKLF
  3262.     JMP    TERM            ;if not, exit
  3263. ;
  3264. CHKLF:    MOV    CH,LF
  3265.     JMPS    NOTOG            ;send locally and to remote
  3266. ;.....
  3267. ;
  3268. ;
  3269. TERML:    CALL    RCVREADY        ;character on the receive-ready line?
  3270.     JZ    L4A16
  3271.     JMP    TERM            ;if not, exit
  3272. L4A16:
  3273.     CALL    IN_MODDATP        ;get the character
  3274.     AND    AL,7FH            ;strip parity
  3275.     JNZ    L4A17
  3276.     JMP    TERM            ;don't bother with nulls
  3277. L4A17:
  3278.     CMP    AL,RUB
  3279.     JNZ    L4A18
  3280.     JMP    TERM            ;don't bother with rubouts for fill
  3281. L4A18:
  3282.     MOV    CH,AL            ;store temporarily
  3283.     MOV    AL,Byte Ptr IGNORCTL   ;ignoring all but necessary ctl-chars?
  3284.     OR    AL,AL
  3285.     JZ    GIVLF            ;if zero, display them all
  3286.     MOV    AL,CH
  3287.     CMP    AL,' '
  3288.     JNB    GIVLF            ;display all printing characters
  3289.     CMP    AL,'G'-40H        ;^g for bell
  3290.     JNB    L4A19
  3291.     JMP    TERM            ;ignore ctl-characters less than ^g
  3292. L4A19:
  3293.     CMP    AL,CR+1
  3294.     JNAE    GIVLF
  3295.     JMP    TERM            ;ignore ctl-charsacters more than ^m
  3296. ;
  3297. GIVLF:    MOV    AL,CH            ;get the character back
  3298.     CALL    STYPE             ;show it on the CRT
  3299.     CALL    CHKSAVE            ;saving for disk file?
  3300.     CALL    CHKPRNT            ;printer running?
  3301.     MOV    AL,Byte Ptr ECHOFLG    ;going to echo the character?
  3302.     OR    AL,AL
  3303.     JZ    NOECH            ;if not, do not resend
  3304. ;
  3305. GIVLF1: CALL    SENDCHR            ;send char. in 'B' to modem
  3306. ;
  3307. NOECH:    MOV    AL,CR
  3308.     CMP    AL,CH            ;was it a 'CR' just now?
  3309.     JZ    L4A21
  3310.     JMP    TERM            ;if not, all done so exit
  3311. L4A21:
  3312.     MOV    AL,Byte Ptr ECHOFLG    ;in the echo mode?
  3313.     OR    AL,AL
  3314.     JNZ    L4A22
  3315.     JMP    TERM
  3316. L4A22:
  3317.     CALL    SENDNOW            ;modem ready for a character?
  3318.     MOV    CH,LF
  3319.     JMPS    GIVLF            ;send lf
  3320. ;.....
  3321. ;
  3322. ;
  3323. ; See if putting character into memory for a disk file
  3324. ;
  3325. CHKSAVE:MOV    AL,Byte Ptr SAVEFLG    ;saving to disk?
  3326.     OR    AL,AL
  3327.     JNZ    L4A23
  3328.     RET                ;if not, exit
  3329. L4A23:
  3330.     MOV    BX,Word Ptr HLSAVE    ;get last address
  3331.     MOV    Byte Ptr [BX],CH    ;store this character
  3332.     INC    BX            ;increment for next character
  3333.     MOV    Word Ptr HLSAVE,BX    ;remember that location
  3334.     MOV    AL,LF
  3335.     CMP    AL,CH            ;this character a line feed?
  3336.     JNZ    CHKSAVE1        ;..type ";" after each line feed..
  3337.     MOV    AL,CR            ;insure at left column with a lf
  3338.     CALL    STYPE
  3339.     CALL    TYPESCLN        ;show a ';' on CRT
  3340. ;
  3341. CHKSAVE1:
  3342.     MOV    AL,BH
  3343.     MOV    BX, Offset BUFTOP    ;get the address at top of buffer
  3344.     CMP    AL,BH
  3345.     JNZ    L4A24
  3346.     CALL    D_CTL_S            ;if different, buffer is not full
  3347. L4A24:
  3348.     RET
  3349. ;.....
  3350. ;
  3351. ;
  3352. ; Memory buffer is full, send a X-OFF (CTL-S, DC3), save any extra in-
  3353. ; coming characters, then dump to disk, reset buffer to include those
  3354. ; characters.
  3355. ;
  3356. D_CTL_S:CALL    SENDNOW            ;modem ready for a character?
  3357.     MOV    AL,XOFF            ;send a ctl-s to stop remote computer
  3358.     CALL    OUT_MODDATP
  3359.     CALL    CHKPRNT            ;insure character gets to the printer
  3360.     MOV    BX, offset BUFFDSK    ;address of aux. buffer
  3361.     CALL    GETDSK            ;put any extra chars. into aux. buffer
  3362.     PUSH    DX            ;save the number of aux. chars.
  3363.     MOV    AL,1            ;show we put something in the buffer..
  3364.     MOV    Byte Ptr WRFLG,AL      ;..to protect erasing an empty file
  3365.     MOV    BX,Word Ptr HLSAVE     ;find current end of buffer
  3366.     CALL    WRTDSK1            ;write the records
  3367.     POP    DX            ;get aux. char. count back
  3368.     MOV    BX, offset BUFFER    ;start again at bottom of buffer
  3369.     XOR    AL,AL            ;set 'A' to zero
  3370.     CMP    AL,DH            ;see if any count in 'D'
  3371.     JZ    D_CTL_Q            ;if nothing, exit and continue
  3372.     MOV    CX, offset BUFFDSK        ;address of aux. buffer
  3373. ;
  3374. ;
  3375. ; Move the characters from the auxiliary buffer to the main buffer and
  3376. ; display
  3377. ;
  3378. D_CTL_S1:
  3379.     MOV    SI,CX            ;get the character there
  3380.     MOV    AL,[SI]
  3381.     MOV    BYTE PTR [BX],AL    ;store in main buffer
  3382.     CALL    STYPE             ;show on CRT
  3383.     PUSH    BX
  3384.     PUSH    DX
  3385.     PUSH    CX
  3386.     LAHF
  3387.     XCHG    AL,AH
  3388.     PUSH    AX
  3389.     XCHG    AL,AH
  3390.     MOV    CH,AL
  3391.     CALL    CHKPRNT
  3392.     POP    AX            ;get the character again
  3393.     XCHG    AL,AH
  3394.     POP    CX
  3395.     POP    DX
  3396.     POP    BX
  3397.     CMP    AL,LF
  3398.     JNZ    L4A25
  3399.     CALL    TYPESCLN
  3400. L4A25:
  3401.     LAHF                ;next buffer position
  3402.     INC    BX
  3403.     SAHF
  3404.     LAHF                ;next aux. buffer position
  3405.     INC    CX
  3406.     SAHF
  3407.     DEC    DH            ;one less to go
  3408.     JNZ    D_CTL_S1        ;if not zero, keep going
  3409.     MOV    CH,0            ;falls through to 'CHKPRNT' next
  3410. ;
  3411. D_CTL_Q:MOV    Word Ptr HLSAVE,BX     ;next position to store in buffer       
  3412.     CALL    SENDNOW
  3413.     MOV    AL,XON            ;allow remote input to continue
  3414.     JMP    OUT_MODDATP
  3415. ;.....
  3416. ;
  3417. ;
  3418. ; Gets any incoming characters after sending an XOFF and stores at BX.
  3419. ; Returns with number of characters stored in D-reg.
  3420. ;
  3421. GETDSK: MOV    DH,0            ;character count in buffer
  3422.     MOV    DL,128            ;maximum for buffer length
  3423. ;
  3424. GETDSK1:CALL    JMP_INMODEM        ;get any character
  3425.     JNB    L4A26
  3426.     RET                ;if none, finished
  3427. L4A26:
  3428.     CMP    AL,' '
  3429.     JNB    GETDSK2            ;if greater, handle normally
  3430.     CMP    AL,CR+1            ;ignore ctl-chars. > cr
  3431.     JNB    GETDSK1
  3432. ;
  3433. GETDSK2:MOV    Byte Ptr [BX],AL    ;store
  3434.     LAHF                ;next buffer location to use
  3435.     INC    BX
  3436.     SAHF
  3437.     INC    DH            ;increment character count
  3438.     DEC    DL            ;room for one less
  3439.     JNZ    GETDSK1            ;if room in buffer, keep going
  3440.     RET                ;if buffer is filled, exit
  3441. ;.....    
  3442. ;
  3443. ;
  3444. ; See if printing the character, if yes, put into buffer
  3445. ;
  3446. CHKPRNT:MOV    AL,Byte Ptr LISTFLG    ;printer in use?
  3447.     OR    AL,AL
  3448.     JNZ    L4A27
  3449.     RET                ;return if not
  3450. L4A27:
  3451.     MOV    BX,Word Ptr HLSAVE1    ;get input address
  3452.     MOV    Byte Ptr [BX],CH    ;save this character there
  3453.     INC    BX            ;increment the buffer location
  3454.     MOV    Word Ptr HLSAVE1,BX    ;store for next character           
  3455.     MOV    AL,Byte Ptr MAXRAM     ;see if at top of buffer yet
  3456.     CMP    AL,BH
  3457.     JNZ    L4A28
  3458.     CALL    P_CTL_S            ;if different, buffer is not full
  3459. L4A28:
  3460.     RET
  3461. ;.....
  3462. ;
  3463. ;
  3464. ; Memory buffer is full, send a X-OFF (CTL-S, DC3), save any extra in-
  3465. ; coming characters, then dump to disk, reset buffer to include those
  3466. ; characters.
  3467. ;
  3468. P_CTL_S:CALL    SENDNOW            ;wait until modem is ready
  3469.     MOV    AL,XOFF            ;send a ctl-s to stop remote computer
  3470.     CALL    OUT_MODDATP
  3471.     MOV    BX, Offset BUFFPNT    ;address of aux. buffer
  3472.     CALL    GETDSK            ;put any extra chars. into aux. buffer
  3473.     MOV    AL,DH            ;get the aux. buffer char. count
  3474.     MOV    Byte Ptr DSTORE,AL    ;save for later
  3475.     RET
  3476. ;.....    
  3477. ;
  3478. ;
  3479. ; Output has now caught up to the input and both are at top of buffer
  3480. ;
  3481. P_CTL_S1:
  3482.     MOV    AL,Byte Ptr DSTORE     ;get the aux. buffer char. count
  3483.     MOV    DH,AL            ;put into 'D' reg.
  3484.     XOR    AL,AL            ;set 'A' to zero
  3485.     CMP    AL,DH            ;see if any count in 'D'
  3486.     MOV    BX, Offset PBUFF    ;address at start of printer buffer
  3487.     JZ    P_CTL_Q            ;if nothing, exit and continue
  3488.     MOV    CX, Offset BUFFPNT    ;address of aux. buffer
  3489. ;
  3490. ;
  3491. ; Move the characters from the aux. buffer to the main buffer and display
  3492. ;
  3493. P_CTL_S2:
  3494.     MOV    SI,CX            ;get the character there
  3495.     MOV    AL,[SI]
  3496.     MOV    Byte Ptr [BX],AL    ;store in main buffer
  3497.     CALL    STYPE             ;show on CRT
  3498.     PUSH    BX
  3499.     PUSH    DX
  3500.     PUSH    CX
  3501.     LAHF
  3502.     XCHG    AL,AH
  3503.     PUSH    AX
  3504.     XCHG    AL,AH
  3505.     MOV    CH,AL
  3506.     CALL    CHKSAVE
  3507.     POP    AX
  3508.     XCHG    AL,AH
  3509.     POP    CX
  3510.     POP    DX
  3511.     POP    BX
  3512.     CMP    AL,LF
  3513.     JNZ    L4A29
  3514.     CALL    TYPESCLN
  3515. L4A29:
  3516.     LAHF                ;next buffer position
  3517.     INC    BX
  3518.     SAHF
  3519.     LAHF                ;next aux. buffer position
  3520.     INC    CX
  3521.     SAHF
  3522.     DEC    DH            ;one less to go
  3523.     JNZ    P_CTL_S2        ;if not zero, keep going
  3524. ;
  3525. P_CTL_Q:MOV    Word Ptr HLSAVE1,BX    ;next position to store in buffer
  3526.     MOV    BX, Offset PBUFF    ;start of buffer location
  3527.     MOV    Word Ptr HLSAVE2,BX    ;output to start of buffer
  3528.     CALL    SENDNOW            ;wait until modem is ready
  3529.     MOV    AL,XON            ;send start character..
  3530.     JMP    OUT_MODDATP        ;..to remote computer, back to work
  3531. ;.....
  3532. ;
  3533. ;
  3534. ; Obtain Printer Status using Direct Bios Call
  3535.  
  3536. LISTST: PUSH    DX
  3537.     MOV    DX, OFFSET REGLIST
  3538.     MOV    Byte Ptr REGLIST,15    ; BIOS function 15
  3539.     MOV    Word Ptr REGLIST+1,0    ; Clear them anyway
  3540.     MOV    Word Ptr REGLIST+3,0    ; As MPM get upset
  3541.     MOV    CX,50            ; Direct Bios Call
  3542.     INT    224
  3543.     POP    DX
  3544.     RET
  3545.  
  3546. REGLIST DB    0    ;  Function Code
  3547.     DW    0    ;  value (CX)
  3548.     DW    0    ;  value (DX)
  3549. ;
  3550. ;
  3551. ;.....
  3552. ;
  3553. ;
  3554. ; List the character on the printer if it is ready, then see if at the
  3555. ; top of the buffer.
  3556. ;
  3557. GOLIST: CALL    LISTST            ;get the printer status
  3558.     OR    AL,AL
  3559.     JNZ    L4A30
  3560.     RET                ;return if printer not ready
  3561. ;
  3562. ;
  3563. ; Compare input and output pointers.  If at same address, nothing to
  3564. ; print.
  3565. ;
  3566. L4A30:    CALL    CMP_I_O            ;if the same, nothing to print
  3567.     JNZ    GOLIST1
  3568.     RET
  3569. ;
  3570. ;
  3571. ; If not the same, print the character
  3572. ;
  3573. GOLIST1:PUSH    BX            ;save current buffer address
  3574.     MOV    DL,Byte Ptr [BX]    ;get the character to display
  3575.     MOV    CL,BLIST        ;list routine
  3576.     INT    224
  3577.     POP    BX            ;restore current buffer address
  3578.     INC    BX            ;increment pointer for next position
  3579.     MOV    Word Ptr HLSAVE2,BX    ;store for next time through here
  3580. ;
  3581. ;
  3582. ; See if the output is at the end of the buffer now.  If yes, go put
  3583. ; the auxiliary characters into the start of the buffer.
  3584. ;
  3585.     MOV    AL,Byte Ptr MAXRAM     ;check for end of buffer area
  3586.     CMP    AL,BH
  3587.     JNZ    L4A32
  3588.     JMP    P_CTL_S1        ;if at end, restore aux. buffer
  3589. L4A32:
  3590. ;
  3591. ;
  3592. ; See if the output has caught up with the input - if so, reset the
  3593. ; pointers to the start of the buffer
  3594. ;
  3595.     CALL    CMP_I_O
  3596.     JZ    L4A33
  3597.     RET                ;if not, back to work
  3598. L4A33:
  3599.     MOV    BX, Offset PBUFF    ;if output caught input, reset both..
  3600.     MOV    Word Ptr HLSAVE1,BX    ;..to bottom of buffer to start over
  3601.     MOV    Word Ptr HLSAVE2,BX
  3602.     RET
  3603. ;.....
  3604. ;
  3605. ;
  3606. ; Compare the input and output pointers to see if the same address
  3607. ;
  3608. CMP_I_O:MOV    BX,Word Ptr HLSAVE1    ;get input pointer address
  3609.     XCHG    BX,DX            ;put in 'DE'
  3610.     MOV    BX,Word Ptr HLSAVE2    ;get output pointer address
  3611.     MOV    AL,BH
  3612.     CMP    AL,DH
  3613.     JZ    L4A34
  3614.     RET                ;return if different
  3615. L4A34:
  3616.     MOV    AL,BL
  3617.     CMP    AL,DL
  3618.     RET
  3619. ;.....
  3620. ;
  3621. ;
  3622. GETMAX: MOV    AL,Byte Ptr BDOS+2     ;'MSP' of 'BDOS' address
  3623.     MOV    Byte Ptr MAXRAM,AL     ;save
  3624.     RET
  3625. ;.....
  3626. ;
  3627. ;
  3628. ; This subroutine will loop until the modem receives a character or 100
  3629. ; milliseconds.     It returns with a character in 'A' reg. but if no char-
  3630. ; acter was recieved it returns after a timeout with carry set.
  3631. ;
  3632. INMODEM:
  3633.     PUSH    BX
  3634.     MOV    BX,33            ;about 100 milliseconds
  3635.     CALL    FIXCNT
  3636.     MOV    CH,BH            ;delay is in 'BX'
  3637.     MOV    CL,BL            ;transfer to 'BC'
  3638.     POP    BX            ;get original value of 'BX' back
  3639. ;
  3640. INMODEM1:
  3641.     CALL    RCVREADY        ;see if there is a character ready
  3642.     JNZ    INMODEM2        ;if no character, exit
  3643.     CALL    IN_MODDATP        ;get the character
  3644.     AND    AL,7FH            ;strip off any parity
  3645.     RET                ;return with character in 'A' reg.
  3646. ;
  3647. INMODEM2:
  3648.     DEC    CX            ;otherwise keep timing
  3649.     MOV    AL,CH
  3650.     OR    AL,CL
  3651.     JNZ    INMODEM1        ;loop until timeout if needed
  3652.     STC                ;shows a timeout occured
  3653.     RET
  3654. ;.....
  3655. ;
  3656. ;
  3657. ; Send a space tone to the phone line for a short time.
  3658. ;
  3659. BREAK:    MOV    AL,Byte Ptr PMMIMODEM  ;using the PMMI modem?  
  3660.     OR    AL,AL
  3661.     JZ    BREAK1            ;if not, exit
  3662.     MOV    AL,Byte Ptr MODCTLB    ;get the last modem control byte
  3663.     AND    AL,BRKMSK        ;set the transmit break bit low
  3664.     CALL    OUT_MODCTL2        ;send it to the modem
  3665.     MOV    CH,2
  3666.     CALL    TIMER            ;send a space tone for 200 ms.
  3667.     MOV    AL,Byte Ptr MODCTLB    ;get the last modem control byte
  3668.     CALL    OUT_MODCTL2        ;restore to normal
  3669.     JMP    TERM            ;back to work
  3670. ;...
  3671. ;
  3672. ;
  3673. BREAK1: CALL    JMP_BREAK        ;get the user'S BREAK ROUTINE
  3674.     JMP    TERM            ;back to work    
  3675. ;.....
  3676. ;
  3677. ;
  3678. ;=======================================================================
  3679. ;             WRITE BUFFER TO DISK
  3680. ;
  3681. ; Make sure this record is included in the count.
  3682. ;
  3683. WRTDSK: MOV    BX,Word Ptr HLSAVE
  3684.     MOV    Byte Ptr [BX],EOFCHAR    ;ascii file, store end-of-file char.
  3685.     MOV    DX,127
  3686.     ADD    BX,DX
  3687. ;
  3688. WRTDSK1:MOV    DX,-( Offset BUFFER)    ;subtract the start of the buffer..
  3689.     ADD    BX,DX            ;by adding a minus number to buffer end
  3690.     MOV    AL,BL            ;divide hl by 128..
  3691.     OR    AL,AL
  3692.     RCL    AL,1            ;..to get the..
  3693.     MOV    BL,BH            ;..number of records
  3694.     MOV    BH,0
  3695.     LAHF
  3696.     XCHG    AL,AH
  3697.     PUSH    AX
  3698.     SHL    BX,1
  3699.     POP    AX
  3700.     XCHG    AL,AH
  3701.     SAHF
  3702.     MOV    AL,0
  3703.     ADC    AL,BL
  3704.     MOV    BL,AL            ;number of records in 'BX'
  3705. ;
  3706. ;
  3707. ; See if buffer is empty.  If yes, see if we need to erase an empty
  3708. ; file or have already written something.
  3709. ;
  3710.     MOV    DX, Offset BUFFER
  3711.     MOV    SI,DX
  3712.     MOV    AL,[SI]
  3713.     CMP    AL,EOFCHAR        ;'EOF' in first address means..
  3714.     JNZ    WRTDSK2            ;..nothing in buffer to write
  3715.     MOV    AL,Byte Ptr WRFLG      ;first time by this way?
  3716.     OR    AL,AL
  3717.     JZ    NOWRITE            ;if yes, show erasing file
  3718.     RET                ;otherwise go close file
  3719. ;.....
  3720. ;    
  3721. ;
  3722. ; Write to disk.  Start from BUFFER (in 'DE').    Number of records to
  3723. ; write in 'BX'.
  3724. ;
  3725. WRTDSK2:MOV    CL,SETDMA
  3726.     CALL    BDOSRT
  3727.     PUSH    DX
  3728.     MOV    CL,WRITE
  3729.     MOV    DX, Offset FCB3        ;location of filename to write to
  3730.     CALL    BDOSRT
  3731.     POP    DX
  3732.     OR    AL,AL
  3733.     JNZ    WRTDSK2A        ;error if disk is full ** special patch
  3734.     XCHG    BX,DX            ;put the current address in 'BX'..
  3735.     PUSH    DX            ;..and number of records left in..
  3736.     MOV    DX,128            ;..for now
  3737.     ADD    BX,DX            ;add for next record write, now in 'BX'
  3738.     POP    DX            ;restore number of records left
  3739.     XCHG    BX,DX            ;records to 'BX' again, address to 'DE' 
  3740.     DEC    BX            ;one less record left
  3741.     MOV    AL,BH
  3742.     OR    AL,BL            ;done writing when 'H' and 'H' both zero
  3743.     JNZ    WRTDSK2            ;otherwise do another disk write
  3744.     RET
  3745. ;
  3746. WRTDSK2A:
  3747.     JMP    WRERRSP
  3748.     
  3749. ;.....
  3750. ;
  3751. ;
  3752. ; Error while writing a record, show why it is aborting
  3753. ;
  3754. WRERR:    MOV    CL,CANCEL        ;send cancel char. to sending station
  3755.     CALL    SEND
  3756.     CALL    CLOSFIL            ;close the current file
  3757. WRERR1: CALL    ERXIT            ;also will reset stack
  3758.     DB    '++ DISK FULL, SAVING PARTIAL FILE ++','$'
  3759. ;.....
  3760. ;
  3761. ;
  3762. ; If no data to store on the disk, close the empty file and erase it
  3763. ;
  3764. NOWRITE:CALL    WRTFIL2            ;close the empty file
  3765.     CALL    NOASK            ;erase the empty file
  3766.     CALL    ILPRT
  3767.     DB    '++ Nothing to save, erasing file ++'
  3768.     DB    CR,LF,BELL,0
  3769.     JMP    DONETCA            ;reset any flags, return to menu
  3770. ;.....
  3771. ;
  3772. ;
  3773. ; Show you are in memory-save for disk write
  3774. ;
  3775. TYPESCLN:
  3776.     MOV    AL,';'
  3777.     JMP    STYPE             ;show on CRT, return
  3778. ;.....
  3779. ;
  3780. ;
  3781. ; Save the registers, call BDOS then restore the registers
  3782. ;
  3783. BDOSRT: PUSH    CX
  3784.     PUSH    DX
  3785.     PUSH    BX
  3786.     INT    224
  3787.     POP    BX
  3788.     POP    DX
  3789.     POP    CX
  3790.     RET
  3791. ;.....
  3792. ;
  3793. ;
  3794. INITFCB:MOV    Byte Ptr [BX],0        ;entry at +2 will leave drive # intact
  3795. L4A6:    INC    BX            ;will initialize an FCB..
  3796.     MOV    CH,11            ;..pointed to by BX-reg. fills 1st pos.
  3797. ;
  3798. LOOP11: MOV    Byte Ptr [BX],' '    ;..with 0, next 11 with..
  3799.     INC    BX            ;..blanks, and last..
  3800.     DEC    CH            ;..21 with nulls.
  3801.     JNZ    LOOP11
  3802.     MOV    CH,21
  3803. ;
  3804. LOOP21: MOV    Byte Ptr [BX],0
  3805.     INC    BX
  3806.     DEC    CH
  3807.     JNZ    LOOP21
  3808.     RET
  3809. ;.....
  3810. ;
  3811. ;
  3812. ; Scans CMDBUF coutning names and putting delimiter (space) after last
  3813. ; name
  3814. ;
  3815. SCAN:    PUSH    BX
  3816.     MOV    BX, Offset NAMECT
  3817.     MOV    Byte Ptr [BX],0
  3818.     MOV    BX, Offset CMDBUF+1    ;find end of cmd line..
  3819.     MOV    CL,Byte Ptr [BX]    ;..and put space there.
  3820.     MOV    CH,0
  3821.     MOV    BX, Offset CMDBUF+2
  3822.     LAHF
  3823.     ADD    BX,CX
  3824.     RCR    SI,1
  3825.     SAHF
  3826.     RCL    SI,1
  3827.     MOV    Byte Ptr [BX],' '
  3828.     MOV    BX, Offset CMDBUF+1
  3829.     MOV    CH,Byte Ptr [BX]
  3830.     INC    CH
  3831.     INC    CH
  3832. ;
  3833. SCANLP1:LAHF
  3834.     INC    BX
  3835.     SAHF
  3836.     DEC    CH
  3837.     JZ    DNSCAN
  3838.     MOV    AL,Byte Ptr [BX]
  3839.     CMP    AL,' '
  3840.     JNZ    SCANLP1
  3841. ;
  3842. SCANLP2:LAHF                ;eat extra spaces
  3843.     INC    BX
  3844.     SAHF
  3845.     DEC    CH
  3846.     JZ    DNSCAN
  3847.     MOV    AL,Byte Ptr [BX]
  3848.     CMP    AL,' '
  3849.     JZ    SCANLP2
  3850.     MOV    Word Ptr BGNMS,BX      ;save start of names in cmdbuf
  3851.     INC    CH
  3852.     LAHF
  3853.     DEC    BX
  3854.     SAHF
  3855. ;
  3856. SCANLP3:LAHF
  3857.     INC    BX
  3858.     SAHF
  3859.     DEC    CH
  3860.     JZ    DNSCAN
  3861.     MOV    AL,Byte Ptr [BX]
  3862.     CMP    AL,' '
  3863.     JNZ    SCANLP3
  3864.     MOV    AL,Byte Ptr NAMECT     ;counts names
  3865.     INC    AL
  3866.     MOV    Byte Ptr NAMECT,AL
  3867. ;
  3868. SCANLP4:LAHF                ;eat spaces
  3869.     INC    BX
  3870.     SAHF
  3871.     DEC    CH
  3872.     JZ    DNSCAN
  3873.     MOV    AL,Byte Ptr [BX]
  3874.     CMP    AL,' '
  3875.     JZ    SCANLP4
  3876.     JMPS    SCANLP3
  3877. ;.....
  3878. ;
  3879. ;
  3880. DNSCAN: MOV    Byte Ptr [BX],' '    ;space after last char
  3881.     POP    BX
  3882.     RET
  3883. ;.....
  3884. ;
  3885. ;
  3886. ; Places next name in buffer so 'CMDLINE' may parse it
  3887. ;
  3888. TRTOBUF:MOV    BX,Word Ptr BGNMS
  3889.     MOV    CH,0
  3890.     MOV    DX, Offset FCBBUF+2
  3891. ;
  3892. TBLP:    MOV    AL,Byte Ptr [BX]
  3893.     CMP    AL,' '
  3894.     JZ    TRBFEND
  3895.     MOV    SI,DX
  3896.     MOV    [SI],AL
  3897.     INC    BX
  3898.     INC    DX
  3899.     INC    CH            ;count chars in name
  3900.     JMPS    TBLP
  3901. ;.....
  3902. ;
  3903. ;
  3904. TRBFEND:INC    BX
  3905.     MOV    AL,Byte Ptr [BX]    ;eat extra spaces
  3906.     CMP    AL,' '
  3907.     JZ    TRBFEND
  3908.     MOV    Word Ptr BGNMS,BX
  3909.     MOV    BX, Offset FCBBUF+1    ;put # chars before name
  3910.     MOV    Byte Ptr [BX],CH
  3911.     RET
  3912. ;.....
  3913. ;
  3914. ;
  3915. CKCPM2: MOV    CL,CPMVER        ;bdos 12 -- version number -- cp/m 2.2?
  3916.     INT    224
  3917.     OR    AL,AL
  3918.     JNZ    L5A2
  3919.     RET
  3920. L5A2:
  3921.     MOV    CL,SETDMA
  3922.     MOV    DX, Offset TBUF
  3923.     INT    224
  3924.     MOV    CL,SRCHF
  3925.     MOV    DX, Offset FCB
  3926.     INT    224
  3927.     CMP    AL,0FFH
  3928.     JNZ    L5A3
  3929.     RET
  3930. L5A3:
  3931. ;
  3932.     CALL    GETADD
  3933.     MOV    DX,9
  3934.     ADD    BX,DX            ;point to R/O attribute byte
  3935.     MOV    AL,Byte Ptr [BX]
  3936.     AND    AL,80H            ;test most significant byte
  3937.     JNZ    MKCHG            ;if set, make change
  3938.     INC    BX            ;check system attribute byte
  3939.     MOV    AL,Byte Ptr [BX]
  3940.     AND    AL,80H
  3941.     JNZ    L5A4
  3942.     RET                ;not $SYS or $R/O attribute
  3943. L5A4:
  3944.     DEC    BX
  3945. ;
  3946. MKCHG:    MOV    DX,-8
  3947.     ADD    BX,DX            ;point BX to filename + 1
  3948.     MOV    DX, Offset FCB+1    ;move directory name to FCB..
  3949.     MOV    CH,11            ;..without changing drive.
  3950.     CALL    MOVE
  3951.     MOV    BX, Offset FCB+9    ;R/O attribute
  3952.     MOV    AL,Byte Ptr [BX]
  3953.     AND    AL,7FH            ;strip R/O attribute
  3954.     MOV    Byte Ptr [BX],AL
  3955.     INC    BX            ;system attribute
  3956.     MOV    AL,Byte Ptr [BX]
  3957.     AND    AL,7FH
  3958.     MOV    Byte Ptr [BX],AL
  3959.     MOV    DX, FCB
  3960.     MOV    CL,30            ;set new attributes in directory
  3961.     INT    224
  3962.  
  3963. ;
  3964. ; Called by 'CKBAKUP' below, return done here .
  3965. ;
  3966. PLANCHG:MOV    BX, FCB            ;change name to type "BAK"
  3967.     MOV    DX, FCB2
  3968.     MOV    CH,9            ;move drive and name (not type)
  3969.     CALL    MOVE
  3970.     MOV    BX,75H            ;start of type in FCB2
  3971.     MOV    Byte Ptr [BX],'B'
  3972.     INC    BX
  3973.     MOV    Byte Ptr [BX],'A'
  3974.     INC    BX
  3975.     MOV    Byte Ptr [BX],'K'
  3976.     MOV    DX, FCB2
  3977.     MOV    CL,ERASE        ;erase any previous backups
  3978.     INT    224
  3979.     MOV    BX, FCB2        ;FCB2 drive field should..
  3980.     MOV    Byte Ptr [BX],0        ;..0 for rename.
  3981.     MOV    DX, FCB
  3982.     MOV    CL,23            ;rename
  3983.     INT    224
  3984.     RET
  3985. ;.....
  3986. ;
  3987. ;
  3988. CKBAKUP:MOV    AL,Byte Ptr BAKUPBYTE
  3989.     OR    AL,AL
  3990.     JNZ    L5A5
  3991.     RET
  3992. L5A5:
  3993.     MOV    CL,SRCHF
  3994.     MOV    DX, FCB
  3995.     INT    224
  3996.     INC    AL
  3997.     JNZ    L5A6
  3998.     RET                ;file not found
  3999. L5A6:
  4000.     JMPS    PLANCHG            ;in 'CKCPM2' - ret done there
  4001. ;.....
  4002. ;
  4003. ;
  4004. ;***********************************************************************
  4005. ;
  4006. ;        RECEIVE A RECORD FROM SENDING STATION
  4007. ;
  4008. ;***********************************************************************
  4009. ;
  4010. ; If CRC is in effect, there is a 10-second timeout to the first SOH.  
  4011. ; It then tries six more times to let the sender know the system is
  4012. ; capable of receiving a 'CRC' check.  At the end of that time a NAK is
  4013. ; sent which tells the sender to use CHECKSUM checking instead of CRC.
  4014. ; This allows automatic compatability with systems implementing CRC -
  4015. ; (Cyclic Redundancy Checking).     The search for SOH will cycle through
  4016. ; one record interval and ignore noise or characters sent by the remote
  4017. ; for any purpose (such as progress reporting).     So extraneous characters
  4018. ; that are sometimes sent by remote-end protocol will be gobbled up until
  4019. ; the first SOH.  EOT is tested only as the first returned character af-
  4020. ; ter each sector.
  4021. ;
  4022. SRCHSOH EQU    160            ;number of times to loop search for SOH
  4023. ;
  4024. RCVRECD:MOV    AL,1
  4025.     MOV    Byte Ptr ERRCT,AL      ;initialize the error count
  4026. ;
  4027. RCVSQ:    MOV    CH,10            ;10 seconds allowed to receive 1st char.
  4028.     MOV    DX,SRCHSOH        ;initialize loof for up to 160 secs.    
  4029.     CALL    RECV            ;get the 1st character
  4030.     JNB    L5A7
  4031.     JMP    RCVSTOT            ;timeout error if not rcvd in 10 seconds
  4032. L5A7:
  4033.     MOV    CL,AL            ;save the character for now
  4034.     CMP    AL,EOT            ;see if end of transmission
  4035.     STC                ;set carry
  4036.     JNZ    L5A8
  4037.     RET                ;return with carry set
  4038. L5A8:
  4039. ;
  4040. SOHLUP: MOV    AL,0FFH
  4041.     MOV    Byte Ptr CHRFLG,AL
  4042.     MOV    Byte Ptr TIMFLG,AL
  4043.     MOV    AL,DL            ;get search count-down value
  4044.     CMP    AL,SRCHSOH        ;see if it is the 1st returned character
  4045.     MOV    AL,CL            ;get the first character now
  4046.     JZ    NORECV            ;skip RECV routine if 1st character
  4047.     MOV    CH,1
  4048.     CALL    RECV
  4049.     MOV    CH,AL
  4050.     JNB    TSTSOH
  4051. ;
  4052. NORECV: MOV    CH,AL
  4053.     XOR    AL,AL            ;else set the value that forces timeoutw
  4054.     MOV    Byte Ptr CHRFLG,AL
  4055. ;
  4056. TSTSOH: MOV    AL,CH            ;get the character
  4057.     CMP    AL,SOH            ;see if it is SOH
  4058.     LAHF
  4059.     XCHG    AL,AH
  4060.     PUSH    AX
  4061.     XCHG    AL,AH
  4062.     XOR    AL,AL
  4063.     MOV    Byte Ptr TIMFLG,AL     ;restore this flag
  4064.     POP    AX
  4065.     XCHG    AL,AH
  4066.     SAHF
  4067.     JNZ    L5A9
  4068.     JMP    RCVSOH            ;got SOH, get rcd # and its complement
  4069. L5A9:
  4070.     MOV    AL,DH
  4071.     OR    AL,DL            ;see if counted-down to zero        
  4072.     LAHF
  4073.     DEC    DX
  4074.     SAHF
  4075.     JNZ    SOHLUP            ;go around again if not
  4076.     MOV    AL,Byte Ptr CHRFLG     ;see if timeout needs to be forced
  4077.     OR    AL,AL
  4078.     JNZ    L5A10
  4079.     JMP    RCVSTOT            ;go do timeout and countthem
  4080. L5A10:
  4081.     MOV    AL,Byte Ptr QFLG
  4082.     OR    AL,AL
  4083.     JZ    RCVSERR
  4084. ;
  4085. RCVSEH: CALL    CRLF
  4086.     MOV    AL,CH
  4087.     CALL    HEXO
  4088.     CALL    ILPRT
  4089.     DB    'H received not SOH - ',0
  4090. ;
  4091. RCVPRN: CALL    SHOWERR            ;display error count
  4092. ;
  4093. RCVSERR:CALL    WAITQ1            ;wait for 1 second with no characters
  4094.     CALL    CKABORT            ;want to stop receiving now?
  4095.     MOV    AL,Byte Ptr CRCFLAG    ;get 'CRC' flag
  4096.     OR    AL,AL            ;'CRC' in effect?
  4097.     MOV    AL,NAK            ;put 'NAK' in 'A' reg.
  4098.     JZ    RCVSER1            ;no, send the 'NAK'
  4099.     MOV    AL,Byte Ptr FIRSTME    ;get first time switch
  4100.     OR    AL,AL            ;has first 'SOH' been received?
  4101.     MOV    AL,NAK            ;put 'NAK' in 'A' reg.
  4102.     JNZ    RCVSER1            ;yes, then send 'NAK'
  4103.     MOV    AL,CRC            ;tell sender 'CRC' is in effect
  4104. ;
  4105. RCVSER1:CALL    SEND            ;..the 'NAK' or 'CRC' request
  4106.     MOV    AL,Byte Ptr ERRCT      ;abort if we have reached error limit
  4107.     INC    AL
  4108.     MOV    Byte Ptr ERRCT,AL      ;store for next time
  4109.     CMP    AL,ERRLIM        ;see if at limit yet
  4110.     JNB    L5A11
  4111.     JMP    RCVSQ            ;if not, keep going
  4112. L5A11:
  4113.     MOV    AL,Byte Ptr RETRY      ;see if retry after 10 errors is set
  4114.     OR    AL,AL
  4115.     JNZ    L5A12
  4116.     JMP    ABORT            ;if 'YES', abort
  4117. L5A12:
  4118.     JMP    CKQUIT            ;if 'NO' check for continued use
  4119.  
  4120. RCVSABT:MOV    SP,STACK        ;reset the stack just in case
  4121.     CALL    CLOSFIL            ;close the partial file
  4122.     CALL    NOASK            ;delete partial file
  4123.     CALL    ILPRT
  4124.     DB    CR,LF,LF
  4125.     DB    '++ RECEIVED FILE CANCELLED ++',CR,LF,BELL
  4126.     DB    '++ UNFINISHED FILE DELETED ++',CR,LF,0
  4127.     JMP    DONETCA
  4128.  
  4129. RCVSTOT:MOV    AL,Byte Ptr QFLG
  4130.     OR    AL,AL
  4131.     JZ    RCVSCRC
  4132. ;
  4133. RCVSPT: CALL    ILPRT
  4134.     DB    CR,LF,'++ Timeout ',0
  4135.     CALL    SHOWERR
  4136. ;
  4137. RCVSCRC:CALL    RCVSCRC2
  4138.     JMP    RCVSERR
  4139. ;
  4140. ;
  4141. ; Routine will switch from 'CRC' to Checksum if 'ERCNT' reaches 'ERRCRC'
  4142. ; and 'FIRSTIME' is false
  4143. ;
  4144. RCVSCRC2:
  4145.     MOV    AL,Byte Ptr ERRCT
  4146.     CMP    AL,ERRCRC
  4147.     JZ    L5A13
  4148.     RET
  4149. L5A13:
  4150.     MOV    AL,Byte Ptr FIRSTME
  4151.     OR    AL,AL
  4152.     JZ    L5A14
  4153.     RET
  4154. L5A14:
  4155.     MOV    AL,Byte Ptr CRCFLAG
  4156.     OR    AL,AL
  4157.     JNZ    L5A15
  4158.     RET
  4159. L5A15:
  4160.     NOT    AL
  4161.     MOV    Byte Ptr CRCFLAG,AL
  4162.     MOV    Byte Ptr CRCDFLT,AL
  4163.     CALL    ILPRTQ
  4164.     DB    '** Switching to Checksum mode **',CR,BELL,LF,0
  4165.     RET
  4166. ;.....
  4167. ;
  4168. ;
  4169. ; Got SOH - get block #, block # complemented
  4170. ;
  4171. RCVSOH: MOV    AL,0FFH
  4172.     MOV    Byte Ptr FIRSTME,AL    ;indicate 1st soh was received
  4173.     MOV    CH,5            ;timeout = 5 seconds
  4174.     CALL    RECV            ;get record
  4175.     JB    RCVSTOT            ;got timeout
  4176.     MOV    DH,AL
  4177.     MOV    CH,5            ;timeout = 5 seconds
  4178.     CALL    RECV
  4179.     JNB    L5A16
  4180.     JMP    RCVSTOT
  4181. L5A16:
  4182.     NOT    AL
  4183.     CMP    AL,DH
  4184.     JZ    RCVDATA
  4185.     MOV    AL,Byte Ptr QFLG
  4186.     OR    AL,AL
  4187.     JNZ    RCVBSE
  4188.     JMP    RCVSERR
  4189. ;
  4190. RCVBSE: CALL    ILPRT
  4191.     DB    CR,LF,'++ Bad record # in header ',0
  4192.     JMP    RCVPRN
  4193. ;
  4194. RCVDATA:MOV    AL,DH
  4195.     MOV    Byte Ptr RCVRNO,AL
  4196.     MOV    AL,1
  4197.     MOV    Byte Ptr DATAFLG,AL
  4198.     MOV    CL,0
  4199.     MOV    BX,0
  4200.     MOV    Word Ptr CRCVAL,BX
  4201.     MOV    BX,80H
  4202. ;
  4203. RCVCHR: MOV    CH,5            ;Wait up to 5 seconds for a character
  4204.     CALL    RECV
  4205.     JNB    L5A18
  4206.     JMP    RCVSTOT
  4207. L5A18:
  4208.     MOV    Byte Ptr [BX],AL
  4209.     INC    BL
  4210.     JNZ    RCVCHR
  4211.     XOR    AL,AL
  4212.     MOV    Byte Ptr DATAFLG,AL
  4213.     MOV    AL,Byte Ptr CRCFLAG
  4214.     OR    AL,AL
  4215.     JNZ    RCVCRC
  4216.     MOV    DH,CL
  4217.     MOV    CH,5            ;wait up to 5 seconds for an answer
  4218.     CALL    RECV
  4219.     JNB    L5A19
  4220.     JMP    RCVSTOT
  4221. L5A19:
  4222.     CMP    AL,DH
  4223.     JNZ    RCVCERR
  4224. ;
  4225. CHKSNUM:MOV    AL,Byte Ptr RCVRNO
  4226.     MOV    CH,AL
  4227.     MOV    AL,Byte Ptr RECDNO
  4228.     CMP    AL,CH
  4229.     JZ    RECVACK
  4230.     INC    AL
  4231.     CMP    AL,CH
  4232.     JZ    L5A20
  4233.     JMP    ABORT
  4234. L5A20:
  4235.     RET
  4236. ;.....
  4237. ;
  4238. ;
  4239. RCVCRC: MOV    DL,2            ;number of 'CRC' bytes
  4240. ;
  4241. RCVCRC2:MOV    CH,5            ;wait up to 5 seconds for a character
  4242.     CALL    RECV
  4243.     JNB    L5A21
  4244.     JMP    RCVSTOT
  4245. L5A21:
  4246.     DEC    DL
  4247.     JNZ    RCVCRC2
  4248.     CALL    CRCCHK
  4249.     OR    AL,AL
  4250.     JZ    CHKSNUM
  4251.     MOV    AL,Byte Ptr QFLG
  4252.     OR    AL,AL
  4253.     JNZ    L5A22
  4254.     JMP    RCVSERR
  4255. L5A22:
  4256. ;
  4257. RCVCRER:CALL    ILPRT
  4258.     DB    '++ CRC error ',0
  4259.     JMP    RCVPRN
  4260. ;
  4261. RCVCERR:MOV    AL,Byte Ptr QFLG
  4262.     OR    AL,AL
  4263.     JNZ    RCVCPR
  4264.     JMP    RCVSERR
  4265. ;
  4266. RCVCPR: CALL    ILPRT
  4267.     DB    '++ CHECKSUM error ',0
  4268.     JMP    RCVPRN
  4269. ;
  4270. RECVACK:CALL    SENDACK
  4271.     JMP    RCVRECD
  4272. ;
  4273. ;
  4274. ; Get the error count and display on CRT
  4275. ;
  4276. SHOWERR:PUSH    BX
  4277.     MOV    BX,Word Ptr ERRCT
  4278.     MOV    BH,0
  4279.     CALL    DECOUT
  4280.     POP    BX
  4281.     CALL    ILPRT
  4282.     DB    ' ++',CR,LF,0
  4283.     MOV    AL,Byte Ptr ERRCT
  4284.     CMP    AL,ERRLIM
  4285.     JNAE    L5A24
  4286.     JMP    ABORT
  4287. L5A24:
  4288.     RET
  4289. ;.....    
  4290. ;
  4291. ;
  4292. SENDHDR:MOV    AL,Byte Ptr QFLG
  4293.     OR    AL,AL
  4294.     JZ    SENDHNM
  4295.     CALL    ILPRT
  4296.     DB    CR,'Sending # ',0
  4297.     PUSH    BX            ;store current address
  4298.     MOV    BX,Word Ptr RECDNO     ;get record number
  4299.     CALL    DECOUT            ;print it in decimal
  4300.     CALL    ILPRT
  4301.     DB    ' ',0
  4302. ;
  4303.     MOV    AL,Byte Ptr HEXSHOW
  4304.     OR    AL,AL
  4305.     JZ    L5A25
  4306.     CALL    ILPRT
  4307.     DB    '(',0
  4308.     CALL    DHXOUT            ;16 bit hex conversion & output
  4309.     CALL    ILPRT
  4310.     DB    'H) ',0
  4311. L5A25:
  4312. ;
  4313.     POP    BX            ;restore current address
  4314. ;
  4315. SENDHNM:MOV    AL,SOH            ;send 'SOH' character to the output
  4316.     CALL    SEND
  4317.     MOV    AL,Byte Ptr RECDNO     ;send record number to the output
  4318.     CALL    SEND
  4319.     MOV    AL,Byte Ptr RECDNO
  4320.     NOT    AL            ;complement the record number
  4321.     JMP    SEND            ;send this value to the output
  4322. ;.....
  4323. ;
  4324. ;
  4325. SENDREC:MOV    AL,1
  4326.     MOV    Byte Ptr DATAFLG,AL
  4327.     MOV    CL,0
  4328.     MOV    BX,0            ;new record, clear 'CHECKSUM' value
  4329.     MOV    Word Ptr CRCVAL,BX    ;new record, clear 'CRC' value
  4330.     MOV    BX, Offset TBUF        ;store at 0080H
  4331. ;
  4332. SENDC:    MOV    AL,Byte Ptr [BX]
  4333.     CALL    SEND
  4334.     INC    BL
  4335.     JNZ    SENDC
  4336.     XOR    AL,AL
  4337.     MOV    Byte Ptr DATAFLG,AL
  4338.     RET
  4339. ;.....
  4340. ;
  4341. ;
  4342. SENDCKS:MOV    AL,CL
  4343.     JMP    SEND
  4344. ;.....
  4345. ;
  4346. ;
  4347. SENDCRC:PUSH    BX
  4348.     MOV    BX,Word Ptr CRCVAL
  4349.     MOV    AL,BH
  4350.     CALL    SEND
  4351.     MOV    AL,BL
  4352.     CALL    SEND
  4353.     POP    BX
  4354.     XOR    AL,AL            ;reset the carry bit
  4355.     RET
  4356. ;.....
  4357. ;
  4358. ;
  4359. ; After a record is sent, a character is returned telling if it was re-
  4360. ; ceived properly or not.  An ACK allows the next record to be sent.  A
  4361. ; NAK causes the current record to be resent.  If no character (or any
  4362. ; character other than ACK or NAK) is received after a short wait (10
  4363. ; to 12 seconds), a timeout error message is shown and the record will
  4364. ; be resent.  The GETACK routine can gobble up a string of up to 191
  4365. ; characters while searching for an 'ACK' or a 'NAK'.
  4366. ;
  4367. GETACK: MOV    DL,192            ;number of characters to gobble
  4368. ;
  4369. ACKLUP: MOV    AL,0FFH
  4370.     MOV    Byte Ptr CHRFLG,AL     ;set the character flag
  4371.     MOV    Byte Ptr TIMFLG,AL     ;set the time flag
  4372.     MOV    CH,1
  4373.     CALL    RECV
  4374.     MOV    CH,AL            ;save the character
  4375.     JNB    ACKTST
  4376.     XOR    AL,AL
  4377.     MOV    Byte Ptr CHRFLG,AL     ;reset the character flag, was none
  4378. ;
  4379. ACKTST: XOR    AL,AL
  4380.     MOV    Byte Ptr TIMFLG,AL
  4381.     MOV    AL,CH            ;get the character back
  4382.     CMP    AL,ACK
  4383.     JNZ    L5A26
  4384.     RET
  4385. L5A26:
  4386.     CMP    AL,NAK
  4387.     JZ    GETACK1
  4388. ;
  4389. NOAKNK: DEC    DL            ;one less to go
  4390.     JNZ    ACKLUP            ;loop around again if not zero
  4391.     MOV    AL,Byte Ptr CHRFLG
  4392.     OR    AL,AL
  4393.     JNZ    GETACK1
  4394.     JMP    GETATOT
  4395. ;
  4396. GETACK1:MOV    AL,Byte Ptr BENHERE
  4397.     XOR    AL,CH
  4398.     JZ    ACKER0            ;do not say 'ACK error' if 1st 'NAK'
  4399.     MOV    AL,Byte Ptr QFLG
  4400.     OR    AL,AL
  4401.     JZ    ACKERR
  4402.     CALL    ILPRT
  4403.     DB    '++ ',0
  4404.     MOV    AL,CH
  4405.     CMP    AL,NAK
  4406.     JZ    GETACK3
  4407.     CALL    HEXO
  4408.     CALL    ILPRT
  4409.     DB    'H',0
  4410.     JMPS    GETACK4
  4411. ;
  4412. GETACK3:CALL    ILPRT
  4413.     DB    'NAK',0
  4414. ;
  4415. GETACK4:CALL    ILPRT
  4416.     DB    ' received not ACK - ',0
  4417.     CALL    SHOWERR
  4418. ;
  4419. ACKER0: XOR    AL,AL
  4420.     MOV    Byte Ptr BENHERE,AL
  4421. ;
  4422. ACKERR: MOV    AL,Byte Ptr ERRCT
  4423.     INC    AL
  4424.     MOV    Byte Ptr ERRCT,AL
  4425.     CMP    AL,ERRLIM+1        ;at error limit yet?
  4426.     JNB    ACKERR1
  4427.     RET                ;if not, return
  4428. ;
  4429. ACKERR1:CALL    ERXIT
  4430.     DB    CR,LF,'++ SEND-FILE CANCELLED ++','$'
  4431. ;.....
  4432. ;
  4433. ;
  4434. ; Reached error limit
  4435. ;
  4436. GETATOT:CALL    ILPRT
  4437.     DB    CR,'++ TIMEOUT - no ACK - ',0
  4438.     CALL    SHOWERR            ;display error count
  4439.     JMPS    ACKERR
  4440. ;.....
  4441. ;
  4442. ;
  4443. CKABORT:MOV    AL,Byte Ptr QFLG
  4444.     OR    AL,AL
  4445.     JNZ    L5A29
  4446.     RET
  4447. L5A29:
  4448.     CALL    STAT
  4449.     JNZ    L5A30
  4450.     RET
  4451. L5A30:
  4452.     CALL    KEYIN
  4453.     CMP    AL,CANCEL
  4454.     JZ    ABORT
  4455.     RET
  4456. ;
  4457. ;
  4458. ; Aborts send or receive routines and returns to command line
  4459. ;
  4460. ABORT:    MOV    SP, Offset STACK
  4461. ;
  4462. ABORTL: MOV    CH,1            ;1-second delay to clear input
  4463.     CALL    RECV
  4464.     JNB    ABORTL
  4465.     MOV    AL,CANCEL        ;show you are cancelling
  4466.     CALL    SEND
  4467. ;
  4468. ABORTW: MOV    CH,1            ;1-second delay to clear input
  4469.     CALL    RECV
  4470.     JNB    ABORTW
  4471.     MOV    AL,' '
  4472.     CALL    SEND
  4473.     MOV    AL,'B'            ;turn multi-file mode..
  4474.     MOV    Byte Ptr BATCHFLG,AL   ;..off so routine ends.
  4475.     MOV    Byte Ptr ABORTFLG,AL   ;shows an abort was made
  4476.     XOR    AL,AL
  4477.     MOV    Byte Ptr NFILFLG,AL    ;stop copy into memory for disk file
  4478.     MOV    AL,Byte Ptr OPTION     ;receiving a file now?
  4479.     CMP    AL,'R'
  4480.     JNZ    L5A32
  4481.     JMP    RCVSABT            ;if yes, cancel the unfinished file
  4482. L5A32:
  4483.     CALL    ILPRT
  4484.     DB    CR,LF,LF,'++ FILE CANCELLED ++',CR,LF,BELL,0
  4485.     JMP    DONETCA
  4486. ;.....
  4487. ;
  4488. ;
  4489. ; Increment the record count
  4490. ;
  4491. INCRRNO:PUSH    BX
  4492.     MOV    BX,Word Ptr RECDNO     ;get record number
  4493.     LAHF                ;bump it
  4494.     INC    BX
  4495.     SAHF
  4496.     MOV    Word Ptr RECDNO,BX     ;store it
  4497.     MOV    AL,BL
  4498.     POP    BX
  4499.     RET
  4500. ;.....
  4501. ;
  4502. ;
  4503. ; First check for any wild cards and disallow, just to be safe.     Do not
  4504. ; want a group of files being accidently erased.
  4505. ;
  4506. ERASFIL:MOV    BX, FCB            ;file name is stored here
  4507.     MOV    CH,11            ;maximum of 11 chars for filename.ext
  4508. ;
  4509. ERASFIL1:
  4510.     INC    BX            ;next location in file name
  4511.     MOV    AL,Byte Ptr [BX]    ;get the char.
  4512.     CMP    AL,'?'            ;check for any wild card chars.
  4513.     JZ    ERRORW            ;error if one is found
  4514.     DEC    CH            ;number of tries left
  4515.     JNZ    ERASFIL1        ;if not zero, keep checking
  4516.     MOV    AL,Byte Ptr BATCHFLG   ;don't ask for erase..
  4517.     OR    AL,AL            ;..in multi-file mode,..
  4518.     JZ    NOASK            ;..just do it.
  4519.     MOV    DX, FCB
  4520.     MOV    CL,SRCHF
  4521.     INT    224
  4522.     INC    AL
  4523.     JNZ    L5A33
  4524.     RET                ;file erased ok, return
  4525. L5A33:
  4526.     CALL    ILPRT            ;otherwise make sure it'S OK
  4527.     DB    'File exists - erase?  (Y/N): ',BELL,0
  4528.     CALL    KBDCHR
  4529.     CMP    AL,'Y'
  4530.     JZ    L5A34
  4531.     JMP    MENU            ;if not a 'Y' do not erase
  4532. L5A34:
  4533.     CALL    CRLF            ;otherwise erase the file
  4534. ;
  4535. NOASK:    MOV    DX, FCB
  4536.     MOV    CL,ERASE
  4537.     INT    224
  4538.     RET
  4539. ;.....
  4540. ;
  4541. ;
  4542. ERRORW: POP    BX            ;restore stack from "call ERASFIL"
  4543.     CALL    ILPRT
  4544.     DB    '++ NO WILDCARDS ALLOWED FOR TEXT FILES ++'
  4545.     DB    CR,LF,BELL,0
  4546.     JMP    MENU
  4547. ;.....
  4548. ;
  4549. ;
  4550. BLKFILE:CALL    ILPRT            ;no file named for send or receive
  4551.     DB    '++ NO FILE SPECIFIED ++',CR,LF,BELL,0
  4552.     JMP    MENU
  4553. ;.....
  4554. ;
  4555. ;
  4556. MAKEFIL:MOV    DX, FCB
  4557.     MOV    CL,MAKE
  4558.     INT    224
  4559.     INC    AL
  4560.     JZ    L5A35
  4561.     RET
  4562. L5A35:
  4563.     CALL    ERXIT
  4564.     DB    '++ ERROR -- Can''t open file ++',CR,LF
  4565.     DB    '++ Directory is perhaps full ++','$'
  4566. ;
  4567. CNREC:    MOV    CL,FILSIZ        ;compute file size function in cp/m 2.x
  4568.     MOV    DX, FCB            ;point to file control block
  4569.     INT    224
  4570.     MOV    BX,Word Ptr .FCB+33    ;get record count
  4571.     MOV    Word Ptr RCNT,BX    ;store it
  4572.     MOV    BX,0            ;zero 'BX'
  4573.     MOV    Word Ptr .FCB+33,BX    ;reset random record in FCB
  4574.     RET
  4575. ;.....
  4576. ;
  4577. ;
  4578. OPENFIL:XOR    AL,AL
  4579.     MOV    Byte Ptr .FCBEXT,AL
  4580.     MOV    DX, FCB
  4581.     MOV    CL,OPEN
  4582.     INT    224
  4583.     INC    AL
  4584.     JZ    L5A36
  4585.     JMP    SENDTIME        ;send transfer time, # of records, etc.
  4586. L5A36:
  4587.     CALL    ERXIT            ;file did not open
  4588.     DB    '++ FILE NOT FOUND ++','$'
  4589. ;.....
  4590. ;
  4591. ;
  4592. CLOSFIL:MOV    DX, FCB             ;get the file name
  4593.     MOV    CL,CLOSE
  4594.     INT    224            ; close the file
  4595.     INC    AL
  4596.     JZ    L5A37
  4597.     RET
  4598. L5A37:
  4599.     JMP    ERXIT1            ;no file to close, exit
  4600. ;.....
  4601. ;
  4602. ;
  4603. ; Update record read
  4604. ;
  4605. RDRECD: MOV    AL,Byte Ptr RECINBF    ;decrement 'RECORDS IN BUFFER' count
  4606.     DEC    AL
  4607.     MOV    Byte Ptr RECINBF,AL
  4608.     JS    RDBLOCK
  4609.     MOV    BX,Word Ptr RECPTR     ;find where last move stopped
  4610.     MOV    DX,128
  4611.     CALL    MOVE128            ;move 128 characters
  4612.     MOV    Word Ptr RECPTR,BX     ;store new address for next move
  4613.     RET
  4614. ;.....
  4615. ;
  4616. ;
  4617. ; Buffer empty so read in another block from the disk
  4618. ;
  4619. RDBLOCK:MOV    AL,Byte Ptr EOFLG
  4620.     CMP    AL,1
  4621.     STC
  4622.     JNZ    L5A38
  4623.     RET
  4624. L5A38:
  4625.     MOV    CL,0
  4626.     MOV    DX, Offset BUFFER
  4627. ;
  4628. RDRECLP:PUSH    CX
  4629.     PUSH    DX
  4630.     MOV    CL,SETDMA
  4631.     INT    224
  4632.     MOV    DX, FCB
  4633.     MOV    CL,READ
  4634.     INT    224
  4635.     POP    DX
  4636.     POP    CX
  4637.     OR    AL,AL
  4638.     JZ    RDRECOK
  4639.     DEC    AL
  4640.     JZ    REOF
  4641.     CALL    ERXIT
  4642.     DB    '++ FILE READ ERROR ++','$'
  4643. ;
  4644. RDRECOK:MOV    BX,128
  4645.     LAHF
  4646.     ADD    BX,DX
  4647.     RCR    SI,1
  4648.     SAHF
  4649.     RCL    SI,1
  4650.     XCHG    BX,DX
  4651.     INC    CL
  4652.     CALL    DSKSIZ            ;establish buffer size
  4653.     JZ    RDBFULL
  4654.     JMPS    RDRECLP
  4655. ;...
  4656. ;
  4657. ;
  4658. REOF:    MOV    AL,1
  4659.     MOV    Byte Ptr EOFLG,AL
  4660.     MOV    AL,CL
  4661. ;
  4662. ;
  4663. ; Buffer full or received "End Of File (EOF)"
  4664. ;
  4665. RDBFULL:MOV    Byte Ptr RECINBF,AL
  4666.     MOV    BX, Offset BUFFER
  4667.     MOV    Word Ptr RECPTR,BX
  4668.     MOV    CL,SETDMA
  4669.     MOV    DX, Offset TBUF
  4670.     INT    224
  4671.     JMP    RDRECD
  4672. ;.....
  4673. ;
  4674. ;
  4675. ; Write a record
  4676. ;
  4677. WRRECD: MOV    BX,Word Ptr RECPTR
  4678.     XCHG    BX,DX
  4679.     MOV    BX,128
  4680.     CALL    MOVE128
  4681.     XCHG    BX,DX
  4682.     MOV    Word Ptr RECPTR,BX     ;new record pointer
  4683.     MOV    AL,Byte Ptr RECINBF    ;increment 'RECORDS IN BUFFER' count
  4684.     INC    AL
  4685.     MOV    Byte Ptr RECINBF,AL
  4686.     MOV    CL,AL            ;store the record count for now
  4687.     CALL    DSKSIZ            ;establish buffer size
  4688.     JZ    WRBLOCK
  4689.     RET                ;buffer not full, return
  4690. ;
  4691. ;
  4692. ; Write a block to disk
  4693. ;
  4694. WRBLOCK:MOV    AL,Byte Ptr RECINBF    ;get the number of records in the buffer
  4695.     OR    AL,AL
  4696.     JNZ    L5A40
  4697.     RET                ;if zero, don't try to move to disk
  4698. L5A40:
  4699.     MOV    CL,AL            ;otherwise store in 'C' reg.
  4700.     MOV    DX,Offset BUFFER    ;start of buffer to move to disk
  4701. ;
  4702. DSKWRT: PUSH    CX
  4703.     PUSH    DX
  4704.     PUSH    BX
  4705.     MOV    CL,SETDMA
  4706.     INT    224
  4707.     MOV    CL,WRITE
  4708.     MOV    DX, FCB
  4709.     INT    224
  4710.     POP    BX
  4711.     POP    DX
  4712.     POP    CX
  4713.     OR    AL,AL
  4714.     JZ    L5A41
  4715.     JMP    WRERR            ;error if disk is full
  4716. L5A41:
  4717.     MOV    BX,128            ;add in another page
  4718.     ADD    BX,DX
  4719.     XCHG    BX,DX
  4720.     DEC    CL            ;one less record left to move to disk
  4721.     JNZ    DSKWRT
  4722.     XOR    AL,AL
  4723.     MOV    Byte Ptr RECINBF,AL    ;zero the 'RECORDS IN BUFFER' count
  4724.     MOV    BX, Offset BUFFER    ;reset location to next buffer start
  4725.     MOV    Word Ptr RECPTR,BX
  4726.     RET
  4727. ;.....
  4728. ;
  4729. ;
  4730. ; Determine if the buffer size is for file transfer or for ASCII capture
  4731. ; to disk then compare with current record length
  4732. ;
  4733. DSKSIZ: MOV    AL,Byte Ptr XFLG       ;see if transferring files now
  4734.     OR    AL,AL
  4735.     MOV    AL,CL            ;get the current record count
  4736.     JZ    DSKSIZ1            ;if yes, exit
  4737.     MOV    AL,CL
  4738.     CMP    AL,BUFSIZ*8        ;buffer size for ASCII capture to disk
  4739.     RET                ;return with flag set for the compare
  4740. ;...
  4741. ;
  4742. ;
  4743. DSKSIZ1:MOV    AL,Byte Ptr SAVSIZ     ;get the file transfer buffer size..
  4744.     CMP    AL,CL            ;..from special storage area and compare
  4745.     RET                ;return with flag set for the compare
  4746. ;.....
  4747. ;
  4748. ;
  4749. ; Timeout time is in B, in seconds.  Entry via 'RECVDG' deletes garbage
  4750. ; characters on the line.  For example, having just sent a record, cal-
  4751. ; ling RECVDG will delete any line noise induced characters LONG before
  4752. ; the ACK/NAK would be received.
  4753. ;
  4754. RECVDG: CALL    CKCHAR            ;catch any garbage characters
  4755. ;
  4756. RECV:    PUSH    DX
  4757. ;
  4758. ;
  4759. ; Get back quickly to gobble 2nd character if TIMFLG is set by the GETNM
  4760. ; routine - or just step through quickly after the first wait for 'SOH'
  4761. ; in the 'SOHLUP' routine.
  4762. ;
  4763. MSEC:    PUSH    BX
  4764.     MOV    BX, Offset TIMFLG
  4765.     MOV    DL, Byte Ptr [BX]
  4766.     INC    DL
  4767.     MOV    BX,Word Ptr QUIKTIM
  4768.     JZ    DOQUIK
  4769.     MOV    BX,Word Ptr TIMVAL
  4770. ;
  4771. DOQUIK: XCHG    BX,DX
  4772.     POP    BX
  4773. ;
  4774. MWTI:    CALL    RCVREADY
  4775.     JZ    MCHAR
  4776.     MOV    AL,DH
  4777.     OR    AL,DL
  4778.     LAHF
  4779.     DEC    DX
  4780.     SAHF
  4781.     JNZ    MWTI
  4782.     DEC    CH
  4783.     JNZ    MSEC
  4784.     POP    DX
  4785.     CALL    CKABORT
  4786.     STC
  4787.     RET
  4788. ;.....
  4789. ;
  4790. ;
  4791. ; Get the character from the modem, but filter out 'ACK' and '.' chars.
  4792. ; if recieving a file name.  ('FILTRFLG' is set by the 'GETNM' routine.)
  4793. ;
  4794. MCHAR:    CALL    IN_MODDATP        ;get the character that is waiting
  4795.     POP    DX
  4796.     LAHF                ;save the character for later use also
  4797.     XCHG    AL,AH
  4798.     PUSH    AX
  4799.     XCHG    AL,AH
  4800.     CMP    AL,ACK            ;see if it is 'ACK'
  4801.     JZ    ISACK
  4802.     CMP    AL,'.'            ;see if it is a period
  4803.     JNZ    DOUPD            ;neither, so update 'CRC'
  4804. ;
  4805. ISACK:    PUSH    BX
  4806.     PUSH    DX
  4807.     MOV    BX,Offset FLTRFLG           ;see if need to each 'ACK' or period
  4808.     MOV    DL,Byte Ptr [BX]
  4809.     INC    DL
  4810.     POP    DX
  4811.     POP    BX
  4812.     JZ    MWTI            ;yes, so do it
  4813. ;
  4814. DOUPD:    CALL    CRCUPD            ;calculate 'CRC'
  4815.     ADD    AL,CL
  4816.     MOV    CL,AL
  4817.     MOV    AL,Byte Ptr RSEEFLG
  4818.     OR    AL,AL
  4819.     JZ    MONIN
  4820.     MOV    AL,Byte Ptr VSEEFLG
  4821.     OR    AL,AL
  4822.     JNZ    NOMONIN
  4823.     MOV    AL,Byte Ptr DATAFLG
  4824.     OR    AL,AL
  4825.     JZ    NOMONIN
  4826. ;
  4827. MONIN:    POP    AX            ;get the character again
  4828.     XCHG    AL,AH
  4829.     SAHF
  4830.     LAHF                ;resave it for later use also
  4831.     XCHG    AL,AH
  4832.     PUSH    AX
  4833.     CALL    CKABORT            ;show the character on the CRT
  4834. ;
  4835. NOMONIN:CALL    CKABORT
  4836.     POP    AX            ;get the character back once more
  4837.     XCHG    AL,AH
  4838.     OR    AL,AL            ;reset the carry flag
  4839.     RET                ;return with the character and flag set
  4840. ;.....
  4841. ;
  4842. ;
  4843. ; Send a character to the modem
  4844. ;
  4845. SEND:    PUSH    AX
  4846.     MOV    AL,Byte Ptr SSEEFLG
  4847.     OR    AL,AL
  4848.     JZ    MONOUT
  4849.     MOV    AL,Byte Ptr VSEEFLG
  4850.     OR    AL,AL
  4851.     JNZ    NOMONOT
  4852.     MOV    AL,Byte Ptr DATAFLG
  4853.     OR    AL,AL
  4854.     JZ    NOMONOT
  4855. ;
  4856. MONOUT: POP    AX
  4857.     PUSH    AX
  4858.     CALL    SHOW
  4859. ;
  4860. NOMONOT:POP    AX
  4861.     PUSH    AX
  4862.     CALL    CRCUPD            ;update the 'CRC' calcuation
  4863.     ADD    AL,CL
  4864.     MOV    CL,AL
  4865. ;
  4866. SENDW:    CALL    SENDRDY
  4867.     JNZ    SENDW
  4868.     POP    AX
  4869.     JMP    OUT_MODDATP        ;send character to modem, done
  4870. ;.....
  4871. ;
  4872. ;
  4873. ; Waits for the first character received while waiting to send a file.
  4874. ; If a character is not received in one second, it loops again until a
  4875. ; char. is received or it times out.  The count is set for two minutes
  4876. ; before timeout.  This gives the receiving station ample time to name
  4877. ; a file, etc.
  4878. ;
  4879. WAITNAK:CALL    ILPRT
  4880.     DB    'Waiting ready signal',CR,LF,0
  4881.     CALL    CRLF
  4882. ;    
  4883. WAITNLP:CALL    CKABORT
  4884.     MOV    CH,1            ;wait up to 1 second for a character
  4885.     CALL    RECV
  4886.     CMP    AL,CANCEL        ;want to quit?
  4887.     JNZ    L5A42
  4888.     JMP    ABORT
  4889. L5A42:
  4890.     CMP    AL,CRC            ;'CRC' request?
  4891.     JZ    WAITCRC            ;yes, go set 'CRC' flag
  4892.     CMP    AL,NAK
  4893.     JZ    WAITCHK
  4894.     DEC    DL
  4895.     JNZ    WAITNLP
  4896.     JMP    ABORT
  4897. ;...
  4898. ;
  4899. ;
  4900. WAITCRC:CALL    ILPRTQ
  4901.     DB    'CRC request received',CR,LF,0
  4902.     MOV    AL,1
  4903.     MOV    Byte Ptr CRCFLAG,AL    ;make sure in 'CRC' mode then
  4904.     RET
  4905. ;.....
  4906. ;
  4907. ;
  4908. WAITCHK:MOV    AL,Byte Ptr BATCHFLG   ;in batch mode?
  4909.     OR    AL,AL
  4910.     JNZ    L5A43
  4911.     RET
  4912. L5A43:
  4913.     CALL    ILPRTQ
  4914.     DB    'Got checksum request',CR,LF,0
  4915.     RET
  4916. ;.....
  4917. ;
  4918. ;
  4919. WAITCHK1:
  4920.     CALL    ILPRTQ
  4921.     DB    'Name NAK received',CR,LF,0
  4922.     RET
  4923. ;.....
  4924. ;
  4925. ;
  4926. ; Finished with the file transfer
  4927. ;
  4928. DONE:    MOV    AL,Byte Ptr BATCHFLG   ;in batch mode?
  4929.     OR    AL,AL
  4930.     JZ    L5A44
  4931.     JMP    DONETC            ;exit if not
  4932. L5A44:
  4933.     MOV    AL,Byte Ptr QFLG
  4934.     OR    AL,AL
  4935.     JNZ    L5A45
  4936.     JMP    NMSTRNS
  4937. L5A45:
  4938.     MOV    CH,12            ;zero out FTRNMSG
  4939.     MOV    BX,(Offset FTRNMSG)
  4940.     MOV    AL,0
  4941. ;
  4942. ZEROLP: MOV    Byte Ptr [BX],AL
  4943.     INC    BX
  4944.     DEC    CH
  4945.     JNZ    ZEROLP
  4946.     MOV    CH,12            ;put file name in FTRNMSG
  4947.     MOV    BX, FCB+1
  4948.     MOV    DX,(Offset FTRNMSG)
  4949. ;
  4950. LOADMSG:MOV    AL,4            ;start of file type?
  4951.     CMP    AL,CH
  4952.     JZ    PERIOD            ;put in period if so
  4953.     MOV    AL,Byte Ptr [BX]
  4954.     CMP    AL,' '            ;don't put in space
  4955.     JZ    SKPSP
  4956.     MOV    SI,DX            ;store in FTRNMSG
  4957.     MOV    [SI],AL
  4958.     INC    DX
  4959. ;
  4960. SKPSP:    INC    BX
  4961.     DEC    CH
  4962.     MOV    AL,CH
  4963.     OR    AL,AL            ;end of file name?
  4964.     JZ    FTRNMSG0        ;display file name
  4965.     JMPS    LOADMSG            ;loop for another character
  4966. ;.....
  4967. ;
  4968. ;
  4969. PERIOD: MOV    AL,Byte Ptr [BX]
  4970.     CMP    AL,' '            ;is file type empty?
  4971.     JZ    FTRNMSG0        ;go if so
  4972.     MOV    AL,'.'            ;else put period in message
  4973.     MOV    SI,DX
  4974.     MOV    [SI],AL
  4975.     INC    DX
  4976.     DEC    CH
  4977.     JMPS    LOADMSG
  4978. ;.....
  4979. ;
  4980. ;
  4981. FTRNMSG0:
  4982.     CALL    ILPRT
  4983.     DB    CR,LF
  4984. ;
  4985.  
  4986. FTRNMSG RS    12
  4987.     DB    0
  4988.     CALL    ILPRT
  4989.     DB    ' Transferred',CR,LF,LF,BELL,0
  4990. ;
  4991. NMSTRNS:MOV    AL,Byte Ptr .FCB    ;save drive no.
  4992.     MOV    Byte Ptr DISKNO,AL
  4993.     MOV    BX, FCB             ;blank out file control blocks
  4994.     CALL    INITFCB
  4995.     MOV    AL,Byte Ptr DISKNO     ;put drive number back
  4996.     MOV    Byte Ptr .FCB,AL
  4997.     MOV    BX,Offset RESTSN    ;restore record numbers..
  4998.     MOV    DX,Offset RECDNOB    ;..for new file transfer.
  4999.     MOV    CH,(Offset RECDNOE)-(Offset RECDNOB) ;routine also done in menu.
  5000.     CALL    MOVE
  5001.     CALL    SENDNOW            ;insures last character is finished
  5002.     CALL    CKCHAR            ;catch any echo characters on line
  5003.     MOV    AL,Byte Ptr SENDFLG    ;goes to either send or..
  5004.     OR    AL,AL            ;..receive file, depending..
  5005.     JZ    L6A1
  5006.     JMP    SENDFIL2        ;..upon which routine set..
  5007. L6A1:
  5008.     JMP    RCVFIL1            ;..the flag in multi-file mode.
  5009. ;.....
  5010. ;
  5011. ;
  5012. DONETC: CALL    CKABORT            ;slight delay for next message
  5013.     CALL    ILPRT
  5014.     DB    CR,LF,'[Transfer completed]',CR,LF,BELL,0
  5015. ;
  5016. DONETCA:MOV    AL,Byte Ptr XITFLG     ;special 'X' flag set?
  5017.     OR    AL,AL
  5018.     JNZ    L6A2
  5019.     JMP    BYEBYE            ;if yes, disconnect and reboot
  5020. L6A2:
  5021.     MOV    AL,Byte Ptr DISCFLG    ;normal 'D' flag set?
  5022.     OR    AL,AL
  5023.     JZ    DONETCD            ;if yes, disconnect, get next command
  5024. ;
  5025. DONETCB:CALL    JMP_NOPARITY        ;reset to no parity
  5026.     XOR    AL,AL
  5027.     MOV    Byte Ptr CRCFLAG,AL    ;reset back to checksum
  5028.     MOV    Byte Ptr FIRSTME,AL    ;reset first-time 'SOH' flag
  5029.     MOV    Byte Ptr FSTFLG,AL     ;reset multi-file trans
  5030.     MOV    Byte Ptr NFILFLG,AL    ;turn off the memory save for disk file
  5031.     MOV    Byte Ptr SAVEFLG,AL    ;stop memory save in term routine.
  5032.     MOV    AL,Byte Ptr VSEEFLG    ;view flag set?
  5033.     OR    AL,AL
  5034.     JNZ    DONETCC            ;if not, exit
  5035.     NOT    AL
  5036.     MOV    Byte Ptr QFLG,AL       ;VSEEFLG also sets the QFLG
  5037.     MOV    Byte Ptr VSEEFLG,AL    ;reset the flag
  5038. ;
  5039. DONETCC:MOV    BX, Offset QFLG        ;in quiet mode?
  5040.     MOV    AL,Byte Ptr [BX]
  5041.     OR    AL,AL
  5042.     MOV    Byte Ptr [BX],'Q'    ;reset the flag to normal
  5043.     JNZ    L6A3
  5044.     JMP    MENU            ;if yes, go back to command line
  5045. L6A3:
  5046.     MOV    AL,Byte Ptr ABORTFLG   ;come here from a timeout?
  5047.     OR    AL,AL
  5048.     JZ    L6A4
  5049.     JMP    MENU            ;if yes, go to command mode
  5050. L6A4:
  5051.     MOV    AL,Byte Ptr JMPCMD     ;requesting return to command mode?
  5052.     OR    AL,AL
  5053.     JNZ    L6A5
  5054.     JMP    MENU            ;if yes go to command mode
  5055. L6A5:
  5056.     CALL    CRLF            ;turn up a new line
  5057.     JMP    TERM            ;otherwise return to terminal mode
  5058. ;.....
  5059. ;
  5060. ;
  5061. DONETCD:CALL    ILPRT
  5062.     DB    CR,LF,'<< DISCONNECTED >>',BELL,CR,LF,0
  5063.     CALL    JMP_GOODBYE        ;set 'DTR' low for 300 ms.
  5064.     MOV    AL,Byte Ptr PMMIMODEM
  5065.     OR    AL,AL
  5066.     JZ    L6A6
  5067.     CALL    JMP_DISCONNT
  5068. L6A6:
  5069.     MOV    AL,Byte Ptr AUTODIAL   ;using a Hayes-type modem?
  5070.     OR    AL,AL
  5071.     JZ    L6A7
  5072.     CALL    JMP_DISCONNT        ;if yes, disconnect
  5073. L6A7:
  5074.     JMP    MENU0            ;back to command line
  5075. ;.....
  5076. ;
  5077. ;
  5078. MOVEFCB:MOV    BX, FCB+16
  5079.     MOV    DX, FCB
  5080.     MOV    CH,16
  5081.     CALL    MOVE
  5082.     XOR    AL,AL
  5083.     MOV    Byte Ptr .FCBSNO,AL
  5084.     MOV    Byte Ptr .FCBEXT,AL
  5085.     RET
  5086. ;.....
  5087. ;
  5088. ;
  5089. SHOW:    CMP    AL,LF
  5090.     JZ    CTYPE
  5091.     CMP    AL,CR
  5092.     JZ    CTYPE
  5093.     CMP    AL,9
  5094.     JZ    CTYPE
  5095.     CMP    AL,' '
  5096.     JB    SEEHEX
  5097.     CMP    AL,7FH
  5098.     JB    CTYPE
  5099. ;
  5100. SEEHEX: LAHF
  5101.     XCHG    AL,AH
  5102.     PUSH    AX
  5103.     MOV    AL,'('
  5104.     CALL    CTYPE
  5105.     POP    AX
  5106.     XCHG    AL,AH
  5107.     SAHF
  5108.     CALL    HEXO
  5109.     MOV    AL,')'
  5110.     JMPS    CTYPE
  5111. ;.....
  5112. ;
  5113. ;
  5114. CTYPE:    PUSH    CX
  5115.     PUSH    DX
  5116.     PUSH    BX
  5117.     MOV    DL,AL
  5118.     MOV    CL,WRCON
  5119.     INT    224
  5120.     POP    BX
  5121.     POP    DX
  5122.     POP    CX
  5123.     RET
  5124. ;.....
  5125. ;
  5126. ;
  5127. CRLF:    LAHF
  5128.     XCHG    AL,AH
  5129.     PUSH    AX
  5130.     MOV    AL,CR
  5131.     CALL    STYPE
  5132.     MOV    AL,LF
  5133.     CALL    STYPE
  5134.     POP    AX
  5135.     XCHG    AL,AH
  5136.     SAHF
  5137.     RET
  5138. ;.....
  5139. ;
  5140. ;
  5141. STAT:    PUSH    CX
  5142.     PUSH    DX
  5143.     PUSH    BX
  5144. ;
  5145. VSTAT:    MOV    DL,0FEH        ; Direct Console I/O Status function flag
  5146.     MOV    CL,6
  5147.     INT    224
  5148.     POP    BX        ; vois la
  5149.     POP    DX
  5150.     POP    CX
  5151.     OR    AL,AL
  5152.     RET
  5153. ;.....
  5154. ;
  5155. ;
  5156. KEYIN:    PUSH    CX
  5157.     PUSH    DX
  5158.     PUSH    BX
  5159. ;
  5160. VKEYIN: MOV    DL,0FFH        ; KEYIN FLAG FOR direct CONSOLE I?O
  5161.     MOV    CL,6
  5162.     INT    224
  5163.     OR    AL,AL
  5164.     JZ    VKEYIN
  5165.     POP    BX            ;..by 'INITADR' routine
  5166.     POP    DX
  5167.     POP    CX
  5168.     RET
  5169. ;.....
  5170. ;
  5171. ;
  5172. STYPE:    LAHF
  5173.     XCHG    AL,AH
  5174.     PUSH    AX
  5175.     XCHG    AL,AH
  5176.     PUSH    CX
  5177.     PUSH    DX
  5178.     PUSH    BX
  5179. ;
  5180. VTYPE:    MOV    DL,AL        ; Direct Conout requirtes Char in DL
  5181.     MOV    CL,6
  5182.     INT    224
  5183.     POP    BX
  5184.     POP    DX
  5185.     POP    CX
  5186.     POP    AX
  5187.     XCHG    AL,AH
  5188.     SAHF
  5189.     RET
  5190. ;.....
  5191. ;
  5192. ;
  5193. ; Get a character from the keyboard, convert to upper-case if needed,
  5194. ; and show on CRT
  5195. ;
  5196. KBDCHR: CALL    KEYIN            ;get a keyboard character
  5197.     CALL    UCASE            ;convert to upper case if needed
  5198.     CALL    STYPE             ;show on CRT
  5199.     RET
  5200. ;.....
  5201. ;
  5202. ;
  5203. UCASE:    CMP    AL,61H            ;changes lower case character..
  5204.     JNB    L6A8
  5205.     RET                ;..in 'A'reg. to upper case.
  5206. L6A8:
  5207.     CMP    AL,7AH+1        ;see if more than small 'Z'
  5208.     JNAE    L6A9
  5209.     RET
  5210. L6A9:
  5211.     AND    AL,5FH
  5212.     RET
  5213. ;.....
  5214. ;
  5215. ;
  5216. DECOUT: LAHF
  5217.     XCHG    AL,AH
  5218.     PUSH    AX
  5219.     PUSH    CX
  5220.     PUSH    DX
  5221.     PUSH    BX
  5222.     MOV    CX,-10
  5223.     MOV    DX,-1
  5224. ;
  5225. DECOU1: ADD    BX,CX
  5226.     INC    DX
  5227.     JB    DECOU1
  5228.     MOV    CX,10
  5229.     ADD    BX,CX
  5230.     XCHG    BX,DX
  5231.     MOV    AL,BH
  5232.     OR    AL,BL
  5233.     JZ    L6A10
  5234.     CALL    DECOUT
  5235. L6A10:
  5236.     MOV    AL,DL
  5237.     ADD    AL,'0'
  5238.     CALL    CTYPE
  5239.     POP    BX
  5240.     POP    DX
  5241.     POP    CX
  5242.     POP    AX
  5243.     XCHG    AL,AH
  5244.     SAHF
  5245.     RET
  5246. ;.....
  5247. ;
  5248. ;
  5249. ;---->    DHXOUT: - double precision hex output routine
  5250. ;
  5251. DHXOUT: PUSH    BX
  5252.     LAHF
  5253.     XCHG    AL,AH
  5254.     PUSH    AX
  5255.     MOV    AL,BH            ;get ms byte
  5256.     CALL    HEXO            ;output high order byte
  5257.     MOV    AL,BL            ;get ls byte
  5258.     CALL    HEXO            ;output low order byte
  5259.     POP    AX
  5260.     XCHG    AL,AH
  5261.     SAHF
  5262.     POP    BX
  5263.     RET
  5264. ;.....
  5265. ;
  5266. ;
  5267. ; Prints a hex value in 'A' on the CRT
  5268. ;
  5269. HEXO:    LAHF
  5270.     XCHG    AL,AH
  5271.     PUSH    AX
  5272.     XCHG    AL,AH
  5273.     RCR    AL,1
  5274.     RCR    AL,1
  5275.     RCR    AL,1
  5276.     RCR    AL,1
  5277.     CALL    NIBBL
  5278.     POP    AX
  5279.     XCHG    AL,AH
  5280. ;
  5281. NIBBL:    AND    AL,0FH
  5282.     CMP    AL,10
  5283.     JB    ISNUM
  5284.     ADD    AL,7
  5285. ;
  5286. ISNUM:    ADD    AL,'0'            ;add in ASCII bias
  5287.     JMP    CTYPE
  5288. ;.....
  5289. ;
  5290. ;
  5291. ; Displays the control-characters shown in the menu
  5292. ;
  5293. SHFTYPE:LAHF
  5294.     XCHG    AL,AH
  5295.     PUSH    AX
  5296.     CALL    ILPRT
  5297.     DB    'CTL-',0
  5298.     POP    AX
  5299.     XCHG    AL,AH
  5300.     ADD    AL,40H            ;convert binary to ASCII chars.
  5301.     CALL    STYPE             ;show on the CRT
  5302.     JMPS    ILPRT
  5303. ;.....
  5304. ;
  5305. ;
  5306. ; Write a string of characters to the CRT
  5307. ;
  5308. ILPRT:    POP    SI
  5309. ;
  5310. ILPRT1: LODS    BYTE PTR [SI]        ;get the character
  5311.     OR    AL,AL            ;see if a "0" for end of string
  5312.     JZ    ILPRT2            ;if yes, all done
  5313.     CALL    CTYPE            ;show on CRT
  5314.     JMPS    ILPRT1
  5315. ;
  5316. ILPRT2: PUSH    SI            ;restore the address
  5317.     RET
  5318. ;.....
  5319. ;
  5320. ;
  5321. ; Write a string of characters unless in the Quiet mode
  5322. ;
  5323. ILPRTQ: POP    SI
  5324. ;
  5325. ILPRTQ1:LODS    Byte Ptr [SI]         ;get the character
  5326.     OR    AL,AL            ;see if a "0" for end of string
  5327.     JZ    ILPRTQ2            ;if yes, all done
  5328.     MOV    BL,Byte Ptr QFLG
  5329.     OR    BL,BL
  5330.     JZ    ILPRTQ1
  5331.     CALL    CTYPE            ;show on CRT if not in quiet mode
  5332.     JMPS    ILPRTQ1
  5333. ;
  5334. ILPRTQ2:PUSH    SI            ;restore the address
  5335.     RET
  5336. ;.....
  5337. ;
  5338. ;
  5339. PRTMSG: MOV    CL,PRINT        ;print the string
  5340.     INT    224
  5341.     RET
  5342. ;.....
  5343. ;
  5344. ;
  5345. ; Displays error statement then resturns to command mode
  5346. ;
  5347. ERXIT:    POP    DX
  5348.     CALL    PRTMSG
  5349.     MOV    AL,BELL
  5350.     CALL    STYPE
  5351.     CALL    CRLF
  5352. ;
  5353. ERXIT1: MOV    AL,1
  5354.     MOV    Byte Ptr ABORTFLG,AL   ;shows an unintentional abort
  5355.     MOV    AL,Byte Ptr BATCHFLG   ;in batch mode?
  5356.     OR    AL,AL
  5357.     JZ    L6A12
  5358.     JMP    DONETCB            ;if not, exit
  5359. L6A12:
  5360.     JMP    ABORT            ;abort other computer
  5361. ;.....
  5362. ;
  5363. ;
  5364. ; Exits directly to CP/M
  5365. ;
  5366. EXIT:    MOV    AL,Byte Ptr OLDUSER    ;get original user number back
  5367.     MOV    DL,AL
  5368.     CALL    SETUSER
  5369.     MOV    CL,SETDMA
  5370.     MOV    DX, ofFSET TBUF        ;restore original buffer area
  5371.     INT    224
  5372.     MOV    CX,1A00H        ;a little delay timer
  5373. ;
  5374. EXIT1:    DEC    CX            ;one less loop to make
  5375.     MOV    AL,CH
  5376.     OR    AL,CL
  5377.     JNZ    EXIT1            ;loop again till both are zero
  5378.     CALL    CKCON            ;catch any extra keyboard characters
  5379.     MOV    AL,Byte Ptr NFILFLG    ;saving for a disk file?
  5380.     OR    AL,AL
  5381.     JZ    L6A13
  5382.     CALL    WRTFIL1            ;if yes, close the file
  5383. L6A13:
  5384. EXIT2:    MOV    CL,0            ;if not,  reboot 
  5385.     MOV    DL,0
  5386.     INT    224
  5387.  
  5388. ;.....
  5389. ;
  5390. ;
  5391. ; Catch any extra keyboard characters coming through BDOS
  5392. ;
  5393. CKCON:    MOV    CL,CONST        ;see if any characters waiting
  5394.     INT    224
  5395.     OR    AL,AL
  5396.     JNZ    L6A15
  5397.     RET                ;if not, exit
  5398. L6A15:
  5399.     MOV    CL,RDCON        ;otherwise get the character
  5400.     INT    224
  5401.     XOR    AL,AL            ;discard the character
  5402.     JMPS    CKCON            ;see if any others
  5403. ;.....
  5404. ;
  5405. ;    
  5406. MOVE128:MOV    CH,128
  5407. ;
  5408. MOVE:    MOV    AL,Byte Ptr [BX]
  5409.     MOV    SI,DX
  5410.     MOV    [SI],AL
  5411.     LAHF
  5412.     INC    BX
  5413.     SAHF
  5414.     LAHF
  5415.     INC    DX
  5416.     SAHF
  5417.     DEC    CH
  5418.     JNZ    MOVE
  5419.     RET
  5420. ;.....
  5421. ;
  5422. ;
  5423. ; Sends the character in 'A' to the modem
  5424. ;
  5425. SENDCHR:CALL    SENDNOW            ;wait until modem is ready for character
  5426.     MOV    AL,CH            ;get the original character back
  5427.     JMP    OUT_MODDATP        ;send the character to modem, return
  5428. ;.....
  5429. ;
  5430. ;
  5431. ; Initializes CP/M file control blocks AT 5CH and 6CH
  5432. ;
  5433. SETFCB: MOV    DX, Offset CMDBUF
  5434.     MOV    BX, FCB
  5435.     JMPS    CMDLINE
  5436. ;.....
  5437. ;
  5438. ;
  5439. ; Adjusts loop counter for the selected clock speed.  Returns with delay
  5440. ; in 'BX'.
  5441. ;
  5442. FIXCNT: MOV    AL,Byte Ptr CLOCK      ;get the user's clock speed
  5443.     PUSH    DX            ;save the current 'DE' value
  5444.     PUSH    BX
  5445.     POP    DX            ;get same value into 'DE' as in 'BX'
  5446. ;
  5447. CNTMUL: LAHF                ;add 'DE' to 'BX'
  5448.     ADD    BX,DX
  5449.     RCR    SI,1
  5450.     SAHF
  5451.     RCL    SI,1
  5452.     DEC    AL            ;one less to go
  5453.     JNZ    CNTMUL
  5454.     POP    DX            ;restore current 'DE', delay in 'BX'
  5455.     RET
  5456. ;.....
  5457. ;
  5458. ;
  5459. ;=======================================================================
  5460. ;
  5461. ; Loads a command line addressed by 'DE' registers (max # characters in
  5462. ; line in 'DE', number of characters in line in DE+1, line starts in
  5463. ; DE+2) into FCB addressed by 'BX' registers.  The FCB should be at least
  5464. ; 33 bytes in length.  The command line buffer must have a maximum length
  5465. ; at least one more than the greatest number of characters that will be
  5466. ; needed.
  5467. CMDLINE:LAHF
  5468.     XCHG    AL,AH
  5469.     PUSH    AX
  5470.     XCHG    AL,AH
  5471.     PUSH    CX
  5472.     PUSH    DX
  5473.     PUSH    BX
  5474.     CALL    INITIAL            ;fills FCBs with blanks and nulls
  5475.     XCHG    BX,DX            ;get start of command line in hl.
  5476.     INC    BX            ;address # bytes in cmd line.
  5477.     MOV    DL,Byte Ptr [BX]    ;load de pair with # bytes.
  5478.     MOV    DH,0
  5479.     INC    BX
  5480.     ADD    BX,DX            ;point to byte after last char..
  5481.     MOV    Byte Ptr [BX],CR    ;..in cmd line and store delimiter.
  5482.     POP    BX            ;restore BX and DE.
  5483.     POP    DX
  5484.     PUSH    DX
  5485.     PUSH    BX
  5486.     INC    DX            ;address start of command.
  5487.     INC    DX
  5488.     CALL    DRIVE
  5489. ;
  5490. NAME1:    MOV    CL,8            ;transfer first filename to FCB.
  5491.     CALL    TRANS
  5492.     CMP    AL,CR
  5493.     JZ    DONEL
  5494.     CMP    AL,' '            ;if space, then start of..
  5495.     JZ    NAME2            ;..second filename.
  5496.     POP    BX            ;filetype must be after..
  5497.     PUSH    BX            ;..eighth byte of name.
  5498.     MOV    CX,9
  5499.     ADD    BX,CX
  5500.     MOV    CL,3            ;transfer type of first file
  5501.     CALL    TRANS
  5502.     CMP    AL,CR
  5503.     JZ    DONEL
  5504. ;
  5505. NAME2:    MOV    SI,DX            ;eat multiple spaces..
  5506.     MOV    AL,[SI]
  5507.     CMP    AL,' '            ;..between names.
  5508.     JNZ    NAME3
  5509.     INC    DX
  5510.     JMPS    NAME2
  5511. ;
  5512. NAME3:    POP    BX            ;second name starts in 16th byte.
  5513.     PUSH    BX            ;point BX to this byte.
  5514.     MOV    CX,16
  5515.     ADD    BX,CX
  5516.     CALL    DRIVE
  5517.     MOV    CL,8
  5518.     CALL    TRANS
  5519.     CMP    AL,CR
  5520.     JZ    DONEL
  5521.     POP    BX            ;second type starts in 25th byte.
  5522.     PUSH    BX
  5523.     MOV    CX,25
  5524.     ADD    BX,CX
  5525.     MOV    CL,3
  5526.     CALL    TRANS
  5527. ;
  5528. DONEL:    POP    BX
  5529.     PUSH    BX
  5530.     INC    BX            ;point to 1st char of 1st name in FCB
  5531.     CALL    SCANL            ;check for * (ambiguous names)
  5532.     POP    BX
  5533.     PUSH    BX
  5534.     MOV    CX,17            ;..to 1st char of second name in FCB
  5535.     ADD    BX,CX
  5536.     CALL    SCANL
  5537.     POP    BX
  5538.     POP    DX
  5539.     POP    CX
  5540.     POP    AX
  5541.     XCHG    AL,AH
  5542.     SAHF
  5543.     RET
  5544. ;.....
  5545. ;
  5546. ;
  5547. ; Subroutines for CMDLINE section
  5548. ;
  5549. INITIAL:PUSH    BX            ;initializes FCB with 1 null (for first drive)..
  5550.     PUSH    CX            ;..11 blanks, 4 nulls, 1 null (for 2nd drive)..
  5551.     MOV    Byte Ptr [BX],0        ;..11 blanks, and 4 nulls.
  5552.     LAHF
  5553.     INC    BX
  5554.     SAHF
  5555.     MOV    CH,11
  5556.     MOV    AL,' '
  5557.     CALL    INITFILL
  5558.     MOV    CH,5
  5559.     XOR    AL,AL
  5560.     CALL    INITFILL
  5561.     MOV    CH,11
  5562.     MOV    AL,' '
  5563.     CALL    INITFILL
  5564.     MOV    CH,4
  5565.     XOR    AL,AL
  5566.     CALL    INITFILL
  5567.     POP    CX
  5568.     POP    BX
  5569.     RET
  5570. ;.....
  5571. ;
  5572. ;
  5573. INITFILL:
  5574.     MOV    Byte Ptr [BX],AL
  5575.     LAHF
  5576.     INC    BX
  5577.     SAHF
  5578.     DEC    CH
  5579.     JNZ    INITFILL
  5580.     RET
  5581. ;.....
  5582. ;
  5583. ;
  5584. DRIVE:    INC    DX            ;check 2nd byte of filename.  if it..
  5585.     MOV    SI,DX            ;..is a ":", then drive was specified..
  5586.     MOV    AL,[SI]
  5587.     DEC    DX
  5588.     CMP    AL,':'
  5589.     JNZ    DEFDR            ;..else zero for default drive ..
  5590.     MOV    SI,DX            ;..('INIT' put zero)
  5591.     MOV    AL,[SI]
  5592.     AND    AL,5FH
  5593.     SUB    AL,40H            ;calculate drive (A=1, B=2,...)..
  5594.     MOV    Byte Ptr [BX],AL    ;..and place it in FCB.
  5595.     LAHF                ;address first byte of..
  5596.     INC    DX
  5597.     SAHF
  5598.     LAHF                ;..in command line,..
  5599.     INC    DX
  5600.     SAHF
  5601. ;
  5602. DEFDR:    LAHF                ;..and name field in FCB
  5603.     INC    BX
  5604.     SAHF
  5605.     RET
  5606. ;.....
  5607. ;
  5608. ;
  5609. TRANS:    MOV    SI,DX            ;transfer from command line to FCB..
  5610.     MOV    AL,[SI]
  5611.     INC    DX            ;..up to number of chars specified..
  5612.     CMP    AL,CR            ;..by 'C' reg. keep scanning field..
  5613.     JNZ    L6A16
  5614.     RET                ;..without transfer until a delimiting..
  5615. L6A16:
  5616.     CMP    AL,'.'            ;..field char such as '.', blank, or..
  5617.     JNZ    L6A17
  5618.     RET                ;..CR (for end of commmand line).
  5619. L6A17:
  5620.     CMP    AL,' '
  5621.     JNZ    L6A18
  5622.     RET
  5623. L6A18:
  5624.     DEC    CL
  5625.     JS    TRANS            ;once c-reg is less than zero, keep..
  5626.     MOV    Byte Ptr [BX],AL    ;..reading cmd line but do not..
  5627.     INC    BX            ;..transfer to FCB.
  5628.     JMPS    TRANS
  5629. ;...
  5630. ;
  5631. ;
  5632. SCANL:    MOV    CH,8            ;scan file name addressed by BX.
  5633. ;
  5634. TSTNAM: MOV    AL,Byte Ptr [BX]
  5635.     CMP    AL,'*'            ;if '*' found, fill in rest of field..
  5636.     JZ    FILL1            ;..with '?' for ambiguous name.
  5637.     INC    BX
  5638.     DEC    CH
  5639.     JNZ    TSTNAM
  5640.     JMPS    TSTTYP
  5641. ;...
  5642. ;
  5643. ;
  5644. FILL1:    CALL    FILL
  5645. ;
  5646. TSTTYP: MOV    CH,3            ;scan and fill type field for name..
  5647. ;
  5648. TSTTYPL:MOV    AL,Byte Ptr [BX]    ;..specified above.
  5649.     CMP    AL,'*'
  5650.     JZ    FILL2
  5651.     LAHF
  5652.     INC    BX
  5653.     SAHF
  5654.     DEC    CH
  5655.     JNZ    TSTTYPL
  5656.     RET
  5657. ;.....
  5658. ;
  5659. ;
  5660. FILL2:    CALL    FILL
  5661.     RET
  5662. ;.....
  5663. ;
  5664. ;
  5665. FILL:    MOV    Byte Ptr [BX],'?'    ;routine transfers '?'.
  5666.     LAHF
  5667.     INC    BX
  5668.     SAHF
  5669.     DEC    CH
  5670.     JNZ    FILL
  5671.     RET
  5672. ;=======================================================================
  5673. ;
  5674. ; LISTS DIRECTORY AND GIVES FREE SPACE REMAINING ON THE REQUESTED DRIVE.
  5675. ;
  5676. ;
  5677. ; Disk system reset - currently bypassed, if you wish this feature, put
  5678. ;    JMP DIRLIST2 instead of JMP DIRLIST3 in the eighth line.  The
  5679. ;    current disk (plus the A: drive) will then reset each DIR re-
  5680. ;    quest.    You can also reset the disk with the LOG command when
  5681. ;    when inserting a different one.     This saves a reset each time
  5682. ;    DIR might be requested.
  5683. ;
  5684. DIRLIST:CALL    GETDISK
  5685.     ADD    AL,'A'            ;change to ascii
  5686.     MOV    Byte Ptr DRNAME,AL    ;show for drive name
  5687.     MOV    Byte Ptr ACTDRV,AL    ;show for space remaining on drive
  5688. ;
  5689. DIRLIST1:
  5690.     JMPS    DIRLIST3
  5691. ;
  5692. DIRLIST2:
  5693.     MOV    CL,RESET        ;13 reset disk system (resetdk)
  5694.     INT    224
  5695. ;
  5696. ;
  5697. ; Directory list routine
  5698. ;
  5699. DIRLIST3:
  5700.     MOV    DX, Offset CMDBUF    ;put command line in FCBb..
  5701.     MOV    BX, FCB            ;..addressed by BX-reg..
  5702.     CALL    CMDLINE            ;..and then...
  5703.     MOV    BX, Offset FCB4
  5704.     CALL    INITFCB
  5705.     MOV    AL,Byte Ptr .FCB2    ;get drive number
  5706.     MOV    Byte Ptr FCB4,AL
  5707.     MOV    AL,Byte Ptr .FCB2+1
  5708.     CMP    AL,' '            ;if a space (blank) get all names
  5709.     LAHF
  5710.     XCHG    AL,AH
  5711.     PUSH    AX
  5712.     JNZ    L6A19
  5713.     CALL    QSTMARK
  5714. L6A19:
  5715.     POP    AX
  5716.     XCHG    AL,AH
  5717.     SAHF
  5718.     JZ    L6A20
  5719.     CALL    MOVNAME            ;else move name into FCB
  5720. L6A20:
  5721.     CALL    DRIVEL
  5722.     MOV    CL,SETDMA
  5723.     MOV    DX,  TBUF
  5724.     INT    224
  5725.     MOV    AL,Byte Ptr NOOFCOL    ;number of columns into 'A' reg.
  5726.     MOV    Byte Ptr NAMECT,AL     ;CRLF after 'NOOFCOL' number of columns
  5727.     MOV    DX, Offset FCB4
  5728.     MOV    CL,SRCHF        ;do first search
  5729.     INT    224
  5730.     INC    AL            ;0FFH --> 0 if no file(s) found
  5731.     JNZ    DIRLOOP
  5732.     CALL    ILPRT
  5733.     DB    '++ FILE NOT FOUND ++',0
  5734.     JMP    STORAGE            ;still show storage on default drive
  5735. ;
  5736. DIRLOOP:CALL    GETADD
  5737.     LAHF                ;point to first letter of filename
  5738.     INC    BX
  5739.     SAHF
  5740.     MOV    DX,(Offset PRTNAME)
  5741.     MOV    CX,8
  5742.     CALL    MOVER    
  5743.     LAHF
  5744.     INC    DX
  5745.     SAHF
  5746.     MOV    CX,3
  5747.     CALL    MOVER
  5748.     CALL    ILPRT
  5749. ;
  5750. PRTNAME DB    '        ','.','   ',0    ; 8 spaces, period, 3 spaces
  5751. ;
  5752. NEXTSR: MOV    DX, oFFSET FCB4
  5753.     MOV    CL,SRCHN        ;do next search
  5754.     INT    224
  5755.     INC    AL            ;if 0FFH --> 0 then..
  5756.     JZ    STORAGE            ;..directory-read finished.
  5757.     LAHF
  5758.     XCHG    AL,AH
  5759.     PUSH    AX
  5760.     PUSH    DX
  5761.     PUSH    BX
  5762.     MOV    AL,Byte Ptr NAMECT
  5763.     DEC    AL
  5764.     MOV    Byte Ptr NAMECT,AL     ;name count updated
  5765.     OR    AL,AL
  5766.     JNZ    L6A21
  5767.     CALL    CRLF            ;terminate line of file names
  5768. L6A21:
  5769.     JNZ    FENCE
  5770.     MOV    AL,Byte Ptr NOOFCOL    ;restart columns-per-line count
  5771.     MOV    Byte Ptr NAMECT,AL
  5772.     JMPS    NOFENCE            ;fence not needed
  5773. ;
  5774. FENCE:    CALL    ILPRT
  5775.     DB    ' : ',0            ;fence if not at end of line or..
  5776. ;                ;..LAST FILENAME
  5777. NOFENCE:POP    BX
  5778.     POP    DX
  5779.     POP    AX
  5780.     XCHG    AL,AH
  5781.     SAHF
  5782.     JMPS    DIRLOOP
  5783. ;.....
  5784. ;
  5785. ;
  5786. ; Determine storage remaining on default drive
  5787. ;
  5788. STORAGE:
  5789.     CALL    CRLF
  5790.     MOV    CL,DSKPAR        ;current disk parameter block
  5791.     INT    224
  5792.     ADD    BX,2
  5793.     MOV    AL,ES: BYTE PTR [BX]    ;Get Block Shift Factor
  5794.     MOV    BSHIFTF,AL
  5795.     INC    BX            ;bump to block mask
  5796.     MOV    AL,ES: BYTE PTR [BX]    ;get it
  5797.     MOV    BMASK,AL
  5798.     ADD    BX,2
  5799.     MOV    DX,ES: WORD PTR [BX]    ;get max block number
  5800.     MOV    Word Ptr BMAX,DX    ;put it away
  5801.     MOV    CL,DSKALL        ;address of CP/m Allocation vector
  5802.     INT    224
  5803.     XCHG    BX,DX            ;get its length
  5804.     MOV    BX, Word Ptr BMAX
  5805.     INC    BX
  5806.     MOV    CX,0            ;initialize block count to zero
  5807. GSPBYT:
  5808.     PUSH    DX            ;save allocation address
  5809.     XCHG    BX,DX
  5810.     MOV    AL,ES: BYTE PTR [BX]
  5811.     XCHG    BX,DX
  5812.     MOV    DL,8            ;set to process 8 blocks
  5813. GSPLUP:
  5814.     RCL    AL,1            ;test bit
  5815.     JC    NOTFRE
  5816.     INC    CX
  5817. NOTFRE:
  5818.     MOV    DH,AL            ;save bits
  5819.     DEC    BX
  5820.     MOV    AL,BL
  5821.     OR    AL,BH
  5822.     JZ    ENDALC            ;quit if out of blocks
  5823.     MOV    AL,DH            ;restore bits
  5824.     DEC    DL            ;count down 8 bits
  5825.     JNZ    GSPLUP            ;do another bit
  5826.     POP    DX            ;bump to next count....
  5827.     INC    DX            ;...of allocation vector
  5828.     JMP    GSPBYT            ;process it
  5829. ;
  5830. ENDALC:
  5831.     POP    DX            ;clear allocation vector pointer from stack
  5832.     MOV    BX,CX            ;copy block to bx
  5833.     MOV    AL,Byte Ptr BSHIFTF    ;get block shift factor
  5834.     SUB    AL,3            ;convert from record to K
  5835.     JZ    PRTFREE            ;skip shifts of 1K blocks
  5836. FREKLP:
  5837.     ADD    BX,BX            ;multiply blocks by 'K per block'
  5838.     DEC    AL
  5839.     JNZ    FREKLP
  5840. ;
  5841. PRTFREE:CALL    DECOUT            ;(# of free k bytes now in 'BX')
  5842.     MOV    DX,(Offset FREEMSG)
  5843.     JMP    PRTMSG
  5844. ;.....
  5845. ;
  5846. ;
  5847. ; Subroutines for 'DIRLIST' section
  5848. ;
  5849. QSTMARK:MOV    AL,'?'            ;if blank in FCB, put in 11 ?'S.
  5850.     MOV    CH,11
  5851.     MOV    BX, oFFSET FCB4+1
  5852. ;
  5853. QSTLP:    MOV    Byte Ptr [BX],AL
  5854.     LAHF
  5855.     INC    BX
  5856.     SAHF
  5857.     DEC    CH
  5858.     JNZ    QSTLP
  5859.     RET
  5860. ;.....
  5861. ;
  5862. ;
  5863. MOVNAME:MOV    BX, FCB2+1
  5864.     MOV    DX, Offset FCB4+1
  5865.     MOV    CX,11
  5866.     CALL    MOVER
  5867.     RET
  5868. ;.....
  5869. ;
  5870. ;
  5871. GETADD: DEC    AL            ;un-do the inr above
  5872.     ADD    AL,AL            ;times 32
  5873.     ADD    AL,AL
  5874.     ADD    AL,AL
  5875.     ADD    AL,AL
  5876.     ADD    AL,AL
  5877.     ADD    AL,TBUF            ;add buffer offset
  5878.     MOV    BL,AL
  5879.     MOV    BH,0
  5880.     RET
  5881. ;.....
  5882. ;
  5883. ;
  5884. DRIVEL: MOV    AL,Byte Ptr FCB4       ;if no drive, use
  5885.     OR    AL,AL            ;default drive in drname.
  5886.     JZ    PRNTHD
  5887.     LAHF
  5888.     XCHG    AL,AH
  5889.     PUSH    AX
  5890.     XCHG    AL,AH
  5891.     DEC    AL
  5892.     MOV    DL,AL
  5893.     MOV    CL,SELDSK
  5894.     INT    224
  5895.     POP    AX
  5896.     XCHG    AL,AH
  5897.     ADD    AL,40H            ;make 1=a, 2=b, etc., and..
  5898.     MOV    Byte Ptr DRNAME,AL    ;..overwrite default stored below.
  5899.     MOV    Byte Ptr ACTDRV,AL
  5900. ;
  5901. PRNTHD: CALL    ILPRT
  5902.     DB    'Drive '
  5903. ;
  5904. DRNAME    DB    ' :',CR,LF,0
  5905.     RET
  5906. ;.....
  5907. ;
  5908. ;
  5909. ; Initialized storage
  5910. ;
  5911. FREEMSG DB    'k bytes free on drive '
  5912. ACTDRV    DB    ' :',CR,LF,'$'
  5913. ;
  5914. ;
  5915. ; Uninitialized storage
  5916. ;
  5917. BMAX    Rb    2            ;highest block number on drive
  5918. BMASK    Rb    1            ;rec/blk - 1
  5919. BSHIFTF Rb    1            ;number of shifts to multiply by rec/blk
  5920. ;.....
  5921. ;
  5922. ;
  5923. ;=======================================================================
  5924. ;
  5925. ; Duplicates 'READ BUFFER' routine same as CP/M function 10, but does
  5926. ; not use CTL-C (reason for the routine).  Does allow controls U, R, E
  5927. ; and H (BACKSPACE).  Outputs bell if the input is greater than the
  5928. ; buffer.
  5929. ;
  5930. INBUF:    LAHF
  5931.     XCHG    AL,AH
  5932.     PUSH    AX
  5933.     XCHG    AL,AH
  5934.     PUSH    BX
  5935.     PUSH    CX
  5936.     PUSH    DX            ;'DE' registers must be pushed last
  5937. ;
  5938. INBUFA: CALL    CLEARBUF        ;clear the buffer area
  5939.     POP    DX            ;get address of buffer on retries
  5940.     PUSH    DX            ;restore stack
  5941.     XOR    AL,AL
  5942.     LAHF                ;address count field
  5943.     INC    DX
  5944.     SAHF
  5945.     MOV    SI,DX            ;initialize with a zero in count byte
  5946.     MOV    [SI],AL
  5947.     LAHF
  5948.     INC    DX
  5949.     SAHF
  5950.     XCHG    BX,DX            ;address first buffer byte with 'BX'
  5951. ;
  5952. INBUFB: CALL    KEYIN            ;(waits for char)
  5953.     CALL    UCASE            ;convert to upper case if needed
  5954.     CMP    AL,CR            ;is it <return> (enter command)?
  5955.     JNZ    L6A24
  5956.     JMP    INBUFR            ;if so, then return.
  5957. L6A24:
  5958.     CMP    AL,08H            ;CTL-H backspaces over deleted character
  5959.     JZ    DELETE
  5960.     CMP    AL,7FH            ;is it a delete?
  5961.     JZ    DELETE
  5962.     CMP    AL,'U'-40H        ;is it a CTL-U?
  5963.     JNZ    L6A25
  5964.     JMP    INBUFO            ;output #, CR, LF, and start over
  5965. L6A25:
  5966.     CMP    AL,'R'-40H        ;CTL-R retypes line
  5967.     JNZ    L6A26
  5968.     JMP    RETYPE
  5969. L6A26:
  5970. ;
  5971. INBUFC: MOV    CH,AL            ;save inputted character
  5972.     XCHG    BX,DX            ;save 'BX' in 'DE'
  5973.     POP    BX            ;get address of buffer in 'BX'
  5974.     PUSH    BX            ;restore stack
  5975.     INC    BX            ;address count byte
  5976.     INC    Byte Ptr [BX]        ;increase count byte
  5977.     DEC    BX            ;address maximum
  5978.     MOV    AL,Byte Ptr [BX]    ;put maximum in 'A'
  5979.     INC    BX            ;address count
  5980.     CMP    AL,Byte Ptr [BX]    ;compare count to maximum
  5981.     JNB    L6A27
  5982.     JMP    ALERTL            ;if maximum, ring bell and wait for cr.
  5983. L6A27:
  5984.     XCHG    BX,DX            ;restore buffer pointer to 'BX'
  5985.     MOV    Byte Ptr [BX],CH    ;put inputted character in buffer
  5986.     MOV    AL,CH            ;output it
  5987.     CMP    AL,EXITCHR        ;exit character?
  5988.     JNZ    L6A28
  5989.     JMP    INBUFR            ;if yes, all done
  5990. L6A28:
  5991.     CMP    AL,20H            ;printing character?
  5992.     JNAE    L6A29
  5993.     CALL    STYPE             ;if yes, print it
  5994. L6A29:
  5995.     LAHF                ;bump pointer
  5996.     INC    BX
  5997.     SAHF
  5998.     JMPS    INBUFB            ;get next character
  5999. ;...
  6000. ;
  6001. ;
  6002. DELETE: XCHG    BX,DX            ;save buffer pointer in 'DE'
  6003.     POP    BX            ;address beginning of buffer
  6004.     PUSH    BX            ;restore stack
  6005.     INC    BX            ;address count field
  6006.     MOV    AL,Byte Ptr [BX]
  6007.     SUB    AL,1            ;decrease count
  6008.     MOV    Byte Ptr [BX],AL
  6009.     JB    NODEL            ;don't delete past beginning of buffer
  6010.     XCHG    BX,DX            ;restore buffer pointer to 'BX'
  6011.     DEC    BX            ;point to last byte inputted
  6012.  
  6013.  
  6014.     MOV    AL,Byte Ptr [BX]    ;get character being deleted
  6015.     MOV    Byte Ptr [BX],' '    ;restore blank
  6016.     CMP    AL,' '            ;see if non-printing character
  6017.     JB    DELETE1            ;if yes, skip the CRT backup
  6018.     MOV    AL,BKSP
  6019.     CALL    STYPE            ;true erase if 08H
  6020.     MOV    AL,' '
  6021.     CALL    STYPE
  6022.     MOV    AL,BKSP
  6023.     CALL    STYPE
  6024. DELETE1:
  6025.     JMP    INBUFB
  6026.     
  6027.  
  6028. ;.....
  6029. ;
  6030. ;
  6031. MORE    DB    '12345'            ;5 bytes extra from DELETE routine fix
  6032. ;
  6033. NODEL:    INC    Byte Ptr [BX]        ;don't leave count negative
  6034.     XCHG    BX,DX            ;restore pointer to 'BX'
  6035.     MOV    AL,BELL            ;says can go no further
  6036.     CALL    STYPE
  6037.     JMP    INBUFB
  6038. ;.....
  6039. ;
  6040. ;
  6041. INBUFO: MOV    AL,'#'            ;announces the line has been removed
  6042.     CALL    STYPE
  6043.     CALL    CRLF
  6044.     JMP    INBUFA
  6045. ;.....
  6046. ;
  6047. ;
  6048. RETYPE: POP    DX
  6049.     PUSH    DX
  6050.     LAHF                ;point to current number..
  6051.     INC    DX
  6052.     SAHF
  6053.     MOV    SI,DX            ;..of characters.
  6054.     MOV    AL,[SI]
  6055.     MOV    CH,AL
  6056.     MOV    AL,'#'
  6057.     CALL    STYPE
  6058.     CALL    CRLF
  6059.     MOV    AL,CH            ;test if zero input
  6060.     OR    AL,AL
  6061.     JNZ    CTLRLP
  6062.     JMP    INBUFB
  6063. ;...
  6064. ;
  6065. ;
  6066. CTLRLP: LAHF
  6067.     INC    DX
  6068.     SAHF
  6069.     MOV    SI,DX
  6070.     MOV    AL,[SI]
  6071.     CALL    STYPE
  6072.     DEC    CH
  6073.     JNZ    CTLRLP
  6074.     JMP    INBUFB
  6075. ;.....
  6076. ;
  6077. ;    
  6078. ALERTL: MOV    AL,BELL            ;alarm for full buffer
  6079.     CALL    STYPE
  6080.     DEC    Byte Ptr [BX]
  6081.     XCHG    BX,DX
  6082.     JMP    INBUFB
  6083. ;.....
  6084. ;
  6085. ;
  6086. PCRLF:    CALL    CRLF
  6087.     JMP    INBUFB
  6088. ;.....
  6089. ;
  6090. ;
  6091. INBUFR: CALL    CRLF            ;1st new line after a command character
  6092.     POP    DX
  6093.     POP    CX
  6094.     POP    BX
  6095.     POP    AX
  6096.     XCHG    AL,AH
  6097.     SAHF
  6098.     RET
  6099. ;.....
  6100. ;
  6101. ;
  6102. CLEARBUF:
  6103.     POP    DX            ;accounts for call
  6104.     POP    BX            ;address buffer in 'BX'
  6105.     PUSH    BX            ;restore..
  6106.     PUSH    DX            ;..stack
  6107.     MOV    CH,Byte Ptr [BX]    ;save maximum in 'B'
  6108.     LAHF                ;point to first..
  6109.     INC    BX
  6110.     SAHF
  6111.     LAHF                ;..buffer byte.
  6112.     INC    BX
  6113.     SAHF
  6114.     MOV    AL,' '
  6115. ;
  6116. CLEARL: MOV    Byte Ptr [BX],AL
  6117.     LAHF
  6118.     INC    BX
  6119.     SAHF
  6120.     DEC    CH
  6121.     JNZ    CLEARL
  6122.     RET
  6123. ;.....
  6124. ;
  6125. ;
  6126. ;=======================================================================
  6127. ;
  6128. ; In-line compare.  Compares string addressed by 'DE' to string after
  6129. ; call (ends with zero).  Return with carry set means strings not the
  6130. ; same.     All registers except 'A'-reg are unaffected.
  6131. ;
  6132. INLNCOMP:
  6133.     POP    BX            ;point 'SI' to 1st char.
  6134.     PUSH    DX
  6135. ;
  6136. ILCOMPL:MOV    AL,Byte Ptr [BX]    ;'BX' points to in-line string.
  6137.     OR    AL,AL            ;end of string if zero.
  6138.     JZ    SAME
  6139.     MOV    SI,DX
  6140.     MOV    AL,[SI]
  6141.     CMP    AL,Byte Ptr [BX]
  6142.     JNZ    NOTSAME
  6143.     INC    BX
  6144.     INC    DX
  6145.     JMPS    ILCOMPL
  6146. ;...
  6147. ;
  6148. ;
  6149. NOTSAME:XOR    AL,AL            ;if not same, finish thru..
  6150. ;
  6151. NSLP:    INC    BX            ;..string so return will..
  6152.     CMP    AL,Byte Ptr [BX]    ;..go to instruction after..
  6153.     JNZ    NSLP            ;..string and not remainder of string.
  6154.     STC
  6155. ;
  6156. SAME:    POP    DX
  6157.     LAHF                ;avoids a NOP instruction..
  6158.     INC    BX
  6159.     SAHF
  6160.     PUSH    BX            ;..when returning.
  6161.     RET
  6162. ;.....
  6163. ;
  6164. ;
  6165. ;=======================================================================
  6166. ;
  6167. ; Multi-file access subroutine.     Allows processing of multiple files
  6168. ; (i.e., *.ASM) from disk.  Builds the correct name in the FCB each time
  6169. ; it is called.     The command is used in programs to process single or
  6170. ; multiple files.  The FCB is set up with the next name, ready to do
  6171. ; normal processing (open, read, etc.) when routine is called.    Carry is
  6172. ; set if no more names are found.
  6173. MFNAME: PUSH    CX
  6174.     PUSH    DX
  6175.     PUSH    BX
  6176.     MOV    CL,SETDMA
  6177.     MOV    DX, TBUF
  6178.     INT    224
  6179.     POP    BX
  6180.     POP    DX
  6181.     POP    CX
  6182.     XOR    AL,AL
  6183.     MOV    Byte Ptr .FCBEXT,AL
  6184.     MOV    AL,Byte Ptr MFFLG1
  6185.     OR    AL,AL
  6186.     JNZ    MFNAME1
  6187.     MOV    AL,1
  6188.     MOV    Byte Ptr MFFLG1,AL
  6189.     MOV    BX, FCB
  6190.     MOV    DX, Offset MFNAME5
  6191.     MOV    CX,12
  6192.     CALL    MOVER
  6193.     MOV    AL,Byte Ptr .FCB
  6194.     MOV    Byte Ptr MFNAME6,AL    ;save disk in current FCB
  6195.     MOV    BX, Offset MFNAME5
  6196.     MOV    DX, FCB
  6197.     MOV    CX,12
  6198.     CALL    MOVER
  6199.     PUSH    CX
  6200.     PUSH    DX
  6201.     PUSH    BX
  6202.     MOV    CL, SRCHF
  6203.     MOV    DX, FCB
  6204.     INT    224
  6205.     POP    BX
  6206.     POP    DX
  6207.     POP    CX
  6208.     JMPS    MFNAME2
  6209. ;...
  6210. ;
  6211. ;
  6212. MFNAME1:MOV    BX, Offset MFNAME6
  6213.     MOV    DX, FCB
  6214.     MOV    CX,12
  6215.     CALL    MOVER
  6216.     PUSH    CX
  6217.     PUSH    DX
  6218.     PUSH    BX
  6219.     MOV    CL,SRCHF
  6220.     MOV    DX, FCB
  6221.     INT    224
  6222.     POP    BX
  6223.     POP    DX
  6224.     POP    CX
  6225.     MOV    BX,Offset MFNAME5
  6226.     MOV    DX,FCB
  6227.     MOV    CX,12
  6228.     CALL    MOVER
  6229.     PUSH    CX
  6230.     PUSH    DX
  6231.     PUSH    BX
  6232.     MOV    CL,SRCHN
  6233.     MOV    DX, FCB
  6234.     INT    224
  6235.     POP    BX
  6236.     POP    DX
  6237.     POP    CX
  6238. ;
  6239. MFNAME2:INC    AL
  6240.     STC
  6241.     JNZ    MFNAME3
  6242.     MOV    Byte Ptr MFFLG1,AL
  6243.     RET
  6244. ;.....
  6245. ;
  6246. ;    
  6247. MFNAME3:DEC    AL
  6248.     AND    AL,3
  6249.     ADD    AL,AL
  6250.     ADD    AL,AL
  6251.     ADD    AL,AL
  6252.     ADD    AL,AL
  6253.     ADD    AL,AL
  6254.     ADD    AL,81H
  6255.     MOV    BL,AL
  6256.     MOV    BH,0
  6257.     PUSH    BX            ;save name pointer
  6258.     MOV    DX, Offset MFNAME6+1
  6259.     MOV    CX,11
  6260.     CALL    MOVER
  6261.     POP    BX
  6262.     MOV    DX, FCB+1
  6263.     MOV    CX,11
  6264.     CALL    MOVER
  6265.     XOR    AL,AL
  6266.     MOV    Byte Ptr .FCBEXT,AL
  6267.     MOV    Byte Ptr .FCBRNO,AL
  6268.     RET
  6269. ;.....
  6270. ;
  6271. ;
  6272. MFNAME4:
  6273. MOVER:    MOV    AL,Byte Ptr [BX]    ;used if an 8080 CPU is active
  6274.     MOV    SI,DX
  6275.     MOV    [SI],AL
  6276.     INC    BX
  6277.     INC    DX
  6278.     DEC    CX
  6279.     MOV    AL,CH
  6280.     OR    AL,CL
  6281.     JNZ    MFNAME4
  6282.     RET
  6283. ;.....
  6284. ;
  6285. ;        (END OF MULTI-FILE ACCESS ROUTINE)    
  6286. ;=======================================================================
  6287. ;         CALCULATE FILE TRANSFER TIME
  6288. ;
  6289. ;
  6290. ; Shows the time to transfer a file at various baud rates.  (110-19200)
  6291. ;
  6292. SENDTIME:
  6293.     CALL    ILPRT            ;print following message:
  6294.     DB    'File open: ',0
  6295.     MOV    BX,Word Ptr RCNT       ;get record count.
  6296.     CALL    DECOUT            ;print decimal number of records
  6297. ;
  6298.     MOV    AL,Byte Ptr HEXSHOW
  6299.     OR    AL,AL
  6300.     JZ    SENDTIME1
  6301.     CALL    ILPRT
  6302.     DB    ' (',0
  6303.     CALL    DHXOUT            ;now print size in hex.
  6304.     CALL    ILPRT
  6305.     DB    'H)',0
  6306. ;
  6307. SENDTIME1:
  6308.     CALL    ILPRT
  6309.     DB    ' records'
  6310.     DB    CR,LF,'Send time: ',0
  6311.     MOV    AL,Byte Ptr MSPEED    ;get the speed indicator
  6312.     MOV    DH,0
  6313.     MOV    DL,AL            ;set up for table access
  6314.     MOV    BX,(Offset BTABLE)    ;point to baud factor table
  6315.     LAHF                ;index to proper factor
  6316.     ADD    BX,DX
  6317.     SAHF
  6318.     LAHF                ;factor in 'DE'
  6319.     ADD    BX,DX
  6320.     SAHF
  6321.     MOV    DL,Byte Ptr [BX]
  6322.     LAHF
  6323.     INC    BX
  6324.     SAHF
  6325.     MOV    DH,Byte Ptr [BX]
  6326.     MOV    BX,Word Ptr RCNT       ;get # of records
  6327.     CALL    DVHLDE            ;divide BX by value in DE (records/min)
  6328.     PUSH    BX
  6329.     MOV    BX,CX
  6330.     CALL    DECOUT            ;print the minutes portion
  6331.     CALL    ILPRT
  6332.     DB    ' mins, ',0
  6333.     MOV    BX,(Offset RECDBL)    ;point to divisors for seconds
  6334.     MOV    DX,0            ;   calculation
  6335.     MOV    AL,Byte Ptr MSPEED     ;get index for baud rate
  6336.     MOV    DL,AL
  6337.     LAHF                ;index into table
  6338.     ADD    BX,DX
  6339.     RCR    SI,1
  6340.     SAHF
  6341.     RCL    SI,1
  6342.     MOV    AL,Byte Ptr [BX]    ;get multiplier
  6343.     POP    BX            ;get remainder
  6344.     CALL    MULHLA            ;multiply the 'BX' x 'A'
  6345.     CALL    SHFTHL
  6346.     CALL    SHFTHL
  6347.     CALL    SHFTHL
  6348.     CALL    SHFTHL
  6349.     MOV    BH,0
  6350.     CALL    DECOUT            ;print the seconds portion
  6351.     CALL    ILPRT
  6352.     DB    ' secs at ',0
  6353.     CALL    PRTBAUD
  6354.     CALL    ILPRTQ
  6355.     DB    'To cancel: use CTL-X',CR,LF,0
  6356.     RET
  6357. ;
  6358. BTABLE    DW    5,13,20,26,29,48,85,152,280,480,0    ;records/min for..
  6359. RECDBL    DB    192,74,48,37,33,20,11,6,3,2,0    ;110-19200 baud
  6360. ;.....
  6361. ;
  6362. ;
  6363. ; Shows baud rates set for 'time to send' file transfer
  6364. ;
  6365. PRTBAUD:MOV    BX,(Offset BAUDSPD)
  6366.     MOV    DH,0
  6367.     MOV    AL,Byte Ptr MSPEED     ;get baud rate code
  6368.     MOV    DL,AL            ;x1
  6369.     ADD    AL,AL            ;x2
  6370.     ADD    AL,AL            ;x4
  6371.     ADD    AL,DL            ;x5
  6372.     ADD    AL,DL
  6373.     MOV    DL,AL
  6374.     LAHF                ;point to correct rate
  6375.     ADD    BX,DX
  6376.     RCR    SI,1
  6377.     SAHF
  6378.     RCL    SI,1
  6379.     XCHG    BX,DX
  6380.     MOV    CL,PRINT
  6381.     INT    224
  6382.     CALL    ILPRT
  6383.     DB    ' bps ',CR,LF,0
  6384.     RET
  6385. ;.....
  6386. ;
  6387. ;
  6388. BAUDSPD DB    '110$',0,0,'300$',0,0,'450$',0,0,'600$',0,0,'710$',0,0
  6389.     DB    '1200$',0,'2400$',0,'4800$',0,'9600$',0,'19200$'
  6390. ;.....
  6391. ;
  6392. ;    
  6393. ;---->    DVHLDE: Divides 'BX' by value in 'DE',
  6394. ;    Upon exit: 'BC'=quotient,'BL'=remainder
  6395. ;
  6396. DVHLDE: PUSH    DX            ;save divisor
  6397.     MOV    AL,DL
  6398.     NOT    AL            ;negate divisor
  6399.     MOV    DL,AL
  6400.     MOV    AL,DH
  6401.     NOT    AL
  6402.     MOV    DH,AL
  6403.     LAHF                ;'DE' is now two's complemented
  6404.     INC    DX
  6405.     SAHF
  6406.     MOV    CX,0            ;init quotient
  6407. ;
  6408. DIVL1:    LAHF                ;subtract divisor from dividend
  6409.     ADD    BX,DX
  6410.     RCR    SI,1
  6411.     SAHF
  6412.     RCL    SI,1
  6413.     LAHF                ;bump quotient
  6414.     INC    CX
  6415.     SAHF
  6416.     JB    DIVL1            ;loop till sign changes
  6417.     LAHF                ;adjust quotient
  6418.     DEC    CX
  6419.     SAHF
  6420.     POP    DX            ;retrieve divisor
  6421.     LAHF                ;adjust remainder
  6422.     ADD    BX,DX
  6423.     RCR    SI,1
  6424.     SAHF
  6425.     RCL    SI,1
  6426.     RET
  6427. ;.....
  6428. ;
  6429. ;
  6430. ;---->    MULHLA:     Multiply the value in 'BX' by the value in 'A'
  6431. ;         Return with answer in 'BX'
  6432. ;
  6433. MULHLA: XCHG    BX,DX            ;multiplicand to 'DE'
  6434.     MOV    BX,0            ;init product
  6435.     INC    AL            ;adjust multiplier for zero test
  6436. ;
  6437. MULLP:    DEC    AL
  6438.     JNZ    L7A5
  6439.     RET
  6440. L7A5:
  6441.     LAHF
  6442.     ADD    BX,DX
  6443.     RCR    SI,1
  6444.     SAHF
  6445.     RCL    SI,1
  6446.     JMPS    MULLP
  6447. ;.....
  6448. ;
  6449. ;
  6450. ; Shift 'BX' register pair one bit to the right
  6451. ;
  6452. SHFTHL: RCR    BX,1
  6453.     RET
  6454. ;.....
  6455. ;
  6456. ;        
  6457. ;         (END OF FILE TRANSFER TIME ROUTINE)
  6458. ;=======================================================================
  6459. ;             CRC SUBROUTINES
  6460. ;
  6461. ;
  6462. ; Check 'CRC' bytes of record just received
  6463. ;
  6464. CRCCHK: PUSH    BX
  6465.     MOV    BX,Word Ptr CRCVAL
  6466.     MOV    AL,BH
  6467.     OR    AL,BL
  6468.     POP    BX
  6469.     JNZ    L7A7
  6470.     RET
  6471. L7A7:
  6472.     MOV    AL,0FFH
  6473.     RET
  6474. ;.....
  6475. ;
  6476. ;
  6477. ; Generate the CRC tables for fast calculations
  6478. ;
  6479. CRCGEN: MOV    BX, OFFSET CRCTBL    ;address at start of 'CRC' lookup table
  6480.     MOV    CL,0
  6481. ;
  6482. CRCGEN1:XCHG    BX,DX            ;store table location into 'DE'
  6483.     MOV    BX,0            ;clear 'BX' pair
  6484.     MOV    AL,CL
  6485.     PUSH    CX
  6486.     MOV    CH,8
  6487.     XOR    AL,BH
  6488.     MOV    BH,AL
  6489. ;
  6490. CRCGEN2:SHL    BX,1            ;index into the table
  6491.     JNB    CRCGEN3
  6492.     MOV    AL,16            ;using x^ 16 + x^12 + x^5 + 1 algorithm
  6493.     XOR    AL,BH
  6494.     MOV    BH,AL
  6495.     MOV    AL,32+1
  6496.     XOR    AL,BL
  6497.     MOV    BL,AL
  6498. ;
  6499. CRCGEN3:DEC    CH
  6500.     JNZ    CRCGEN2            ;make 8 loops, one for each bit
  6501. ;
  6502. ;
  6503. ; Value now in 'BX', table address still stored in 'DE'.  Exchange, and
  6504. ; store the 'CRC' value in the two tables after splitting.
  6505. ;
  6506.     POP    CX            ;finished borrowing the 'B' reg.
  6507.     XCHG    BX,DX            ;address back in 'BX', 'CRC' in 'DE'
  6508.     MOV    Byte Ptr [BX],DH    ;store 1st part of 'CRC' value
  6509.     INC    BH            ;move up 256 bytes
  6510.     MOV    Byte Ptr [BX],DL    ;store 2nd part of 'CRC' value
  6511.     DEC    BH            ;move back 256 bytes
  6512.     LAHF                ;increment to next location
  6513.     INC    BX
  6514.     SAHF
  6515.     INC    CL            ;done when 'C' reg. turns zero again
  6516.     JNZ    CRCGEN1            ;now go do the next location
  6517.     RET
  6518. ;.....
  6519. ;
  6520. ;
  6521. ; Update the CRC value from a character in the 'A' register
  6522. ;
  6523. CRCUPD: LAHF                ;save all registers just in case
  6524.     XCHG    AL,AH
  6525.     PUSH    AX
  6526.     XCHG    AL,AH
  6527.     PUSH    CX
  6528.     PUSH    DX
  6529.     PUSH    BX
  6530.     MOV    BX,Word Ptr CRCVAL     ;get current value
  6531.     XCHG    BX,DX            ;put in 'DE' for now
  6532.     MOV    CH,0
  6533.     XOR    AL,DH
  6534.     MOV    CL,AL            ;now have the character in 'BC' pair
  6535.     MOV    BX, Offset CRCTBL    ;start of 'CRC' lookup-table
  6536.     ADD    BX,CX            ;index into the 'CRC' table    
  6537.     MOV    AL,Byte Ptr [BX]    ;get the value from the table
  6538.     XOR    AL,DL
  6539.     MOV    DH,AL
  6540.     INC    BH            ;move 256 bytes for 2nd table location
  6541.     MOV    DL,Byte Ptr [BX]    ;put value there into 'E' register
  6542.     XCHG    BX,DX            ;put 'DE' into 'BX'
  6543.     MOV    Word Ptr CRCVAL,BX     ;updated 'CRC' value with this character
  6544.     POP    BX            ;restore all registers
  6545.     POP    DX
  6546.     POP    CX
  6547.     POP    AX
  6548.     XCHG    AL,AH
  6549.     SAHF
  6550.     RET
  6551. ;.....
  6552. ;
  6553. ;==================== END OF CRC SUBROUTINE ============================
  6554. ;
  6555. ;
  6556. ;=========================START OF MENU ================================
  6557. ;
  6558. ;
  6559. MENU0:    MOV    AL,Byte Ptr NFILFLG
  6560.     OR    AL,AL
  6561.     JZ    MENU            ;exit if not saving memory for disk file
  6562.     CALL    ILPRT            ;else print message
  6563.     DB    CR,LF,'** File still open, use DEL, DIR, WRT, E, L '
  6564.     DB    'or T ** ',CR,LF,BELL,0
  6565.     JMPS    MENU1
  6566. ;
  6567. MENU:    XOR    AL,AL
  6568.     MOV    Byte Ptr ABORTFLG,AL   ;null the flag
  6569. ;
  6570. MENU1:    MOV    BX, OFFSET RESTSN    ;restore record numbers..
  6571.     MOV    DX, OFFSET RECDNOB    ;..for new file transfer.
  6572.     MOV    CH, (OFFSET RECDNOE)-(OFFSET RECDNOB)
  6573.     CALL    MOVE
  6574.     MOV    BX,OFFSET RESTROPT           ;restore option table
  6575.     MOV    DX,OFFSET OPTBL
  6576.     MOV    CH, (OFFSET OPTBE)-(OFFSET OPTBL)
  6577.     CALL    MOVE
  6578.     XOR    AL,AL
  6579.     MOV    Byte Ptr FSTFLG,AL
  6580.     MOV    Byte Ptr TIMFLG,AL
  6581.     MOV    Byte Ptr FLTRFLG,AL    ;reset multi-file trans
  6582.     MOV    Byte Ptr MFFLG1,AL     ;reset mfaccess routine..
  6583.     JMP    XPRT
  6584. ;.....
  6585. ;
  6586. ;
  6587. ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6588. ;
  6589. ;               MENU OF COMMANDS
  6590. ;
  6591. ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6592. ;
  6593. MENU2:    CALL    CLRTST
  6594.     CALL    ILPRT
  6595.     DB    '                  Single Letter Commands',CR,LF,LF
  6596.     DB    ' ?  - Display current settings',CR,LF
  6597. MENU3    DB    ' ^  - Function key intercept character, '
  6598.     DB    'then (0-9)',CR,LF
  6599.     DB    ' M  - Display the menu',CR,LF
  6600.     DB    ' E  - Terminal mode with echo',CR,LF
  6601.     DB    ' L  - Terminal mode with local echo',CR,LF
  6602.     DB    ' T  - Terminal mode',CR,LF
  6603.     DB    '         For copying text to disk use T (E or L) '
  6604.     DB    'FILENAME.TYP',CR,LF
  6605.     DB    '         Start or Stop toggles described on subsequent'
  6606.     DB    ' screen.',CR,LF
  6607.     DB    ' R  - Receive CP/M file using Christensen Protocol'
  6608.     DB    CR,LF
  6609.     DB    ' S  - Send CP/M file using Christensen Protocol',CR,LF
  6610.     DB    '         COMMAND: R (or S) FILENAME.TYP',CR,LF
  6611.     DB    '         R and S can use the following subcommands:'
  6612.     DB    CR,LF
  6613.     DB    '            B  - Bulk transfer using wildcards '
  6614.     DB    '(e.g., *.*)',CR,LF
  6615.     DB    '            D  - Disconnect when done'
  6616.     DB    CR,LF
  6617.     DB    '            Q  - Quiet mode (no messages to console)'
  6618.     DB    CR,LF
  6619.     DB    '            V  - View <R> or <S> bytes on console'
  6620.     DB    CR,LF
  6621.     DB    '            X  - When done, disconnect, go to CP/M'
  6622.     DB    CR,LF,LF
  6623.     DB    '      The single letter commands may also be used on '
  6624.     DB    'the',CR,LF
  6625.     DB    '      command line when the program is initially '
  6626.     DB    'executed.',CR,LF,LF,0
  6627. ;
  6628. THREELTR:
  6629.     CALL    JMP_NXTSCRN
  6630.     CALL    ILPRT
  6631.     DB    '                Three Letter Commands',CR,LF,LF
  6632.     DB    'CPM - Exit from this program to CP/M',CR,LF
  6633.     DB    'DIR - List directory and space free (may specify '
  6634.     DB    'drive)',CR,LF
  6635.     DB    'ERA - Erase file (may specify drive)',CR,LF
  6636.     DB    'LOG - Change default drive/user no. (specify '
  6637.     DB    'drive/user)',CR,LF
  6638.     DB    '      and reset disks.  e.g. LOG A0: or LOG B:  '
  6639.     DB    '(user # unchanged)',CR,LF
  6640.     DB    'SPD - Set file output speed in terminal mode'
  6641.     DB    CR,LF,0
  6642. ;
  6643.     CALL    SORPTST
  6644.     JNZ    NOTIME
  6645.     CALL    ILPRT
  6646.     DB    'TIM - Select Baud rate for "time-to-send" msg.',CR,LF,0
  6647. ;
  6648. NOTIME: MOV    AL,Byte Ptr TOGGLECRC
  6649.     OR    AL,AL
  6650.     JZ    NOTOCRC
  6651.     CALL    ILPRT
  6652.     DB    'TCC - Toggle CRC/Checksum mode on receive',CR,LF,0
  6653. ;
  6654. NOTOCRC:MOV    AL,Byte Ptr TOGGLELOC
  6655.     OR    AL,AL
  6656.     JZ    NOTOGLOC
  6657.     CALL    ILPRT
  6658.     DB    'TLC - Toggle local command immediate or after ',0
  6659.     MOV    AL,Byte Ptr EXTCHR
  6660.     CALL    SHFTYPE
  6661.     DB    CR,LF,0
  6662. ;
  6663. NOTOGLOC:
  6664.     MOV    AL,Byte Ptr TOGGLELF
  6665.     OR    AL,AL
  6666.     JZ    NOTOGRUB
  6667.     CALL    ILPRT
  6668.     DB    'TLF - Toggle LF after CR in "L" or "T" mode for '
  6669.     DB    'a disk file',CR,LF,0
  6670. ;
  6671. NOTOGRUB:
  6672.     MOV    AL,Byte Ptr TOGGLERUB
  6673.     OR    AL,AL
  6674.     JZ    NOTOGLF
  6675.     CALL    ILPRT
  6676.     DB    'TRB - Toggle rubout to backspace conversion',CR,LF,0
  6677. ;
  6678. NOTOGLF:MOV    AL,Byte Ptr TOGXOFF
  6679.     OR    AL,AL
  6680.     JZ    NOTOGXOF
  6681.     CALL    ILPRT
  6682.     DB    'TXO - Toggle XOFF testing in terminal mode '
  6683.     DB    'file output',CR,LF,0
  6684. ;
  6685. NOTOGXOF:
  6686.     MOV    AL,Byte Ptr PMMIMODEM  ;using a PMMI modem?
  6687.     OR    AL,AL
  6688.     JNZ    NONUM
  6689.     MOV    AL,Byte Ptr AUTODIAL   ;using a Hayes-type modem?
  6690.     OR    AL,AL
  6691.     JNZ    NOTOGX2
  6692. ;
  6693. NOTOGX1:CALL    ILPRT
  6694.     DB    'NUM - List remote systems',CR,LF,0
  6695. ;
  6696. NOTOGX2:MOV    AL,Byte Ptr SETUPTST
  6697.     OR    AL,AL
  6698.     JZ    NONUM
  6699.     CALL    ILPRT
  6700.     DB    'SET - Set modem baud rate',CR,LF,0
  6701. ;
  6702. NONUM:    CALL    ILPRT
  6703.     DB    'BYE - Disconnect, then return to CP/M'
  6704.     DB    CR,LF,0
  6705.     MOV    AL,Byte Ptr PMMIMODEM  ;using a PMMI modem?
  6706.     OR    AL,AL
  6707.     JNZ    NONUM0            ;if yes, display 'CAL'
  6708.     MOV    AL,Byte Ptr AUTODIAL   ;usina a Hayes-type modem?
  6709.     OR    AL,AL
  6710.     JZ    NOPMMI            ;exit if neither
  6711. ;
  6712. NONUM0: CALL    ILPRT
  6713.     DB    'CAL - Dial number',CR,LF,0
  6714. ;
  6715. NOPMMI: CALL    ILPRT
  6716.     DB    'DSC - Disconnect from the phone line',CR,LF,LF
  6717.     DB    '          The following are terminal text '
  6718.     DB    'buffer commands:',CR,LF,LF,0
  6719. ;
  6720. SKIPLF: CALL    ILPRT
  6721.     DB    'DEL - Delete memory buffer and file',CR,LF
  6722.     DB    'WRT - Write memory buffer to disk file',CR,LF,LF,0
  6723.     CALL    NXTSCRN
  6724.     CALL    ILPRT
  6725.     DB    '        Local Commands while in Terminal Mode'
  6726.     DB    CR,LF,LF,0
  6727.     MOV    AL,Byte Ptr BRKCHR
  6728.     CALL    SHFTYPE
  6729.     DB    '  - Send a break tone for 300 ms.',CR,LF,0
  6730.     MOV    AL,Byte Ptr PMMIMODEM
  6731.     OR    AL,AL
  6732.     JZ    SKIPLF1
  6733.     MOV    AL,Byte Ptr CHGBAUD
  6734.     CALL    SHFTYPE
  6735.     DB    '  - Change baud rate',CR,LF,0
  6736. ;
  6737. SKIPLF1:MOV    AL,EXITCHR
  6738.     CALL    SHFTYPE
  6739.     DB    '  - Exit to command mode',CR,LF,0
  6740.     MOV    AL,Byte Ptr TRANLOGON
  6741.     OR    AL,AL
  6742.     JZ    NOTRNLOG
  6743.     MOV    AL,Byte Ptr LOGCHR
  6744.     CALL    SHFTYPE
  6745.     DB    '  - Send log-on message',CR,LF,0
  6746. ;
  6747. NOTRNLOG:
  6748.     MOV    AL,Byte Ptr NOCONNCT
  6749.     CALL    SHFTYPE
  6750.     DB    '  - Disconnect from the phone line',CR,LF,0
  6751.     MOV    AL,Byte Ptr LSTTST
  6752.     OR    AL,AL
  6753.     JZ    NOTLIST
  6754.     MOV    AL,Byte Ptr LSTCHR
  6755.     CALL    SHFTYPE
  6756.     DB    '  - Toggle printer',CR,LF,0
  6757. ;
  6758. NOTLIST:MOV    AL,LF
  6759.     CALL    STYPE
  6760.     MOV    AL,Byte Ptr SAVECHR
  6761.     CALL    SHFTYPE
  6762.     DB    '  - Start copy into buffer',CR,LF,0
  6763.     MOV    AL,Byte Ptr UNSAVECHR
  6764.     CALL    SHFTYPE
  6765.     DB    '  - Stop copy into buffer',CR,LF,LF
  6766.     DB    '             Start & Stop may be toggled as often as '
  6767.     DB    'desired.',CR,LF
  6768.     DB    '             A ";" at start of line indicates buffer '
  6769.     DB    'is copying.',CR,LF
  6770.     DB    '             XOFF automatically used to stop input '
  6771.     DB    'when writing',CR,LF
  6772.     DB    '                full buffer to disk, XON sent to '
  6773.     DB    'resume.',CR,LF,LF,0
  6774.     MOV    AL,Byte Ptr TRANCHR
  6775.     CALL    SHFTYPE
  6776.     DB    '  - Transfer ASCII file to remote',CR,LF,LF,0
  6777.     MOV    AL,Byte Ptr LOCNXTCHR
  6778.     OR    AL,AL
  6779.     MOV    AL,Byte Ptr EXTCHR
  6780.     JNZ    REMDFLT
  6781.     CALL    SHFTYPE
  6782.     DB    '  - Send local control character to remote'
  6783.     DB    CR,LF,LF,0
  6784.     JMPS    CKSPCL
  6785. ;
  6786. REMDFLT:CALL    SHFTYPE
  6787.     DB    '  - Next character will be used for local control'
  6788.     DB    CR,LF,0
  6789. ;
  6790. CKSPCL: CALL    JMP_SPCLMENU        ;may have a special menu in the overlay
  6791. ;                ;FALLS ON THROUGH TO 'XPRT'    
  6792. ;
  6793. ;
  6794. ;             (END OF COMMAND MENU)
  6795. ;=======================================================================
  6796. ;            START OF COMMAND LINE HANDLING
  6797. ;
  6798. ;
  6799. ; Check first to see if a file was opened for copying incoming to disk
  6800. ;
  6801. XPRT:    CALL    CRLF            ;turn up a blank line to look nice
  6802. L7A8:
  6803.     MOV    AL,Byte Ptr NFILFLG    ;have a file open for text mode copy?
  6804.     OR    AL,AL
  6805.     JZ    XPRT1            ;if not, exit
  6806. ;
  6807.     CALL    GETSPC            ;otherwise show remaining space 
  6808.     CALL    ILPRT
  6809.     DB    ' Bytes of buffer free',CR,LF,LF,0
  6810. ;
  6811. ;
  6812. ; Show disk drive and user number, then command line
  6813. ;
  6814. XPRT1:    MOV    CL,CURDSK        ;current disk function
  6815.     INT    224
  6816.     ADD    AL,'A'            ;make ASCII
  6817.     CALL    STYPE
  6818.     CALL    GETUSER            ;get current user number
  6819.     OR    AL,AL
  6820.     JZ    XPRT2            ;skip if user 0
  6821.     MOV    BH,0
  6822.     MOV    BL,AL
  6823.     CALL    DECOUT            ;show current user area
  6824. ;
  6825. XPRT2:    MOV    AL,'>'
  6826.     CALL    STYPE
  6827.     MOV    AL,'>'
  6828.     CALL    STYPE
  6829.     CALL    ILPRT
  6830.     DB    'COMMAND: ',0
  6831.     XOR    AL,AL
  6832.     MOV    Byte Ptr XFLG,AL       ;null the buffer-length flag
  6833. ;
  6834. ;
  6835. ; Get the command line parameters
  6836. ;
  6837. GETCMD: MOV    DX,OFFSET CMDBUF    ;enter command
  6838.     CALL    INBUF
  6839.     MOV    AL,Byte Ptr CMDBUF+2
  6840.     CMP    AL,EXITCHR        ;exit character
  6841.     JZ    XPRT1
  6842. ;
  6843. GETCMD1:CMP    AL, Byte Ptr Fncky    ;function key intercept character
  6844.     JNZ    L7A9
  6845.     JMP    FUNCT            ;   (supplied from 'INTCPT' table)
  6846. L7A9:
  6847.     CMP    AL,'?'
  6848.     JNZ    L7A10
  6849.     JMP    CURPAR
  6850. L7A10:
  6851.     CMP    AL,' '
  6852.     JNZ    L7A11
  6853.     JMP    L7A8             ;skip the extra line feed
  6854. L7A11:
  6855.     MOV    AL,Byte Ptr CMDBUF+3
  6856.     CMP    AL,':'            ;see if request for new drive/user
  6857.     JNZ    L7A12
  6858.     JMP    SETDRV
  6859. L7A12:
  6860.     MOV    DX,OFFSET CMDBUF+2    ;point to command
  6861.     CALL    INLNCOMP
  6862.     DB    'CPM',0
  6863.     JNAE    L7A13
  6864.     JMP    EXIT
  6865. L7A13:
  6866.     CALL    CRLF            ;(1st CR/LF at 'INBUFR')
  6867.     CALL    INLNCOMP
  6868.     DB    'LOG',0
  6869.     JNAE    L7A14
  6870.     JMP    LOGNEW
  6871. L7A14:
  6872.     CALL    INLNCOMP
  6873.     DB    'DIR',0
  6874.     JNAE    L7A15
  6875.     JMP    DIR
  6876. L7A15:
  6877.     CALL    INLNCOMP
  6878.     DB    'ERA',0
  6879.     JNAE    L7A_16
  6880.     JMP    ERASEF
  6881. L7A16:
  6882.     CALL    INLNCOMP
  6883.     DB    'SPD',0
  6884.     JNAE    L7A17
  6885.     JMP    SETSPD
  6886. L7A17:
  6887.     CALL    INLNCOMP
  6888.     DB    'TIM',0
  6889.     JNAE    L7A18
  6890.     JMP    SETTIM
  6891. L7A18:
  6892.     CALL    INLNCOMP
  6893.     DB    'TCC',0
  6894.     JNAE    L7A19
  6895.     JMP    TOGCRC
  6896. L7A19:
  6897.     CALL    INLNCOMP
  6898.     DB    'TRB',0
  6899.     JNAE    L7A20
  6900.     JMP    TOGRUB
  6901. L7A20:
  6902.     CALL    INLNCOMP
  6903.     DB    'TLC',0
  6904.     JNAE    L7A21
  6905.     JMP    TOGLOC
  6906. L7A21:
  6907.     CALL    INLNCOMP
  6908.     DB    'TLF',0
  6909.     JNAE    L7A22
  6910.     JMP    TOGLF
  6911. L7A22:
  6912.     CALL    INLNCOMP
  6913.     DB    'TXO',0
  6914.     JNAE    L7A23
  6915.     JMP    TOGTXOFF
  6916. L7A23:
  6917.     MOV    AL,Byte Ptr PMMIMODEM  ;using a PMMI  modem?
  6918.     OR    AL,AL
  6919.     JNZ    NONUM1            ;if yes, exit
  6920.     MOV    AL,Byte Ptr AUTODIAL   ;using a Hayes-type modem?
  6921.     OR    AL,AL
  6922.     JNZ    NONUM1            ;if yes, exit
  6923.     CALL    INLNCOMP
  6924.     DB    'NUM',0
  6925.     JNAE    L7A24
  6926.     JMP    NUMPRN
  6927. L7A24:
  6928. ;
  6929. NONUM1: MOV    AL,Byte Ptr SETUPTST
  6930.     OR    AL,AL
  6931.     JZ    NXTOPT1
  6932.     CALL    INLNCOMP
  6933.     DB    'SET',0
  6934.     JNAE    L7A25
  6935.     JMP    SETUPENT
  6936. L7A25:
  6937. ;
  6938. NXTOPT1:CALL    INLNCOMP
  6939.     DB    'WRT',0
  6940.     JNAE    L7A26
  6941.     JMP    WRTFIL
  6942. L7A26:
  6943.     CALL    INLNCOMP
  6944.     DB    'DEL',0
  6945.     JNAE    L7A27
  6946.     JMP    NEWFILE
  6947. L7A27:
  6948.     CALL    INLNCOMP
  6949.     DB    'BYE',0
  6950.     JNAE    L7A28
  6951.     JMP    BYEBYE
  6952. L7A28:
  6953.     CALL    INLNCOMP
  6954.     DB    'DSC',0
  6955.     JNAE    L7A29
  6956.     JMP    DONETCD
  6957. L7A29:
  6958.     MOV    AL,Byte Ptr PMMIMODEM  ;using a PMMI modem?
  6959.     OR    AL,AL
  6960.     JNZ    NXTOPT0            ;if yes, exit
  6961.     MOV    AL,Byte Ptr AUTODIAl   ;using a Hayes-type modem?
  6962.     OR    AL,AL
  6963.     JZ    NXOPT2            ;exit if neither modem-type
  6964. ;
  6965. NXTOPT0:CALL    INLNCOMP        ;'DE' set from 1st 'INLNCOMP' call
  6966.     DB    'CAL',0
  6967.     JB    NXOPT2
  6968.     MOV    AL,' '            ;fool the system
  6969.     MOV    Byte Ptr CMDBUF+3,AL   ;..'TBUF' so that it..
  6970.     JMPS    DOOPT            ;..looks at option for dial
  6971. ;
  6972. NXOPT2: MOV    AL,Byte Ptr CMDBUF+2
  6973.     MOV    BX, Offset COMPLIST
  6974.     CALL    COMPARE            ;compares list pointed to by BX..
  6975.     JB    NOTVLD            ;carry set = no match
  6976. ;
  6977. DOOPT:    CALL    SETFCB            ;loads command buffer into FCB
  6978.     CALL    PROCOPT             ;check out the options
  6979.     JMP    RESTART            ;go to work
  6980. ;.....
  6981. ;
  6982. ;
  6983. NOTVLD: CALL    NTVLDMSG
  6984.     JMP    XPRT
  6985. ;.....
  6986. ;
  6987. ;
  6988. NTVLDMSG:
  6989.     CALL    ILPRT
  6990.     DB    '++ Invalid command ++',CR,LF,BELL,0
  6991.     RET
  6992. ;.....
  6993. ;
  6994. ;
  6995. FUNCT:    MOV    AL,Byte Ptr INTCPT     ;get the function key intercept char.
  6996.     AND    AL,07FH            ;strip off any parity
  6997.     LAHF                ;save the character for now
  6998.     XCHG    AL,AH
  6999.     PUSH    AX
  7000.     CALL    CLRTST
  7001.     CALL    ILPRT
  7002.     DB    '         SPECIAL FUNCTION KEY TABLE'
  7003.     DB    CR,LF,LF,0
  7004.     POP    AX            ;get the character back
  7005.     XCHG    AL,AH
  7006.     CMP    AL,' '            ;see if a printing character
  7007.     JNB    FUNCT1            ;if a printing character, show it
  7008.     LAHF
  7009.     XCHG    AL,AH
  7010.     PUSH    AX
  7011.     CALL    ILPRT
  7012.     DB    'CTL-',0
  7013.     POP    AX
  7014.     XCHG    AL,AH
  7015.     ADD    AL,40H            ;convert binary to ASCII character
  7016. ;
  7017. FUNCT1: CALL    STYPE             ;show on the CRT
  7018.     CALL    ILPRT
  7019.     DB    ' current function key intercept character',CR,LF,LF,0
  7020. ;
  7021. ;
  7022. ; Shows the functions of the (0-9) keys
  7023. ;
  7024.     MOV    BX, Offset FNCTBL-1    ;index into the function key table
  7025.     MOV    CH,10            ;has ten entries
  7026. ;
  7027. FUNCT2: INC    BX            ;next table location
  7028.     MOV    AL,Byte Ptr [BX]    ;get the binary function number
  7029.     ADD    AL,'0'            ;convert binary to ASCII digits
  7030.     CALL    STYPE
  7031.     MOV    AL,' '
  7032.     CALL    STYPE
  7033. ;
  7034. FUNCT3: INC    BX            ;next table location    
  7035.     MOV    AL,Byte Ptr [BX]
  7036.     OR    AL,AL            ;see if a binary zero
  7037.     JZ    FUNCT5
  7038.     CMP    AL,CR
  7039.     JNZ    FUNCT4
  7040.     CALL    ILPRT
  7041.     DB    '<CR>',0
  7042.     JMPS    FUNCT3
  7043. ;
  7044. FUNCT4: CALL    STYPE
  7045.     JMPS    FUNCT3
  7046. ;    
  7047. FUNCT5: CALL    CRLF
  7048.     DEC    CH
  7049.     JNZ    FUNCT2
  7050.     CALL    CRLF
  7051.     JMP    XPRT
  7052. ;.....
  7053. ;
  7054. ;
  7055. BYEBYE: MOV    AL,Byte Ptr PMMIMODEM  ;using a PMMI modem?
  7056.     OR    AL,AL
  7057.     JZ    L7A30
  7058.     CALL    JMP_GOODBYE        ;if yes, disconnect
  7059. L7A30:
  7060.     MOV    AL,Byte Ptr AUTODIAL   ;using a Hayes-type modem?
  7061.     OR    AL,AL
  7062.     JZ    L7A31
  7063.     CALL    SMRESET            ;if yes, disconnect
  7064. L7A31:
  7065.     CALL    JMP_GOODBYE        ;user's custom-area goodbye routine
  7066.     CALL    ILPRT
  7067.     DB    CR,LF,'<< Exit to CP/M >>',CR,LF,0
  7068.     JMP    EXIT            ;return to CP/M
  7069. ;
  7070. SMRESET:MOV    CH,20
  7071.     CALL    TIMER
  7072.     MOV    BX, Offset SM_DISC
  7073.     CALL    SENDOUT
  7074.     MOV    CH,20
  7075.     CALL    TIMER
  7076.     MOV    AL,' '
  7077. ;
  7078. ; If showing the +++ and ATH and ATD, etc. move the three semicolons up
  7079. ; one line.
  7080. ;
  7081.     DB    90H,90H,90H
  7082. ;;;    CALL    STYPE
  7083.     MOV    BX,(Offset SM_ATZ)
  7084.     CALL    SENDOUT
  7085. ;
  7086. SMRESET1:
  7087.     MOV    CH,2
  7088.     CALL    RECV
  7089.     JNB    SMRESET1
  7090.     RET
  7091. ;.....
  7092. ;
  7093. ;
  7094. SM_ATZ    DB    'ATZ',CR,'$'
  7095. ;.....
  7096. ;
  7097. ;
  7098. DIR:    MOV    CL,CURDSK
  7099.     INT    224
  7100.     MOV    Byte Ptr DISKSAV,AL
  7101.     CALL    DIRLIST
  7102.     MOV    AL,Byte Ptr DISKSAV
  7103.     MOV    DL,AL
  7104.     MOV    CL,SELDSK
  7105.     INT    224
  7106.     JMP    XPRT
  7107. ;.....
  7108. ;
  7109. ;
  7110. ERASEF: MOV    DX, OFFSET CMDBUF        ;put cmd line into FCB at 'BX'
  7111.     MOV    BX, FCB
  7112.     CALL    CMDLINE
  7113.     CALL    MOVEFCB            ;move FCB+16 to FCB
  7114.     MOV    AL,Byte Ptr .FCB+1
  7115.     CMP    AL,' '
  7116.     JNZ    L7A34
  7117.     JMP    NOTVLD            ;go if no file specified
  7118. L7A34:
  7119.     MOV    DX, FCB
  7120.     MOV    CL,SRCHF
  7121.     INT    224
  7122.     INC    AL            ;0 if file not found
  7123.     JNZ    ERAFILE            ;ok, go erase
  7124.     CALL    ILPRT
  7125.     DB    '++ File not found ++',CR,LF,BELL,0
  7126.     JMP    XPRT
  7127. ;.....
  7128. ;
  7129. ;
  7130. ERAFILE:MOV    DX, FCB
  7131.     MOV    CL,ERASE
  7132.     INT    224
  7133.     CALL    ILPRT
  7134.     DB    'File erased',CR,LF,0
  7135.     JMP    XPRT
  7136. ;.....
  7137. ;
  7138. ;
  7139. LOGNEW: MOV    AL,Byte Ptr NFILFLG    ;file open for memory save to disk?
  7140.     OR    AL,AL
  7141.     JZ    L7A35
  7142.     JMP    NORESET            ;if yes, do not reset disk drive now
  7143. L7A35:
  7144.     MOV    AL,Byte Ptr CMDBUF+6   ;any disk drive specified?
  7145.     CMP    AL,' '
  7146.     JNZ    LOGNEW1            ;if not a blank, exit
  7147.     CALL    GETDISK            ;if not, use current drive
  7148.     ADD    AL,'A'            ;to compensate for next line
  7149. ;
  7150. LOGNEW1:SUB    AL,'A'
  7151.     CMP    AL,15+1            ;for drives 0-15
  7152.     JNAE    L7A36
  7153.     JMP    NOTVLD            ;if more than 15, display error message
  7154. L7A36:
  7155.     MOV    Byte Ptr DISKSAV,AL    ;store requested drive
  7156.     CALL    GETUSER            ;pick up current user number
  7157.     MOV    CH,AL            ;save it
  7158.     MOV    AL,Byte Ptr CMDBUF+7   ;get new user number
  7159.     CALL    CHRCHK            ;check the char.
  7160.     CALL    FINDUSER
  7161.     MOV    AL,Byte Ptr CMDBUF+8   ;get 2nd digit
  7162.     CALL    CHRCHK            ;check the char.
  7163.     CALL    L7A37
  7164. ;
  7165. LOGNEW2:CALL    SAVEUSER
  7166.     MOV    CL,RESET
  7167.     INT    224
  7168.     MOV    AL,Byte Ptr DISKSAV
  7169.     MOV    DL,AL
  7170.     MOV    CL,SELDSK
  7171.     INT    224
  7172.     MOV    AL,Byte Ptr SAVUSR
  7173.     MOV    DL,AL
  7174.     CALL    SETUSER
  7175.     JMP    XPRT
  7176. ;.....
  7177. ;
  7178. ;
  7179. CHRCHK: CMP    AL,' '
  7180.     JZ    CHRCHK1
  7181.     CMP    AL,':'            ;in case of A: or A1: or A11:  (etc.)
  7182.     JZ    CHRCHK1
  7183.     RET
  7184. ;
  7185. CHRCHK1:POP    AX            ;reset the 'CALL' on the stack
  7186.     JMPS    LOGNEW2
  7187. ;.....
  7188. ;
  7189. ;
  7190. FINDUSER:
  7191.     MOV    CH,0            ;zero the 'B' reg. for 1st time through
  7192. L7A37:
  7193.     CALL    NUMCHK            ;if neither, see if a valid number
  7194.     MOV    CL,AL            ;save
  7195.     MOV    AL,CH            ;get save first digit
  7196.     ADD    AL,AL            ;x2
  7197.     ADD    AL,AL            ;x4
  7198.     ADD    AL,AL            ;x8
  7199.     ADD    AL,CH            ;x9
  7200.     ADD    AL,CH            ;x10
  7201.     ADD    AL,CL
  7202.     MOV    CH,AL            ;save
  7203.     RET
  7204. ;.....
  7205. ;
  7206. ;
  7207. SAVEUSER:
  7208.     MOV    AL,CH
  7209.     CMP    AL,15+1            ;user numbers are 0-15
  7210.     JNAE    L7A39
  7211.     JMP    NOTVLD
  7212. L7A39:
  7213.     MOV    Byte Ptr SAVUSR,AL
  7214.     RET
  7215. ;.....
  7216. ;    
  7217. ;
  7218. NUMGET: MOV    DX, Offset CMDBUF
  7219.     CALL    INBUF
  7220.     MOV    AL,Byte Ptr CMDBUF+2   ;get number
  7221.     CMP    AL,' '
  7222.     JNZ    L7A40
  7223.     RET
  7224. L7A40:
  7225. ;
  7226. NUMCHK: SUB    AL,'0'            ;remove ascii bias
  7227.     CMP    AL,9+1
  7228.     JNB    L7A41
  7229.     RET                ;ok if 9 or less
  7230. L7A41:
  7231.     POP    BX            ;remove 1st call from the stack
  7232.     POP    BX            ;remove 2nd call from the stack 
  7233.     JMP    NOTVLD
  7234. ;
  7235. GETUSER:MOV    DL,0FFH            ;get current user
  7236. ;
  7237. SETUSER:MOV    CL,USER            ;set up bdos call
  7238.     INT    224
  7239.     RET
  7240. ;.....
  7241. ;
  7242. ;
  7243. GETDISK:MOV    CL,CURDSK        ;get current drive
  7244.     INT    224
  7245.     RET
  7246. ;.....
  7247. ;
  7248. ;
  7249. NORESET:CALL    ILPRT
  7250.     DB    '++      Terminal mode file open      ++',CR,LF
  7251.     DB    '++ Use WRT or DEL before LOG command ++',CR,LF
  7252.     DB    CR,LF,BELL,0
  7253.     XOR    AL,AL
  7254.     JMP    XPRT
  7255. ;.....
  7256. ;
  7257. ;
  7258. SETSPD: CALL    ILPRT
  7259.     DB    'Delay between chars. (0-9): ',0
  7260. ;
  7261. NOKEYS: CALL    STAT
  7262.     JZ    NOKEYS
  7263.     CALL    KEYIN
  7264.     CALL    STYPE
  7265.     CALL    SAVEA
  7266.     SUB    AL,'0'
  7267.     CMP    AL,10
  7268.     JNAE    L7A42
  7269.     JMP    NOTVLD
  7270. L7A42:
  7271.     MOV    Byte Ptr BYTDLY,AL
  7272. ;
  7273.     CALL    ILPRT
  7274.     DB    'Delay at end of line (0-9): ',0
  7275. ;
  7276. NOKEYS1:CALL    STAT
  7277.     JNZ    L8A1
  7278.     JMP    NOKEYS1
  7279. L8A1:
  7280.     CALL    KEYIN
  7281.     CALL    STYPE
  7282.     CALL    SAVEA
  7283.     SUB    AL,'0'
  7284.     CMP    AL,10
  7285.     JNAE    L8A2
  7286.     JMP    NOTVLD
  7287. L8A2:    
  7288.     MOV    Byte Ptr CRDLY,AL
  7289. ;
  7290. SPDMSG: CALL    ILPRT
  7291.     DB    CR,LF,'Char. delay (terminal file mode) is:  ',0
  7292.     MOV    AL,Byte Ptr BYTDLY
  7293.     MOV    CH,AL
  7294.     MOV    AL,CH
  7295.     PUSH    BX
  7296.     MOV    BL,AL
  7297.     MOV    BH,0
  7298.     CALL    DECOUT
  7299.     POP    BX
  7300.     CALL    ILPRT
  7301.     DB    '0 ms. per character',CR,LF
  7302.     DB    'Line  delay (terminal file mode) is: ',0
  7303.     MOV    AL,Byte Ptr CRDLY
  7304.     MOV    CH,AL
  7305.     PUSH    BX
  7306.     MOV    BL,AL
  7307.     MOV    BH,0
  7308.     CALL    DECOUT
  7309.     POP    BX
  7310.     CALL    ILPRT
  7311.     DB    '00 ms. per character',CR,LF,0
  7312.     JMP    XPRT
  7313. ;......
  7314. ;
  7315. ;
  7316. SAVEA:    LAHF
  7317.     XCHG    AL,AH
  7318.     PUSH    AX
  7319.     CALL    ILPRT
  7320.     DB    CR,LF,0
  7321.     POP    AX
  7322.     XCHG    AL,AH
  7323.     SAHF
  7324.     RET
  7325. ;.....
  7326. ;
  7327. ;
  7328. SETDRV: MOV    AL,Byte Ptr CMDBUF+2    ;get the disk drive
  7329.     SUB    AL,'A'            ;convert to binary value
  7330.     CMP    AL,15+1            ;for drives 0-15
  7331.     JNAE    L8A3
  7332.     JMP    NOTVLD
  7333. L8A3:
  7334.     MOV    DL,AL
  7335.     MOV    CL,SELDSK        ;select requested drive
  7336.     INT    224
  7337.     MOV    AL,Byte Ptr CMDBUF+5    ;get user number, if any
  7338.     CMP    AL,' '            ;keep current user area?
  7339.     JNZ    L8A4
  7340.     JMP    XPRT
  7341. L8A4:
  7342.     SUB    AL,'0'            ;convert to binary value
  7343.     CMP    AL,1            ;if a '1', could be units or tens
  7344.     JNZ    SETDRV1            ;if not, numbers stop at 15 so exit
  7345.     MOV    AL,Byte Ptr CMDBUF+6    ;check for a 2nd digit
  7346.     CMP    AL,'0'
  7347.     JB    SETDRV2            ;if less, not a valid number, ignore
  7348.     SUB    AL,'0'-10        ;leave the '10' in as two digits used
  7349. ;
  7350. SETDRV1:CMP    AL,15+1            ;user areas are 0-15
  7351.     JNAE    L8A5
  7352.     JMP    NOTVLD
  7353. L8A5:
  7354.     MOV    DL,AL
  7355.     CALL    SETUSER
  7356.     JMP    XPRT            ;back to work
  7357. ;
  7358. SETDRV2:MOV    AL,1
  7359.     JMPS    SETDRV1
  7360. ;.....
  7361. ;
  7362. ;
  7363. SETTIM: CALL    SORPTST
  7364.     JZ    L8A6
  7365.     CALL    ILPRT
  7366. L8A6:
  7367.     CALL    ILPRT
  7368.     DB    'Use 0-8 to give baud rate for ''S'' mode '
  7369.     DB    'time-to-send message,',CR,LF
  7370.     DB    'where 0=110, 1=300, 2=450, 3=600, 4=710, 5=1200, '
  7371.     DB    '6=2400, ',CR,LF,'7=4800 8=9600 and 9=19200 Baud.'
  7372.     DB    CR,LF,LF,'Enter value: ',0
  7373.     CALL    NUMGET
  7374.     CMP    AL,9+1            ;only looking for 0-9 answers
  7375.     JNAE    L8A7
  7376.     JMP    NOTVLD
  7377. L8A7:
  7378.     MOV    Byte Ptr MSPEED,AL
  7379.     CALL    SETTIM1
  7380.     JMP    XPRT
  7381. ;.....
  7382. ;
  7383. ;
  7384. SETTIM1:CALL    SORPTST
  7385.     JNZ    SETTIM2
  7386.     CALL    ILPRT
  7387.     DB    'Rate for the S mode time-to-send message is set to ',0
  7388.     JMPS    SETTIM3
  7389. ;...
  7390. ;
  7391. ;
  7392. SETTIM2:CALL    ILPRT
  7393.     DB    'Modem speed is ',0
  7394. ;
  7395. SETTIM3:JMP    PRTBAUD
  7396. ;.....
  7397. ;
  7398. ;        
  7399. SORPTST:MOV    AL,Byte Ptr SETUPTST   ;if setup is 'YES' or PMMIMODEM is..
  7400.     MOV    CH,AL            ;..'YES' or autodial modem is 'YES'..
  7401.     MOV    AL,Byte Ptr PMMIMODEM  ;..return with zero bit not set.
  7402.     OR    AL,CH
  7403.     JZ    L8A8
  7404.     RET
  7405. L8A8:
  7406.     MOV    AL,Byte Ptr AUTODIAL
  7407.     OR    AL,CH
  7408.     RET
  7409. ;.....
  7410. ;
  7411. ;
  7412. TOGCRC: MOV    AL,Byte Ptr TOGGLECRC  ;allowing CRC/CHECKSUM toggle?
  7413.     OR    AL,AL
  7414.     JNZ    L8A9
  7415.     JMP    NOTVLD            ;if not, exit
  7416. L8A9:
  7417.     MOV    AL,Byte Ptr CRCDFLT    ;get present value and switch it
  7418.     NOT    AL
  7419.     MOV    Byte Ptr CRCDFLT,AL
  7420.     CALL    TOGCRC1            ;show on CRT it has been changed
  7421.     JMP    XPRT
  7422. ;.....
  7423. ;
  7424. ;
  7425. TOGCRC1:CALL    ILPRT
  7426.     DB    'Mode: ',0
  7427.     MOV    AL,Byte Ptr CRCDFLT    ;see if set for 'CRC' or 'CHECKSUM'
  7428.     OR    AL,AL
  7429.     JZ    CHEKMSG
  7430.     CALL    ILPRT
  7431.     DB    'CRC',CR,LF,0
  7432.     RET
  7433. ;.....
  7434. ;
  7435. ;
  7436. CHEKMSG:CALL    ILPRT
  7437.     DB    'CHECKSUM',CR,LF,0
  7438.     RET
  7439. ;.....
  7440. ;
  7441. ;
  7442. TOGRUB: MOV    AL,Byte Ptr TOGGLERUB
  7443.     OR    AL,AL
  7444.     JNZ    L8A10
  7445.     JMP    NOTVLD
  7446. L8A10:
  7447.     MOV    AL,Byte Ptr CONVRUB
  7448.     NOT    AL
  7449.     MOV    Byte Ptr CONVRUB,AL
  7450.     CALL    TOGRUB1
  7451.     JMP    XPRT
  7452. ;.....
  7453. ;
  7454. ;
  7455. TOGRUB1:MOV    AL,Byte Ptr CONVRUB
  7456.     OR    AL,AL
  7457.     JZ    NORUBMSG
  7458.     CALL    ILPRT
  7459.     DB    'Rub is backspace',CR,LF,0
  7460.     RET
  7461. ;.....
  7462. ;
  7463. ;
  7464. NORUBMSG:
  7465.     CALL    ILPRT
  7466.     DB    'Rub is rub',CR,LF,0
  7467.     RET
  7468. ;.....
  7469. ;
  7470. ;
  7471. TOGLOC: MOV    AL,Byte Ptr TOGGLELOC
  7472.     OR    AL,AL
  7473.     JNZ    L8A11
  7474.     JMP    NOTVLD
  7475. L8A11:
  7476.     MOV    AL,Byte Ptr LOCNXTCHR
  7477.     NOT    AL
  7478.     MOV    Byte Ptr LOCNXTCHR,AL
  7479.     CALL    TOGLOC1
  7480.     JMP    XPRT
  7481. ;.....
  7482. ;
  7483. ;
  7484. TOGLOC1:CALL    ILPRT
  7485.     DB    'Use ',0
  7486.     MOV    AL,Byte Ptr LOCNXTCHR
  7487.     OR    AL,AL
  7488.     MOV    AL,Byte Ptr EXTCHR
  7489.     JZ    LOCMSG
  7490.     CALL    SHFTYPE
  7491.     DB    ' before local command',CR,LF,0
  7492.     RET
  7493. ;...
  7494. ;
  7495. ;
  7496. LOCMSG: CALL    SHFTYPE
  7497.     DB    ' to send local command to remote',CR,LF,0
  7498.     RET
  7499. ;.....
  7500. ;
  7501. ;
  7502. TOGLF:    MOV    AL,Byte Ptr TOGGLELF
  7503.     OR    AL,AL
  7504.     JNZ    L8A12
  7505.     JMP    NOTVLD
  7506. L8A12:
  7507.     MOV    AL,Byte Ptr ADDLF
  7508.     NOT    AL
  7509.     MOV    Byte Ptr ADDLF,AL
  7510.     CALL    TOGLF1
  7511.     JMP    XPRT
  7512. ;.....
  7513. ;
  7514. ;
  7515. TOGLF1: CALL    ILPRT
  7516.     DB    'LF ',0
  7517.     MOV    AL,Byte Ptr ADDLF      ;adding lf after cr?               
  7518.     OR    AL,AL
  7519.     JNZ    LFMSG            ;if yes, exit
  7520.     CALL    ILPRT
  7521.     DB    'NOT ',0
  7522. ;
  7523. LFMSG:    CALL    ILPRT
  7524.     DB    'sent after CR in "L" or "T" for a disk file',CR,LF,0
  7525.     RET
  7526. ;.....
  7527. ;
  7528. ;
  7529. TOGTXOFF:
  7530.     MOV    AL,Byte Ptr TOGXOFF
  7531.     OR    AL,AL
  7532.     JNZ    L8A13
  7533.     JMP    NOTVLD
  7534. L8A13:
  7535.     CALL    ILPRT
  7536.     DB    'Use XOFF testing? (Y/N): ',0
  7537.     CALL    GETANS
  7538.     JB    NOCHG3
  7539.     MOV    Byte Ptr XOFFTST,AL
  7540. ;
  7541. NOCHG3: CALL    XOFFMSG
  7542.     CALL    ILPRT
  7543.     DB    CR,LF,'Use XON waiting after <CR> (Y/N): ',0
  7544.     CALL    GETANS
  7545.     JB    NOCHG4
  7546.     MOV    Byte Ptr XONWAIT,AL
  7547. ;
  7548. NOCHG4: CALL    XONMSG
  7549.     MOV    AL,Byte Ptr XONWAIT
  7550.     OR    AL,AL
  7551.     JNZ    L8A14
  7552.     JMP    XPRT
  7553. L8A14:
  7554.     NOT    AL
  7555.     MOV    Byte Ptr XOFFTST,AL    ;do not allow both
  7556.     CALL    ILPRT
  7557.     DB    'Therefore ',0
  7558.     CALL    XOFFMSG
  7559.     JMP    XPRT
  7560. ;.....
  7561. ;
  7562. ;
  7563. GETANS: MOV    DX,(Offset CMDBUF)
  7564.     CALL    INBUF
  7565.     MOV    AL,Byte Ptr CMDBUF+2    ;get answer
  7566.     CMP    AL,' '
  7567.     CMC                ;set the carry flag
  7568.     JNZ    L8A15
  7569.     RET
  7570. L8A15:
  7571.     MOV    CH,AL
  7572.     CMP    AL,'N'
  7573.     MOV    AL,0
  7574.     JNZ    L8A16
  7575.     RET
  7576. L8A16:
  7577.     MOV    AL,CH
  7578.     CMP    AL,'Y'
  7579.     MOV    AL,1
  7580.     JNZ    L8A17
  7581.     RET
  7582. L8A17:
  7583.     POP    AX            ;preserve stack
  7584.     JMP    NOTVLD
  7585. ;.....
  7586. ;
  7587. ;
  7588. XOFFMSG:CALL    ILPRT
  7589.     DB    'XOFF testing ',0
  7590.     MOV    AL,Byte Ptr XOFFTST
  7591.     OR    AL,AL
  7592.     JNZ    XOTSTON
  7593.     CALL    ILPRT
  7594.     DB    'NOT ',0
  7595. ;
  7596. XOTSTON:CALL    ILPRT
  7597.     DB    'used',0
  7598. ;
  7599. XONMSG1:CALL    ILPRT
  7600.     DB    ' in terminal mode file output',CR,LF,0
  7601.     RET
  7602. ;.....
  7603. ;
  7604. ;
  7605. XONMSG: CALL    ILPRT
  7606.     DB    'XON ',0
  7607.     MOV    AL,Byte Ptr XONWAIT
  7608.     OR    AL,AL
  7609.     JNZ    XONMSG2
  7610.     CALL    ILPRT
  7611.     DB    'NOT ',0
  7612. ;
  7613. XONMSG2:CALL    ILPRT
  7614.     DB    'automatically tested after CR',0
  7615.     JMPS    XONMSG1
  7616. ;...
  7617. ;
  7618. ;
  7619. SETUPENT:
  7620.     MOV    AL,Byte Ptr SETUPTST
  7621.     OR    AL,AL
  7622.     JNZ    L8A18
  7623.     JMP    NOTVLD
  7624. L8A18:
  7625.     MOV    DX,(Offset CMDBUF)+1
  7626.     CALL    JMP_SETUPR
  7627.     MOV    AL,Byte Ptr AUTODIAL   ;using a Hayes-type modem?
  7628.     OR    AL,AL
  7629.     JNZ    L8A19
  7630.     JMP    XPRT            ;if not, exit, otherwise..
  7631. L8A19:
  7632.     MOV    CH,'A'            ;..send 'AT',CR to autodial modem..
  7633.     CALL    SENDCHR            ;..to insure its baud rate..
  7634.     MOV    CH,'T'            ;..matches that just selected.
  7635.     CALL    SENDCHR
  7636.     MOV    CH,CR
  7637.     CALL    SENDCHR
  7638.     JMP    XPRT
  7639. ;.....
  7640. ;
  7641. ;
  7642. NEWFILE:MOV    AL,Byte Ptr NFILFLG    ;file open for disk save?
  7643.     OR    AL,AL
  7644.     JZ    NOFILOPN        ;if not, show "no file open" message
  7645.     MOV    AL,Byte Ptr FCB3+1    ;check that file was requested
  7646.     CMP    AL,' '
  7647.     JZ    NOFILOPN        ;if no file, do not erase
  7648.     MOV    DX,(Offset FCB3)    ;otherwise erase the old file
  7649.     MOV    CL,ERASE
  7650.     INT    224
  7651.     XOR    AL,AL
  7652.     MOV    Byte Ptr NFILFLG,AL    ;no file mentioned, reset flags
  7653.     MOV    Byte Ptr SAVEFLG,AL
  7654.     MOV    BX,(Offset FCB3)
  7655.     CALL    INITFCB
  7656.     MOV    BX,(Offset BUFFER)    ;reset flags to bottom of ram just..
  7657.     MOV    Word Ptr HLSAVE,BX    ;..to insure they are there
  7658.     JMP    XPRT
  7659. ;.....
  7660. ;
  7661. ;
  7662. WRTFIL: MOV    AL,Byte Ptr NFILFLG    ;saving memory for a disk file?
  7663.     OR    AL,AL
  7664.     JZ    NOFILOPN        ;not saving a file, don't bother writing
  7665.     CALL    WRTFIL1            ;close the file
  7666.     MOV    Byte Ptr SAVEFLG,AL
  7667.     MOV    Byte Ptr WRFLG,AL
  7668.     MOV    BX,(Offset FCB3)
  7669.     CALL    INITFCB            ;blank out 'FCB' to written file
  7670.     MOV    BX,(Offset BUFFER)    ;can't be erased
  7671.     MOV    Word Ptr HLSAVE,BX    ;reset to buffer start for next time
  7672.     JMP    XPRT
  7673. ;...
  7674. ;
  7675. ;
  7676. WRTFIL1:MOV    AL,Byte Ptr FCB3+1    ;check that file was requested
  7677.     CMP    AL,' '
  7678.     JNZ    L8A20
  7679.     RET
  7680. L8A20:
  7681.     CALL    WRTDSK            ;write buffer to disk if not empty
  7682. WRTFIL2:
  7683.     MOV    DX,(Offset FCB3)    ;close the file
  7684.     MOV    CL,CLOSE
  7685.     INT    224
  7686.     XOR    AL,AL
  7687.     MOV    Byte Ptr NFILFLG,AL    ;file written, reset flags
  7688.     RET
  7689. ;.....
  7690. ;
  7691. ;
  7692. NOFILOPN:
  7693.     CALL    ILPRT
  7694.     DB    '++ No File Open ++',CR,LF,BELL,0
  7695.     JMP    XPRT
  7696. ;.....
  7697. ;
  7698. ;
  7699. ; THIS ROUTINE DISPLAYS THE PHONE NUMBERS IN THE LIBRARY
  7700. ;
  7701. NUMPRN: PUSH    BX
  7702.     CALL    CLRTST
  7703.     CALL    ILPRT
  7704.     DB    '           Library of Phone Numbers of Remote Systems'
  7705.     DB    0
  7706.     MOV    CL,18            ;number of lines to move
  7707.     MOV    BX, (OFFSET NUMBLIB)    ;address of source memory
  7708.     MOV    DX,(Offset BUFFER)    ;address of target memory
  7709.     CALL    NEWLINE            ;start with CRLF
  7710.     MOV    SI,DX            ;+LF
  7711.     MOV    [SI],AL
  7712.     LAHF                ;and bump it
  7713.     INC    DX
  7714.     SAHF
  7715. ;
  7716. NUMPRN1:LAHF                ;skip PMMI dialing letter
  7717.     INC    BX
  7718.     SAHF
  7719.     LAHF                ;and equal sign
  7720.     INC    BX
  7721.     SAHF
  7722.     MOV    CH,LIBLEN-2        ;number of bytes to move
  7723.     CALL    MOVE            ;move to buffer
  7724.     CALL    SPACES            ;2 entries + 3 spaces = 63 characters
  7725.     PUSH    BX            ;save source address
  7726.     PUSH    DX            ;save destination address
  7727.     LAHF                ;skip next two characters
  7728.     INC    BX
  7729.     SAHF
  7730.     LAHF
  7731.     INC    BX
  7732.     SAHF
  7733.     MOV    DX,(17*LIBLEN)        ;get offset of 17 times entry length
  7734.     LAHF                ;add it to the source address
  7735.     ADD    BX,DX
  7736.     RCR    SI,1
  7737.     SAHF
  7738.     RCL    SI,1
  7739.     POP    DX            ;restor destination address
  7740.     MOV    CH,LIBLEN-2        ;get length of library entry
  7741.     CALL    MOVE            ;move another entry
  7742.     POP    BX            ;restore source address
  7743.     CALL    NEWLINE            ;start next line
  7744.     DEC    CL            ;one less line to print
  7745.     JNZ    NUMPRN1            ;if not finished, do another
  7746.     MOV    AL,'$'
  7747.     MOV    SI,DX
  7748.     MOV    [SI],AL
  7749.     MOV    CL,PRINT
  7750.     MOV    DX,(Offset BUFFER)    ;point to table of numbers to print
  7751.     INT    224
  7752.     CALL    CRLF
  7753.     CALL    CRLF
  7754.     POP    BX
  7755.     JMP    XPRT            ;finished, back to prompt
  7756. ;.....
  7757. ;
  7758. ;
  7759. NEWLINE:MOV    AL,CR            ;puts CRLF at memory pointed by 'DE'
  7760.     MOV    SI,DX            ;store it
  7761.     MOV    [SI],AL
  7762.     MOV    AL,LF            ;line feed
  7763.     LAHF                ;bump pointer
  7764.     INC    DX
  7765.     SAHF
  7766.     MOV    SI,DX            ;store lf
  7767.     MOV    [SI],AL
  7768.     LAHF                ;bump pointer
  7769.     INC    DX
  7770.     SAHF
  7771.     RET
  7772. ;.....
  7773. ;
  7774. ;
  7775. SPACES: MOV    AL,' '            ;space
  7776.     MOV    SI,DX
  7777.     MOV    [SI],AL
  7778.     LAHF                ;1
  7779.     INC    DX
  7780.     SAHF
  7781.     MOV    SI,DX
  7782.     MOV    [SI],AL
  7783.     LAHF                ;2
  7784.     INC    DX
  7785.     SAHF
  7786.     MOV    SI,DX
  7787.     MOV    [SI],AL
  7788.     LAHF                ;3
  7789.     INC    DX
  7790.     SAHF
  7791.     RET
  7792. ;.....
  7793. ;
  7794. ;
  7795. ;
  7796. ;
  7797. COMPARE:MOV    CH,Byte Ptr [BX]    ;compares 'A' reg. with list..
  7798. ;
  7799. COMPLP: INC    BX            ;..addressed by BX. first element..
  7800.     CMP    AL,Byte Ptr [BX]    ;..of list must be number of elements..
  7801.     JZ    VALID            ;..being compared. returns with..
  7802.     DEC    CH            ;..carry set if 'A' reg. does not..
  7803.     JNZ    COMPLP            ;.. contain an element in list.
  7804.     STC
  7805. ;
  7806. VALID:    RET
  7807. ;.....
  7808. ;
  7809. ;
  7810. NXTSCRN:CALL    ILPRT
  7811.     DB    'HIT any KEY to CONTINUE',0
  7812. ;
  7813. NOKEY1: CALL    STAT            ;get keyboard status
  7814.     JZ    NOKEY1            ;keep looping until keypress
  7815.     CALL    KEYIN            ;gobble up keypress
  7816.     CMP    AL,'C'-40H        ;control-c to abort?
  7817.     JNZ    CLRTST
  7818.     POP    BX            ;clear stack of return address
  7819.     CALL    CRLF            ;turn up a blank line
  7820.     JMP    XPRT
  7821. ;.....
  7822. ;
  7823. ;
  7824. CLRTST: MOV    AL,Byte Ptr SCRNTEST
  7825.     OR    AL,AL
  7826.     JZ    LOTSALF
  7827.     JMP    CLRSCRN
  7828. ;.....
  7829. ;
  7830. ;
  7831. LOTSALF:MOV    AL,CR
  7832.     CALL    STYPE
  7833.     MOV    CH,12
  7834.     MOV    AL,LF
  7835. ;
  7836. LFLOOP: CALL    STYPE
  7837.     DEC    CH
  7838.     JNZ    LFLOOP
  7839.     RET
  7840. ;.....
  7841. ;
  7842. ;
  7843. CURPAR: CALL    CLRTST
  7844.     CALL    ILPRT
  7845.     DB    '                Current Settings',CR,LF,LF,0
  7846.     CALL    TOGCRC1
  7847.     CALL    TOGRUB1
  7848.     MOV    AL,Byte Ptr LSTTST
  7849.     OR    AL,AL
  7850.     JZ    NOLIST1
  7851.     CALL    LSTMSG
  7852. ;
  7853. NOLIST1:CALL    SETTIM1
  7854.     CALL    ILPRT
  7855.     DB    'Terminal mode file buffer is ',0
  7856.     MOV    AL,Byte Ptr NFILFLG    ;saving memory for a disk file?
  7857.     OR    AL,AL
  7858.     JNZ    ACTIVE            ;if yes, go say "active"
  7859.     CALL    ILPRT
  7860.     DB    'in',0            ;if not, say "inactive"
  7861. ;
  7862. ACTIVE: CALL    ILPRT
  7863.     DB    'active',CR,LF,'Unused portion of buffer is ',0
  7864.     CALL    GETSPC
  7865.     CALL    ILPRT
  7866.     DB    ' bytes',CR,LF,0
  7867.     CALL    TOGLOC1
  7868.     CALL    TOGLF1
  7869.     CALL    XOFFMSG
  7870.     CALL    XONMSG
  7871.     CALL    SPDMSG
  7872.     CALL    CRLF
  7873.     CALL    CRLF
  7874.     CALL    CRLF
  7875.     JMP    XPRT
  7876. ;.....
  7877. ;
  7878. ;
  7879. GETSPC: MOV    BX,(Offset BUFTOP)    ;top of memory buffer
  7880.     MOV    DX,Word Ptr HLSAVE    ;current buffer location
  7881.     SUB    BX,DX
  7882.     CALL    DECOUT            ;print the space remaining
  7883.     RET
  7884. ;.....
  7885. ;
  7886. ;
  7887. ;***********************************************************************
  7888. ;
  7889. ;    D - A - T - A     A - R - E - A
  7890. ;
  7891. ;***********************************************************************
  7892. ;
  7893. ;
  7894. COMPLIST DB    6,'S','R','T','E','L','M'
  7895. ;.....
  7896. ;
  7897. ;
  7898. ; OPTION TABLE
  7899. ;
  7900. OPTBL    EQU    (Offset $)
  7901. ANSWFLG DB    'A'
  7902. BATCHFLG DB    'B'
  7903. DISCFLG DB    'D'
  7904. JMPCMD    DB    'J'
  7905. LOCCHFLG DB    'L'
  7906. ORIGFLG DB    'O'
  7907. QFLG    DB    'Q'
  7908. RSEEFLG DB    'R'
  7909. SSEEFLG DB    'S'
  7910. VSEEFLG DB    'V'
  7911. XITFLG    DB    'X'
  7912. EPARITY DB    '0'            ;even parity sub-option (only in S or R mode)
  7913. OPARITY DB    '1'            ;odd parity sub-option    (only in S or R mode)
  7914. OPTBE    EQU    (Offset $)        ;..transfer when program initially called.
  7915. ;
  7916. ;
  7917. ; The following must be in the same order as the table above:
  7918. ;
  7919. RESTROPT DB    'A','B','D','J','L','O','Q','R','S','V','X','0','1'
  7920. ;
  7921. ;
  7922. ; The next 14 bytes equal the number of bytes between RECDNOB and
  7923. ; RECDNOE.
  7924. ;
  7925. RESTSN    DB    0,0,0,0,0,0
  7926.     DW    (Offset BUFFER)
  7927.     DB    0,0,0,0,0,NAK
  7928. ;
  7929. RECDNOB EQU    (Offset $)        ;start of table marker
  7930. RCVRNO    DB    0            ;\
  7931. RECDNO    DB    0,0            ; \
  7932. ERRCT    DB    0            ;  \
  7933. ERRCDE    DB    0            ;   \
  7934. EOFLG    DB    0            ;    \    14 bytes between table markers
  7935. RECPTR    DW    (Offset BUFFER)        ;    /
  7936. RECINBF DB    0            ;   /
  7937. MAXEXT    DB    0            ;  /
  7938. RCNT    DB    0,0            ; /
  7939. DATAFLG DB    0            ;/
  7940. BENHERE DB    NAK            ;
  7941. RECDNOE EQU    (Offset $)        ;end of table marker
  7942. ;
  7943. ;
  7944. ; Additional 16-bit initialized storage
  7945. ;
  7946. CRCVAL    DW    0
  7947. DIALCT    DW    0
  7948. HLSAVE    DW    (Offset BUFFER)
  7949. HLSAVE1 DW    (Offset PBUFF)
  7950. HLSAVE2 DW    (Offset PBUFF)
  7951. ;
  7952. ;
  7953. ; Additional general purpose initialized storage
  7954. ;
  7955. ABORTFLG DB    0
  7956. ACKFLG    DB    0
  7957. CRCFLAG DB    0
  7958. CRFLAG    DB    0
  7959. CURRENT DB    52            ;PMMI 300 baud speed value (defaults to 300)
  7960. DLYFLG    DB    0
  7961. ECHOFLG DB    0
  7962. EXACFLG DB    0
  7963. FIRSTME DB    0
  7964. FNCKY    DB    '^'            ; Function Key Intercept character
  7965. FNKFLG    DB    0            ;function key activity flag
  7966. FSTFLG    DB    0
  7967. LISTFLG DB    0
  7968. LOCFLG    DB    0
  7969. MFFLG1    DB    0
  7970. MODCTLB DB    07FH
  7971. NFILFLG DB    0
  7972. ONERR    DB    0
  7973. OPTION    DB    0
  7974. ORIGSAV DB    0
  7975. RINGBKFL DB    0
  7976. SAVEFLG DB    0
  7977. UARTCTLB DB    ORIGMOD            ;for originate mode
  7978. WRFLG    DB    0
  7979. XFLG    DB    0
  7980. CMDBUF    DB    80H,0            ;command buffer control area
  7981. ;
  7982. ;
  7983. ; General purpose unitialized storage area
  7984. ;
  7985.     RS    128            ;storage area for 'CMDBUF'
  7986. BGNMS    RS    2
  7987. TIMFLG    RS    1
  7988. FLTRFLG RS    1
  7989. CHRFLG    RS    1
  7990. TIMVAL    RS    2
  7991. QUIKTIM RS    2
  7992. DISKNO    RS    1
  7993. DISKSAV RS    1
  7994. DSTORE    RS    1
  7995. FILECT    RS    1
  7996. FTYCNT    RS    1
  7997. MAXRAM    RS    1
  7998. NAMECT    RS    1
  7999. NBSAVE    RS    2
  8000. OLDUSER RS    1
  8001. SENDFLG RS    1
  8002. SAVUSR    RS    1
  8003. ;
  8004. FCB3    RS    33
  8005. FCB4    RS    33
  8006. FCBBUF    RS    15
  8007. MFNAME5 RS    12            ;requested name
  8008. MFNAME6 RS    12            ;current name
  8009.     RS    100            ;stack depth
  8010. ;
  8011. ;
  8012. EVENPAGE EQU    ((Offset $)+255)/256*256    ;sets buffers on even page
  8013. ;
  8014. ;
  8015.     ORG    EVENPAGE
  8016. ;
  8017. ;
  8018. STACK    EQU    (Offset EVENPAGE)-2    ;store original stack pointer
  8019. CRCTBL    RS    512            ;two tables of 128 bytes each
  8020. BUFFDSK RS    128            ;buffer for disk save
  8021. BUFFPNT RS    128            ;buffer for printer
  8022. BUFFER    RS    1024*BUFSIZ        ;send/receive file buffer
  8023. BUFTOP    RS    0            ;filled in when length is found
  8024. PBUFF    EQU    (Offset $)        ;printer buffer starts here
  8025. NAMEBUF EQU    (Offset $)        ;batch-mode filenames buffer
  8026. ;.....
  8027. ;
  8028. ;   ; BDOS EQUATES
  8029. ;
  8030. RDCON    EQU    1
  8031. WRCON    EQU    2
  8032. BLIST    EQU    5
  8033. PRINT    EQU    9
  8034. RDBUF    EQU    10
  8035. CONST    EQU    11
  8036. CPMVER    EQU    12
  8037. RESET    EQU    13
  8038. SELDSK    EQU    14
  8039. OPEN    EQU    15
  8040. CLOSE    EQU    16
  8041. SRCHF    EQU    17
  8042. SRCHN    EQU    18
  8043. ERASE    EQU    19
  8044. READ    EQU    20
  8045. WRITE    EQU    21
  8046. MAKE    EQU    22
  8047. REN    EQU    23
  8048. CURDSK    EQU    25
  8049. SETDMA    EQU    26
  8050. DSKALL    EQU    27
  8051. DSKPAR    EQU    31
  8052. USER    EQU    32
  8053. FILSIZ    EQU    35
  8054. REIPL    EQU    0
  8055. BDOS    EQU    5
  8056. FCB    EQU    5CH
  8057. FCBEXT    EQU    FCB+12
  8058. FCBSNO    EQU    FCB+32
  8059. FCBRNO    EQU    FCB+32
  8060. FCB2    EQU    6CH
  8061. TBUF    EQU    80H
  8062. ;.....
  8063. ;
  8064. ;
  8065.     END
  8066.