
 1000  *SAVE S.NEW CATALOG
 1010  *--------------------------------
 1020  DOS.ARITH.REG          .EQ $44,45
 1030  *--------------------------------
 1040  ADV.NEXT.DIR.ENTRY     .EQ $B230
 1050  DOS.INIT.FM            .EQ $ABDC
 1060  EXIT.FM                .EQ $AD86
 1070  MON.COUT               .EQ $FDED
 1080  MON.CROUT              .EQ $FD8E
 1090  MON.RDKEY              .EQ $FD0C
 1100  READ.DIRECTORY.SECTOR  .EQ $B011
 1110  READ.VTOC              .EQ $AFF7
 1120  *--------------------------------
 1130  DEC.CONVERSION.TABLE   .EQ $B3A4
 1140  FILE.TYPE.NAME.TABLE   .EQ $B3A7
 1150  *--------------------------------
 1160  CATALOG.LINE.COUNT     .EQ $B39D
 1170  DIRECTORY.ENTRY        .EQ $B4C6
 1180  DIRECTORY.INDEX        .EQ $B39C
 1190  DISK.VOL.NUMBER        .EQ $B7F6
 1200  FILE.NAME              .EQ $B4C9
 1210  FILE.SIZE              .EQ $B4E7
 1220  FILE.TYPE              .EQ $B4C8
 1230  FM.VOL.NUMBER          .EQ $B5F9
 1240  VTOC.BUFFER            .EQ $B3BB
 1250  *--------------------------------
 1260  *    New Catalog for DOS 3.3
 1270  *    by  Robert F.O'Brien
 1280  *--------------------------------
 1290         .OR $AD98
 1300         .TF NEW CATALOG PART 1
 1310  *--------------------------------
 1320  CATALOG
 1330         JSR DOS.INIT.FM   Init file manager.
 1340         LDA #$FF          Set Volume = 0
 1350         STA FM.VOL.NUMBER   (matches any volume)
 1360         JSR READ.VTOC     Load in VTOC into buffer.
 1370  *---Print Volume Number----------
 1380         LDY #0            High byte = 0
 1390         STY LINE.SKIP.FLAG    (signal to skip)
 1400         LDA DISK.VOL.NUMBER   low byte
 1410         JSR PRINT.DECIMAL.YA
 1420  *---Calculate Free Space---------
 1430         LDX #$74          Trk 0 VTOC offset
 1440  .1     LDA VTOC.BUFFER+$38-$74,X     Bit Map Byte
 1450  .2     BPL .3            This sector in use
 1460         INC DOS.ARITH.REG   Count a free sector.
 1470         BNE .3
 1480         INC DOS.ARITH.REG+1
 1490  .3     ASL               Check next bit
 1500         BNE .2            Still more in this byte
 1510  .4     INX               Next byte of bit map
 1520         BNE .1            ...still more
 1530         JSR PRINT.DECIMAL    print number free
 1540  *---Start Line count-------------
 1550         JSR SET.LINE.COUNT        lines to print.
 1560  *---Start reading directory------
 1570         CLC               Get first sector.
 1580  READ.SECTOR
 1590         JSR READ.DIRECTORY.SECTOR 
 1600         BCS EXIT.FM       No more sectors
 1610         LDX #0            Index to 1st file in sector
 1620  SET.ENTRY.INDEX
 1630         STX DIRECTORY.INDEX   Set entry offset
 1640         LDA DIRECTORY.ENTRY,X See if valid filename
 1650  EXIT   BEQ EXIT.FM       ...end of directory
 1660         BMI NEXT.ENTRY    ...ignore deleted file.
 1670  *---Start next file display------
 1680         JSR SKIP.LINE     Next line or Tab
 1690  *---Locked or Unlocked-----------
 1700         JSR LOCKED.FILE.CHECK     "*" if locked file.
 1710  *---File Type--------------------
 1720         TYA               Get file type byte
 1730         LDY #-1           Index to type table
 1740         ASL               Ignore Bit 7
 1750  .1     INY               Next file type code
 1760         LSR               Check bit of type byte
 1770         BNE .1            ...not yet
 1780  .2     LDA FILE.TYPE.NAME.TABLE,Y Get file type
 1790         JSR MON.COUT      ...and print it
 1800  *---File Size--------------------
 1810         LDY FILE.SIZE+1,X         high order byte
 1820         LDA FILE.SIZE,X           low order byte
 1830         JSR PRINT.DECIMAL.YA      print total sect.
 1840  *---File Name--------------------
 1850         LDY #30
 1860  .3     LDA FILE.NAME,X           char. no. in Y.
 1870         JSR MON.COUT          print file name.
 1880         INX                       next char.
 1890         DEY                       
 1900         BNE .3                    not done yet!
 1910  *---Next File in Directory-------
 1920  NEXT.ENTRY
 1930         JSR ADV.NEXT.DIR.ENTRY  Set X-Reg for next file
 1940         BCC SET.ENTRY.INDEX     more in sector
 1950         BCS READ.SECTOR         get next sector
 1960  *--------------------------------
 1970  SKIP.LINE
 1980         JSR PRINT.SPACE   Separate 2nd line entry
 1990         INC LINE.SKIP.FLAG  Toggle lsbit
 2000         LDA LINE.SKIP.FLAG  Check Odd or Even
 2010         SEC        <<<Change to "LSR" for double
 2020  *                    column CATALOG >>>
 2030         BCC RETURN
 2040         JSR MON.CROUT     Start a new line
 2050         DEC CATALOG.LINE.COUNT    continue countdown
 2060         BNE RETURN                not full screen yet
 2070         JSR MON.RDKEY     Pause for keypress!
 2080         CMP #$9B          Is it  ESC-key?
 2090         BEQ EXIT          ...yes, exit file manager
 2100  SET.LINE.COUNT
 2110         LDA #21           lines per screenful
 2120         STA CATALOG.LINE.COUNT
 2130  RETURN RTS               Continue catalog
 2140  *--------------------------------
 2150         .BS 17            17 FREE BYTES!
 2160  *--------------------------------
 2170  *   Print (YA) with leading and
 2180  *      trailing blanks.
 2190  *--------------------------------
 2200  PRINT.DECIMAL.YA
 2210         STY DOS.ARITH.REG+1
 2220         STA DOS.ARITH.REG
 2230         JSR PRINT.SPACE
 2240  *--------------------------------
 2250  *   Print ($44,45) with trailing blank
 2260  *--------------------------------
 2270  PRINT.DECIMAL
 2280         LDY #2            Set for 3 divisors
 2290  .1     LDA #$B0          ASCII zero
 2300  .2     PHA               save digit on stack
 2310         SEC               Subtract 100, 10, or 1
 2320         LDA DOS.ARITH.REG    from remainder
 2330         SBC DEC.CONVERSION.TABLE,Y    
 2340         PHA               save remainder on stack
 2350         LDA DOS.ARITH.REG+1  
 2360         SBC #0            (divisor high byte = 0)
 2370         BCC .3            ...far enough
 2380         STA DOS.ARITH.REG+1   Update remainder
 2390         PLA
 2400         STA DOS.ARITH.REG
 2410         PLA               get current digit
 2420         ADC #0            and count the subtraction
 2430         BNE .2            ...continue subtracting
 2440  .3     PLA               Discard stacked remainder byte
 2450         PLA               Get quotient digit
 2460         JSR MON.COUT      and print it!
 2470         DEY               Next divisor
 2480         BPL .1            ...not finished yet
 2490         JMP PRINT.SPACE   Trailing space
 2500  *--------------------------------
 2510  LINE.SKIP.FLAG .DA #0    LEAST SIGNIFICANT BIT IS FLAG
 2520  *--------------------------------
 2530         .OR $B3AF
 2540         .TF NEW CATALOG PART 2
 2550  *--------------------------------
 2560  *   OVERLAYS "DISK VOLUME " MESSAGE
 2570  *--------------------------------
 2580  LOCKED.FILE.CHECK
 2590         LDA #"*"
 2600         LDY FILE.TYPE,X   file type code.
 2610         BMI CAT.COUT      ...the file is locked
 2620  PRINT.SPACE
 2630         LDA #" "
 2640  CAT.COUT
 2650         JMP MON.COUT
 2660  *--------------------------------
 2670         .LIF

