home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / zmodem / rzmplog4.lbr / RZMPLOG4.ZZ0 / RZMPLOG4.Z80
Text File  |  1989-11-02  |  37KB  |  1,771 lines

  1.  
  2.  
  3. ; RZMPLOG.Z80
  4. ;
  5. ;v4.0 - equate ver4 true makes rzmplog compatible with new userin.lib
  6. ;       routine. ver4 false is the same as rzmplog3. Version 4 gets the
  7. ;       upload category from the userin.lib insert via a low memory location
  8. ;       at 4ah. If KMD is true, then the FOR file header info will show the
  9. ;       drive and user that the file is uploaded to.
  10. ;v3.0 - provide patch point at KMD: to turn off du,size,date in FOR
  11. ;    header line. Set to FF for KMD format. 
  12. ;    fixed bug in filename routine if no file extent. rkr
  13. ;
  14. ;v2.4 - please report problems or suggestions to 
  15. ;    Houston N/W Znode  TXHOU (713)- 937-8886
  16. ;    Performs log function for RZMP
  17. ;    Rzmp16 writes a text file consisting of a list of names received or 
  18. ;     sent. Rzmp then chains to RZMPLOG, which reads the RZMP.OUT file left
  19. ;       by Rzmp.
  20. ;    To test this program offline, set TEST equ true and drive to store
  21. ;    files on and assemble. A RZMP.OUT file must be located in the test
  22. ;       directory. Format for the  0:00 b0:filename.ext 3k
  23. ;                                    |                  |
  24. ;                                 xfer time            size
  25. ;
  26. ;    Run by typing RZMPLOG R or RP
  27. ;        or    RZMPLOG S or SP
  28. ;
  29. ;    Assembly requires SYSLIB.REL, preferably version 4.0.
  30. ;
  31. ;    Using SLRASM and SLRNK+ 
  32. ;        SLRASM RZMPLOG/6
  33. ;        SLRNK RZMPLOG/N,/P:100,RZMPLOG,SYSLIB/S,/E
  34. ;
  35. ;    Called by RZMP, which leaves 'R' or 'S' in fcb1 depending on
  36. ;    whether files were received or sent. Files transferred are in
  37. ;    a file called RZMP.OUT, with data on file length and transmission
  38. ;    time.
  39. ;
  40. ;    Started with RZMPLOG.MAC from RZMP16.LBR
  41. ;    Added FOR file descriptions with code borrowed from KMD23. 
  42. ;    handles single or batch uploads and downloads.
  43. ;    Puts DU:, filesize, and date  in the header in the format 
  44. ;    of Gene Nolan's UFOR program.
  45. ;
  46. ;    Private uploads will not have FOR entries requested.
  47. ;    Zmodem tranfers can be determined by a large K in the filesize
  48. ;    as opposed to a lowercase k for KMD or ZMD.
  49. ;
  50. ;       set equates for test and filenames below.
  51. ;    FOR name is at end of program.
  52.  
  53. version    equ    40
  54.  
  55. false    equ    0
  56. true    equ    not false
  57. yes     equ     true
  58. no      equ     0
  59. ver4    equ     true            ;* set false if userin.lib is not used.
  60. test    equ     false           ;  true for test mode to run without BYE
  61.                                 ;  using fake data
  62.  
  63. mspeed    equ    003ch        ; Address of mspeed byte
  64.  
  65.     cseg
  66.     .z80
  67.  
  68. dma    equ    080h
  69. cr    equ    0dh
  70. lf    equ    0ah
  71. fcb1    equ    5ch
  72. bdos    equ    5
  73.  
  74. ; SYSLIB routines used:
  75.     ext    print, putud, getud, fname, retud, logud
  76.     ext    setdma, initfcb, ialloc, alloc, f$open
  77.     ext    f$exist, f$make, f$appl, f$write, f$read
  78.     ext    f$close, capstr, argv, caps, eval10, mhldc
  79.     ext    cout, f$delete, isalpha
  80. ;
  81. rzmplog:
  82.     jp    start
  83.     db    'Z3ENV'        ; In case of ZCPR3
  84.     db    1        ; External environment
  85.  
  86. z3env:    dw    0
  87.     db    0,0,0        ;filler
  88. descrb:    db    0ffh        ;set to zero if descriptions not wanted
  89. kmd:    db    0h        ;set to nonzero if kmd style FOR entries
  90.                 ;ie no DU:,size, or date.
  91.  
  92. lognam:    db    'A14:KMD.LOG',0        ; du: and name of .LOG file
  93.     ds    16 - ($ - lognam)
  94.  
  95. lcname:    db    'A14:LASTCALR',0
  96.     ds    16 - ($ - lcname)
  97.  
  98. dausa:    db    'DATEUSA>'
  99. dateusa:
  100.     db    0ffh        ; flag: 0ffh for USA-style date
  101.     ds    16 - ($ - dausa)
  102.  
  103. ;
  104. MHZ:    DB    4        ; *Clock speed, use integer (2,4,5,8, etc.)
  105. DRIVE:  DB    'A'             ; Drive to store FOR file
  106. USER:    DB    14        ; User area of FOR file
  107. ;
  108. ; File categories, this will be shown when a file upload description is
  109. ; needed. 
  110. ;
  111. FILDES:
  112.         DB    CR,LF,' [A] - Zcpr3                 '
  113.     DB    CR,LF,' [B] - Generic Cp/m          '
  114.         DB    CR,LF,' [C] - Modem,BBS,Rcp/m       '
  115.     DB    CR,LF,' [D] - Technical             '
  116.         DB    CR,LF,' [E] - Text & Information    '
  117.     DB    CR,LF,' [F] - Games & Basic         '
  118.         DB    CR,LF,' [G] - Wdproc & Printer      '
  119.     DB    CR,LF,' [H] - Pascal                '
  120.         DB    CR,LF,' [I] - Cstuf                 '
  121.     DB    CR,LF,' [J] - Machine Specific      '
  122.         DB    CR,LF,' [K] - Business & Database   '
  123.     DB    CR,LF,' [L] - Msdos communication   '
  124.         DB    CR,LF,' [M] - Msdos Disk Utility    '
  125.     DB    CR,LF,' [N] - Msdos Utility         '
  126.         DB    CR,LF,' [O] - Msdos Game            '
  127.     DB    CR,LF,' [P] - Msdos Business        '
  128.         DB    CR,LF,' [Q] - Msdos O.S enhancement '
  129.     DB    CR,LF,' [R] - Msdos Wdprocessing    '
  130.         DB        CR,LF,'$'
  131. ;
  132. GUIDE  EQU    'S'             ; Maximun category letter + 1
  133. ;.....
  134.  
  135.  
  136. start:
  137.     ld    (stack),sp
  138.     ld    sp,stack
  139. ;
  140.     call    print
  141.     db    cr,lf,'RZMPLOG v',version / 10 + '0'
  142.     db    '.', version mod 10 + '0',cr,lf,0
  143.  
  144.     call    putud        ; save current du:
  145.  
  146.      if    not test
  147.     ld    c,32        ; is BYE running?
  148.     ld    e,241
  149.     call    bdos
  150.     cp    77        ; A has 77 if so
  151.     jr    z,byeok
  152.     call    print
  153.     db    'BYE not running -- aborted.',cr,lf,0
  154.     jp    quit
  155.      endif        ; not test
  156.  
  157. byeok:
  158.         ld      a,(fcb1+2)    ;save P for later use
  159.         ld      (pvtopt),a
  160.  
  161.         ld      a,(fcb1+1)      ; get direction
  162.     cp    'R'        ; must be R or S
  163.     jr    z,dirok
  164.     cp    'S'
  165.     jr    z,dirok
  166.     call    print
  167.     db    'Must use R or S.',cr,lf,0
  168.     jp    quit
  169.  
  170. dirok:
  171.     ld    (direct),a
  172.     xor    a        ; use all of memory
  173.     call    ialloc
  174.     jr    nz,stkok
  175.     jp    stkok
  176. memerr:
  177.     call    print
  178.     db    'Memory allocation error.',cr,lf,0
  179.     jp    quit
  180.  
  181. stkok:
  182.         ld      de,128                  ; 128 bytes for inbuf
  183.         call    alloc
  184.         jr      z,memerr
  185.         ld      (inbuf),hl
  186.         ld      de,128                  ; 128 for outbuf
  187.         call    alloc
  188.         jr      z,memerr
  189.         ld      (outbuf),hl
  190.         ld      de,128
  191.         call    alloc
  192.         jr      z,memerr
  193.         ld      (lcbuf),hl              ; 128 for lastcalr buffer
  194.  
  195.         ld      de,24*128               ; 3k bytes for names buffer
  196.     call    alloc
  197.     jr    z,memerr
  198.     ld    (nambuf),hl
  199.     ld    de,128*128        ; 16k for disk buffer
  200.     call    alloc
  201.     jr    z,memerr
  202.     ld    (dbuf),hl
  203.  
  204.      if    not test
  205.     ld    c,81        ; get mxtime
  206.     ld    e,255
  207.     call    bdos
  208.     push    af        ; save
  209.     ld    c,81        ; set to zero
  210.     ld    e,0
  211.     call    bdos
  212.     ld    c,79        ; get rtcbuf address
  213.     call    bdos
  214.      else
  215.     ld    hl,fakertc    ; use fake data for test
  216.          endif                  ; not test
  217.  
  218.     ld    de,rtcbuf    ; transfer it
  219.     ld    bc,13
  220.     ldir
  221.  
  222.      if    not test
  223.     pop    af        ; restore old mxtime
  224.     LD    e,a
  225.     ld    c,81
  226.     call    bdos
  227.      endif
  228.  
  229.     ld    hl,lcname    ; parse LASTCALR name
  230.     ld    de,lcfcb
  231.     call    fname
  232.     jr    nz,lcfok
  233.     call    print
  234.     db    'Invalid LASTCALR filename.',cr,lf,0
  235.     jp    quit
  236.  
  237. lcfok:
  238.     call    newdu        ; go to new du:
  239.         ld      hl,(lcbuf)        ; set dma
  240.     call    setdma
  241.     ld    de,lcfcb    ; try to open LASTCALR file
  242.     call    f$open
  243.     or    a
  244.     jr    nz,lcerr    ; error
  245.     call    f$read        ; read it
  246.     or    a
  247.     jr    nz,lcerr    ; error
  248.  
  249.         ld      hl,(lcbuf)        ; Check the file
  250.     ld    b,128        ; max 128 bytes
  251.  
  252. lcck1:
  253.     ld    a,(hl)        ; ignore leading non-alpha
  254.     call    isalpha
  255.     jr    z,lcck2
  256.     inc    hl
  257.     djnz    lcck1
  258.     jr    lcerr        ; error
  259.  
  260. lcck2:
  261.     ld    (lcnam1),hl    ; save address of first name
  262.     inc    hl
  263.  
  264. lcck3:
  265.     ld    a,(hl)        ; look for separator for second name
  266.     call    isalpha
  267.     jr    nz,lcck4
  268.     inc    hl
  269.     djnz    lcck3
  270.     jr    lcerr        ; overrun
  271.  
  272. lcck4:
  273.     ld    (hl),0        ; terminate
  274.     inc    hl        ; point to second name
  275.     ld    (lcnam2),hl    ; save it
  276.  
  277. lcck5:
  278.     ld    a,(hl)        ; look for end
  279.     or    a        ; either zero,
  280.     jr    z,lcck6
  281.     cp    cr        ; or cr
  282.     jr    z,lcck6
  283.     cp    lf        ; or lf
  284.     jr    z,lcck6
  285.     cp    ' '        ; or space
  286.     jr    z,lcck6
  287.     cp    01ah        ; or 1a
  288.     jr    z,lcck6
  289.     inc    hl
  290.     djnz    lcck5
  291.  
  292. lcck6:
  293.     ld    (hl),0        ; terminate
  294.     jr    lclrok        ; ok
  295.  
  296. lcerr:
  297.     call    print
  298.     db    'LASTCALR file error.',cr,lf,0
  299.     jp    quit
  300.  
  301. lclrok:
  302.     ld    hl,dma        ; reset dma
  303.     call    setdma
  304.     ld    hl,lognam    ; parse filename
  305.     ld    de,outfcb
  306.     call    fname
  307.     jr    nz,fnok        ; ok if nz
  308.     call    print
  309.     db    'Invalid .LOG filename.',cr,lf,0
  310.     jp    quit
  311.  
  312. fnok:
  313.     call    newdu        ; go to new du:
  314.  
  315.     ld    hl,innam    ; move input file name
  316.     ld    de,infcb+1    ; to its fcb
  317.     ld    bc,11
  318.     ldir
  319.     ld    de,infcb
  320.     call    initfcb        ; initialise
  321.     call    f$open        ; open it
  322.     or    a
  323.     jr    z,iook        ; ok if Z
  324.     call    print
  325.     db    'Input file not found.',cr,lf,0
  326.     jp    quit
  327.  
  328. iook:
  329.     ld    a,128        ; set input file counter
  330.     ld    (incnt),a
  331.  
  332.     ld    de,outfcb    ; is output file there?
  333.     call    f$exist
  334.     jr    nz,outex    ; yes if nz
  335.     call    f$make        ; else make it
  336.     cp    0ffh        ; ok?
  337.     jr    nz,makeok
  338.     call    print
  339.     db    'Error in creating output file.',cr,lf,0
  340.     jp    quit
  341.  
  342. makeok:
  343.         ld      hl,(outbuf)       ; set output pointer
  344.     ld    (outpnt),hl
  345.     xor    a        ; and counter
  346.     ld    (outcnt),a
  347.     jr    outset
  348. outex:
  349.         ld      hl,(outbuf)       ; set dma
  350.     call    setdma
  351.     ld    de,outfcb
  352.     call    f$appl        ; open file for append
  353.     jr    z,oldok        ; ok if zero
  354.     cp    3        ; 3 means file empty
  355.     jr    z,makeok    ; so same as new file
  356.     call    print
  357.     db    'Error in opening output file.',cr,lf,0
  358.     jp    quit
  359.  
  360. oldok:
  361.     ld    a,01ah        ; look for closing 1a
  362.         ld      hl,(outbuf)
  363.     ld    bc,128
  364.     cpir
  365.     jp    po,oldnf    ; parity odd means not found
  366.     dec    hl        ; found it, point to it
  367.     ld    (outpnt),hl    ; use as pointer
  368.         ld      bc,(outbuf)       ; calculate count
  369.     or    a
  370.     sbc    hl,bc
  371.     ld    a,l
  372.     ld    (outcnt),a
  373.     jr    outset
  374.  
  375. oldnf:
  376.     ld    de,outfcb    ; not found: must be full buffer
  377.     call    f$write        ; so write it
  378.     or    a
  379.     jp    nz,wrerr
  380.  
  381. ;At this point, the output counter and pointer are set. Now we read each
  382. ; line from the input file and construct an output line for it.
  383. outset:
  384.     ld    hl,(nambuf)
  385.     LD    (forpnt),HL
  386.  
  387.     call    print
  388.     db    'Logging ',0
  389.     ld    a,(direct)    ; print 'up' or 'down'
  390.     cp    'R'
  391.     jr    nz,outs1
  392.     call    print
  393.     db    'up',0
  394.     jr    outs2
  395.  
  396. outs1:
  397.     call    print
  398.     db    'down',0
  399.  
  400. outs2:
  401.     call    print
  402.     db    'loads to disk',0
  403.  
  404. ;Loop here for each file
  405. mloop:
  406.     call    readln        ; read a line
  407.     jr    nz,linok    ; ok if nz
  408.     ld    a,01ah        ; else terminate in 1a
  409.     call    putbyt
  410.     call    flush        ; write any output record
  411.     ld    de,outfcb    ; close it
  412.     call    f$close
  413.  
  414.     IF    NOT TEST
  415.     ld    de,infcb    ; delete input file
  416.     call    f$delete
  417.     ENDIF
  418.  
  419.         ld      a,(direct)    ; see if uploads    
  420.     cp    'R'
  421.     jp    nz,quit    
  422.     call    getud
  423.     ld    a,(gotone)    ; see if we got at least one
  424.     or    a
  425.     jp    z,quit    
  426.     jp    ask        ; got one, get description
  427. linok:
  428.     ld    hl,inline    ; parse input line
  429.     ld    de,inftok
  430.     ld    a,0ffh        ; null-terminate
  431.     call    argv
  432.     ld    a,(infnum)    ; must have at least 3
  433.     cp    3
  434.     jr    nc,rlinok
  435.     call    print
  436.     db    'Error in input line format.',cr,lf,0
  437.     jp    quit
  438.  
  439. rlinok:
  440.     ld    a,1
  441.     ld    (gotone),a    ; show we have one
  442.     ld    a,'.'        ; do a dot
  443.     call    cout
  444.         ld      a,(pvtopt)
  445.         cp      'P'
  446.         jr      nz,rlin1
  447.         call    putbyt        ; put P into logfile instead of R or S
  448.         jr      z,rlin2
  449.  
  450. rlin1:  ld      a,(direct)      ; send R or S
  451.         call    putbyt
  452. rlin2:  ld      a,(mspeed)      ; modem speed
  453.     add    a,'0'        ; in ascii
  454.     call    putbyt
  455.     ld    a,' '        ; space
  456.     call    putbyt
  457.     ld    ix,(inftim)    ; look at transmission time
  458.     ld    a,(ix+1)    ; if <10,
  459.     cp    ':'
  460.     jr    nz,sendtim
  461.     ld    a,'0'        ; do leading zero
  462.     call    putbyt
  463.  
  464. sendtim:
  465.     ld    hl,(inftim)    ; rest of transmission time
  466.     call    putstr
  467.     ld    a,' '        ; space
  468.     call    putbyt
  469.     ld    hl,(inffil)    ; get filename
  470.     call    capstr        ; capitalised
  471.     ld    a,(hl)        ; send drive
  472.     call    putbyt
  473.     inc    hl
  474.     push    hl
  475.     pop    ix        ; user area < 10?
  476.     ld    a,(ix+1)
  477.     cp    ':'
  478.     jr    nz,sendfn
  479.     ld    a,'0'        ; leading zero if so
  480.     call    putbyt
  481.  
  482. sendfn:
  483.     ld    a,(hl)        ; send next
  484.     inc    hl
  485.     cp    ':'        ; done user area when :
  486.     jr    z,sfn1
  487.     call    putbyt
  488.     jr    sendfn
  489.  
  490. sfn1:
  491.         ld      a,':'  
  492.     call    putbyt
  493.         ld      b,8             ; 8 chars in filename
  494.  
  495. sfn2:                ; tranfer filename
  496.     ld    a,(hl)
  497.     inc    hl
  498.     or    a        ; done if zero
  499.     jr    z,sfn2a
  500.     cp    '.'        ; or .
  501.     jr    z,sfn3
  502.     call    putbyt
  503.     call    putfor        ;
  504.     djnz    sfn2        ; do all 8
  505.     jr    sfn4
  506.  
  507. sfn2a:
  508.     ld    a,1
  509.     ld    (tmpflg),a
  510. sfn3:
  511.     ld    a,' '        ; pad with space
  512.     call    putbyt
  513.     call    putfor        ;
  514.     djnz    sfn3
  515.  
  516. sfn4:
  517.     ld    a,(hl)        ; skip dot
  518.     cp    '.'
  519.     jr    nz,sfn5
  520.     inc    hl
  521.  
  522. sfn5:
  523.     ld    b,3        ; 3 bytes more
  524.     ld    a,(tmpflg)
  525.     or    a    
  526.     jp    nz,sfn7    
  527. sfn6:
  528.     ld    a,(hl)
  529.     or    a        ; done if zero
  530.     jr    z,sfn7
  531.     cp    ' '
  532.     jr    z,sfn7
  533.     call    putbyt
  534.     call    putfor        ;
  535.     inc    hl
  536.     djnz    sfn6
  537.     jr    sfn8
  538.  
  539. sfn7:
  540.     ld    a,' '        ; pad with spaces
  541.     call    putbyt
  542.     call    putfor
  543.     djnz    sfn7
  544.  
  545. sfn8:
  546.     ld    a,' '        ; 11 x space (no library files!)
  547.     ld    b,11
  548.  
  549. rlsplp:
  550.     call    putbyt
  551.     djnz    rlsplp
  552.     xor    a
  553.     ld    (tmpflg),a
  554.     ld    a,' '
  555.     call    putfor
  556.  
  557.     ld    hl,(infsiz)    ; get filesize
  558.     call    eval10        ; convert to binary
  559.     ex    de,hl
  560.     ld    de,numbuf    ; convert to ascii
  561.     call    mhldc
  562.     xor    a        ; zero-terminate
  563.     ld    (de),a
  564.  
  565.     ld    hl,numbuf    ; and send to buffer
  566.     call    putstr
  567.     ld    hl,numbuf
  568.     call    forstr        ;
  569.  
  570.     ld    a,'K'        ; use uppercase so we know its from rzmp
  571.     call    putbyt
  572.     call    putfor        ;
  573.  
  574.     ld    a,' '
  575.     call    putbyt
  576.     call    putfor        ; space over to date
  577.     call    putfor
  578.     call    putfor
  579.     call    putfor
  580.  
  581.     ld    ix,rtcbuf    ; now do date/time
  582.     ld    a,(dateusa)    ; American date?
  583.     or    a
  584.     jr    nz,dusa        ; yes if nz
  585.     ld    a,(ix+6)    ; day
  586.     call    putbcd
  587.     ld    a,(ix+6)
  588.     call    forbcd        ;
  589.  
  590.     ld    a,'/'
  591.     call    putbyt
  592.     call    putfor        ;
  593.  
  594.     ld    a,(ix+5)    ; month
  595.     call    putbcd
  596.     ld    a,(ix+5)
  597.     call    forbcd        ;
  598.  
  599.     jr    dyear
  600.  
  601. dusa:
  602.     ld    a,(ix+5)    ; month
  603.     call    putbcd
  604.     ld    a,(ix+5)
  605.     call    forbcd        ;
  606.     ld    a,'/'
  607.     call    putbyt
  608.     call    putfor        ;
  609.     ld    a,(ix+6)    ; day
  610.     call    putbcd
  611.     ld    a,(ix+6)
  612.     call    forbcd        ;
  613. dyear:
  614.     ld    a,'/'
  615.     call    putbyt
  616.     call    putfor        ;
  617.     ld    a,(ix+4)    ; year
  618.     call    putbcd
  619.     ld    a,(ix+4)
  620.     call    forbcd        ;
  621.     ld    a,cr
  622.     call    putfor
  623.     ld    a,lf
  624.     call    putfor
  625. ;
  626.     ld    a,' '
  627.     call    putbyt
  628.     ld    a,(ix)        ; hours
  629.     call    putbcd
  630.     ld    a,':'
  631.     call    putbyt
  632.  
  633.     ld    a,(ix+1)    ; minutes
  634.     call    putbcd
  635.     ld    a,' '
  636.     call    putbyt
  637.     ld    hl,(lcnam1)    ; first name
  638.     call    capnam
  639.     call    putstr
  640.     ld    a,' '
  641.     call    putbyt
  642.     ld    hl,(lcnam2)    ; second name
  643.     call    capnam
  644.     call    putstr
  645.     ld    a,cr        ; cr/lf
  646.     call    putbyt
  647.     ld    a,lf
  648.     call    putbyt
  649.  
  650.     LD    A,(filcnt)
  651.     INC    A
  652.     LD    (filcnt),A    
  653.     jp    mloop        ; then read next line
  654.  
  655. ;Come here when finished
  656. quit:
  657.     ld    hl,(stack)    
  658.     ld    sp,hl        
  659.     call    getud        ; restore original du:
  660.     jp    0        ; back to system: MUST do warm boot
  661.  
  662. ;Read a line from the input file. Exit with Z set if eof.
  663. readln:
  664.     ld    b,40        ; max = 40
  665.     ld    hl,inline    ; set pointer
  666.  
  667. rlnlp:
  668.     call    getbyt        ; get a byte
  669.     ret    z        ; eof encountered
  670.     cp    cr        ; don't store cr
  671.     jr    z,rlnlp
  672.     cp    lf        ; lf = end
  673.     jr    z,rln1
  674.     ld    (hl),a        ; else store it
  675.     inc    hl        ; bump pointer
  676.     djnz    rlnlp        ; loop till full
  677.  
  678. rln1:
  679.     ld    (hl),0        ; zero terminate
  680.     xor    a        ; ensure nz
  681.     dec    a
  682.     ret            ; done
  683.  
  684. ;Get a byte from the input file. Read new record if necessary. Exit with
  685. ;Z set if eof
  686. getbyt:
  687.     push    de        ; save de, hl
  688.     push    hl
  689.     ld    a,(incnt)    ; need to read new record?
  690.     cp    128
  691.     jr    c,gb1
  692.         ld      hl,(inbuf)        ; yes, set dma
  693.     call    setdma
  694.     ld    de,infcb
  695.     call    f$read        ; and read it
  696.     or    a        ; ok if z
  697.     jr    nz,gbeof    ; else eof
  698.     ld    (incnt),a    ; clear count
  699.         ld      hl,(inbuf)        ; set pointer
  700.     ld    (inpnt),hl
  701.  
  702. gb1:
  703.     inc    a        ; bump counter
  704.     ld    (incnt),a
  705.     ld    hl,(inpnt)    ; get pointer
  706.     ld    a,(hl)        ; get the byte
  707.     inc    hl        ; bump pointer
  708.     ld    (inpnt),hl
  709.     cp    01ah        ; 1a = eof
  710.     jr    nz,gb2
  711.  
  712. gbeof:
  713.     xor    a        ; eof, so set Z
  714.  
  715. gb2:
  716.     pop    hl
  717.     pop    de
  718.     ret
  719.  
  720. ;Pretty up a name string in (hl) by capitalising the first character
  721. ;and setting the rest to lower case.
  722. capnam:
  723.     push    af
  724.     push    hl
  725.     ld    a,(hl)        ; do first
  726.     or    a
  727.     jr    z,capnex    ; quit if null
  728.     call    caps        ; make it a capital
  729.     ld    (hl),a        ; and store it
  730.  
  731. capnlp:
  732.     inc    hl
  733.     ld    a,(hl)
  734.     or    a        ; done when zero
  735.     jr    z,capnex
  736.     cp    'A'        ; A-Z --> a-z
  737.     jr    c,capnlp
  738.     cp    'Z'+1
  739.     jr    nc,capnlp
  740.     or    20h
  741.     ld    (hl),a        ; store it back
  742.     jr    capnlp
  743.  
  744. capnex:
  745.     pop    hl
  746.     pop    af
  747.     ret
  748.  
  749. ;Write a string in (hl) to the output buffer.
  750. putstr:
  751.     ld    a,(hl)
  752.     inc    hl
  753.     or    a
  754.     ret    z        ; done if zero
  755.     call    putbyt        ; else send it
  756.     jr    putstr
  757.  
  758. forstr: ld      a,(hl)
  759.         inc     hl
  760.         or      a
  761.         ret     z
  762.     call    putfor
  763.     jr    forstr
  764. ;Convert a BCD value in A to 2-byte ASCII and store in the output buffer.
  765. putbcd:
  766.     push    af        ; save it
  767.     rra
  768.     rra            ; do hi nybble
  769.     rra
  770.     rra
  771.     call    pbcd1
  772.     pop    af        ; then low nybble
  773.  
  774. pbcd1:
  775.     and    0fh        ; mask off
  776.     add    a,'0'        ; add ascii part
  777.     call    putbyt        ; and store
  778.     ret
  779.  
  780. forbcd: push    af
  781.         rra
  782.         rra
  783.         rra
  784.         rra
  785.     call    pbcd2
  786.         pop     af
  787. pbcd2:  and     0Fh
  788.         add     A,'0'
  789.         call    putfor
  790.         ret
  791.  
  792. ;Write a byte to the output buffer. Write buffer to disk if necessary.
  793. putbyt:
  794.     push    af
  795.     push    hl
  796.     ld    hl,(outpnt)    ; get pointer
  797.     ld    (hl),a        ; store in buffer
  798.     inc    hl        ; bump pointer
  799.     ld    (outpnt),hl
  800.     ld    a,(outcnt)    ; and counter
  801.     inc    a
  802.     ld    (outcnt),a
  803.     cp    128        ; flush if 128 bytes written
  804.     call    z,flush
  805.     pop    hl
  806.     pop    af
  807.     ret
  808.  
  809. putfor:
  810.     push    af
  811.     push    hl
  812.         ld      hl,(forpnt)     ; get pointer
  813.     ld    (hl),a        ; store in buffer
  814.     inc    hl        ; bump pointer
  815.         ld      (forpnt),hl
  816.     pop    hl
  817.     pop    af
  818.     ret
  819.  
  820.  
  821. ;Flush output buffer and reset pointers
  822. flush:
  823.     push    af
  824.     push    de
  825.     push    hl        ; preserve all regs
  826.         ld      hl,(outbuf)
  827.     call    setdma        ; set dma
  828.     ld    de,outfcb
  829.     call    f$write        ; write it
  830.     or    a
  831.     jr    nz,wrerr    ; error
  832.     ld    (outcnt),a    ; clear counter
  833.         ld      hl,(outbuf)       ; and set pointer
  834.     ld    (outpnt),hl
  835.     pop    hl
  836.     pop    de
  837.     pop    af
  838.     ret
  839.  
  840. wrerr:
  841.     call    print
  842.     db    'Error in writing output file.',cr,lf,0
  843.     jp    quit
  844.  
  845. ;Log into du: in bc parsed by fname. Correct for unentered drive or user.
  846. newdu:
  847.     push    bc        ; save parsed du:
  848.     pop    hl
  849.     call    retud        ; and get current one
  850.     ld    a,l        ; was user area specified?
  851.     cp    0ffh
  852.     jr    z,nousr
  853.     ld    c,a        ; yes, set it
  854.  
  855. nousr:
  856.     ld    a,h        ; was drive specified?
  857.     cp    0ffh
  858.     jr    z,nodisk
  859.     dec    a        ; yes, subtract 1
  860.     ld    b,a        ; and set it
  861.  
  862. nodisk:
  863.     call    logud        ; go to correct du:
  864.     ret
  865.  
  866.  
  867. ;end of rzmplog
  868. ;
  869. ;                       FOR FILE ROUTINES
  870. ;
  871. ;
  872. ; Asks user to add description of an uploaded file
  873. ;
  874.  
  875. ASK:    
  876.     LD    A,(DESCRB)    ;descriptions wanted?
  877.     OR    A
  878.     RET    Z        
  879.         LD    A,(PVTOPT)      ; Sending to "private area"?
  880.         CP      'P'
  881.         RET     Z               ; If yes, do not ask for description
  882.         LD      HL,(DBUF)       ;
  883.     LD    (BCHADR),HL    ;init buffer pointers
  884.     LD    (BUFADR),HL
  885.     LD    (OUTADR),HL
  886.  
  887.         LD      HL,(NAMBUF)
  888.         LD      (NBSAVE),HL     ; set counter to first filename
  889.         CALL    BCHDCR          ;  get the filname
  890.  
  891. ;
  892. ASK1:
  893.     if    not ver4
  894.     CALL    SHONM        ; Show the file name
  895.         CALL    PRINT
  896.         DEFB    ' - this file is for:',13,10,0
  897.         LD      C,9             ; Display the file descriptors
  898.         LD      DE,FILDES
  899.         CALL    5
  900.         CALL    PRINT
  901.         DEFB    13,10,'Select a category: ',0
  902.  
  903. ASK1A:    
  904.         CALL    INPUT           ; Get a character
  905.         CALL    UCASE
  906.         CP      'A'
  907.         JP      C,ASK1A
  908.         CP      GUIDE
  909.         JP      NC,ASK1A
  910.         CALL    TYPE
  911.         LD      (KIND),A
  912.         endif   ;not ver4
  913. ;
  914. ASK2:   CALL    PRINT
  915.     DEFB    13,10,13,10
  916.     DEFB    'Please describe this file in 7 lines or less.  '
  917.     DEFB    13,10,13,10,0
  918. ;
  919. ;
  920. ; Get the file name from FCB, skip any blanks
  921. ;
  922.         LD      HL,HLINE        ; Store short line with dashes
  923.     CALL    DSTOR1        ; Store and show
  924.     LD    A,CR
  925.     CALL    OUTCHR
  926.     LD    A,LF
  927.     CALL    OUTCHR
  928.  
  929.         XOR    A
  930.         LD      (LNCNTR),A
  931.  
  932.         LD      B,8             ; Get FILENAME
  933.         LD      DE,NEWNAM    ;source
  934.     LD    HL,OLINE    ;destination
  935.     CALL    LOPFCB
  936.  
  937.     LD    A,(DE)
  938.     CP    32        ; Any file extent?
  939.     JP    Z,AFIND1    ; If not, skip the period and extent
  940.     LD    A,46
  941.     LD    (HL),A        ; Separate FILENAME and EXTENT
  942.     CALL    TYPE
  943.     INC    HL
  944.     LD    B,3        ; Get EXTENT name
  945.     CALL    LOPFCB
  946.  
  947.         if  not ver4
  948. AFIND1: LD      A,(KIND)        ; Get the answer
  949.         else
  950. afind1:    ld    a,(4ah)        ;passed category selection from userin.
  951.     cp    'A'
  952.     jp    c,afinda    ;make sure it's in range
  953.     cp    (guide)
  954.     jp    c,afind2
  955. afinda:    call    print
  956.     db    'No category selected',cr,lf,0
  957.     ret
  958.         endif                   ;userin fildes and rzmplog fildes should match
  959.  
  960. afind2: SUB     40H             ; Convert to binary
  961.     LD    C,A        ; Store for now
  962.     LD    DE,FILDES
  963. ;
  964. ALOOP:    LD    A,(DE)
  965.     CP    '$'
  966.     JP    Z,ASK1
  967.     CP    10        ; New line yet?
  968.     INC    DE
  969.     JP    NZ,ALOOP    ; Look for a LF
  970.     DEC    C        ; One less line to go
  971.     JP    NZ,ALOOP
  972.     INC    DE        ; move past [A] in categories
  973.     INC    DE
  974.     INC    DE
  975.     INC    DE
  976.     CALL    DKIND        ; move category in de to oline in hl
  977. ;
  978.     CALL    DSTOR        ; copy oline to FOR buffer and show
  979.  
  980. ; add B0: and size and date here
  981.  
  982. ;at this point lncntr has number of characters at end of category. 
  983. ;we will count from there and fill spaces up to 46 where DU: will be put
  984. ;in.
  985.     ld    a,(kmd)        ;see if its kmd format
  986.     or    a
  987.     jp    nz,alignf    ;yes, so skip du,size,date
  988. align:        
  989.         ld      a,(lncntr)      ;current position
  990.         ld      b,a
  991.         ld      a,46            ;location of DU: for UFOR style
  992.         sub     b            ;b now has # of spaces to fill
  993.     ld    b,a
  994. align1: 
  995.         ld      a,' '
  996.         call    outchr          ;not there yet so put in space
  997.         call    type
  998.         djnz    align1             
  999.  
  1000. ;new routines for RZMPLOG4
  1001.     ld    hl,(inffil)    ; get filename
  1002.     call    capstr        ; capitalised
  1003.     ld    a,(hl)        ; send drive
  1004.     call    outchr
  1005.     inc    hl
  1006.     push    hl
  1007.     pop    ix        ; user area < 10?
  1008. sndfn:
  1009.     ld    a,(hl)        ; send next
  1010.     inc    hl
  1011.     cp    ':'        ; done user area when :
  1012.     jr    z,sn1
  1013.     call    outchr
  1014.     jr    sndfn
  1015.  
  1016. sn1:
  1017.         ld      a,':'  
  1018.     call    outchr
  1019.  
  1020. ;-------
  1021.     ld    a,' '
  1022.     call    outchr
  1023.     call    outchr
  1024.  
  1025.     ld    hl,newnam    ;put file size and date
  1026.         ld      de,12           ;add offset
  1027.     add    hl,de 
  1028.     call    dstor1
  1029. alignf:
  1030.     ld    a,cr        ;end of line
  1031.     call    outchr
  1032.     call    type
  1033.     ld    a,lf
  1034.     call    outchr
  1035.     call    type
  1036.     
  1037.         CALL    print
  1038.     DEFB    13,10,'0: ---------1---------2---------3'
  1039.     DEFB    '---------4---------5---------6---------',13,10,0
  1040.     XOR    A
  1041.     LD    (ANYET),A    ; Reset the flag for no information yet
  1042.     LD    C,48
  1043.  
  1044.  
  1045. EXPLN:  INC     C
  1046.     LD    A,C
  1047.     CP    56
  1048.     JP    NC,EXPL1
  1049.     CALL    TYPE
  1050.     LD    A,32
  1051.     CALL    OUTCHR
  1052.     CALL    OUTCHR
  1053.     CALL    OUTCHR
  1054.         CALL    print
  1055.     DEFB    ': ',0
  1056.     CALL    DESC        ; Get a line of information
  1057.     CALL    DSTOR
  1058. ;
  1059.     LD    A,CR
  1060.     CALL    OUTCHR
  1061.     LD    A,LF
  1062.     CALL    OUTCHR
  1063.     JP    EXPLN
  1064. ;
  1065. EXPL1:    
  1066.     LD    A,13        ; All finished, put in an extra CR-LF
  1067.     CALL    OUTCHR
  1068.     LD    A,10
  1069.     CALL    OUTCHR
  1070.     XOR    A
  1071.     CALL    OUTCHR
  1072.         CALL    print
  1073.     DEFB    13,10,'   Repeating to verify:',13,10,13,10,0
  1074.     LD    HL,(BUFADR)    ; Get starting address of description
  1075. ;
  1076. EXPL1A:    LD    A,(HL)        ; Get the character
  1077.     OR    A        ; Is it a '0' to terminate?
  1078.     JP    Z,EXPL1B    ; If yes, exit
  1079.     CALL    TYPE        ; Show character on CRT, send to modem
  1080.     INC    HL        ; Next location
  1081.     JP    EXPL1A        ; Go do next charcter
  1082. ;
  1083. EXPL1B: LD      HL,(OUTPTR)
  1084.     DEC    HL        ; Skip the '0'
  1085.     LD    (OUTPTR),HL    ; Store address at end of this entry
  1086. ;
  1087. EXPL2:  CALL    print
  1088.     DEFB    13,'Is this ok (Y/N)? ',0
  1089.     CALL    INPUT
  1090.     AND    5FH        ; Change to upper case
  1091.     CP    'Y'
  1092.     JP    Z,EXPL4        ; Exit if this description was ok
  1093.     CP    'N'
  1094.     JP    NZ,EXPL2
  1095.     CALL    TYPE
  1096. ;
  1097. EXPL3:    LD    HL,(BCHPTR)    ; Else restart at beginning of text
  1098.     LD    (OUTPTR),HL    ; Start over at this address
  1099.     JP    ASK2        ; Go do this one again
  1100. ;...
  1101. ;
  1102. ;
  1103. ; See if any more batch files need descriptions
  1104. ;
  1105. EXPL4:    CALL    TYPE
  1106.         LD      A,(FILCNT)      ; Any more file names left in buffer?
  1107.     OR    A
  1108.     JP    Z,EXPL5        ; If not, all finished
  1109.     LD    HL,(BCHADR)    ; Get the current output address
  1110.     LD    (BUFADR),HL    ; Store for next verify
  1111.     LD    HL,(OUTPTR)    ; Get end of current description
  1112.     LD    (BCHPTR),HL    ; Store for start of next one
  1113.     JP    ASK1-3        ; Get the next file description
  1114. ;
  1115. ;
  1116. ; Now open the file and put this at the beginning
  1117. ;
  1118. EXPL5:    LD    A,(0004H)    ; Get current drive/user
  1119.     LD    (DRUSER),A    ; Store
  1120. ;
  1121. ;
  1122. ; Set drive/user to the area listed above
  1123. ;
  1124.     LD    A,(USER)    ; Get requested user number
  1125.     LD    C,32
  1126.     LD    E,A        ; Put user number into 'E' register
  1127.     CALL    5
  1128.     LD    A,(DRIVE)    ; Get requested drive
  1129.     SUB    65
  1130.     LD    C,14
  1131.     LD    E,A
  1132.     CALL    5
  1133. ;
  1134. ;
  1135. ; Open source file
  1136. ;
  1137.         CALL    PRINT
  1138.     DEFB    13,10,0
  1139.     LD    C,15
  1140.     LD    DE,FILE        ; Open FOR text file
  1141.     CALL    5
  1142.     INC    A        ; Check for no open
  1143.     JP    NZ,OFILE    ; File exists, exit
  1144.     LD    C,22        ; None exists, make a new file
  1145.     LD    DE,FILE
  1146.     CALL    5
  1147.     INC    A
  1148.     JP    Z,NOROOM    ; Exit if cannot open new file
  1149. ;
  1150. OFILE:    LD    HL,FILE        ; Otherwise use same filename
  1151.     LD    DE,DEST        ; With .$$$ extent for now
  1152.     LD    B,9
  1153.     CALL    MOVE
  1154. ;
  1155. ;
  1156. ; Open the destination file
  1157. ;
  1158.     XOR    A
  1159.     LD    (DEST+12),A
  1160.     LD    (DEST+32),A
  1161.     LD    HL,16*1024    ; Size of output buffer
  1162.     LD    (OUTSIZ),HL    ; Set for comparison
  1163.     LD    C,19        ; Delete any existing file that name
  1164.     LD    DE,DEST
  1165.     CALL    5
  1166.     LD    C,22        ; Now make a new file that name
  1167.     LD    DE,DEST
  1168.     CALL    5
  1169. ;
  1170.     INC    A
  1171.     JP    Z,NOROOM    ; Cannot open file, no directory room
  1172.         CALL    print
  1173.     DEFB    13,10,'wait a moment...',0
  1174. ;
  1175. ;
  1176. ; Read sector from source file
  1177. ;
  1178. READLP:    LD    C,26
  1179.         LD      DE,DMA
  1180.     CALL    5
  1181.     LD    C,20
  1182.     LD    DE,FILE        ; Read from FOR text file
  1183.     CALL    5
  1184.     OR    A        ; Read ok?
  1185.     JP    NZ,RERROR
  1186.         LD      HL,DMA        ; Read buffer address
  1187. ;
  1188. ;
  1189. ; Write sector to output file (with buffering)
  1190. ;
  1191. WRDLOP:    LD    A,(HL)        ; Get byte from read buffer
  1192.     AND    127        ; Strip parity bit
  1193.     CP    127        ; Del (rubout)?
  1194.     JP    Z,NEXT        ; Yes, ignore it
  1195.     CP    26        ; End of file marker?
  1196.     JP    Z,TDONE        ; Transfer done, close, exit
  1197.     CALL    OUTCHR
  1198. ;
  1199. NEXT:    INC    L        ; Done with sector?
  1200.     JP    Z,READLP    ; If yes get another sector
  1201.     JP    WRDLOP        ; No, get another byte
  1202. ;.....
  1203. ;
  1204. ;
  1205. ; Handle a backspace character while entering a character string
  1206. ;
  1207. BCKSP:    CALL    TYPE
  1208.     LD    A,B        ; Get position on line
  1209.     OR    A
  1210.     JP    NZ,BCKSP1    ; Exit if at initial column
  1211.         LD      A,' '            ; Delete the character
  1212.     JP    BCKSP3
  1213. ;
  1214. BCKSP1:    DEC    B        ; Show one less column used
  1215.     DEC    HL        ; Decrease buffer location
  1216.         LD      A,' '
  1217.     LD    (HL),A        ; Clear memory at this point
  1218.     CALL    TYPE        ; Backspace the "CRT"
  1219. ;
  1220. BCKSP2:    LD    A,8        ; Reset the "CRT" again
  1221. ;
  1222. BCKSP3:    JP    TYPE        ; Write to the "CRT", done
  1223. ;.....
  1224. ;
  1225. ;
  1226. ; Asks for line of information
  1227. ;
  1228. DESC:    XOR    A
  1229.     LD    (FIRST),A
  1230.     LD    B,A
  1231.     LD    HL,OLINE
  1232. ;
  1233. DESC1:    CALL    INPUT        ; Get keyboard character
  1234.         CP      CR
  1235.     JP    Z,DESC5
  1236.     CP    9
  1237.     JP    Z,DESC7
  1238.     CP    8        ; Backspace character?
  1239.     JP    Z,DESC2
  1240.     CP    127        ; Delete character?
  1241.     JP    NZ,DESC3
  1242. ;
  1243. DESC2:    CALL    BCKSP
  1244.     JP    DESC1        ; Get the next character
  1245. ;
  1246. DESC3:  CP      ' '              ; Space character?
  1247.     JP    C,DESC1        ; If non-printing character, ignore
  1248.     JP    NZ,DESC4
  1249.     LD    A,(FIRST)    ; Any non-space characters yet?
  1250.     OR    A
  1251.     JP    Z,DESC1        ; If not, ignore this space
  1252.         LD      A,' '            ; Restore the value
  1253. ;
  1254. DESC4:    LD    (ANYET),A    ; Show a character has been sent now
  1255.     LD    (FIRST),A
  1256.     LD    (HL),A
  1257.     CALL    TYPE        ; Display the character
  1258.     INC    HL
  1259.     INC    B
  1260.     LD    A,B
  1261.     CP    70        ; Do not exceed line length
  1262.     JP    C,DESC1
  1263.     CALL    BCKSP2
  1264.     CALL    BCKSP1        ; Do not allow a too-long line
  1265.     JP    DESC1
  1266. ;
  1267. DESC5:    LD    A,(ANYET)    ; Any text typed on first line yet?
  1268.     OR    A
  1269.     JP    NZ,DESC6    ; If yes, exit
  1270.     POP    HL
  1271.     JP    EXPL3        ; Ask again for a description
  1272. ;
  1273. DESC6:  LD      (HL),CR
  1274.     LD    A,(HL)
  1275.     CALL    TYPE
  1276.     INC    HL        ; Ready for next character
  1277.         LD      (HL),LF
  1278.     LD    A,(HL)
  1279.     CALL    TYPE        ; Display the line feed
  1280.     INC    HL
  1281.     LD    A,B        ; See if at first of line
  1282.     OR    A
  1283.     RET    NZ        ; If not, ask for next line
  1284.     POP    HL        ; Clear "CALL" from stack
  1285.     JP    EXPL1
  1286. ;
  1287. DESC7:    LD    A,B        ; At end of line now?
  1288.     CP    68
  1289.     JP    NC,DESC1    ; If yes, disregard
  1290.     LD    (HL),32
  1291.     LD    A,(HL)
  1292.     CALL    TYPE
  1293.     INC    HL
  1294.     INC    B
  1295.     LD    A,B
  1296.     AND    7
  1297.     JP    NZ,DESC7
  1298.     JP    DESC1        ; Ask for next character
  1299. ;.....
  1300. ;
  1301. ;
  1302. ; Print message then exit to CP/M
  1303. ;
  1304. DEXIT:    LD    C,9        ; Print message
  1305.     POP    DE        ; Get message address
  1306.     CALL    5
  1307.     JP    RESET        ; Reset the drive/user, then finished
  1308. ;.....
  1309. ;
  1310. DKIND:    LD    A,(DE)        ; Get the character from the string
  1311.     CALL    TYPE        ; Otherwise display the character
  1312.     LD    (HL),A        ; Put in the buffer
  1313.     CP    LF
  1314.     RET    Z
  1315.     INC    DE        ; Next position in the string
  1316.     INC    HL        ; Next postion in the buffer
  1317.     JP    DKIND        ; Keep going until a LF
  1318. ;.....
  1319. ;
  1320. ;
  1321. DSTOR:  LD      HL,OLINE
  1322. ;
  1323. DSTOR1:    LD    A,(HL)
  1324.     CP    CR
  1325.     RET    Z
  1326.     CALL    OUTCHR
  1327.     INC    HL
  1328.         LD    A,(LNCNTR)        ;bump position counter
  1329.         INC     A
  1330.         LD      (LNCNTR),A
  1331.         JP      DSTOR1
  1332. ;.....
  1333. UCASE:    CP    97
  1334.     RET    C
  1335.     CP    123
  1336.     RET    NC
  1337.     AND    95
  1338.     RET
  1339. ;
  1340. ;
  1341. ; Disk is full, save original file, erase others.
  1342. ;
  1343. FULL:    LD    C,19
  1344.     LD    DE,DEST
  1345.     CALL    5
  1346.     CALL    DEXIT
  1347.     DEFB    13,10,'++ DISK FULL, ABORTING, SAVING ORIGINAL FILE','$'
  1348. ;.....
  1349. ;
  1350. ;
  1351. ; Get a character, if none ready wait up to 3 minutes, then exit from
  1352. ; the program.
  1353. ;
  1354. INPUT:    PUSH    HL        ; Save current values
  1355.     PUSH    DE
  1356.     PUSH    BC
  1357.     LD    A,3        ; Wait up to 3 minutes
  1358.     ADD    A,A        ; Double the number, bell each 30 sec.
  1359.     LD    H,A        ; Put in 'H' for 1/2 minute loops
  1360. ;
  1361. INPUT1:    LD    DE,300        ; Outer loop count 600 loops per min.
  1362.  
  1363. INPUT2:    LD    A,(MHZ)        ; Get the clock speed
  1364.     LD    L,A        ; Put in 'L' for 'clock loops'
  1365. ;
  1366. INPUT3: 
  1367. ;
  1368. INPUT4:    PUSH    HL
  1369.     PUSH    DE        ; Save the outer delay count
  1370.     PUSH    BC        ; Save the inner delay count
  1371.     LD    C,6        ; Get console character, if any
  1372.     LD    E,255
  1373.     CALL    5
  1374.     AND    127        ; Remove any parity
  1375.     POP    BC        ; Restore the inner delay count
  1376.     POP    DE        ; Restore the outer delay count
  1377.     POP    HL        ; Restore the Number of minutes count
  1378.     OR    A        ; Have a character yet?
  1379.     JP    NZ,INPUT5    ; If yes, exit and get it
  1380. ;
  1381.     DEC    BC
  1382.     LD    A,C        ; See if inner loop is finished
  1383.     OR    B
  1384.     JP    NZ,INPUT4    ; If not loop again
  1385. ;
  1386.     DEC    L        ; One less clock loop to go
  1387.     JP    NZ,INPUT3
  1388. ;
  1389.     DEC    DE
  1390.     LD    A,E
  1391.     OR    D
  1392.     JP    NZ,INPUT2    ; If not reset inner loop and go again
  1393. ;
  1394. ;
  1395. ; No character received, ding the bell each 1/2 minute
  1396. ;
  1397.     PUSH    HL
  1398.         call    print
  1399.         db      7,0
  1400.     POP    HL
  1401.     DEC    H
  1402.     JP    NZ,INPUT1
  1403. ;
  1404. ;
  1405. ; Out of time, no character so abort
  1406. ;
  1407.     LD    A,13
  1408.     CALL    OUTCHR
  1409.     LD    A,10
  1410.     CALL    OUTCHR
  1411.     LD    SP,STACK    ; Restore the stack
  1412.     CALL    EXPL5        ; Finish appending previous information
  1413.     JP    EXIT        ; File is closed, return to CP/M
  1414. ;
  1415. INPUT5:    POP    BC
  1416.     POP    DE
  1417.     POP    HL
  1418.     RET            ; Got a character, return with it
  1419. ;.....
  1420. ;
  1421. ;
  1422. ; Stores the Filename/extent in the buffer temporarily
  1423. ;
  1424. LOPFCB:    LD    A,(DE)        ; Get FCB FILENAME/EXT character
  1425.     CP    33        ; Skip any blanks
  1426.     JP    C,LOPF1
  1427.     LD    (HL),A        ; Store in OLINE area
  1428.     CALL    TYPE        ; Display on CRT
  1429.     INC    HL        ; Next OLINE position
  1430. ;
  1431. LOPF1:    INC    DE        ; Next FCB position
  1432.     DEC    B        ; One less to go
  1433.     JP    NZ,LOPFCB    ; If not done, get next one
  1434.     RET
  1435. ;.....
  1436. ;
  1437. ;
  1438. BCHDCR: 
  1439.     LD    A,(FILCNT)
  1440.     DEC    A
  1441.     LD    (FILCNT),A
  1442.  
  1443. BCHD1:    LD    HL,(NBSAVE)    ; Get address of next batch filename
  1444.         LD      DE,NEWNAM       ; Where to put it
  1445.     LD    B,32
  1446.     CALL    MOVE
  1447.     LD    (NBSAVE),HL    ; Store address for next filename
  1448.     RET
  1449. ;
  1450. ;--------------------------
  1451. DONE:   
  1452. ; Finished, clean up and return to CP/M
  1453. EXIT:    
  1454. ;
  1455. ; Restore original drive/user area
  1456. ;
  1457. EXIT2:    
  1458.     LD    HL,DMA
  1459.     CALL    SETDMA
  1460. ;
  1461. EXIT3:    XOR    A        ; Clear the register and carry bit
  1462.     LD    HL,(STACK)    ; Get original return adress back
  1463.     LD    SP,HL        ; Put on the stack pointer
  1464.     jp    0
  1465. ;
  1466. ;.....
  1467. ;
  1468. MOVE:    LD    A,(HL)        ; Get a byte
  1469.     LD    (DE),A        ; Put at new home
  1470.     INC    DE        ; Bump pointers
  1471.     INC    HL
  1472.     DEC    B        ; Decrement byte count
  1473.     JP    NZ,MOVE        ; If more, do it
  1474.     RET            ; If not, return
  1475. ;.....
  1476. ;
  1477. ;
  1478. ; No room to open a new file
  1479. ;
  1480. NOROOM:    CALL    DEXIT
  1481.     DEFB    13,10,'NO DIR SPACE: OUTPUT','$'
  1482. ;.....
  1483. ;
  1484. ;
  1485. ; Output error - cannot close destination file
  1486. ;
  1487. OERROR:    CALL    DEXIT
  1488.     DEFB    13,10,'CANNOT CLOSE OUTPUT','$'
  1489. ;.....
  1490. ;
  1491. ;
  1492. ; See if there is room in the buffer for this character
  1493. ;
  1494. OUTCHR:    PUSH    HL
  1495.     PUSH    AF        ; Store the character for now
  1496.     LD    HL,(OUTSIZ)    ; Get buffer size
  1497.     EX    DE,HL        ; Put in 'DE'
  1498.     LD    HL,(OUTPTR)    ; Now get the buffer pointers
  1499.     LD    A,L        ; Check to see if room in buffer
  1500.     SUB    E
  1501.     LD    A,H
  1502.     SBC    A,D
  1503.     JP    C,OUT3        ; If room, go store the character
  1504.     LD    HL,0        ; Otherwise reset the pointers
  1505.     LD    (OUTPTR),HL    ; Store the new pointer address
  1506. ;
  1507. OUT1:    EX    DE,HL        ; Put pointer address into 'DE'
  1508.     LD    HL,(OUTSIZ)    ; Get the buffer size into 'HL'
  1509.     LD    A,E        ; See if buffer is max. length yet
  1510.     SUB    L        ; By subtracting 'HL' from 'DE'
  1511.     LD    A,D
  1512.     SBC    A,H
  1513.     JP    NC,OUT2        ; If less, exit and keep going
  1514. ;
  1515. ;
  1516. ; No more room in buffer, stop and transfer to destination file
  1517. ;
  1518.     LD    HL,(OUTADR)    ; Get the buffer address
  1519.     ADD    HL,DE        ; Add pointer value
  1520. ;    EX    DE,HL        ; Put into 'DE'
  1521.     CALL    SETDMA
  1522.     LD    C,21
  1523.     EX    DE,HL        ;kr
  1524.     LD    DE,DEST
  1525.     CALL    5
  1526.     OR    A
  1527.     JP    NZ,FULL        ; Exit with error, if disk is full now
  1528.     LD    DE,128
  1529.     LD    HL,(OUTPTR)
  1530.     ADD    HL,DE
  1531.     LD    (OUTPTR),HL
  1532.     JP    OUT1
  1533. ;
  1534. OUT2:
  1535.     LD    HL,DMA
  1536.     CALL    SETDMA
  1537.     LD    HL,0
  1538.     LD    (OUTPTR),HL
  1539. ;
  1540. OUT3:    EX    DE,HL
  1541.     LD    HL,(OUTADR)
  1542.     ADD    HL,DE
  1543.     EX    DE,HL
  1544.     POP    AF        ; Get the character back
  1545.     LD    (DE),A        ; Store the character
  1546.     EX    DE,HL
  1547.     LD    (BCHADR),HL
  1548.     LD    HL,(OUTPTR)    ; Get the buffer pointer
  1549.     INC    HL        ; Increment them
  1550.     LD    (OUTPTR),HL    ; Store the new pointer address
  1551.     POP    HL
  1552.     RET
  1553. ;.....
  1554. ;
  1555. ;
  1556. RERROR:    CP    1        ; File finished?
  1557.     JP    Z,TDONE        ; Exit, then
  1558.     LD    C,19        ; Erase destination file, keep original
  1559.     LD    DE,DEST
  1560.     CALL    5
  1561.     CALL    DEXIT
  1562.     DEFB    '++ SOURCE FILE READ ERROR ++$'
  1563. ;.....
  1564. ;
  1565. ;
  1566. ; Reset the Drive/User to original
  1567. ;
  1568. RESET:    LD    A,(DRUSER)    ; Get original drive/user area back
  1569.     RRA
  1570.     RRA
  1571.     RRA
  1572.     RRA
  1573.     AND    15        ; Just look at the user area
  1574.     LD    C,32
  1575.     LD    E,A
  1576.     CALL    5
  1577.     LD    A,(DRUSER)    ; Get the original drive/user back
  1578.     AND    15        ; Just look at the drive for now
  1579.     LD    C,14        ; Restore original drive
  1580.     LD    E,A
  1581.     CALL    5
  1582.         CALL    PRINT          ; Print CRLF before quitting
  1583.     DEFB    13,10,0
  1584.     JP    EXIT
  1585. ;.....
  1586. ;
  1587. ;
  1588. ; Shows the Filename/extent
  1589. ;
  1590. SHONM:
  1591.         CALL    print
  1592.     DEFB    13,10,13,10,0
  1593.         LD      HL,NEWNAM    
  1594. ;
  1595. SHONM1:    LD    B,8        ; Maximum size of file name
  1596.     CALL    SHONM2
  1597.     LD    A,(HL)        ; Get the next character
  1598.     CP    32        ; Any file extent?
  1599.     RET    Z        ; If not, finished
  1600.     LD    A,46
  1601.     CALL    CTYPE
  1602.     LD    B,3        ; Maximum size of file extent
  1603. ;
  1604. SHONM2:    LD    A,(HL)        ; Get FCB FILENAME/EXT character
  1605.     CP    32        ; Skip any blanks
  1606.     CALL    NZ,CTYPE
  1607.     INC    HL        ; Next FCB position
  1608.     DEC    B        ; One less to go
  1609.     JP    NZ,SHONM2    ; If not done, get next one
  1610.     RET
  1611. ;.....
  1612. ;
  1613. ;
  1614. ; Transfer is done - close destination file
  1615. ;
  1616. TDONE:    LD    HL,(OUTPTR)
  1617.     LD    A,L
  1618.     AND    127
  1619.     JP    NZ,TDONE1
  1620.     LD    (OUTSIZ),HL
  1621. ;
  1622. TDONE1:    LD    A,26        ; Fill remainder of record with ^Z's
  1623.     PUSH    AF
  1624.     CALL    OUTCHR
  1625.     POP    AF
  1626.     JP    NZ,TDONE
  1627.     LD    C,16        ; Close FOR text file
  1628.     LD    DE,FILE
  1629.     CALL    5
  1630.     LD    C,16        ; Close FOR.$$$ text file
  1631.     LD    DE,DEST
  1632.     CALL    5
  1633.     INC    A
  1634.     JP    Z,OERROR
  1635. ;
  1636. ;
  1637. ;  Rename both files as no destination file name was specified
  1638. ;
  1639.     LD    HL,FILE+1    ; Prepare to rename old file to new
  1640.     LD    DE,DEST+17
  1641.     LD    B,16
  1642.     CALL    MOVE
  1643.     LD    C,19        ; Delete original FOR text file
  1644.     LD    DE,FILE
  1645.     CALL    5
  1646.     LD    C,23
  1647.     LD    DE,DEST        ; Rename FOR.$$$ to FOR text file
  1648.     CALL    5
  1649.     JP    RESET        ; Reset the drive/user, finished
  1650. ;.....
  1651. ;
  1652. ;
  1653. ; Send character in 'A' register to console
  1654. ;
  1655. TYPE:    PUSH    BC
  1656.     PUSH    DE
  1657.     PUSH    HL
  1658.     PUSH    AF
  1659.     LD    C,2        ; Write to console
  1660.     LD    E,A        ; Character to 'E' for CP/M
  1661.     CALL    5
  1662.     POP    AF
  1663.     POP    HL
  1664.     POP    DE
  1665.     POP    BC
  1666.     RET
  1667. ;.....
  1668. ;
  1669. ;           end of file description area
  1670. ;-----------------------------------------------------------------------
  1671. ;
  1672. ;
  1673. CTYPE:    PUSH    BC        ; Save all registers
  1674.     PUSH    DE
  1675.     PUSH    HL
  1676.     LD    E,A        ; Character to 'E' in case BDOS (normal)
  1677.     LD    C,2        ; BDOS console output, to CRT and modem
  1678.     CALL    5        ; Since 'BYE' intercepts the char.
  1679.     POP    HL        ; Restore all registers
  1680.     POP    DE
  1681.     POP    BC
  1682.     RET
  1683. ;.....
  1684. ;
  1685. ; Restore the old user area and drive from a received file
  1686. ;
  1687. RECARE:    LD    E,A        ; Stuff it in E
  1688.     LD    C,32        ; Tell BDOS what we want to do
  1689.     JP    5        ; Now do it
  1690. ;.....
  1691. ;data
  1692.  
  1693. innam:    db    'RZMP    OUT'    ; input filename
  1694.  
  1695. ; Fake strings for test mode
  1696.      if    test
  1697. fakertc:
  1698.     db    20h,20h,34h,19h,89h,06h,07h,02h,00h,14h,14h,14h,12h
  1699.  
  1700.      endif        ; test
  1701.  
  1702. ;Token pointer table for input line
  1703. inftok:
  1704.     db    3        ; 3 tokens
  1705. infnum:    ds    1        ; # found by argv
  1706. inftim:    ds    2        ; pointer to transmission time
  1707. inffil:    ds    2        ; pointer to filename
  1708. infsiz:    ds    2        ; pointer to filesize
  1709.  
  1710. direct:    ds    1        ; 'R' or 'S'
  1711. inbuf:  ds      2               ; pointer to input buffer
  1712. outbuf: ds      2               ; pointer to output buffer
  1713. lcbuf:  ds      2               ; pointer to LASTCALR buffer
  1714. lcnam1:    ds    2        ; address of first name in LASTCALR
  1715. lcnam2:    ds    2        ; address of second name in LASTCALR
  1716. incnt:    ds    1        ; input file counter
  1717. inpnt:    ds    2        ; input file pointer
  1718. outcnt:    ds    1        ; output file counter
  1719. outpnt:    ds    2        ; output file pointer
  1720. numbuf:    ds    6        ; number conversion buffer
  1721. outfcb:    ds    36        ; FCB for .LOG file
  1722. infcb:    ds    36        ; FCB for input file
  1723. lcfcb:    ds    36        ; FCB for LASTCALR file
  1724. inline:    ds    41        ; input line from file
  1725. rtcbuf:    ds    15        ; RTC buffer from BYE
  1726. lncntr: ds    1        ; count postion in FOR header line
  1727. tmpflg:    ds    1        ; flag to indicate no file extent
  1728. pvtopt:    ds    1        ; is it a private upload
  1729. gotone:    ds    1        ; show we have at least one upload
  1730. ;
  1731. FILE:    DEFB    0,'FOR        ',0,0,0,0,0,0,0
  1732.     DEFB    0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1733. DEST:    DEFB    0,'        $$$',0,0,0,0,0,0,0
  1734.     DEFB    0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1735. ;
  1736. FORPNT:    DS    2
  1737. NEWNAM:    ds    80
  1738. ;
  1739. ; Batch stuff
  1740. ;
  1741. BCHADR:    DEFW    0        ; For multiple descriptions
  1742. BCHPTR:    DEFW    0
  1743. BUFADR:    DEFW    0        ; For multiple file display
  1744. ;
  1745. ;
  1746. FILCNT:    DEFB    0        ; # of files in batch mode
  1747. NBSAVE:    DS    2        ; Start address in NAMBUF for next file
  1748. ;
  1749. ANYET:    DEFB    0        ; Any description typed yet?
  1750. DRUSER:    DEFB    0        ; Original drive/user, for return
  1751. FIRST:    DEFB    0        ; Used in file description
  1752. KIND:    DEFB    0        ; Asks what kind of file this is
  1753. OLDDRV:    DEFB    0        ; Save the original drive number
  1754. OLDUSR:    DEFB    0        ; Save the original user number
  1755. OUTADR:    DW    0
  1756. OUTPTR:    DEFW    0
  1757. OUTSIZ:    DEFW    16*1024        ;kr was 16 Size of  buffer (use caution)
  1758. ;
  1759. ;
  1760. HLINE:    DEFB    '----',13,10
  1761. OLINE:    DEFS    80    ; Temporary buffer to store line
  1762.     DEFS    100    ; Area for stack
  1763. STACK:    DW    0
  1764. NAMBUF:    ds    2    ; Allow room for 256 batch filenames
  1765. DBUF:    ds    2    ; 16k disk buffer
  1766.  
  1767. ;
  1768. ;
  1769.     END
  1770. ;
  1771.