2021-06-10 22:49:00 +00:00
|
|
|
*--------------------------------------
|
|
|
|
* DU: Disk Usage - Bobbi June 2021
|
|
|
|
*--------------------------------------
|
|
|
|
.LIST OFF
|
|
|
|
.OP 65C02
|
|
|
|
.OR $2000
|
|
|
|
.TF bin/du
|
|
|
|
*--------------------------------------
|
|
|
|
.INB inc/macros.i
|
|
|
|
.INB inc/a2osx.i
|
|
|
|
.INB inc/kernel.i
|
|
|
|
.INB inc/mli.i
|
|
|
|
.INB inc/mli.e.i
|
|
|
|
*--------------------------------------
|
|
|
|
X.ENTER.SUBDIR .EQ 1
|
|
|
|
X.COPY.TO.DEST .EQ 0
|
|
|
|
X.DELETE.SOURCE .EQ 0
|
|
|
|
*--------------------------------------
|
2021-06-11 02:58:48 +00:00
|
|
|
.DUMMY
|
|
|
|
.OR ZPBIN
|
2021-06-10 22:49:00 +00:00
|
|
|
ZS.START
|
|
|
|
ZPPtr1 .BS 2
|
|
|
|
ZPPtr2 .BS 2
|
|
|
|
ZPFileName .BS 2
|
|
|
|
ZPFileStat .BS 2
|
|
|
|
ZPPW .BS 2
|
|
|
|
hLineBuf .BS 1
|
|
|
|
ZPLineBuf .BS 2
|
|
|
|
bPass2 .BS 1
|
|
|
|
ZS.END
|
2021-06-11 02:58:48 +00:00
|
|
|
.ED
|
2021-06-10 22:49:00 +00:00
|
|
|
*--------------------------------------
|
|
|
|
* File Header (16 Bytes)
|
|
|
|
*--------------------------------------
|
|
|
|
CS.START cld
|
|
|
|
jmp (.1,x)
|
|
|
|
.DA #$61 6502,Level 1 (65c02)
|
|
|
|
.DA #1 BIN Layout Version 1
|
|
|
|
.DA #0 S.PS.F.EVENT
|
|
|
|
.DA #0
|
|
|
|
.DA CS.END-CS.START Code Size (without Constants)
|
|
|
|
.DA DS.END-DS.START Data SegmentSize
|
|
|
|
.DA #64 Stack Size
|
|
|
|
.DA #ZS.END-ZS.START Zero Page Size
|
|
|
|
.DA 0
|
|
|
|
*--------------------------------------
|
|
|
|
* Relocation Table
|
|
|
|
*--------------------------------------
|
|
|
|
.1 .DA CS.INIT
|
|
|
|
.DA CS.RUN
|
|
|
|
.DA CS.DOEVENT
|
|
|
|
.DA CS.QUIT
|
2021-06-11 02:58:48 +00:00
|
|
|
L.MSG.USAGE .DA MSG.USAGE
|
|
|
|
L.MSG.REG1 .DA MSG.REG1
|
|
|
|
L.MSG.REG2 .DA MSG.REG2
|
2021-06-10 22:49:00 +00:00
|
|
|
L.MSG.DIRSUMM .DA MSG.DIRSUMM
|
|
|
|
L.MSG.BDEV .DA MSG.BDEV
|
|
|
|
L.MSG.BDEVEXT .DA MSG.BDEVEXT
|
2021-06-11 02:58:48 +00:00
|
|
|
L.MSG.CWD .DA MSG.CWD
|
2021-06-10 22:49:00 +00:00
|
|
|
L.MSG.TOTSUMM .DA MSG.TOTSUMM
|
|
|
|
J.CS.RUN.PRINT .DA CS.RUN.PRINT.REG
|
|
|
|
.DA CS.RUN.PRINT.DIR
|
|
|
|
.DA CS.RUN.PRINT.CDEV
|
|
|
|
.DA CS.RUN.PRINT.BDEV
|
|
|
|
.DA CS.RUN.PRINT.CDEV
|
|
|
|
.DA CS.RUN.PRINT.CDEV
|
|
|
|
.DA CS.RUN.PRINT.CDEV
|
|
|
|
.DA CS.RUN.PRINT.CDEV
|
|
|
|
.DA 0
|
|
|
|
*--------------------------------------
|
|
|
|
CS.INIT
|
|
|
|
clc
|
|
|
|
rts
|
|
|
|
*--------------------------------------
|
|
|
|
CS.RUN
|
|
|
|
.1 >INC.G ArgCount
|
|
|
|
>SYSCALL ArgV
|
|
|
|
bcs .6
|
|
|
|
>STYA ZPPtr1
|
|
|
|
lda (ZPPtr1)
|
|
|
|
cmp #'-'
|
|
|
|
bne .4
|
|
|
|
ldy #1
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
|
|
|
ldx #OptionVars-OptionList-1
|
|
|
|
|
|
|
|
.2 cmp OptionList,x
|
|
|
|
beq .3
|
|
|
|
dex
|
|
|
|
bpl .2
|
|
|
|
|
2021-06-11 02:58:48 +00:00
|
|
|
>PUSHW L.MSG.USAGE
|
|
|
|
>PUSHBI 0
|
|
|
|
>SYSCALL PrintF
|
2021-06-10 22:49:00 +00:00
|
|
|
lda #E.SYN
|
|
|
|
sec
|
|
|
|
rts
|
|
|
|
|
|
|
|
.3 ldy OptionVars,x
|
|
|
|
lda #$80
|
|
|
|
sta (pData),y
|
|
|
|
bra .1
|
|
|
|
.4 >LDYA ZPPtr1
|
|
|
|
jsr InitSrcDirYA
|
|
|
|
bcc .1 scan for any other args
|
|
|
|
.9 rts
|
|
|
|
.6 >LDA.G index do we have a Source dir ?
|
|
|
|
bne .8
|
|
|
|
ldy #S.PS.hCWD
|
|
|
|
lda (pPS),y
|
|
|
|
>SYSCALL GetMemPtr
|
|
|
|
jsr InitSrcDirYA
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
.8 >PUSHEA.G TIME.SysTime
|
|
|
|
>SYSCALL Time
|
|
|
|
|
|
|
|
>LDYAI S.PW
|
|
|
|
>SYSCALL GetMem
|
|
|
|
bcs .9
|
|
|
|
>STYA ZPPW
|
|
|
|
txa
|
|
|
|
>STA.G hPW
|
|
|
|
|
|
|
|
>LDYAI 256
|
|
|
|
>SYSCALL GetMem
|
|
|
|
bcs .9
|
|
|
|
>STYA ZPLineBuf
|
|
|
|
stx hLineBuf
|
|
|
|
*--------------------------------------
|
|
|
|
CS.RUN.LOOP stz bPass2
|
|
|
|
|
|
|
|
.1 ldy #S.PS.hStdIn
|
|
|
|
lda (pPS),y
|
|
|
|
>SYSCALL FEOF
|
|
|
|
bcs .99 I/O error
|
|
|
|
|
|
|
|
tay
|
|
|
|
bne .2 no char
|
|
|
|
|
|
|
|
>SYSCALL GetChar
|
|
|
|
cmp #$03 Ctrl-C
|
|
|
|
beq .99 Abort....
|
|
|
|
|
|
|
|
cmp #$13 Ctrl-S
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
>LDA.G bPause
|
|
|
|
eor #$ff
|
|
|
|
sta (pData),y
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
.2 >LDA.G bPause
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
jsr GetEntry First entry
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
jsr FilterMatch Filter filename
|
|
|
|
bcs .8 no match, skip....
|
|
|
|
|
|
|
|
lda (ZPFileName)
|
|
|
|
cmp #'.'
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
.4 ldy #S.STAT.MODE+1
|
|
|
|
lda (ZPFileStat),y
|
|
|
|
|
|
|
|
and #$70
|
|
|
|
lsr
|
|
|
|
lsr
|
|
|
|
lsr
|
|
|
|
tax
|
|
|
|
jsr CS.RUN.PRINT.JMP
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
.8 jsr GetNextEntry Next entry
|
|
|
|
bcc .1 If there is one, go again
|
|
|
|
|
|
|
|
bit bPass2
|
|
|
|
bmi .9
|
|
|
|
|
|
|
|
jsr MyResetSrcDir
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
dec bPass2
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
.9 >LDA.G bSummary
|
|
|
|
bne .91
|
|
|
|
|
|
|
|
jsr CS.RUN.PrintDirSumm
|
2021-06-11 02:58:48 +00:00
|
|
|
jsr CS.RUN.PrintCwd
|
2021-06-10 22:49:00 +00:00
|
|
|
jsr CS.RUN.NewLine
|
|
|
|
|
|
|
|
.91 jsr LeaveSubDir "cd .."
|
|
|
|
bcs .98 This means we are done
|
|
|
|
|
|
|
|
jsr BasePath.. Prune pathname
|
|
|
|
|
|
|
|
jsr GetNextEntry Get next entry
|
|
|
|
jmp CS.RUN.LOOP Go again
|
|
|
|
|
|
|
|
.98
|
|
|
|
jsr CS.RUN.PrintTotSumm
|
|
|
|
jsr CS.RUN.NewLine.1
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
sec
|
|
|
|
.99 rts
|
|
|
|
*--------------------------------------
|
|
|
|
CS.RUN.PRINT.JMP
|
|
|
|
jmp (J.CS.RUN.PRINT,x)
|
|
|
|
*--------------------------------------
|
|
|
|
CS.RUN.PRINT.REG
|
|
|
|
bit bPass2
|
2021-06-11 02:58:48 +00:00
|
|
|
bmi .1
|
|
|
|
clc
|
|
|
|
rts
|
2021-06-10 22:49:00 +00:00
|
|
|
|
2021-06-11 02:58:48 +00:00
|
|
|
.1 ldy #S.STAT.BLOCKS+1
|
2021-06-10 22:49:00 +00:00
|
|
|
lda (ZPFileStat),y
|
|
|
|
pha
|
|
|
|
dey
|
|
|
|
lda (ZPFileStat),y
|
|
|
|
clc
|
|
|
|
>ADC.G DirBlksL
|
|
|
|
sta (pData),y
|
|
|
|
pla
|
|
|
|
iny
|
|
|
|
adc (pData),y
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
ldy #S.STAT.BLOCKS+1
|
|
|
|
lda (ZPFileStat),y
|
|
|
|
pha
|
|
|
|
dey
|
|
|
|
lda (ZPFileStat),y
|
|
|
|
clc
|
|
|
|
>ADC.G TotBlksL
|
|
|
|
sta (pData),y
|
|
|
|
pla
|
|
|
|
iny
|
|
|
|
adc (pData),y
|
|
|
|
sta (pData),y
|
|
|
|
|
2021-06-11 02:58:48 +00:00
|
|
|
>LDA.G bAllFiles
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
>PUSHW L.MSG.REG1
|
|
|
|
ldy #S.STAT.BLOCKS+1
|
|
|
|
ldx #2
|
|
|
|
.2 lda (ZPFileStat),y
|
|
|
|
>PUSHA
|
|
|
|
dey
|
|
|
|
dex
|
|
|
|
bne .2 (2)
|
|
|
|
>PUSHBI 2
|
|
|
|
>SYSCALL PrintF
|
|
|
|
bcs .9
|
|
|
|
jsr CS.RUN.PrintCwd
|
|
|
|
>PUSHW L.MSG.REG2
|
|
|
|
>PUSHW ZPFileName (2)
|
|
|
|
>PUSHBI 2
|
|
|
|
>SYSCALL PrintF
|
|
|
|
bcs .9
|
|
|
|
jmp CS.RUN.NewLine.1
|
2021-06-10 22:49:00 +00:00
|
|
|
|
|
|
|
.8 clc
|
|
|
|
.9 rts
|
|
|
|
*--------------------------------------
|
|
|
|
CS.RUN.PRINT.DIR
|
|
|
|
bit bPass2
|
|
|
|
bmi .8
|
|
|
|
|
|
|
|
lda (ZPFileName)
|
|
|
|
cmp #'.'
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
>LDYA ZPFileName
|
|
|
|
jmp EnterSubDirYA
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
.9 rts
|
|
|
|
*--------------------------------------
|
|
|
|
CS.RUN.PRINT.CDEV
|
|
|
|
clc
|
|
|
|
rts
|
|
|
|
*--------------------------------------
|
|
|
|
CS.RUN.PRINT.BDEV
|
|
|
|
bit bPass2
|
|
|
|
bmi .8
|
|
|
|
|
|
|
|
>PUSHW L.MSG.BDEVEXT
|
|
|
|
>PUSHW ZPFileName
|
|
|
|
|
|
|
|
ldy #S.STAT.P.SLOT
|
|
|
|
>PUSHB (ZPFileStat),y
|
|
|
|
iny DRIVE
|
|
|
|
>PUSHB (ZPFileStat),y
|
|
|
|
ldy #S.STAT.BLOCKS+1
|
|
|
|
>PUSHB (ZPFileStat),y
|
|
|
|
dey
|
|
|
|
>PUSHB (ZPFileStat),y
|
|
|
|
ldy #S.STAT.P.DEVBLOCKS+1
|
|
|
|
>PUSHB (ZPFileStat),y
|
|
|
|
dey
|
|
|
|
>PUSHB (ZPFileStat),y
|
|
|
|
|
|
|
|
>PUSHBI 8
|
|
|
|
>SYSCALL PrintF
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
jsr CS.RUN.NewLine.1
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
>LDYA ZPFileName
|
|
|
|
jsr EnterSubDirYA
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
.9 rts
|
|
|
|
*--------------------------------------
|
|
|
|
CS.RUN.PrintDirSumm >PUSHW L.MSG.DIRSUMM
|
|
|
|
>LDA.G DirBlksL
|
|
|
|
>PUSHW.G DirBlksL
|
|
|
|
>PUSHBI 2
|
|
|
|
>SYSCALL PrintF
|
|
|
|
|
|
|
|
lda #$00
|
|
|
|
>STA.G DirBlksL
|
|
|
|
>STA.G DirBlksH
|
|
|
|
rts
|
|
|
|
*--------------------------------------
|
|
|
|
CS.RUN.PrintTotSumm >PUSHW L.MSG.TOTSUMM
|
|
|
|
>LDA.G TotBlksL
|
|
|
|
>PUSHW.G TotBlksL
|
|
|
|
>PUSHBI 2
|
|
|
|
>SYSCALL PrintF
|
|
|
|
rts
|
|
|
|
*--------------------------------------
|
2021-06-11 02:58:48 +00:00
|
|
|
CS.RUN.PrintCwd
|
|
|
|
>PUSHW L.MSG.CWD
|
2021-06-10 22:49:00 +00:00
|
|
|
ldy #hSrcBasePath
|
|
|
|
lda (pData),y
|
|
|
|
>SYSCALL GetMemPtr
|
|
|
|
>PUSHYA
|
|
|
|
>PUSHBI 2
|
|
|
|
>SYSCALL PrintF
|
|
|
|
rts
|
|
|
|
*--------------------------------------
|
|
|
|
CS.RUN.NewLine
|
|
|
|
CS.RUN.NewLine.1
|
|
|
|
lda #C.CR
|
|
|
|
>SYSCALL PutChar
|
|
|
|
|
|
|
|
* bit bCRLF
|
|
|
|
* bpl CS.RUN.NewLine.8
|
|
|
|
|
|
|
|
lda #C.LF
|
|
|
|
>SYSCALL PutChar
|
|
|
|
CS.RUN.NewLine.8
|
|
|
|
clc
|
|
|
|
rts
|
|
|
|
*--------------------------------------
|
|
|
|
MyResetSrcDir jsr GethDIR Not in Kernel I am building against
|
|
|
|
>SYSCALL CloseDir
|
|
|
|
>LDA.G hSrcBasePath
|
|
|
|
>SYSCALL GetMemPtr
|
|
|
|
>SYSCALL OpenDir
|
|
|
|
bcs .9
|
|
|
|
pha
|
|
|
|
>LDA.G index
|
|
|
|
clc
|
|
|
|
adc #hDIRs-1
|
|
|
|
tay
|
|
|
|
pla
|
|
|
|
sta (pData),y
|
|
|
|
* clc
|
|
|
|
.9 rts
|
|
|
|
*----------------------------------------------
|
|
|
|
|
|
|
|
CS.DOEVENT sec
|
2021-06-11 02:58:48 +00:00
|
|
|
rts
|
2021-06-10 22:49:00 +00:00
|
|
|
*--------------------------------------
|
|
|
|
|
|
|
|
CS.QUIT
|
2021-06-11 02:58:48 +00:00
|
|
|
jsr LeaveSubDir
|
|
|
|
bcc CS.QUIT
|
|
|
|
>LDA.G hFilter
|
|
|
|
beq .3
|
|
|
|
>SYSCALL FreeMem
|
|
|
|
.3 >LDA.G hPW
|
|
|
|
beq .4
|
2021-06-10 22:49:00 +00:00
|
|
|
|
2021-06-11 02:58:48 +00:00
|
|
|
>SYSCALL FreeMem
|
2021-06-10 22:49:00 +00:00
|
|
|
|
2021-06-11 02:58:48 +00:00
|
|
|
.4 lda hLineBuf
|
|
|
|
beq .8
|
2021-06-10 22:49:00 +00:00
|
|
|
|
2021-06-11 02:58:48 +00:00
|
|
|
>SYSCALL FreeMem
|
2021-06-10 22:49:00 +00:00
|
|
|
|
2021-06-11 02:58:48 +00:00
|
|
|
.8 clc
|
|
|
|
rts
|
2021-06-10 22:49:00 +00:00
|
|
|
*--------------------------------------
|
2021-06-11 02:58:48 +00:00
|
|
|
.INB usr/src/shared/x.fileenum.s
|
2021-06-10 22:49:00 +00:00
|
|
|
*--------------------------------------
|
|
|
|
CS.END
|
|
|
|
*--------------------------------------
|
2021-06-11 02:58:48 +00:00
|
|
|
OptionList .AS "SAsa"
|
|
|
|
OptionVars .DA #bSummary,#bAllFiles,#bSummary,#bAllFiles
|
2021-06-10 22:49:00 +00:00
|
|
|
*--------------------------------------
|
2021-06-11 02:58:48 +00:00
|
|
|
MSG.USAGE .AS "Usage : DU\r\n"
|
|
|
|
.AS " -A : Show all files (not only directories)\r\n"
|
|
|
|
.AZ " -S : Show only summary\r\n"
|
|
|
|
MSG.REG1 .AZ "%5D "
|
|
|
|
MSG.REG2 .AZ "%s"
|
|
|
|
MSG.CWD .AZ "%s"
|
2021-06-10 22:49:00 +00:00
|
|
|
MSG.DIRSUMM .AZ "%5D "
|
|
|
|
MSG.BDEVEXT .AZ "/%15s s%dd%d Blocks Used:%5D Total:%5D"
|
|
|
|
MSG.BDEV .AZ "\e[32m%s/\e[0m"
|
|
|
|
MSG.TOTSUMM .AZ "Total: %5D blocks"
|
|
|
|
*--------------------------------------
|
2021-06-11 02:58:48 +00:00
|
|
|
.DUMMY
|
|
|
|
.OR 0
|
2021-06-10 22:49:00 +00:00
|
|
|
DS.START
|
|
|
|
ArgCount .BS 1
|
|
|
|
TIME.SysTime .BS S.TIME
|
|
|
|
bPause .BS 1
|
|
|
|
bSummary .BS 1
|
2021-06-11 02:58:48 +00:00
|
|
|
bAllFiles .BS 1
|
2021-06-10 22:49:00 +00:00
|
|
|
DirBlksL .BS 1
|
|
|
|
DirBlksH .BS 1
|
|
|
|
TotBlksL .BS 1
|
|
|
|
TotBlksH .BS 1
|
|
|
|
hPW .BS 1
|
|
|
|
.INB usr/src/shared/x.fileenum.g
|
|
|
|
DS.END .ED
|
|
|
|
*--------------------------------------
|