home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / TURBOM2 / LONG-SUB.MOD < prev    next >
Text File  |  2000-06-30  |  9KB  |  246 lines

  1. NOTE on a SUBmit utility for ZCPR33 for long submit files.
  2.     by Thomas E. Croley II, 2 July 1987
  3.         * Corrects ZCPR33 error in submit processing for $$$.SUB
  4.             files longer than can be accessed with a single
  5.             directory entry.
  6.         * Requires modification of ZCPR33 CCP !!!! (see below).
  7.         * Requires modification of submit utility, SUB34 (see below).
  8.         * XSUB not supported (I can't get XSUB to work properly with
  9.             the unchanged SUB34 and ZCPR33 with short submit files
  10.             yet, let alone the changed versions with long files!)
  11.  
  12. Submit file processing is (and has always been?) limited to short *.SUB file
  13. lengths (fewer than 128 lines for disk allocation blocks of 2k, 256 lines
  14. for disk allocation blocks of 4k, ...).  This is because ZCPR33 finds the
  15. last record in the $$$.SUB file for processing and attempts to close the file
  16. one record shorter to remove that record (command) from further processing;
  17. to do this, ZCPR33 decrements the record count in the FCB for the file before
  18. the close.  This works if there is only one directory entry in the directory
  19. for the $$$.SUB file but it does not work if there are more.  If you use a
  20. disk allocation block size of 2k, then one directory entry manages 16k (one
  21. extent) of file space (=128 records) which, at one line per record in a
  22. $$$.SUB file, limits your submit files (*.SUB) to 128 lines.  Likewise, a 4k
  23. block size allows one directory entry to manage 32k (two extents) of file
  24. space (=256 records), limiting submit files to 256 lines, and so forth.
  25. Subsequently, for longer $$$.SUB files, ZCPR33 neither finds the end of file
  26. correctly, nor is it able to reduce the file length past the point allocated
  27. to an earlier directory entry.  The proper way around this is to implement
  28. direct access ("random access" in old CP/M terminology) file manipulations to
  29. find the end of the file and to keep track of the last record processed.  The
  30. SUB utility must be modified also to use this method so that the last record
  31. (first command) to be accessed by the CCP is pointed to in the file (the last
  32. record of the file is used for this purpose here).  Also, file append (for
  33. nesting of SUB commands), must properly maintain this pointer.
  34.  
  35. If you use wish to use long submit files, you must modify BOTH the SUB
  36. command AND your ZCPR33 CCP by changing the following code as instructed
  37. below.
  38.  
  39. The PENALTY is that it will slow submit file processing (hardly noticeable on
  40. a RAM disk but may be significant on a floppy) since additional disk reads
  41. and writes are required to find and maintain the next-command pointer.  These
  42. reads and writes are not to sequential records on the disk since the pointer
  43. is maintained in the last record of the file while commands are taken
  44. successively toward the beginning.
  45.  
  46. The ADVANTAGE is that it will allow arbitrary length submit files for
  47. processing.
  48.  
  49. IF YOU DO NOT MODIFY THE SUB COMMAND AND DO NOT MODIFY YOUR ZCPR33 CCP AS
  50. FOLLOWS, THEN _BEWARE_ THAT SUMBIT FILES WITH LINE LENGTHS EXCEEDING THE ABOVE
  51. LIMITS WILL NOT BE POSSIBLE _AND_ THERE IS NO ERROR MESSAGE NOR ERROR CHECKING
  52. FOR THIS CONDITION WITHIN THE CCP.
  53.  
  54. NOTE also that XSUBZ must be modified to be consistent with the new file
  55. structure for $$$.SUB.  I spent a day trying to modify XSUBZ12 but could not
  56. get it to work.  There are difficulties already present in XSUBZ12 since I
  57. could not get the unmodified XSUBZ to work correctly with the unmodified
  58. SUB34 and ZCPR33.  These difficulties should be resolved before similar
  59. changes are made to XSUBZ to allow direct access of records.  For now, XSUBZ
  60. or XSUB cannot be used with the modified SUB routine (nor, apparently, with
  61. the unmodified routine either).
  62.  
  63.  
  64. MODIFICATIONS TO ZCPR33.Z80 (may require reconfiguration in Z33HDR.LIB to
  65.         make room for the additional code on your machine)
  66.  
  67. Find the label "subfcr:" in ZCPR33.Z80 and add the code denoted by ";TEC" as
  68. follows:
  69.  
  70. subfcr:
  71.     defs    1        ; Current record number
  72. subfr:                ;TEC
  73.     defs    3        ;TEC Random record no. (16 bits) + ovrflw byte
  74.  
  75. Find the label "readbuf:" in ZCPR33.Z80 and modify or add the code as denoted
  76. by ";TEC" as follows:
  77.  
  78. readbuf:
  79.  
  80.     ld    a,(zexrunfl)    ; Get ZEX-running flag
  81.     or    a
  82.     jp    nz,userinput    ; If ZEX running, go directly to user input
  83.  
  84.      if    subon        ; If submit facility is enabled, check for it
  85.  
  86.     ld    a,(subflag)    ; Test for submit file running
  87.     or    a
  88.     jr    z,shellinput    ; If not, go on to possible shell input
  89.  
  90.     xor    a        ; Log into user 0
  91.     call    setuser
  92.     call    defltdma    ; Initialize DMA pointer
  93.     ld    de,subfcb    ; Point to submit file FCB
  94.     call    open        ; Try to open file
  95.     jr    z,readbuf1    ; Branch if open failed
  96.  
  97. ;TEC    ld    hl,subfrc    ; Point to record count in submit FCB
  98. ;TEC    ld    a,(hl)        ; Get the number of records in file
  99. ;TEC    dec    a        ; Reduce to number of last record
  100. ;TEC    ld    (subfcr),a    ; ..and put into current record field
  101.     ld    c,23h        ;TEC "Compute file size" bdos call no.
  102.     call    bdossave    ;TEC DE still => subfcb; get file size in subfr
  103.     ld    hl,(subfr)    ;TEC Get file size
  104.     dec    hl        ;TEC Decrement to get last record no.
  105.     ld    (subfr),hl    ;TEC Replace in random record field
  106.     ld    c,21h        ;TEC "Read random" bdos call no.
  107.     call    bdossave    ;TEC DE still => subfcb; randm read last record
  108.     ld    hl,(tbuff)    ;TEC Get current "last record" from last record
  109.     dec    hl        ;TEC Point to next earlier record to read
  110.     ld    (tbuff),hl    ;TEC Save pointer in actual last record
  111.     inc    c        ;TEC ... and write back to file (c=22h)
  112.     call    bdossave    ;TEC DE still => subfcb; randm write last recrd
  113.     ld    (subfr),hl    ;TEC Now prepare to read new "last record"
  114.     dec    c        ;TEC (c=21h)
  115.     call    bdossave    ;TEC Random read record; DE still => subfcb
  116. ;TEC    call    read        ; Attempt to read submit file
  117. ;TEC    jr    nz,readbuf1    ; Branch if read failed
  118.  
  119. ;TEC    dec    (hl)        ; Reduce file record cound
  120. ;TEC    dec    hl        ; Point to S2 byte of FCB (yes, this is req'd!)
  121. ;TEC    ld    (hl),a        ; Stuff a zero in there (A=0 from call to READ)
  122.     ld    (subfrc-1),a    ;TEC Zero FCB S2 byte (A=0 from previous read)
  123.     call    close        ; Close the submit file one record smaller
  124.     jr    z,readbuf1    ; Branch if close failed
  125.  
  126. END of ZCPR33.Z80 changes...
  127.  
  128.  
  129. MODIFICATIONS TO SUB34.Z80
  130.  
  131. Find the label "wrset:" in SUB34.Z80 and modify or add the code denoted by
  132. ";TEC" as follows:
  133.  
  134. ;
  135. ;    SET UP THE $$$.SUB FILE
  136. ;    FOR WRITING
  137. ;
  138. wrset:
  139.     call    print
  140.     db    cr,lf,' Writing Command File to Disk',0
  141.  
  142.     ld    e,0        ; Set user 0
  143.     ld    c,20h
  144.     call    bdos
  145.  
  146.     ld    de,subfcb
  147.     ld    c,openf
  148.     call    bdos        ; Open the file
  149.     inc    a        ; Check cpm return
  150.     jp    z,none1        ; None exists already
  151. ;
  152. ;    $$$.SUB EXISTS, SO SET
  153. ;    FCB TO APPEND TO IT
  154. ;
  155.  
  156.     ld    de,subfcb    ;TEC Point to submit file FCB
  157.     ld    c,23h        ;TEC "Compute file size" bdos call no.
  158.     call    bdos        ;TEC Get file size in subfr
  159.     ld    hl,(subfr)    ;TEC Get file size
  160.     dec    hl        ;TEC Decrement to get last record no.
  161.     ld    (oldfsz),hl    ;TEC Save present file last record no.
  162.     ld    (subfr),hl    ;TEC Replace in random record field
  163.     ld    de,subfcb    ;TEC Point to submit file FCB again
  164.     ld    c,21h        ;TEC "Read random" bdos call no.
  165.     call    bdos        ;TEC Random read last record
  166.     ld    hl,(tbuf)    ;TEC Get current "last record" pointer
  167.     dec    hl        ;TEC Decr. to point to last unprocessed record
  168.     ld    (subfr),hl    ;TEC Now read "last record"
  169.     ld    de,subfcb    ;TEC Point to submit file FCB again
  170.     ld    c,21h        ;TEC "Read random" bdos call no.
  171.     call    bdos        ;TEC Random read record
  172.     ld    de,subfcb    ;TEC Prepare for sequential (re)write to update
  173.     ld    c,15h        ;TEC ... DOS pointers for further writes
  174.     call    bdos        ;TEC Write same info back to set DOS pointers
  175. ;TEC    ld    a,(subfcb+fcbrc) ; Get record count
  176. ;TEC    ld    (subfcb+fcbnr),a ; Make next record
  177.     ret
  178. oldfsz:    ds    2        ;TEC space for "old file size"
  179. ;
  180. ;    COME HERE WHEN NO $$$.SUB EXISTS
  181. ;
  182. none1:
  183.     xor    a        ;TEC
  184.     ld    (oldfsz),a    ;TEC Zero "old file size" since it did'nt exist
  185.     ld    (oldfsz+1),a    ;TEC
  186.     ld    de,subfcb
  187.     ld    c,makef
  188.     call    bdos
  189.     inc    a
  190.     jp    z,nomake    ; 0ffh=can't create file
  191.     ret
  192.  
  193. Find the label "close:" in SUB34.Z80 and add the code denoted by ";TEC" as
  194. follows:
  195.  
  196. ;
  197. ;    $$$.SUB IS WRITTEN, CLOSE THE FILE
  198. ;
  199. close:
  200.     ld    de,subfcb    ;TEC
  201.     ld    c,24h        ;TEC Set random record number for record after
  202.     call    bdos        ;TEC ... last write
  203.     ld    hl,(subfr)    ;TEC Get rndm record no. for last record write
  204.     ld    (tbuf),hl    ;TEC Place in write buffer
  205.     ld    de,(oldfsz)    ;TEC DE = old last record number
  206.     xor    a        ;TEC Clear carry bit
  207.     sbc    hl,de        ;TEC Is new last record number >= old?
  208.     jr    nc,nfeok    ;TEC New file end O.K.
  209.     ld    (subfr),de    ;TEC ... else use old last record number
  210. nfeok:    ld    de,subfcb    ;TEC
  211.     ld    c,22h        ;TEC "Write random" bdos call no.
  212.     call    bdos        ;TEC Write current record no. to last record.
  213.     ld    de,subfcb
  214.     ld    c,closef
  215.     jp    bdos
  216.  
  217. Find the label "subfcb:" in SUB34.Z80 and modify or add the code denoted by
  218. ";TEC" as follows:
  219.  
  220. ;
  221. ;
  222. ;    FCB FOR $$$.SUB
  223. ;
  224. subfcb:
  225.     db    1        ; Drive specifier (a selected)
  226.     db    '$$$     '
  227. subtyp:
  228.     db    'SUB'
  229.     dw    0,0,0,0        ; Initialize rest of fcb
  230.     dw    0,0,0,0
  231. ;TEC    dw    0,0,0,0
  232.     dw    0,0        ;TEC
  233.     db    0        ;TEC
  234. subfr:    dw    0        ;TEC Direct-access 16-bit record number
  235.     db    0        ;TEC Overflow byte
  236. ;
  237. clbuf:    ds    2        ; Ptr to command line buffer
  238. fremem:    ds    2        ; Ptr to free memory area
  239. ;
  240.     end
  241.  
  242. END of SUB34.Z80 changes...
  243.  
  244.  
  245. END OF NOTE on a SUBmit utility for ZCPR33 for long submit files.
  246.