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 / CATLOG / XCAT43.LBR / XCAT43.AQM / XCAT43.ASM
Assembly Source File  |  2000-06-30  |  32KB  |  1,474 lines

  1. ; XCAT v4.3 -- CATALOG CROSS-REFERENCE PROGRAM FOR MAST.CAT -- 11/20/85
  2. ;
  3. ;         COPYRIGHTED 1983, 1984, 1985 BY IRV HOFF
  4. ;
  5. ;     This program makes a cross-reference listing of the MAST.CAT file.
  6. ; It names this new file MAST.LST.  This file may then be listed using
  7. ; the normal printer routine, or viewed on the CRT using the TYPE com-
  8. ; mand.  It is copryighted to deter commercialization.
  9. ;
  10. ;     It can use any length MAST.CAT files, even beyond 6-8-10,000 file
  11. ; names.  If the file is too long for available memory, it puts a note
  12. ; on the CRT to that effect, handles that portion of the file and con-
  13. ; tinues with the rest of the file until finished.  A computer having
  14. ; 64k memory could typically handle about 3200 file names before this
  15. ; happens.
  16. ;
  17. ;        Rapid information can also be obtained
  18. ;        regarding any file and the disk it is on
  19. ;        by using an auxiliary program 'FIND.COM'
  20. ;        Example:
  21. ;
  22. ;
  23. ; A>FIND MAST.LST PIP
  24. ;
  25. ;    This will print a list (on CRT and on hard copy via CTL-P) of
  26. ;    any file names in the MAST.LST file having the characters PIP in
  27. ;    the contents.  (You can as easily find all .ASM files, etc.)
  28. ;    The combination of MAST.LST plus FIND.COM makes an excellent way
  29. ;    to keep an updated catalog listing without the necessity of hard
  30. ;    copy.  (Use XCAT.COM to keep the MAST.CAT file current.)
  31. ;
  32. ;    This program assumes each disk has an unique volume number as a
  33. ;    disk ID.  It ignores any volume name that may be on the same
  34. ;    line.  An example of one method in common use:
  35. ;
  36. ;
  37. ; A>SAVE 0 B:-.123
  38. ; A>SAVE 0 B:-01AUG82
  39. ; A>SAVE 0 B:-UNIQUE
  40. ;
  41. ;    The first line places a disk volume number on the B: disk of
  42. ;    zero length.  The "-" identifies it as a volume number for MCAT.
  43. ;    The second line shows how, if desired, an extra unique disk vol-
  44. ;    ume date could be added.  The third line shows an unique volume
  45. ;    name.    All the lines could be used, but only the disk volume
  46. ;    number is used for the MAST.LST cross-reference list.  (Don't
  47. ;    forget the period in front of the volume number to show it is a
  48. ;    file type, not a file name.  That automatically gives it eight
  49. ;    spaces for a file name, so it will alphabetize ahead of any
  50. ;    other lines startins with "-" and be considered the disk volume
  51. ;    number.)
  52. ;
  53. ;    If "USER" is set YES, it will include the user number for each
  54. ;    program.  (This assumes your MAST.CAT file has the user numbers
  55. ;    included, which is an option on the MCAT catalog program.  Even
  56. ;    if it does have user numbers, you can still say NO to the USER
  57. ;    equate if you wish.)  If user numbers are not needed, just set
  58. ;    "USER" to NO.
  59. ;
  60. ; FILENAME.TYP    -  023    045  093  123  131  145     (no user numbers)
  61. ;
  62. ; FILENAME.TYP    -  023/02  045/12  093/00  123/15   (w/user numbers)
  63. ;
  64. ;                     Irvin M. Hoff W6FFC
  65. ;                     Los Altos Hills, CA 94022
  66. ;
  67. ;=======================================================================
  68. ;
  69. ; 11/20/85  Numerous changes.  Major rewrite to fix an obscure error oc-
  70. ;   v4.3    curing when the buffer was full (takes around 3000 filenames
  71. ;        or so), which did not display or count the last filename
  72. ;        properly.  Many other subtle changes to simplify the program
  73. ;        and speed up its response.    - Irv Hoff
  74. ;
  75. ; 08/22/84  Fixed error, restored original format.
  76. ;   v4.2                - Irv Hoff
  77. ;
  78. ; 08/20/84  Optional user area added.
  79. ;   v4.1                - Paul Traina
  80. ;
  81. ; 11/20/83  Original version, fixed for use with MCAT, based on a 1979
  82. ;   v4.0    program called CROSSREF.    - Irv Hoff
  83. ;
  84. ;=======================================================================
  85. ;
  86. ;
  87. NO    EQU    0
  88. YES    EQU    NOT NO        ; Some assemblers cannot use 0FFH here
  89. ;
  90. ;
  91. USER    EQU    NO        ; Yes to display user numbers
  92. ;
  93.      IF    USER
  94. IDLEN    EQU    7        ; Each entry is 7 characters long
  95. LENGTH    EQU    19        ; Length of line to store
  96. NUMPRL    EQU    7        ; Maximum number of entries per line
  97.      ENDIF            ; USER
  98. ;
  99.      IF    NOT USER
  100. IDLEN    EQU    4        ; Each entry is 4 characters long
  101. LENGTH    EQU    16        ; Length of line to store
  102. NUMPRL    EQU    10        ; Maximum number of entries per line
  103.      ENDIF            ; NOT USER
  104. ;
  105. ;
  106. ; Equates
  107. ;
  108. DASLEN    EQU    4        ; Length of dash line
  109. NAMTYP    EQU    12        ; Length of filename/separator/extent
  110. ;
  111. ;
  112. ; BDOS commands
  113. ;
  114. BDOS    EQU    0005H        ; Bdos entry location
  115. ;
  116. RCFC    EQU    1        ; Console input
  117. WCFC    EQU    2        ; Console output
  118. WCLD    EQU    5        ; Write character to list device
  119. KSTAT    EQU    11        ; Get console status
  120. OPEN    EQU    15        ; Open file
  121. CFFC    EQU    16        ; Close file
  122. DFFC    EQU    19        ; Delete file
  123. RNFC    EQU    20        ; Read sequential
  124. WRFC    EQU    21        ; Write sequential
  125. MFFC    EQU    22        ; Make file
  126. SDMA    EQU    26        ; Set 'DMA' address
  127. ;.....
  128. ;
  129. ;
  130. ; ASCII characters
  131. ;
  132. BS    EQU    08H        ; Backspace
  133. CR    EQU    0DH        ; Carriage return
  134. EX    EQU    12
  135. FN    EQU    01
  136. FT    EQU    09
  137. LF    EQU    0AH        ; Line feed
  138. NR    EQU    32
  139. SI    EQU    16H        ; Synch idle
  140. TFCB    EQU    005CH        ; Default file control block
  141. ;.....
  142. ;
  143. ;
  144. ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  145. ;                                       ;
  146. ;                                       ;
  147. ;               PROGRAM STARTS HERE                   ;
  148. ;                                       ;
  149. ;                                       ;
  150. ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  151. ;
  152. ;
  153.     ORG    100H
  154. ;
  155. ;
  156. START:    LXI    H,0
  157.     DAD    SP        ; 'CCP' return address
  158.     SHLD    STACK
  159.     LXI    SP,STACK
  160. ;
  161.     LXI    H,MSG0        ; Print sign-on message
  162.     CALL    WASC
  163.     CALL    INPUT        ; Get keyboard character
  164.     ANI    5FH        ; Change to upper-case if needed
  165.     CPI    'Y'
  166.     JNZ    START1        ; If not, exit
  167.     XRA    A        ; Otherwise ignore and continue
  168.     STA    LOOP+1
  169. ;
  170. START1:    LXI    H,MSG21        ; Turn up a new line
  171.     CALL    WASC
  172. ;
  173. ;
  174. ;------------------ read 'MAST.CAT' into memory ------------------------
  175. ;
  176. ;
  177. ; Open MAST.CAT file to read filenames into buffer
  178. ;
  179.     CALL    SETR        ; Disk read 'DMA' to 'BUFREC' address
  180.     LXI    D,FCB
  181.     MVI    C,OPEN
  182.     CALL    BDOS
  183.     INR    A
  184.     LXI    H,MSG7
  185.     JZ    ERXIT        ; Jump if unable to open
  186.     CALL    PRHC        ; Want hard copy?
  187.     LXI    H,MSG8        ; Keep user informed
  188.     CALL    WASC
  189.     LHLD    BDOS+1        ; Start of 'BDOS' area
  190.     MOV    A,H
  191.     SUI    8
  192.     STA    CCP        ; Store 'CCP' starting page
  193.     LXI    H,BUFREC+80
  194.     SHLD    DBUFI        ; Force initial disk read
  195.     LXI    H,FNTBL
  196.     SHLD    FNTP        ; Initialize filename table pointer
  197.     CALL    CLEAR        ; Clear useable RAM area
  198. ;
  199. ;
  200. ; Skip the 'IGNORE' file names at the head of the 'MAST.CAT' file
  201. ;
  202. SKPIGN:    CALL    RDCHR        ; Get a character from the file
  203.     CPI    ')'
  204.     JNZ    SKPIGN        ; Wait until at end of the IGNORE list
  205. ;
  206. ;
  207. ; Main read loop.  Read a line from MAST.CAT, discard any disk name and
  208. ; put the rest into the FNTBL buffer.
  209. ;
  210. ; Skip to end of line (L/F) in MAST.CAT file
  211. ;
  212. SKIPLF:    CALL    TERM        ; Ready to quit?
  213.     CALL    RDCHR        ; Read until <LF>
  214.     CPI    LF
  215.     JNZ    SKIPLF        ; Wait until next LF is found, skips CR
  216. ;
  217. ;
  218. ; See if the first character is a null (skips date lines, etc.)
  219. ;
  220.     CALL    RDCHR
  221.     ORA    A
  222.     JZ    SKIPLF        ; If yes, ignore this line
  223. ;
  224. ;
  225. ; See if it is a '.FRE' line or one with '-' at start
  226. ;
  227. LOOP:    CPI    '+'        ; (overwritten by "begin" if wanted)
  228.     JZ    SKIPLF        ; If yes, ignore this line
  229.     CPI    '-'        ; Ignore any lines starting with '-'
  230.     JZ    SKIPLF
  231. ;
  232.     LHLD    FNTP        ; Get location in table
  233.     XCHG            ; Put into 'DE'
  234. ;
  235. ; Get the filename
  236. ;
  237.     MVI    B,8
  238.     CALL    GETNF+3
  239. ;
  240. ;
  241. ; Put in the separator (now instead of later)
  242. ;
  243.     MVI    A,'.'
  244.     STAX    D
  245.     INX    D
  246. ;
  247. ;
  248. ; Get the filetype
  249. ;
  250.     MVI    B,3
  251.     CALL    GETNF
  252. ;
  253. ;
  254. ; Skip over any disk name and take only the disk number (up to three
  255. ; alphanumeric characters).
  256. ;
  257.     PUSH    D        ; Save table pointer
  258.     LXI    D,TRASH        ; Throw away any disk name
  259.     MVI    B,8
  260.     CALL    GETNF
  261. ;
  262. ;
  263. ; Now move in the disk FILETYPE (number)
  264. ;
  265.     POP    D        ; Get the table pointer back
  266.     MVI    A,' '        ; Put in leading space
  267.     STAX    D
  268.     INX    D
  269.     MVI    B,3
  270.     CALL    GETNF        ; File type
  271. ;
  272.      IF    USER
  273.     MVI    A,'/'        ; And separator for user area
  274.     STAX    D
  275.     INX    D
  276.     CALL    RDCHR        ; Get next char. (which is user area)
  277.     CPI    'N'-40H        ; CTL-N for user area?
  278.     JNZ    $+5        ; If not, skip next line
  279.     MVI    A,'0'        ; Else show user 0 for '.FRE' line
  280.     CPI    'A'        ; Digits are 0-9
  281.     CC    PAD0        ; No, go pad with 0
  282.     CNC    PAD1        ; Otherwise go pad with a '1'
  283.     JC    NOCVT        ; Not necessary to convert
  284.     SUI    'A'-'0'        ; Convert to decimal
  285. ;
  286. NOCVT:    STAX    D
  287.     INX    D
  288.      ENDIF            ; USER
  289. ;
  290.     XCHG            ; Put buffer position into 'HL'
  291.     SHLD    FNTP        ; Save pointer for next character
  292. ;
  293. ;
  294. ; Bump the buffer by one line length to see if another line would be
  295. ; too much.
  296. ;
  297.     LXI    D,LENGTH    ; Get length of filename, size, etc.
  298.     DAD    D        ; Add to current position
  299. ;
  300. ;
  301. ; Stop if it will exceed the buffer length (jump into 'CCP' area)
  302. ;
  303.     LDA    CCP        ; Get 'CCP' start page
  304.     CMP    H        ; Compare addresses
  305.     JNZ    SKIPLF        ; If less, ok to continue
  306. ;
  307. ;
  308. ; If running too long, print what we have, and get the rest later
  309. ;
  310.     LHLD    DBUFI        ; See if next character is a CTL-Z
  311.     INX    H        ; Index past last line feed char.
  312.     MOV    A,M
  313.     CPI    'Z'-40H
  314.     JZ    $+8        ; If CTL-Z, do not show more coming
  315.     MVI    A,1        ; Some non-zero value
  316.     STA    NEXT
  317.     STA    ONCE
  318.     LHLD    FNTP        ; End of buffer address
  319.     MOV    A,L        ; Subtract one name length for last name
  320.     SUI    LENGTH
  321.     MOV    L,A
  322.     MOV    A,H
  323.     SBI    0
  324.     MOV    H,A
  325.     LXI    D,MSG11        ; Move file name into message
  326.     MVI    B,NAMTYP    ; Length of filename/separator/extent
  327.     CALL    MOVE
  328.     LXI    H,MSG10        ; 'File too long' message
  329.     CALL    WASC        ; Show the message
  330. ;.....
  331. ;
  332. ;
  333. ;----------------- Print file from 'FNTBL' to disk ---------------------
  334. ;
  335. ; Check first to see if have been this way before
  336. ;
  337. PRNT:    CALL    SETO        ; Set disk output 'DMA' address
  338.     CALL    SETFNT        ; Set the filename counters
  339.     LDA    REPEAT
  340.     ORA    A
  341.     JZ    PRNT1
  342. ;
  343.     LDA    MATCH        ; Was there a match, last time?
  344.     ORA    A
  345.     JZ    PRNT4        ; If not, proceed normally
  346.     JMP    PRNT5        ; If yes, see if new one matches
  347. ;
  348. ;
  349. ; Now see if an output file name was given initially
  350. ;
  351. PRNT1:    INR    A
  352.     STA    REPEAT        ; Show we have been this way now
  353.     LDA    HCFLG        ; For hard copy to printer
  354.     ORA    A
  355.     JNZ    PRNT3        ; If yes, do not open file
  356.     LDA    TFCB+FN        ; Jump if non-blank name or type
  357.     CPI    ' '
  358.     JNZ    PRNT2
  359.     LDA    TFCB+FT        ; Allow blank file type
  360.     CPI    ' '
  361.     JNZ    PRNT2
  362.     LXI    H,DEFLT        ; Default to 'MAS.LST'
  363.     LXI    D,TFCB
  364.     MVI    B,NAMTYP    ; Length of drive/filename/extent
  365.     CALL    MOVE
  366. ;
  367. PRNT2:    XRA    A
  368.     STA    TFCB+EX
  369.     CALL    CREATE
  370.     INR    A        ; New file started ok?
  371.     LXI    H,MSG15
  372.     JZ    ERXIT        ; Error message if not
  373.     LDA    NEXT
  374.     ORA    A
  375.     LXI    H,MSG14        ; Says file is writing now
  376.     CZ    WASC
  377.     XRA    A
  378.     STA    TFCB+NR
  379. ;
  380. PRNT3:    LXI    H,BUFOUT
  381.     SHLD    DBUFO
  382.     XRA    A
  383.     STA    DBUFC
  384. ;
  385. ;
  386. ; Move filename, extent, file length and 'dash line' into OBUF line
  387. ;
  388. PRNT4:    LHLD    ICNT        ; Copy name (ICNT) into 'OBUF'
  389.     LXI    D,OBUF
  390.     MVI    B,NAMTYP    ; Copy filename into OBUF
  391.     CALL    MOVE
  392.     PUSH    H
  393.     LXI    H,DASH        ; Copy ' - ' into 'OBUF'
  394.     MVI    B,DASLEN
  395.     CALL    MOVE
  396.     POP    H
  397.     MVI    B,IDLEN        ; Copy disk designator
  398.     CALL    MOVE
  399.     XRA    A        ; Flag end of 'OBUF'
  400.     STAX    D
  401.     XCHG            ; Put OBUF ending address into HL
  402.     SHLD    SAVEOB        ; Save in case next line matches
  403.     MVI    A,1        ; Start with one disk ID on the line
  404.     STA    CNT
  405.     CALL    FILESD        ; Increment the unique file count
  406. ;
  407. ;
  408. ; Compare file first filename/ext with second one for match
  409. ;
  410. PRNT5:    CALL    FILES        ; Increment the total file count
  411.     XRA    A
  412.     MVI    C,NAMTYP    ; Compare filename and type
  413.     CALL    COMP        ; See if the same filename and type
  414. ;
  415. ;
  416. ; If the same except for disk ID, exit
  417. ;
  418.     JZ    PRNT6
  419. ;
  420. ;
  421. ; Since different, put 'OBUF' into output buffer
  422. ;
  423.     CALL    WRBUF        ; Write OBUF line to disk buffer
  424.     LDA    XDONE        ; See if finished now
  425.     ORA    A
  426.     JNZ    PRNT10        ; If yes, go terminate
  427.     STA    MATCH        ; Show this was not a match
  428. ;
  429. ;
  430. ; Check on end of filename buffer
  431. ;
  432.     LHLD    JCNT        ; Get next 'second name' starting addr
  433.     XCHG            ; Put into DE
  434.     LHLD    FNTP        ; Get end of buffer address
  435.     MOV    A,D        ; Compare ones done with total
  436.     CMP    H
  437.     JC    PRNT4        ; If less, go get another
  438.     MOV    A,E
  439.     CMP    L
  440.     JC    PRNT4        ; If less go get another
  441. ;
  442.     LDA    NEXT        ; See if more to come
  443.     ORA    A
  444.     JNZ    PRNT9        ; If more to come, exit
  445.     INR    A
  446.     STA    XDONE
  447.     JMP    PRNT4
  448. ;
  449. ;
  450. ; Since file names are identical, cross-reference the disk ID.
  451. ;
  452. PRNT6:    LHLD    SAVEOB        ; Get current end address on OBUF line
  453.     XCHG
  454.     LDA    CNT        ; Add one to number on line
  455.     CPI    NUMPRL        ; Exit if less that maximum entries yet
  456.     JC    PRNT8
  457.     CALL    WRBUF        ; Write 'OBUF' line to disk buffer
  458. ;
  459. ;
  460. ; If maximum entries this line, start a new line, blank at beginning
  461. ;
  462.     LXI    D,OBUF        ; Start new 'OBUF' line
  463.     MVI    B,LENGTH
  464.     MVI    A,' '
  465. ;
  466. PRNT7:    STAX    D
  467.     INX    D
  468.     DCR    B
  469.     JNZ    PRNT7
  470.     XRA    A        ; Back to one disk ID on  'OBUF' line
  471. ;
  472. ;
  473. ; Add new ID to this line
  474. ;
  475. PRNT8:    INR    A
  476.     STA    CNT        ; Store number of ID entries
  477.     STA    MATCH
  478.     MVI    A,' '        ; Insert 1 blank in 'OBUF'
  479.     STAX    D
  480.     INX    D
  481.     LHLD    ICNT        ; Copy disk ID (ICNT) into 'OBUF'
  482.     LXI    B,LENGTH-IDLEN    ; Include filename, type and length
  483.     DAD    B
  484.     MVI    B,IDLEN        ; Include the identifier initial
  485.     CALL    MOVE
  486.     XRA    A        ; Terminate 'OBUF' line
  487.     STAX    D
  488.     XCHG            ; Compare address with end of buffer
  489.     SHLD    SAVEOB        ; Save current end of OBUF line address
  490.     XCHG            ; Put back into 'DE' to compare end
  491. ;
  492. ;
  493. ; Now see if there are any more entries
  494. ;
  495.     LHLD    JCNT        ; Start of next line in FNTBL
  496.     XCHG            ; Put into DE to compare end of buffer
  497.     LHLD    FNTP        ; Get end of buffer address
  498.     MOV    A,D        ; Compare ones done with total
  499.     CMP    H
  500.     JC    PRNT5        ; If less, go get another
  501.     MOV    A,E
  502.     CMP    L
  503.     JC    PRNT5        ; If less, go get another
  504.     LDA    NEXT        ; More to come?
  505.     ORA    A
  506.     JNZ    PRNT9        ; If yes, exit
  507.     MVI    A,1
  508.     STA    XDONE
  509.     JMP    PRNT5
  510. ;
  511. ;
  512. ; See if there is still more 'MAS.CAT' file to input
  513. ;
  514. PRNT9:    XRA    A
  515.     STA    NEXT        ; Reset the flag
  516.     LHLD    ICNT        ; Count of last file name line
  517.     LXI    D,FNTBL        ; Move last name to start of buffer
  518.     MVI    B,LENGTH    ; Filename, extent and filesize
  519.     CALL    MOVE        ; Put name into special buffer
  520.     XCHG            ; HL is now end of first name in buffer
  521.     CALL    CLEAR1+3    ; Clear rest of useable memory
  522.     LXI    H,FNTBL+LENGTH    ; Start loading buffer after first name
  523.     SHLD    FNTP
  524.     MVI    A,1
  525.     STA    REPEAT        ; Show we have already opened the file
  526.     CALL    SETR        ; Set disk recieve 'DMA' address
  527.     LXI    H,MSG13
  528.     CALL    WASC        ; Print the message
  529.     JMP    SKIPLF        ; Get next group of files
  530. ;.....
  531. ;
  532. ;
  533. PRNT10:    LXI    H,LCNT        ; Get the line count
  534.     MOV    A,M
  535.     CPI    52
  536.     JNC    PRNT11        ; If too close to end, skip MSG17
  537.     ADI    3
  538.     MOV    M,A        ; Store new line count
  539.     LXI    H,MSG17
  540.     CALL    WASD
  541. ;
  542. PRNT11:    CALL    FLUSH        ; Finish end of file
  543.     LDA    HCFLG        ; Printing hard copy?
  544.     ORA    A
  545.     JZ    EXIT        ; Exit if not
  546.     XRA    A
  547.     STA    STOP        ; Reset flag if set
  548.     CALL    ROLL
  549.     JMP    EXIT        ; Finished
  550. ;.....
  551. ;
  552. ;
  553. ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  554. ;
  555. ;              SUPPLEMENTAL ROUTINES
  556. ;
  557. ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  558. ;
  559. ;
  560. ; Handle a backspace character while entering a file name
  561. ;
  562. BCKSP:    MOV    A,B        ; Get position on line
  563.     ORA    A
  564.     JNZ    BCKSP1        ; Exit if at initial column
  565.     MVI    A,' '        ; Delete the character
  566.     JMP    BCKSP3
  567. ;
  568. BCKSP1:    DCR    B        ; Show one less column used
  569.     DCX    H        ; Decrease buffer location
  570.     MVI    A,' '
  571.     MOV    M,A        ; Replace to original
  572.     CALL    WACC        ; Backspace the CRT
  573. ;
  574. BCKSP2:    MVI    A,BS        ; Reset the CRT again
  575. ;
  576. BCKSP3:    CALL    WACC        ; Write to CRT
  577.     RET
  578. ;.....
  579. ;
  580. ;
  581. ; Check to see if ready to start printing yet
  582. ;
  583. CKST:    PUSH    H        ; Save the registers
  584.     PUSH    D
  585.     PUSH    B
  586.     LXI    H,PAGES+2    ; Address of starting page answer
  587. ;
  588. CKST1:    INX    H        ; Find the rightmost digit
  589.     MOV    A,M
  590.     CPI    ' '
  591.     JNZ    CKST1
  592.     DCX    H
  593.     LXI    D,HEAD3+2    ; Rightmost digit for page number
  594.     MVI    C,2
  595. ;
  596. CKST2:    LDAX    D        ; Compare two strings of numbers
  597.     CMP    M
  598.     JNZ    CKST5        ; If different, not ready yet
  599.     DCX    D        ; Check next digit
  600.     DCX    H
  601.     DCR    C
  602.     JNZ    CKST2
  603.     STA    PRINT        ; Allows hard copy to commence
  604. ;
  605. CKST3:    DB    0,0,0        ; Overwritten if using roll paper
  606.     DB    0,0,0
  607. ;
  608. CKST4:    LXI    H,HEAD1-2
  609.     CALL    WASD
  610. ;
  611. CKST5:    POP    B        ; Restore the registers
  612.     POP    D
  613.     POP    H
  614.     RET
  615. ;.....
  616. ;
  617. ;
  618. ; Check to see if ready to stop printing yet
  619. ;
  620. CKSP:    PUSH    H        ; Save the registers
  621.     PUSH    D
  622.     PUSH    B
  623.     LXI    H,PAGEQ+2    ; Address of quitting page answer
  624. ;
  625. CKSP1:    INX    H        ; Find the rightmost digit
  626.     MOV    A,M
  627.     CPI    ' '
  628.     JNZ    CKSP1
  629.     DCX    H
  630.     LXI    D,HEAD3+2    ; Rightmost digit for page number
  631.     MVI    C,2
  632. ;
  633. CKSP2:    LDAX    D        ; Compare two strings of numbers
  634.     CMP    M
  635.     JNZ    CKSP3        ; If different, not ready yet
  636.     DCX    D        ; Check next digit
  637.     DCX    H
  638.     DCR    C
  639.     JNZ    CKSP2
  640.     STA    STOP        ; Allows hard copy to commence
  641. ;
  642. CKSP3:    POP    B        ; Restore the registers
  643.     POP    D
  644.     POP    H
  645.     RET
  646. ;.....
  647. ;
  648. ;
  649. ; Clear useable memory from start of buffer to start of 'CCP'
  650. ;
  651. CLEAR:    LXI    H,BUFOUT    ; Clear all of user-ram above stack
  652.     JMP    CLEAR1+3    ; Skip next line
  653. ;
  654. CLEAR1:    LXI    H,FNTBL        ; Start of file name table area
  655.     LDA    CCP        ; Get 'CCP' starting page
  656.     MOV    D,A        ; Put in 'D' reg.
  657. ;
  658. CLEAR2:    MVI    M,0        ; Null the location
  659.     INX    H        ; Next location
  660.     MOV    A,H        ; Check current page address
  661.     CMP    D        ; Compare with stopping address
  662.     JC    CLEAR2        ; If less, keep going
  663.     RET
  664. ;.....
  665. ;
  666. ;
  667. ; Close disk file
  668. ;
  669. CLOSE:    PUSH    H
  670.     PUSH    D
  671.     PUSH    B
  672.     LXI    D,TFCB
  673.     MVI    C,CFFC
  674.     CALL    BDOS
  675.     LXI    H,MSG16        ; Close error?
  676.     CPI    0FFH
  677.     JZ    ERXIT        ; Jump if so
  678.     POP    B
  679.     POP    D
  680.     POP    H
  681.     RET
  682. ;.....
  683. ;
  684. ;
  685. ; Compare entries in 'FNTBL', and swap if necessary
  686. ;
  687. COMP:    LHLD    ICNT        ; HL=FNTBL
  688.     XCHG            ; Put into DE
  689.     LHLD    JCNT        ; DE=FNTBL+LENGTH
  690. ;
  691. COMP1:    LDAX    D        ; Compare next byte
  692.     ORA    A        ; Null for end-of-file?
  693.     JZ    COMP3        ; If yes, finished with line
  694.     CMP    M        ; See if characters are the same
  695.     JNZ    COMP3        ; Return with 'Z' flag set if not eqaul
  696.     INX    D
  697.     INX    H
  698.     DCR    C        ; Keep trying
  699.     JNZ    COMP1        ; If not done, check next character
  700.     XRA    A        ; Strings are equal, so reset 'Z' flag
  701.     JMP    COMP3
  702. ;
  703. COMP2:    LDA    NEXT
  704.     ORA    A
  705.     JNZ    COMP3        ; If more coming, back to work
  706.     CALL    WRBUF        ; Write the final line
  707.     POP    H        ; Clear stack from 'CALL COMP'
  708.     JMP    PRNT10        ; Terminate
  709. ;...
  710. ;
  711. ;
  712. ; Increment for next compare
  713. ;
  714. COMP3:    LHLD    ICNT
  715.     LXI    D,LENGTH
  716.     DAD    D
  717.     SHLD    ICNT
  718.     DAD    D
  719.     SHLD    JCNT
  720.     RET
  721. ;.....
  722. ;
  723. ;
  724. ; Create disk file
  725. ;
  726. CREATE:    PUSH    H
  727.     PUSH    D
  728.     PUSH    B
  729.     LXI    D,TFCB
  730.     MVI    C,DFFC        ; First erase any similar file
  731.     CALL    BDOS
  732.     LXI    D,TFCB
  733.     MVI    C,MFFC        ; Now open new file
  734.     CALL    BDOS
  735.     POP    B
  736.     POP    D
  737.     POP    H
  738.     RET
  739. ;.....
  740. ;
  741. ;
  742. ; Exit routines:  ERXIT - come here on error of some type.  Print
  743. ;                  msg in (HL), then print 'ABORT' msg.
  744. ;          EXIRT - normal exit.    Print msg in (HL) and
  745. ;                  return to CP/M.
  746. ;
  747. ERXIT:    CALL    WEOLC        ; Initial <CR><LF>
  748.     CALL    WASC
  749.     LXI    H,MSG20
  750.     CALL    WASC
  751.     JMP    0000H        ; Warm boot - in case of an error
  752. ;
  753. EXIT:    LXI    H,MSG17
  754.     CALL    WASC
  755. ;
  756. EXIT1:    XRA    A        ; Clear the 'A' reg. and all flags
  757.     LHLD    STACK        ; Get the original stack pointer back
  758.     SPHL            ; Set the stack pointer to that address
  759.     RET
  760. ;.....
  761. ;
  762. ;
  763. ; Counts total number of files handled
  764. ;
  765. FILES:    LXI    H,MSG19+3
  766.     MVI    C,5
  767.     CALL    NMBR1
  768.     RET
  769. ;.....
  770. ;
  771. ;
  772. ; Counts total number of unique file names handled
  773. ;
  774. FILESD:    LXI    H,MSG18+3
  775.     MVI    C,5
  776.     CALL    NMBR1
  777.     RET
  778. ;.....
  779. ;
  780. ;
  781. ; Flush disk output buffer
  782. ;
  783. FLUSH:    LDA    HCFLG        ; Hard copy this time?
  784.     ORA    A
  785.     RNZ            ; If yes, no file to close
  786.     PUSH    H
  787.     PUSH    D
  788.     MVI    A,1AH
  789.     CALL    WACD
  790.     LHLD    DBUFO
  791.     LDA    DBUFC
  792. ;
  793. FLUSH1:    CPI    128
  794.     JZ    FLUSH2
  795.     MVI    M,1AH
  796.     INX    H
  797.     INR    A
  798.     JMP    FLUSH1
  799. ;
  800. FLUSH2:    CALL    WRREC
  801.     CALL    CLOSE
  802.     POP    D
  803.     POP    H
  804.     RET
  805. ;.....
  806. ;
  807. ;
  808. ; Get next filename or filetype from 'MAST.CAT'.  Terminate when 'B'
  809. ; characterss have been read.  If name is shorter than 'B' chars, left-
  810. ; justify and blank-fill.
  811. ;
  812. GETNF:    CALL    RDCHR        ; Get one char from disk
  813.     STAX    D        ; Assume good character
  814.     CPI    '.'        ; End of filename?
  815.     JZ    PAD
  816.     CPI    ','
  817.     JZ    PAD
  818.     CPI    ';'
  819.     JZ    PAD
  820.     CPI    CR
  821.     JZ    PAD
  822.     INX    D        ; Else keep char & prepare for next
  823.     DCR    B        ; Enough chars read?
  824.     JNZ    GETNF        ; Jump if not
  825.     CALL    RDCHR        ; Else throw away separator
  826.     RET            ; And return
  827. ;.....
  828. ;
  829. ;
  830. ; For hard copy to list device, character in 'A' reg.
  831. ;
  832. HCOPY:    LDA    PRINT        ; Ready to start printing yet?
  833.     ORA    A
  834.     JZ    HCOPY2        ; If not, exit and wait
  835.     LDA    STOP        ; Not supposed to print now?
  836.     ORA    A
  837.     JNZ    EXIT        ; If not, exit and terminate
  838.     POP    PSW        ; Get the character back
  839.     CALL    WACC        ; Show on the CRT
  840. ;
  841. HCOPY1:    PUSH    H        ; Save the values
  842.     PUSH    D
  843.     PUSH    B
  844.     PUSH    PSW
  845.     MOV    E,A
  846.     MVI    C,WCLD        ; Send to list device
  847.     CALL    BDOS
  848.     POP    PSW
  849.     POP    B
  850.     POP    D
  851.     POP    H
  852.     RET
  853. ;...
  854. ;
  855. ;
  856. HCOPY2:    POP    PSW
  857.     RET
  858. ;.....
  859. ;
  860. ;
  861. ; Get a character from the keyboard
  862. ;
  863. INPUT:    PUSH    H        ; Save the values
  864.     PUSH    D
  865.     PUSH    B
  866.     MVI    C,RCFC
  867.     CALL    BDOS
  868.     ANI    7FH        ; Strip off any parity
  869.     POP    B
  870.     POP    D
  871.     POP    H
  872.     CPI    'C'-040H    ; CTL-C?
  873.     JZ    EXIT1        ; If yes, terminate
  874.     RET
  875. ;.....
  876. ;
  877. ;
  878. ; Move up to 256 bytes of memory, entry conditions
  879. ;
  880. ;    'HL'     'FWA' of source
  881. ;    'DE'     'FWA' of destination
  882. ;    'B'      number of bytes to move
  883. ;
  884. MOVE:    MOV    A,M
  885.     STAX    D
  886.     INX    D
  887.     INX    H
  888.     DCR    B        ; One less to go
  889.     JNZ    MOVE        ; If not zero, do another
  890.     RET
  891. ;.....
  892. ;
  893. ;
  894. ; Increment the page number for hard copy
  895. ;
  896. NMBR:    LXI    H,HEAD3+2
  897.     MVI    C,2
  898. ;
  899. NMBR1:    MOV    A,M        ; Get the value
  900.     CPI    ' '        ; Is it a space?
  901.     JNZ    NMBR2        ; Exit if not
  902.     MVI    A,'0'        ; Otherwise call it a zero
  903. ;
  904. NMBR2:    INR    A
  905.     MOV    M,A
  906.     CPI    '9'+1        ; Ready to start next digit?
  907.     JNZ    NMBR3        ; If not, finished
  908.     MVI    M,'0'        ; Otherwise make this one a zero
  909.     DCX    H        ; Work on next column
  910.     DCR    C        ; One less to go
  911.     JNZ    NMBR1        ; Go do the next one
  912. ;
  913. NMBR3:    RET            ; Finished
  914. ;.....
  915. ;
  916. ;
  917. ; If no print, tell what maximum page was
  918. ;
  919. NOPNT:    LXI    H,MSG21        ; Turn up a blank line
  920.     CALL    WASC
  921.     LXI    H,MSG22        ; Final page msg
  922.     CALL    WASC
  923.     LXI    H,HEAD3
  924.     CALL    WASC
  925.     JMP    EXIT        ; All done now
  926. ;
  927. ;
  928. ; Fill area between file names and file types uniformly
  929. ;
  930. PAD:    MVI    A,' '        ; Blank-fill if necessary
  931.     STAX    D
  932.     INX    D
  933.     DCR    B
  934.     JNZ    PAD+2
  935.     RET
  936. ;.....
  937. ;
  938. ;
  939. PAD0:    PUSH    PSW
  940.     MVI    A,'0'
  941.     JMP    PADC
  942. ;
  943. PAD1:    PUSH    PSW
  944.     MVI    A,'1'
  945. ;
  946. PADC:    STAX    D
  947.     INX    D
  948.     POP    PSW
  949.     RET
  950. ;.....
  951. ;
  952. ;
  953. ;----------------------------------------------------------------------
  954. ;            hard copy requests
  955. ;
  956. ; Print hard copy request from keyboard
  957. ;
  958. PRHC:    LXI    H,MSG2        ; Want hard copy?
  959.     CALL    WASC
  960.     CALL    INPUT        ; Get character from keyboard
  961.     ANI    5FH        ; Change go upper-case if needed
  962.     CPI    'Y'
  963.     JNZ    PRHC9        ; No hard copy if not 'Y' answer
  964.     STA    HCFLG        ; Set flag for hard copy
  965.     LXI    H,MSG21        ; Turn up a line
  966.     CALL    WASC
  967.     CALL    RPAPER        ; Using roll paper?
  968. ;
  969. ;
  970. ; Ask for current date
  971. ;
  972.     LXI    H,MSG4        ; Current date
  973.     CALL    WASC
  974.     MVI    B,0
  975.     LXI    H,HEAD2
  976. ;
  977. PRHC1:    CALL    INPUT        ; Get keyboard character
  978.     CPI    CR        ; Finished if 'RET'
  979.     JZ    PRHC3
  980.     CPI    BS
  981.     JNZ    PRHC2
  982.     CALL    BCKSP
  983.     JMP    PRHC1
  984. ;
  985. PRHC2:    MOV    M,A
  986.     INX    H
  987.     INR    B
  988.     MOV    A,B
  989.     CPI    34+1
  990.     JC    PRHC1
  991.     CALL    BCKSP2
  992.     CALL    BCKSP1        ; Do not allow a too-long line
  993.     JMP    PRHC1
  994. ;
  995. ;
  996. ; Ask for starting page
  997. ;
  998. PRHC3:    LXI    H,MSG21        ; Turn up a new line
  999.     CALL    WASC
  1000.     LXI    H,MSG5
  1001.     CALL    WASC
  1002.     MVI    B,0
  1003.     LXI    H,PAGES+2    ; Starting page storage
  1004. ;
  1005. PRHC4:    CALL    INPUT
  1006.     CPI    CR
  1007.     JZ    PRHC6
  1008.     CPI    BS
  1009.     JNZ    PRHC5
  1010.     CALL    BCKSP
  1011.     JMP    PRHC4
  1012. ;
  1013. PRHC5:    MOV    M,A
  1014.     INX    H
  1015.     INR    B
  1016.     MOV    A,B
  1017.     CPI    3+1        ; Three maximum page numbers
  1018.     JC    PRHC4
  1019.     CALL    BCKSP2
  1020.     CALL    BCKSP1        ; Do not allow a too-long line
  1021.     JMP    PRHC4
  1022. ;
  1023. ;
  1024. ; Ask for stopping page
  1025. ;
  1026. PRHC6:    LXI    H,MSG21        ; Turn up a new line
  1027.     CALL    WASC
  1028.     LXI    H,MSG6
  1029.     CALL    WASC
  1030.     MVI    B,0
  1031.     LXI    H,PAGEQ+2    ; Quitting page storage
  1032. ;
  1033. PRHC7:    CALL    INPUT
  1034.     CPI    CR
  1035.     JZ    PRHC9
  1036.     CPI    BS
  1037.     JNZ    PRHC8
  1038.     CALL    BCKSP
  1039.     JMP    PRHC7
  1040. ;
  1041. PRHC8:    MOV    M,A
  1042.     INX    H
  1043.     INR    B
  1044.     MOV    A,B
  1045.     CPI    3+1        ; Three maximum page numbers
  1046.     JC    PRHC7
  1047.     CALL    BCKSP2
  1048.     CALL    BCKSP1        ; Do not allow a too-long line
  1049.     JMP    PRHC7
  1050. ;
  1051. PRHC9:    LXI    H,MSG21        ; Turn up a new line
  1052.     CALL    WASC
  1053.     RET
  1054. ;.....
  1055. ;
  1056. ;            end of hard copy requests
  1057. ;-----------------------------------------------------------------------
  1058. ;
  1059. ; Read character from disk
  1060. ;
  1061. RDCHR:    PUSH    B
  1062.     PUSH    D
  1063.     LXI    D,BUFREC+80H    ; One byte past buffer stop address
  1064.     LHLD    DBUFI        ; Buffer start address
  1065.     MOV    A,H        ; See if ready to get disk sector
  1066.     CMP    D
  1067.     JC    NOREAD        ; If not continue reading
  1068.     LXI    D,FCB        ; Otherwise get next record from disk
  1069.     MVI    C,RNFC
  1070.     CALL    BDOS
  1071.     ORA    A
  1072.     LXI    H,MSG9        ; Early end?
  1073.     JNZ    ERXIT        ; Jump if so
  1074.     LXI    H,BUFREC    ; Pointers to start of buffer
  1075. ;
  1076. NOREAD:    MOV    A,M        ; Get character
  1077.     INX    H
  1078.     SHLD    DBUFI
  1079.     POP    D
  1080.     POP    B
  1081.     CPI    'Z'-040H    ; EOF?
  1082.     RNZ            ; If not, keep going
  1083. ;
  1084. ;
  1085. ; If CTL-Z, abort read routine and print the file - end of file marker
  1086. ;
  1087.     POP    H        ; If yes, erase CALL from stack
  1088.     LDA    ONCE
  1089.     ORA    A
  1090.     LXI    H,MSG12
  1091.     CNZ    WASC
  1092.     JMP    PRNT        ; Go print what we have in the buffer
  1093. ;.....
  1094. ;
  1095. ;
  1096. ; Option for roll paper (changes fanfold areas)
  1097. ;
  1098. RPAPER:    LXI    H,MSG3
  1099.     CALL    WASC
  1100.     CALL    INPUT
  1101.     ANI    5FH        ; Change to upper-case if needed
  1102.     CPI    'Y'
  1103.     JNZ    PRAP1        ; If not, exit
  1104.     MVI    A,21H        ; 'LXI    H,' instruction
  1105.     STA    CKST3
  1106.     MVI    A,0CDH        ; 'CALL' instruction
  1107.     STA    CKST3+3
  1108.     LXI    H,WASD
  1109.     SHLD    CKST3+4
  1110.     LXI    H,QUITR
  1111.     SHLD    CKST3+1        ; Starts first page with tear tabs
  1112.     SHLD    ROLL2+1        ; Finishes last page with tear tabs
  1113.     SHLD    WRBUF2+1    ; Finishes each papge with tear tabs
  1114.     LXI    H,HEAD1
  1115.     SHLD    CKST4+1        ; Start first page
  1116.     SHLD    WRBUF3+1    ; Starts new page
  1117. ;
  1118. PRAP1:    LXI    H,MSG21
  1119.     CALL    WASC
  1120.     RET
  1121. ;.....
  1122. ;
  1123. ;
  1124. ; Roll up page to terminate
  1125. ;
  1126. ROLL:    LDA    PRINT        ; Any printing yet?
  1127.     ORA    A
  1128.     JZ    NOPNT        ; If not, display last page number
  1129.     MVI    A,CR
  1130.     CALL    HCOPY1        ; Send
  1131. ;
  1132. ROLL1:    MVI    A,LF
  1133.     CALL    HCOPY1        ; Send
  1134.     LDA    LCNT
  1135.     INR    A
  1136.     STA    LCNT
  1137.     CPI    54
  1138.     JC    ROLL1
  1139. ;
  1140. ROLL2:    LXI    H,QUIT        ; Final lines to finish page
  1141.     JMP    WASD
  1142. ;.....
  1143. ;
  1144. ;
  1145. ; Set the filename counters to start of table
  1146. ;
  1147. SETFNT:    PUSH    D
  1148.     PUSH    H
  1149.     LXI    H,FNTBL        ; Start of filename table
  1150.     SHLD    ICNT        ; For first name
  1151.     LXI    D,LENGTH
  1152.     DAD    D
  1153.     SHLD    JCNT        ; For second name
  1154.     POP    H
  1155.     POP    D
  1156.     RET
  1157. ;.....
  1158. ;
  1159. ;
  1160. ; Set 'DMA' address to 'BUFOUT' location for output to disk
  1161. ;
  1162. SETO:    MVI    C,SDMA
  1163.     LXI    D,BUFOUT
  1164.     CALL    BDOS
  1165.     RET
  1166. ;.....
  1167. ;
  1168. ;
  1169. ; Set 'DMA' address to 'BUFREC' location for input from disk
  1170. ;
  1171. SETR:    MVI    C,SDMA
  1172.     LXI    D,BUFREC
  1173.     CALL    BDOS
  1174.     RET
  1175. ;.....
  1176. ;
  1177. ;
  1178. ; See if ready to terminate
  1179. ;
  1180. TERM:    PUSH    B        ; Save the values
  1181.     PUSH    D
  1182.     PUSH    H
  1183.     MVI    C,KSTAT        ; Read console status
  1184.     CALL    BDOS
  1185.     ANI    1        ; CRT have a character?
  1186.     POP    H
  1187.     POP    D
  1188.     POP    B
  1189.     JNZ    INPUT        ; Else get the character
  1190.     RET
  1191. ;.....
  1192. ;
  1193. ;
  1194. ; Write ASCII character to disk or to list device/CRT
  1195. ;
  1196. WAC:    CPI    SI        ; Space take-up character
  1197.     RZ            ; If yes, ignore
  1198.     PUSH    PSW        ; Save the character in 'A' reg.
  1199.     LDA    HCFLG        ; Making hard copy this time?
  1200.     ORA    A
  1201.     JNZ    HCOPY        ; If yes, go write to list device
  1202.     POP    PSW
  1203.     JMP    WACD        ; Otherwise write to disk
  1204. ;.....
  1205. ;
  1206. ;
  1207. ; Write ASCII character to console, entry conditions:
  1208. ;    'A'      character to write
  1209. ;
  1210. WACC:    PUSH    H
  1211.     PUSH    D
  1212.     PUSH    B
  1213.     PUSH    PSW
  1214.     MOV    E,A
  1215.     MVI    C,WCFC
  1216.     CALL    BDOS
  1217.     POP    PSW
  1218.     POP    B
  1219.     POP    D
  1220.     POP    H
  1221.     RET
  1222. ;.....
  1223. ;
  1224. ;
  1225. ; Write ASCII character to disk
  1226. ;
  1227. WACD:    PUSH    H
  1228.     PUSH    PSW
  1229.     LDA    DBUFC
  1230.     CPI    128
  1231.     JC    WACD1
  1232.     CALL    WRREC
  1233.     LXI    H,BUFOUT
  1234.     SHLD    DBUFO
  1235.     XRA    A
  1236. ;
  1237. WACD1:    INR    A
  1238.     STA    DBUFC
  1239.     POP    PSW
  1240.     LHLD    DBUFO
  1241.     MOV    M,A
  1242.     INX    H
  1243.     SHLD    DBUFO
  1244.     POP    H
  1245.     RET
  1246. ;.....
  1247. ;
  1248. ;
  1249. ; Write ASCII string to console, entry conditions:
  1250. ;    'HL'     'FWA' of string (term. by zero byte)
  1251. ;
  1252. WASC:    MOV    A,M
  1253.     ORA    A
  1254.     RZ            ; Null character terminates the string
  1255. ;
  1256.     CALL    WACC
  1257.     INX    H
  1258.     JMP    WASC
  1259. ;
  1260. ;
  1261. ; Write ASCII string to disk, entry conditions:
  1262. ;    'HL'     'FWA' of string (terminated by zero byte)
  1263. ;
  1264. WASD:    MOV    A,M
  1265.     ORA    A
  1266.     RZ            ; Null character terminates string
  1267. ;
  1268.     CALL    WAC        ; Write the ASCII character
  1269.     INX    H
  1270.     JMP    WASD
  1271. ;.....
  1272. ;
  1273. ;
  1274. ; Write end of line to console
  1275. ;
  1276. WEOLC:    MVI    A,CR
  1277.     CALL    WACC
  1278.     MVI    A,LF
  1279.     CALL    WACC
  1280.     RET
  1281. ;.....
  1282. ;
  1283. ;
  1284. ; Write end of line to disk
  1285. ;
  1286. WEOLD:    MVI    A,CR
  1287.     CALL    WAC        ; Write the ASCII character
  1288.     MVI    A,LF
  1289.     CALL    WAC        ; Write the ASCII character
  1290.     RET
  1291. ;.....
  1292. ;
  1293. ;
  1294. ; Write the 'OBUF' line into the disk buffer
  1295. ;
  1296. WRBUF:    LDA    HCFLG        ; Printing hard copy?
  1297.     ORA    A
  1298.     JZ    WRBUF1        ; If not, exit right away
  1299. ;
  1300.     CALL    TERM        ; Want to terminate?
  1301.     LDA    PRINT        ; Already printing?
  1302.     ORA    A
  1303.     CZ    CKST        ; If not, check when ready
  1304. ;
  1305. WRBUF1:    LXI    H,OBUF        ; Start of file name buffer
  1306.     CALL    WASD        ; Write into the buffer
  1307.     CALL    WEOLD        ; Finish the CR-LF at end of line
  1308.     LDA    HCFLG        ; Writing hard copy?
  1309.     ORA    A
  1310.     RZ            ; Exit if not
  1311. ;
  1312.     LDA    LCNT
  1313.     INR    A
  1314.     STA    LCNT
  1315.     CPI    54
  1316.     RC            ; Exit if less
  1317.     XRA    A
  1318.     STA    LCNT        ; Otherwise reset the count
  1319.     PUSH    H
  1320.     PUSH    B
  1321.     CALL    NMBR        ; Increment page count in heading
  1322.     POP    B
  1323. ;
  1324. WRBUF2:    LXI    H,QUIT
  1325.     CALL    WASD
  1326.     CALL    CKSP        ; Check on stop request
  1327. ;
  1328. WRBUF3:    LXI    H,HEAD        ; Send new page start
  1329.     CALL    WASD
  1330.     POP    H
  1331.     RET
  1332. ;.....
  1333. ;
  1334. ;
  1335. ; Write record to disk
  1336. ;
  1337. WRREC:    PUSH    H
  1338.     PUSH    D
  1339.     PUSH    B
  1340.     LXI    D,TFCB
  1341.     MVI    C,WRFC
  1342.     CALL    BDOS
  1343.     LXI    H,MSG16        ; Write error?
  1344.     ORA    A
  1345.     JNZ    ERXIT        ; Jump if so
  1346.     POP    B
  1347.     POP    D
  1348.     POP    H
  1349.     RET
  1350. ;.....
  1351. ;
  1352. ;            end of subroutines
  1353. ;----------------------------------------------------------------------
  1354. ;             data storage area
  1355. ;
  1356. ; Messages
  1357. ;
  1358. MSG0:    DB    CR,LF,'CATALOG X-REFERENCE PGM v4.2 - 11/20/85',CR,LF
  1359. ;
  1360.      IF    USER
  1361.     DB    '(includes user numbers for each program)',CR,LF
  1362.      ENDIF            ; USER
  1363. ;
  1364. MSG1:    DB    LF,'Do you want to include the ".FRE" space? (Y/N): ',0
  1365. MSG2:    DB    'Do you want hard copy instead of a file? (Y/N): ',0
  1366. MSG3:    DB    'Do you want tear tabs to use roll paper? (Y/N): ',0
  1367. MSG4:    DB    'Current date is: ',0
  1368. MSG5:    DB    'Start at page  : ',0
  1369. MSG6:    DB    'Quit  at page  : ',0
  1370. MSG7:    DB    '++ UNABLE TO OPEN MAST.CAT ++',CR,LF,0
  1371. MSG8:    DB    CR,LF,'** READING MAST.CAT FILE **',CR,LF,0
  1372. MSG9:    DB    '++ READ ERROR OR EARLY EOF ++',CR,LF,0
  1373. MSG10:    DB    CR,LF,'   LAST NAME THIS SECTION:  "'
  1374. MSG11:    DB    '            "',CR,LF
  1375. MSG12:    DB    '   WRITING TO OUTPUT FILE',CR,LF,LF,0
  1376. MSG13:    DB    '   WORKING ON NEXT SECTION',CR,LF,0
  1377. MSG14:    DB    '** WRITING OUTPUT FILE **',CR,LF,0
  1378. MSG15:    DB    '++ UNABLE TO MAKE OUTPUT FILE ++',CR,LF,0
  1379. MSG16:    DB    '++ DISK OR DIRECTORY FULL ++',CR,LF,0
  1380. MSG17:    DB    CR,LF,'   DONE: '
  1381. MSG18:    DB    '   0 UNIQUE NAMES',CR,LF,'         '
  1382. MSG19:    DB    '   0 TOTAL FILES',CR,LF,0
  1383. MSG20:    DB    '++ PROGRAM ABORTED ++'
  1384. MSG21:    DB    CR,LF,0
  1385. MSG22:    DB    'FINAL PAGE IS:  ',0
  1386. ;....
  1387. ;
  1388. ;
  1389. ; Misc storage locations
  1390. ;
  1391. DASH:    DB    '  - '        ; Used to format printout (put length in
  1392.                 ;   'DASLEN' equate)
  1393. ;.....
  1394. ;
  1395. ;
  1396. CCP:    DB    0        ; Initial 'CCP' page
  1397. CNT:    DB    0        ; Number of diskid'S ON LINE
  1398. DBUFC:    DB    0        ; Output buffer count
  1399. HCFLG:    DB    0        ; Hard copy flag, '1' for hard copy
  1400. MATCH:    DB    0        ; Used if a match during "end around"
  1401. LCNT:    DB    0        ; Line count for hard copy
  1402. NEXT:    DB    0        ; Input next series of files
  1403. ONCE:    DB    0        ; For a particular print message
  1404. PRINT:    DB    0        ; Begin printing flag
  1405. REPEAT:    DB    0        ; For continuous printing
  1406. STOP:    DB    0        ; Stop printing flag
  1407. XDONE:    DB    0        ; Use last name file
  1408. ;
  1409. DBUFI:    DW    0        ; Input buffer pointer
  1410. DBUFO:    DW    0        ; Output buffer pointer
  1411. FNTP:    DW    0        ; File name table pointer
  1412. ICNT:    DW    0        ; Outer loop index
  1413. JCNT:    DW    0        ; Inner loop index
  1414. SAVEOB:    DW    0        ; Save output buffer position
  1415. ;.....
  1416. ;
  1417. ;
  1418. ; Heading line for hard copy
  1419. ;
  1420. HEAD:    DB    CR,LF,LF,LF,CR,LF
  1421. HEAD1:    DB    'Master Catalog as of '
  1422. HEAD2:    DB    '                                    Page '
  1423. HEAD3:    DB    '  1',CR,LF,LF,LF,0
  1424. PAGES:    DB    '  1   '
  1425. PAGEQ:    DB    '      '
  1426. QUIT:    DB    CR,LF,LF,LF,LF,LF,0
  1427. QUITR:    DB    CR,LF,LF,LF,LF
  1428.     DB    '-                       '
  1429.     DB    '                        '
  1430.     DB    '                       -'
  1431.     DB    CR,LF,LF,LF,LF,LF,0
  1432. ;.....
  1433. ;
  1434. ;
  1435. ; To give the final listing a left-margin so that it can be more easily
  1436. ; used in a binder, extra spaces can be inserted automatically into
  1437. ; 'HEAD1' and 'PRBUF' areas when answering the question at boot time.
  1438. ; (None needed if your printer has ; adjustable margins.)
  1439. ;
  1440. OBUF:    DB    '               ' ; Output buffer, 75 columns max.
  1441.     DB    '               '
  1442.     DB    '               '
  1443.     DB    '               '
  1444.     DB    '               '
  1445. TRASH:    DB    '          '    ; Storage for unwanted disk name
  1446. ;.....
  1447. ;
  1448. ;
  1449. ; FCB for reading MAST.CAT
  1450. ;
  1451. FCB:    DB    0,'MAST    CAT',0 ;2nd 0 = extent #
  1452.     DB    '          '
  1453.     DB    '         '    ; Rest of 'FCB' for 32 bytes
  1454.     DB    0        ; Number field
  1455. ;
  1456. DEFLT:    DB    0,'MAST    '
  1457. DEF1:    DB    'LST'        ; Default output file name
  1458. ;.....
  1459. ;
  1460. ;
  1461.     DS    80        ; Minimum stack size
  1462. ;
  1463. BUFF    EQU    ($+255)/256*256    ; Insures an even sector
  1464.  
  1465.     ORG    BUFF        ; 'BUFREC' needs to be on a half-page
  1466. ;
  1467. ;
  1468. STACK    EQU    BUFF-2        ; Local stack
  1469. BUFOUT:    DS    128        ; 1-record output buffer
  1470. BUFREC:    DS    128        ; 1-record input buffer
  1471. FNTBL:    DS    0        ; File name table starts here
  1472. ;
  1473.     END    START
  1474.