NAM CAT COMMAND
OPT PAG
PAG
* Improved CAT UTILITY for SK*DOS
*
* Program by Bruno Puglia and Leo Taylor
*
* Calling format for HELP:
*
* CAT + note no parameters, or
* CAT ?
*
* Calling format for using default options:
*
* CAT complete disk in work drive.
* CAT 1,2 two complete disks.
* CAT AB .TXT files starting with AB then
* files with TXT extension.
*
* Calling format for setting options:
*
* CAT +DAP complete disk with date,
* alphabetical, and paging.
*
* CAT +M LET maximum DIR options of
* files starting with LET.
*
* Option letters:
*
* A Alphabetical order
* D include file Date
* F include File number
* M Maximum dir
* N include Non-existent files
* P Paging
* R Repeat
* S include file Size
*
* Option M is used to invoke several options
* at once. When Maxi-cat is used the following
* information about each file will be displayed:
*
* FILE, NAME, BEGIN, END, SIZE, DATE, PROTECT
*
*
* There are several options that must be edited
* in the source before assembly. All options
* are located at the beginning of the source
* code. The default options are selected by
* setting flags; DC.B 1 is used for those options
* you want defaulted. Hardware options are set to
* match your terminal and printer.
*
* Commas and spaces can be used interchangeably.
*
* Random files are displayed with a slash between
* the name and extension. Example: ERRORS /SYS.
*
* Modified 2/13/2000 by P Stark for Y2K compatibility
* Modified 6-25-85 by P Stark to allow lower case extensions
* Modified 5-26-86 for 68K SK*DOS
* Modified 1-03-87 ver 1.3 for better help message
* Modified 1-18-87 ver 1.4 to put name on even boundary
* Modified 3-09-87 ver 1.5 to fix problem with +A option
* Modified 4-17-88 ver 1.6 to make default to +M
* Modified 6-13-88 ver 1.7 for subdirectories
* Modified 12-28-88 ver 1.8 to fix pblm with file 256
* Modified 2-26-89 for lower case extension
* Modified 6-26-89 to fix problem introduced by Jeff
*
PAG
************************************************
*
* SK*DOS Address assignments:
LIB SKEQUATE
************************************************
*
* CAT COMMAND UTILITY
*
CAT BRA.S EXEC
VN DC.W $0201 VERSION
* USER HARDWARE OPTIONS
*
* SET TERMINAL AND PRINTER WIDTH TO THE
* MAXIMUM NUMBER OF CHARACTERS YOUR
* HARDWARE WILL DISPLAY WITHOUT ADVANCING
* TO THE NEXT LINE. SET PAGE LENGTH TO
* CONTROL THE NUMBER OF LINES TO PRINT
* BEFORE FORM FEED.
*
TWIDTH EQU 75 TYPICAL 63 or 79
PRWDTH EQU 79 TYPICAL 79 or 131
PAGLEN EQU 66 LINES PER PAGE
* PRINTER FORM FEED STRING
* IF YOUR PRINTER DOES NOT HAVE
* A TOP OF PAGE COMMAND USE:
* FFEED DC.B $D,$A,$D,$A,4
FFEED DC.B $C,0,0,0,4
PAG
* DEFAULT OPTION BYTES WILL BE COPIED
* TO OPTION FLAGS WHEN INITIALIZED.
DEFALT DC.B 0 ALPHABETIZE
DC.B 0 DATE
DC.B 0 FILE NUMBER
DC.B 1 MAXI-DIR
DC.B 0 NON-EXISTENT
DC.B 0 PAGING
DC.B 0 REPEAT
DC.B 1 SIZE
* OPTION LETTERS
*
LETTER DC.B $41 A
DC.B $44 D
DC.B $46 F
DC.B $4D M
DC.B $4E N
DC.B $50 P
DC.B $52 R
DC.B $53 S
* OPTION FLAGS
ALPFLG DC.B 0
DATFLG DC.B 0
FILFLG DC.B 0
MAXFLG DC.B 0
NONFLG DC.B 0
PAGFLG DC.B 0
RPTFLG DC.B 0
SIZFLG DC.B 0
HOFFST EQU LETTER-DEFALT
PAG
* WORKSPACE VARIABLES
*
NAME2 DC.L 0 DUMMY SPACE
NAME DC.L 0 FILE NAME
DC.L 0
EXT DC.B 0,0,0 FILE EXTENSION
ALLFLG DC.B 0 1=ALL FILES
ALLDRV DC.B 0 ALL DRIVES
LOOP DC.B 0
LINCNT DC.B 0 LINE COUNTER
COLCNT DC.B 0 COLUMN COUNTER
MAXCOL DC.B 0 MAXIMUM COLUMNS
POINTR DC.L 0
TEMP DC.L 0
DATPNT DC.L 0
INDEX DC.L 0
SECCNT DC.L 0 TOTAL SECTORS THIS CAT
FILNUM DC.L 0 FILE NUMBER COUNT
FTOTAL DC.L 0 TOTAL FILE
SECTRS DC.L 0 TOTAL SECTORS THIS DISK
LARGST DC.L 0 LARGEST FILE
BUFSAV DC.L 0 START OF PARAMETERS
MDIR DC.B 0 DESIRED DIRECTORY
PAG
************************************************
*
* EXECUTIVE PROGRAM CALLS SUBROUTINES
*
EXEC DC VPOINT POINT TO VARIABLE AREA
MOVE.L LPOINT(A6),A5
MOVE.B (A5),D7 NEXT CHAR
CMP.B #$3F,D7 QUESTION MARK?
BEQ.L HELP YES, GO HELP HIM
LEA BUFSAV(PC),A5
MOVE.L LPOINT(A6),(A5) KEEP FOR REPEAT
EXEC2 LEA LPOINT(A6),A5
MOVE.L BUFSAV(PC),(A5) RESTORE TO BEGINNING
BSR.S INIT SET UP
BSR.S PARSE READ COMMAND LINE
MOVE.B MAXFLG(PC),D7 MAXIMUM OPTIONS?
BEQ.S NOTMAX
LEA FILFLG(PC),A5
ADD.B #1,(A5)
LEA DATFLG(PC),A5
ADD.B #1,(A5)
LEA SIZFLG(PC),A5
ADD.B #1,(A5)
NOTMAX BSR.L HCOLUM SET COLUMNS ACROSS
BRA.L DIRECT
************************************************
*
* INITIALIZE WORKSPACE
*
INIT LEA DEFALT(PC),A0
LEA LETTER(PC),A5
MOVDEF MOVE.B (A0),HOFFST*2(A0) MOVE DEFAULTS
ADD.L #1,A0
CMP.L A0,A5 DONE?
BNE.S MOVDEF NO
LEA NAME2(PC),A0 YES
LEA BUFSAV(PC),A5
CLRTMP CLR.B (A0) clear workspace
ADD.L #1,A0
CMP.L A0,A5 LAST VARIABLE?
BNE.S CLRTMP NO
RETRN2 RTS
************************************************
*
* PARSE COMMAND LINE FOR OPTIONS
*
* IF BAD OPTION FOUND DISPLAY HELP LIST
*
PARSE MOVE.L LPOINT(A6),A0
SUB.L #1,A0
MOVE.B (A0),D0 GET NEXT CHAR
CMP.B #$2B,D0 PLUS SIGN?
BEQ.S GOTPLS YES
MOVE.B 1(A0),D0 GET NEXT
CMP.B #$2B,D0 PLUS SIGN?
BNE.S RETRN2 NO
DC GETNXT SKIP OVER PLUS
MOVE.B 2(A0),D0 AND NEXT
BSR.L TSTTR2 TERM AFTER PLUS?
BEQ.S HELP
GOTPLS LEA ALPFLG(PC),A0
CLROPT CLR.B (A0) CLEAR ALL FLAGS
ADD.L #1,A0
LEA SIZFLG+1(PC),A5
CMP.L A0,A5
BNE.S CLROPT
OPTLOP DC GETNXT GET OPTION CHAR
BCS.S RETRN2 NON-ALPHANUMERIC
MOVE.L D5,D0 GETNXT RETURNS CHAR IN D5!
CMP.B #$39,D0
BHI.S NOTCOL
SUB.B #$30,D0 MAKE HEX
LEA MAXCOL(PC),A5
MOVE.B D0,(A5) 1-9 IS COLUMN
BRA.S OPTLOP
NOTCOL AND.B #$5F,D0 MAKE UPPER CASE
LEA LETTER-1(PC),A0 OPTION LETTER(PC) TABLE
OPTLO2 ADD.L #1,A0
LEA ALPFLG(PC),A5 END OF LETTER TABLE
CMP.L A5,A0 SEE IF END OF TABLE
BEQ.S HELP LETTER NOT FOUND?
CMP.B (A0),D0 COMPARE LETTER TO TBL NTRY
BNE.S OPTLO2
ADD.B #1,HOFFST(A0) SET FLAG
BRA.S OPTLOP
* PRINT HELP LIST
*
HELP LEA HLPMSG(PC),A4
DC PSTRNG
EXIT2 BRA.L EXIT EXIT
* COMPUTE NUMBER OF COLUMNS THAT WILL FIT
* ON TERMINAL. IF THE COMMAND LINE DOES
* NOT SPECIFY THE NUMBER OF COLUMNS THIS
* ROUTINE WILL ADD UP THE CHARACTERS NEEDED
* PER COLUMN AND DIVIDE INTO TERMINAL SIZE.
*
HCOLUM MOVE.B MAXCOL(PC),D7 SPECIFIED ALREADY?
BNE.S RETRN1
MOVE.B #17,D1 WIDTH OF NAM.EXT
MOVE.B FILFLG(PC),D7
BEQ.S FILOFF
ADD.B #6,D1 WIDTH OF FILE NUM
FILOFF MOVE.B SIZFLG(PC),D7
BEQ.S SIZOFF
ADD.B #6,D1 WIDTH OF SIZE-1
SIZOFF MOVE.B DATFLG(PC),D7
BEQ.S DATOFF
ADD.B #10,D1 WIDTH OF DATE
DATOFF MOVE.B MAXFLG(PC),D7
BEQ.S MAXOFF
ADD.B #17,D1 WIDTH OF BEGIN/END/PROT
MAXOFF MOVE.B #TWIDTH,D0 WIDTH OF TERMINAL
MOVE.B PAGFLG(PC),D7
BEQ.S NOPAG2
MOVE.B #PRWDTH,D0 WIDTH OF PRINTER
NOPAG2 LEA MAXCOL(PC),A5
SUB.B #1,(A5) START -1
FNDCOL ADD.B #1,(A5)
SUB.B D1,D0 COMPUTE COLUMNS
BCC.S FNDCOL
RETRN1 RTS
* FIND DRIVE NUMBER
*
DIRECT BSR.S SETPTR POINT TO BUFFER
DIRLOP DC PCRLF PRINT CR & LF
MOVE.B ALLDRV(PC),D7 ALL DRIVES?
BEQ.S CHKPER
NXTDRV MOVE.L A6,A4 POINT TO FCB
DC FDRIVE FIND NEXT DRIVE
BNE.S EXIT2
BSR.S RESPTR RESTORE POINTER
MOVE.B (A0),D4 GET CHARACTER
MOVE.B D4,LASTRM(A6) SET TERM
BRA.L GETDI2
CHKPER MOVE.L POINTR(PC),A0 GET POINTER
BSR.L CHECP1 Check for Period
BEQ.S CHKLOP
MOVE.B D0,D4 CLASSIFY NEEDS IN D4
DC CLASFY CLASSIFY IT
BCS.S CHKLOP TERM?
CMP.B #$39,D4 IS IT NUMBER?
BLS.S GETDRV
CHKLOP MOVE.B LOOP(PC),D7 LOOPING?
BEQ.S USEASN
MOVE.B RPTFLG(PC),D7
EXIT3 BEQ.L EXIT2
* MOVE.B #$FF,D0
* MOVE.B D0,OUTSWT
LEA RPTMSG(PC),A4
DC PSTRNG ASK REPEAT
* CLR.B OUTSWT
DC GETCH
AND.B #$5F,D5 LOWER CASE
CMP.B #$45,D5 E?
BEQ.S EXIT3
BRA.L EXEC2 START OVER
* Save pointer
*
SETPTR LEA POINTR(PC),A5
MOVE.L LPOINT(A6),(A5)
RTS
* Restore pointer
*
RESPTR MOVE.L POINTR(PC),LPOINT(A6)
RTS RTS
USEASN MOVE.L A6,A4 POINT TO FCB
LEA MDIR(PC),A5
MOVE.B WRKDIR(A6),(A5) ASSUME DEFAULT DIRECTORY
MOVE.B WORKDR(A6),FCBDRV(A4) PUT DRIVE IN FCB
BPL.L GETDI2
LEA MDIR(PC),A5
CLR.B (A5) ELSE ROOT DIRECTORY
LEA ALLDRV(PC),A5
MOVE.B D0,(A5) SET ALL DRIVES
BRA.S NXTDRV
GETDRV BSR.S RESPTR RESTORE POINTER
DC GETNXT GET NEXT CHAR
SUB.B #$30,D5 CVT TO NUMBER
MOVE.B D5,FCBDRV(A6) SAVE IN DRIVE
LEA MDIR(PC),A5 WHEN SWITCHING DRIVES, USE
CLR.B (A5) ...ROOT DIRECTORY
DC GETNXT GET NEXT CHAR
CMP.B #$0D,D5 CR?
BEQ.S GETDIR YES, GO ON
CMP.B ENDLNC(A6),D5 :?
BEQ.S GETDIR YES, GO ON
CMP.B #$20,D5 SPACE?
BEQ.S GETDIR YES, CONTINUE
CMP.B #',',D5 COMMA?
BEQ.S GETDIR YES, CONTINUE
CMP.B #'.',D5 PERIOD?
BNE.L SYNTAX ERROR
DC GETNXT NEXT CHAR SHOULD BE DIR
CMP.B #'*',D5 ALLOW DIRECTORY = *
BEQ.S PRODIR
CMP.B #$41,D5
BCS.L SYNTAX
CMP.B #$7A,D5 ONLY A-z ALLOWED
BHI.L SYNTAX
CMP.B FNCASE(A6),D5 IS D5 LOWER THAN FNCASE?
BCS.S PRODIR LEAVE AS IS IF YES
AND.B #$DF,D5 NO, CVT TO UPPER CASE
PRODIR LEA MDIR(PC),A5
MOVE.B D5,(A5) SAVE DIRECTORY LETTER
DC GETNXT NEXT CHAR SHOULD BE / BUT..
CMP.B #$20,D5 SPACE?
BEQ.S GETONC YES, CONTINUE
CMP.B #',',D5 COMMA?
BEQ.S GETONC YES, CONTINUE
CMP.B #'/',D5 SLASH?
BEQ.S GETONC YES, CONTINUE
CMP.B #$0D,D5 CR?
BEQ.S GETDIR YES, GO ON
CMP.B ENDLNC(A6),D5 :?
BEQ.S GETDIR YES, GO ON
BRA.L SYNTAX IF NOT, ERROR
GETONC DC GETNXT SKIP TERMINATOR
BRA.L GETDIR THEN CONTINUE
* Check for period
*
CHECKP MOVE.L LPOINT(A6),A0 RESET POINTER
CHECP1 CLR.L D0
MOVE.B (A0),D0
CMP.B #$2E,D0 Is it period ?
RTS
GETDIR BSR.L SETPTR
GETDI2 MOVE.B ALPFLG(PC),D7
BEQ.S NOTALP
BSR.L ALPHA
NOTALP LEA COLCNT(PC),A5
CLR.B (A5) RESET COLUMNS
LEA LINCNT(PC),A5
MOVE.B #PAGLEN-7,(A5) REST LINES
MOVE.L A6,A4 POINT TO FCB
DC SISOPN OPEN SIS
BNE.S ERROR3
LEA SECCNT(PC),A5
CLR.W (A5) RESET THIS CAT
BSR.L GETIR GET FIRST RECORD
ERROR3 BNE.L ERROR2
LEA DIRST(PC),A4 DRIVE:
DC PSTRNG
CLR.L D4
MOVE.B FCBDRV(A6),D4
CLR.L D5 NO SPACES
DC OUT5D PRINT DRIVE NUMBER
MOVE.B MDIR(PC),D4
BEQ.S NODMSG NO DIR MESSAGE IF ROOT
LEA DIRMSG(PC),A4
DC PNSTRN DIR:
DC PUTCH
MOVE.B #'/',D4
DC PUTCH
NODMSG LEA VOLMSG(PC),A4 DISK:
DC PNSTRN
LEA FCBNAM(A6),A4 POINT TO NAME
CLR.B D4 NO SPACES
DC FNPRNT PRINT NAME
BSR.L OUTSPC PRINT A SPACE
LEA 16(A6),A0 POINT TO NUMBER
CLR.L D4
MOVE.B 15(A6),D4 LEFT BYTE OF NUMBER
LSL.W #8,D4
MOVE.B 16(A6),D4 RIGHT BYTE OF NUMBER
BSR.L DECSPC PRINT IT
LEA CREATM(PC),A4 CREATED:
DC PNSTRN
LEA FCBMON(A6),A0 POINT TO DATE
BSR.L OUTDAT PRINT IT
DC PCRLF
MOVE.B MAXFLG(PC),D7
BEQ.S NOHEAD
LEA HEADER(PC),A4 FILE NAME ETC
DC PSTRNG
* CLEAR THE NAME AND PUT IN OUR DIRECTORY
NOHEAD LEA NAME+1(PC),A5 POINT TO 2ND CHAR OF NAME
CLR.L -1(A5) CLEAR 1ST 4 CHARS
CLR.L 3(A5) CLEAR 2ND 4 CHARS
MOVE.B MDIR(PC),D5 DESIRED DIRECTORY
SODLOO LSL.B #1,D5 SHIFT NEXT BIT INTO BIT 7
BEQ.S SOEXIT QUIT IF ALL BITS DONE
BPL.S SODERO IF >0 THEN IT'S ZERO
MOVE.B #$80,(A5) IF <0 THEN PUT IN PARITY BIT
SODERO LEA 1(A5),A5 THEN GO TO NEXT CHAR
BRA.S SODLOO AND DO NEXT BIT/CHAR
SOEXIT BSR.L TSTTRM
BNE.S CHKPR2
LEA ALLFLG(PC),A5
CLR.B (A5) CLEAR FLAG
BRA.S MATCH2
CHKPR2 BSR.L CHECKP RESET POINTER
BEQ.S MATCH
MOVE.B D0,D4 CLASFY EATS FROM D4
DC CLASFY CLASSIFY IT
BCS.W SYNTAX TERM?
CMP.B #$39,D4 IS IT NUMBER?
BHI.S MATCH
FNDTRM DC GETNXT GET NEXT
BCC.S FNDTRM TERM?
BRA.S NOHEAD
MATCH BSR.L HGETNM INPUT NAME
BCS.L SYNTAX ERROR?
MATCH2 BSR.L PCAT GOGET DIRECTOY
BSR.L TSTTRM TEST TERM
BNE.S MATCH
MOVE.L A6,A4
DC SISOPN OPEN SIS
ERROR2 BNE.L ERROR
BSR.L GETIR GET FIRST RECORD
BNE.L ERROR
DC PCRLF
LEA FILMSG(PC),A4 FILES=
DC PSTRNG
LEA FTOTAL(PC),A0
MOVE.W (A0),D4
BSR.S DECSPC TOTAL FILES
LEA LARMSG(PC),A4 BIGGEST=
DC PNSTRN
LEA LARGST(PC),A0
MOVE.W (A0),D4
BSR.S DECSPC PRINT LARGEST
LEA SECMSG(PC),A4 TOTAL=
DC PNSTRN
CLR.L D4
MOVE.W SECCNT(PC),D4
CLR.L D5 NO SPACES
DC OUT5D PRINT SECTORS THIS CAT
MOVE.B #$2F,D4 /
DC PUTCH
MOVE.W SECTRS(PC),D4
CLR.L D5 NO SPACES
DC OUT5D PRINT SECTORS THIS DISK
BSR.W OUTSPC PRINT A SPACE
LEA FREEMS(PC),A4 FREE=
DC PNSTRN
MOVE.B FCBDAT+4(A6),D7 TEST FOR FAT
CMP.B #$01,D7
BEQ.S USEFAT USE FAT IF =$01
LEA FCBMON(A6),A0
MOVE.W -4(A0),D4
SZCONT CLR.L D5 NO SPACES
DC OUT5D PRINT AVAILABLE SECTORS
BSR.W OUTSPC
MOVE.B PAGFLG(PC),D7
BEQ.S NOPAGE
LEA FFEED(PC),A4 PAGE EJECT STRING
DC PSTRNG
NOPAGE BRA.L DIRLOP REPEAT
DECSPC BSR.L OUTDE2 DECIMAL THEN SPACES
BRA.L OUT2SP
* USEFAT - IF THERE IS A FAT ON THE DISK, THEN USE FAT TO
* DETERMINE NUMBER OF FREE SECTORS INSTEAD OF USING SIS DATA
USEFAT MOVE.L A6,A4 POINT TO FCB AGAIN
MOVE.W #$0101,FCBCTR(A4) READY TO START READING FAT
DC SREAD READ BEGINNING OF FAT
BNE.L ERROR IF ERROR
MOVE.W FCBDAT(A4),D1 SIZE OF FAT IN BYTES
MOVE.L #$FFFFFFFF,FCBDAT(A4) ERASE SIZE, TRKS, SECT
CLR.L D0 ZERO FREE SO FAR
BRA.S UFCONT CONTINUE, SKIP 2ND READ
UFLOO1 ADD.B #1,FCBCSE(A4)
DC SREAD READ SECTOR OF FAT
BNE.S ERROR IF ERROR
UFCONT MOVE.W #255,D3 COUNTER OF BYTES
LEA FCBDAT(A6),A0 POINT TO DATA AREA
UFLOO2 MOVE.B (A0)+,D7 GET NEXT BYTE
MOVE.W #7,D4 COUNTER OF BITS
UFLOO3 BTST D4,D7 CHECK A BIT
BNE.L UFNOTF 1 = NOT FREE
ADD.W #1,D0 0 = ADD TO FREE
UFNOTF DBRA D4,UFLOO3 REPEAT FOR 8 BITS
SUB.W #1,D1 DECREMENT OVERALL BYTE COUNT
BEQ.S UFDONE QUIT WHEN DONE
DBRA D3,UFLOO2 REPEAT FOR 256 BYTES
BRA.S UFLOO1 KEEP GOING TIL NO MORE BYTES
UFDONE MOVE.L D0,D4 SIZE OF FREE SPACE
BRA.L SZCONT AND THEN CONTINUE AS BEFORE
* REPORT ERROR AND EXIT
*
SYNTAX MOVE.L A6,A4 POINT TO FCB
MOVE.B #26,FCBERR(A4) ERROR 26
ERROR DC PERROR REPORT ERROR
EXIT DC PCRLF PRINT CR & LF
DC WARMST RETURN TO SK*DOS
* TEST FOR TERMINATOR
*
TSTTRM MOVE.B LASTRM(A6),D0 CHECK LAST TERM
TSTTR2 CMP.B #$D,D0 IS IT CR?
BEQ.S RETRN3
CMP.B ENDLNC(A6),D0 IS IT EOL?
RETRN3 RTS
* PRINT DIRECTORY LIST
PCAT LEA BUFSAV(PC),A5 LOAD END OF AREA TO CLEAR
LEA FILNUM(PC),A0 LOAD BEGINNING " " "
BSR.L CLRTMP CLEAR TEMPORARIES
CLR.L D0
MOVE.L A6,A4 POINT TO FCB
DC DIROPN OPEN DIRECTORY
BNE.S ERROR
LEA LOOP(PC),A5
ADD.B #1,(A5) SET LOOP COUNTER
PCAT2 BSR.L GETIR GET INFO RECORD
BEQ.S PCAT3 ERRORS?
CMP.B #8,FCBERR(A6) IS IT EOF?
BEQ.S RETRN3 YES
BRA.S ERROR NO
PCAT3 MOVE.B FCBNAM(A6),D7 END OF
BEQ.S RETRN3
LEA FILNUM(PC),A5
ADD.W #1,(A5) BUMP FILE NUMBER
MOVE.B FCBNAM(A4),D7 DELETED FILE?
BPL.S KEEP NO
MOVE.B #'-',FCBNAM(A4) YES, REPLACE WITH -
MOVE.B NONFLG(PC),D7 YES; CHECK DELETED FLAG
BNE.S KEEPDL DELETED OK?
BRA.S PCAT2 SKIP DELETED
KEEP MOVE.W FCBSIZ(A6),D0 GET FILE SIZE
LEA LARGST(PC),A5
CMP.W (A5),D0 LARGEST?
BCS.S NOLARG
ISLARG MOVE.W D0,(A5) SET NEW LARGEST
NOLARG ADD.W SECTRS(PC),D0 ADD IN SECTOR COUNT
LEA SECTRS(PC),A5
MOVE.W D0,(A5) SAVE NEW COUNT
LEA FTOTAL(PC),A5
ADD.W #1,(A5) BUMP FILE COUNT
KEEPDL LEA FCBNAM(A6),A0 POINT TO NAME
MOVE.B ALLFLG(PC),D7 ALL FILES?
BNE.L PCAT4
LEA DATPNT(PC),A5
MOVE.L A0,(A5) SAVE POINTER
LEA NAME(PC),A0 TRY TO MATCH NAME
LEA INDEX(PC),A5
MOVE.L A0,(A5)
* FOUND A VALID ENTRY, SO SAVE IT IF IT MATCHES MASK
MOVE.L DATPNT(PC),A5 POINT TO NAME FROM DIR
LEA NAME(PC),A0 AND TO NAME MASK
MOVE.B #10,D6 COUNTER = 11-1
MOVE.B MDIR(PC),D5
CMP.B #'*',D5 TREAT DIR=* DIFFERENTLY
BEQ.S DISTAR
NALOOP MOVE.B (A0)+,D5 GET NAME MASK
BEQ.S IS00 00 = COMPARE DIR ONLY
CMP.B #$80,D5
BEQ.S IS80 80 = COMPARE DIR ONLY
CMP.B #$2A,D5
BEQ.S IS00 2A = COMPARE DIR ONLY
CMP.B #$AA,D5
BEQ.S IS80 AA = COMPARE DIR ONLY
CMP.B 0(A5),D5 ELSE COMPARE
BNE.L PCAT2 UNEQUAL, DON'T MATCH SO DON'T PRINT
NLEND LEA 1(A5),A5 STEP TO NEXT
DBRA D6,NALOOP REPEAT FOR 11 CHARS
BRA.S PCAT4 SAVE IT IF IT MATCHES
IS00 TST.B 0(A5) CHECK ACTUAL NAME
BMI.L PCAT2 IF DIF SIGN, NG
BRA.S NLEND
IS80 TST.B 0(A5) CHECK ACTUAL NAME
BPL.L PCAT2 IF DIF SIGN, NG
BRA.S NLEND
DISTAR MOVE.B (A0)+,D5 GET NAME MASK
AND.B #$7F,D5 IGNORE PARITY
BEQ.S DISEND AND IGNORE ZERO
SUB.B 0(A5),D5 COMPARE
AND.B #$7F,D5 BUT WITHOUT PARITY
BNE.L PCAT2 UNEQUAL, DON'T MATCH SO DON'T PRINT
DISEND LEA 1(A5),A5 STEP TO NEXT
DBRA D6,DISTAR REPEAT FOR 11 CHARS
BRA.L PCAT4 SAVE IT IF IT MATCHES
PCAT4 MOVE.W FCBSIZ(A6),D0 ADD SIZE TO COUNT
LEA SECCNT(PC),A5
ADD.W (A5),D0
MOVE.W D0,(A5)
MOVE.B COLCNT(PC),D7 LINE FULL?
BNE.S NOCRLF
LEA COLCNT(PC),A5
MOVE.B MAXCOL(PC),(A5) RESET MAXIMUM ACROSS
DC PCRLF
MOVE.B PAGFLG(PC),D7 PAGING?
BEQ.S NOCRLF
LEA LINCNT(PC),A5
SUB.B #1,(A5)
BNE.S NOCRLF
LEA FFEED(PC),A4
DC PSTRNG EJECT PAGE
LEA LINCNT(PC),A5
MOVE.B #PAGLEN-3,(A5) NEW LINE COUNT
NOCRLF LEA COLCNT(PC),A5
SUB.B #1,(A5)
MOVE.B FILFLG(PC),D7
BEQ.S NOFILE
MOVE.B #1,D5 LDB #1 SET FLAG
MOVE.W FILNUM(PC),D4
DC OUT5D PRINT FILE NUMBER
BSR.L OUTSPC
NOFILE LEA FCBNAM(A6),A4 POINT TO NAME
MOVE.B #$1,D4 PAD WITH SPACES
DC FNPRNT PRINT FILE NAME
MOVE.B #$20,D4 SPACE AFTER IT
DC PUTCH MAYBE 2?
MOVE.B FCBRAN(A6),D7 IS IT RANDOM FILE?
BEQ.S NOTRAN NO
MOVE.B #'R',D4 R IF RANDOM
NOTRAN DC PUTCH OUTPUT SPACE OR r
MOVE.B MAXFLG(PC),D7
BNE.S DOSPC
MOVE.B SIZFLG(PC),D7
BNE.S SKPSPC IF SIZE FOLLOWS NAME
DOSPC BSR.S OUTSPC
SKPSPC MOVE.B MAXFLG(PC),D7
BEQ.S NOTMX2
LEA FCBFTR(A6),A0 OUTPUT START
BSR.L OUTPNT
BSR.S OUTSPC
LEA FCBLTR(A6),A0 OUTPUT END
BSR.L OUTPNT
NOTMX2 MOVE.B SIZFLG(PC),D7
BEQ.S NOTSIZ
MOVE.W FCBSIZ(A6),D4
MOVE.B #1,D5
DC OUT5D OUTPUT SIZE
BSR.S OUT2SP
NOTSIZ MOVE.B DATFLG(PC),D7
BEQ.S NOTDAT
LEA FCBMON+2(A6),A0
BSR.L OUTDAT OUTPUT DATE
BSR.S OUTSPC
NOTDAT MOVE.B MAXFLG(PC),D7
BEQ.S NOTMX3
MOVE.B #$57,D4 W OUTPUT PROT CODES
MOVE.B #7,D1 WRITE?
BSR.L OUTPRO
MOVE.B #$44,D4 D
MOVE.B #6,D1 DELETE?
BSR.L OUTPRO
MOVE.B #$43,D4 C
MOVE.B #4,D1 CATALOG?
BSR.L OUTPRO
NOTMX3 BRA.L PCAT2 REPEAT
* OUTPUT SPACE
*
OUT2SP BSR.S OUTSPC
NOP
OUTSPC MOVEM.L D4-D4,-(A7) SAVE D4
MOVE.B #$20,D4 SPACE
OUTSP2 DC PUTCH PRINT IT
MOVEM.L (A7)+,D4-D4 RESTORE D4
RTS
* OUTPUT A ZERO (ADDED BY Y2K ISSUES )
*
OUTZER MOVEM.L D4-D4,-(A7) PUSH D4
MOVE.B #$30,D4 ZERO
BRA.S OUTSP2
* GET INFO RECORD
*
GETIR MOVE.L A6,A4 POINT TO FCB
DC DSREAD READ DIR OR SIS RECORD
RTS
* PRINT D1 CHARACTERS IN STRING POINTED TO BY A0
* HAD TO MOVE FORWARD 2 BYTES IN FCB TO MAKE IT CORRECT!
PDATAB MOVE.B (A0),D4 GET CHARACTER
BNE.S PDATA2 CONT IF NOT NULL
MOVE.B #$20,D4 REPLACE NULL WITH SPACE
PDATA2 CMP.B #4,D4 EOT?
BEQ.S RETRN4 YES, QUIT
CMP.B #$FF,D4 NO, DELETED FILE?
BNE.S NOTDEL NO, PRINT IT
MOVE.B #$2D,D4 YES, REPLACE WITH DASH
NOTDEL DC PUTCH PRINT CHAR
ADD.L #1,A0 BUMP TO NEXT
SUB.B #1,D1
BNE.S PDATAB
RETRN4 RTS
* GET FILE MATCH NAME
*
HGETNM LEA ALLFLG(PC),A5
CLR.B (A5) CLEAR ALL
LEA NAME2(PC),A0 POINT TO BUFFER
MOVE.B #15,D1 SET COUNT
GETNA2 CLR.B (A0) CLEAR BUFFER
ADD.L #1,A0
SUB.B #1,D1
BNE.S GETNA2
BSR.L CHECKP POINT TO NAME
BEQ.S GETNA4
LEA NAME2(PC),A4 RESET POINTER
DC GETNAM GET FILE NAME
BRA.S GETNA6
GETNA4 ADD.L #1,LPOINT(A6) FIX POINTER
MOVE.B #3,D1 SET COUNT
LEA EXT(PC),A0 POINT TO EXT
GETNA5 DC GETNXT GET CHARACTER
BCS.S GETNA6 TERM?
CMP.B FNCASE(A6),D5 IS D5 LOWER THAN FNCASE?
BCS.S GTNM5A LEAVE AS IS IF YES
AND.B #$DF,D5 NO, CVT TO UPPER CASE
GTNM5A MOVE.B D5,(A0) SAVE CHAR
ADD.L #1,A0
SUB.B #1,D1
BPL.S GETNA5
OR.B #1,CCR SET CARRY
RTS RETURN
* SUBSTITUTE OUR DIRECTORY FOR ANY OF HIS
GETNA6 LEA NAME+1(PC),A5 POINT TO 2ND CHAR OF NAME
AND.L #$7F7F7F7F,-1(A5) 1ST 4 CHARS
AND.L #$7F7F7F7F,3(A5) 2ND 4 CHARS
MOVE.B MDIR(PC),D5 GET DIRECTORY CHAR
CPDLOO LSL.B #1,D5 SHIFT NEXT BIT INTO BIT 7
BEQ.S CPEXIT QUIT IF ALL BITS DONE
BPL.S CPDERO IF >0 THEN IT'S ZERO
OR.B #$80,(A5) IF <0 THEN OR IN PARITY BIT
CPDERO LEA 1(A5),A5 THEN GO TO NEXT CHAR
BRA.S CPDLOO AND DO NEXT BIT/CHAR
CPEXIT AND.B #$FE,CCR CLEAR CARRY
RTS RTS
* PRINT MINUS SIGN
*
OUTDSH MOVE.B #$2D,D4 DASH
PUTCH2 DC PUTCH PRINT IT
RTS
* OUTPUT PROT CODE
*
OUTPRO BTST.B D1,FCBATT(A6) TEST BYTE
BNE.S PUTCH2 OUTPUT C(D4) IF BIT=1
BRA.L OUTSPC PRINT SPACE
* OUTPUT DATE - ENTER WITH A0 POINTING TO MONTH
*
OUTDAT MOVE.L A0,A1 SAVE POINTER
CLR.L D4
MOVE.B -1(A0),D4 GET DAY
BSR.S OUTD PRINT IT
BSR.S OUTDSH DASH
CLR.L D0
MOVE.B -2(A1),D0 GET MONTH
BEQ.S BADMON
CMP.B #13,D0
BLT.S OKMON
BADMON MOVE.W #13,D0 REPLACE BAD WITH 13
OKMON LEA MONTHM-3(PC),A0 POINT TO MONTHS
MULU #3,D0 MULT BY 3
OUTDA5 LEA 0(A0,D0.W),A0 POINT TO STRING
MOVE.B #3,D1 SET COUNT
BSR.L PDATAB PRINT MONTH
BSR.S OUTDSH
CLR.L D4
MOVE.B 0(A1),D4 GET YEAR
OUTD CMP.B #9,D4 LESS THAN 10?
BHI.S OUTDE2 NO
BSR.L OUTZER YES, PRECEDE WITH ZERO
OUTDE2 MOVE.L #0,D5
DC OUT5D PRINT DIGITS
RTS
* PRINT DISK ADDRESS
*
OUTPNT MOVE.B (A0),D4 GET FIRST BYTE
BSR.S OUTHX2 OUTPUT IT
BSR.S OUTDSH PRINT '-'
MOVE.B 1(A0),D4 GET SECOND BYTE
OUTHX2 DC OUT2H PRINT BYTE
RTS
* FILL LINE BUFFER WITH ALPHABET
*
ALPHA MOVE.L LPOINT(A6),A0
MOVE.B #$20,LASTRM(A6) DESTROY WITH SPACE
MOVE.B 0(A0),D0
CMP.B #$D,D0
BNE.S NOTCR
MOVE.B #$20,0(A0) SUBSTITUTE SPACE
ADD.L #1,A0
MOVE.L A0,LPOINT(A6) RESTORE LPOINT
NOTCR MOVE.B #$41,D0 A=FIRST LETTER
ALPHA2 MOVE.B D0,(A0)+ STUFF LETTER
MOVE.B #$20,(A0)+ STUFF SPACE
ADD.B #01,D0
CMP.B #$5A,D0 A?
BLE.S ALPHA2 REPEAT IF Z OR LESS
SUB.L #1,A0 RETURN TO LAST SPACE
MOVE.B #$D,(A0) REPLACE WITH CR
RTS
* MESSAGES
*
HEADER DC.B 'File# Name Type Begin End Size Date Prot'
DC.B 4
FILMSG DC.B 'Files='
DC.B 4
SECMSG DC.B 'Total='
DC.B 4
LARMSG DC.B 'Biggest='
DC.B 4
FREEMS DC.B 'Free='
DC.B 4
DIRST DC.B 'Drive: '
DC.B 4
DIRMSG DC.B ' Dir: '
DC.B 4
CREATM DC.B 'Created: '
DC.B 4
VOLMSG DC.B ' Disk: '
DC.B 4
RPTMSG DC.B '-E?'
DC.B 4
MONTHM DC.B 'JanFebMarAprMayJun'
DC.B 'JulAugSepOctNovDec'
DC.B 'BAD'
HLPMSG DC.B 'CAT is used to print a catalog of the files on a disk.'
DC.B $0D,$0A
DC.B 'Various options may be used to catalog just some files, or'
DC.B $0D,$0A
DC.B 'to print in different formats. The general syntax is'
DC.B $0D,$0A
DC.B ' CAT <+format> '
DC.B $0D,$0A
DC.B 'All of the arguments are optional, and mean the following:'
DC.B $0D,$0A
DC.B '<+format> option letters (preceded by a + sign) are'
DC.B $0D,$0A
DC.B ' A Alpha sort N Non-existent (deleted) files'
DC.B $0D,$0A
DC.B ' D print file Date P Page output format'
DC.B $0D,$0A
DC.B ' F print File Number R Repeat'
DC.B $0D,$0A
DC.B ' M show Maximum display S print file Size'
DC.B $0D,$0A
DC.B ' is optional and specifies where to look for files.'
DC.B $0D,$0A
DC.B ' Its format is either a drive-number or drive.dir/, and it'
DC.B $0D,$0A
DC.B ' defaults to the current work drive and its directory.'
DC.B $0D,$0A
DC.B 'The is also optional and may consist of'
DC.B $0D,$0A
DC.B ' one or more full or partial file names and/or extensions'
DC.B $0D,$0A
DC.B ' to be searched for.'
DC.B $0D,$0A
DC.B 'For example, CAT +DF 1.A/ .CMD AB would list all files on'
DC.B $0D,$0A
DC.B 'drive 1, directory A, whose names begin with AB or whose'
DC.B $0D,$0A
DC.B 'extension is .CMD, listing their dates and file numbers.'
DC.B $0D,$0A
DC.B '(* inside a match-list file-name is a wild-card character.)',4
END CAT