mirror of
https://github.com/A2osX/A2osX.git
synced 2024-09-10 22:54:59 +00:00
517 lines
10 KiB
Plaintext
517 lines
10 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.SRC
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
*--------------------------------------
|
||
* In :
|
||
* X = #SYSCall
|
||
* Y,A = PATH (PSTR)
|
||
* Out :
|
||
* CC : Y,A = PTR to S.DIR
|
||
* CS : A = EC
|
||
*--------------------------------------
|
||
K.OPENDIRYA jsr S.PFTCHECKPATHYA
|
||
>STYA ZPQuickPtr2
|
||
>STYA MLICALL.PARAMS+1 For MLIOPEN
|
||
|
||
>PUSHWI S.DIR.PRODOS
|
||
>PUSHBI S.MEM.F.INIT0
|
||
jsr K.GetMem
|
||
bcs .9
|
||
|
||
>STYA ZPQuickPtr1
|
||
stx hDIR
|
||
|
||
lda (ZPQuickPtr2)
|
||
cmp #1 One char ?
|
||
bne .7 No, Go open dir....
|
||
tay Y=1
|
||
lda (ZPQuickPtr2),y
|
||
cmp #'/' Root required ?
|
||
beq .8 Yes, Go for ONLINE Call (S.DIR.PRODOS.REF=0)
|
||
|
||
lda #SYSMGR.ERRSYN
|
||
sec
|
||
.9 rts
|
||
|
||
.7 >PUSHWI 1024 get a ProDOS IOBUF
|
||
>PUSHBI S.MEM.F.ALIGN+S.MEM.F.NOMOVE
|
||
jsr K.GetMem
|
||
bcs .98
|
||
|
||
>STYA MLICALL.PARAMS+3 Save Ptr to IOBUF for MLIOPEN call
|
||
txa
|
||
ldy #S.DIR.PRODOS.IOBUF
|
||
sta (ZPQuickPtr1),y
|
||
|
||
>MLICALL MLIOPEN
|
||
bcs .98
|
||
|
||
lda MLICALL.PARAMS+5 get ref_num
|
||
ldy #S.DIR.PRODOS.REF
|
||
sta (ZPQuickPtr1),y
|
||
|
||
.8 lda hDIR
|
||
clc
|
||
rts
|
||
|
||
.98 pha save MLI error
|
||
jsr K.CLOSEDIRA.1
|
||
pla get back MLI error
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
hDIR .BS 1
|
||
*--------------------------------------
|
||
* In :
|
||
* A = hDIR
|
||
* Out :
|
||
* CC : X = hDIREND, Y,A = PTR to S.DIRENT
|
||
* CS : A = EC, A = 0 : no more entry
|
||
*--------------------------------------
|
||
K.READDIRA jsr S.PFTCHECKDIRA
|
||
jsr K.GetMemPtrA
|
||
>STYA ZPQuickPtr1
|
||
|
||
ldy #S.DIR.F
|
||
lda (ZPQuickPtr1),y
|
||
and #S.DIR.F.NOMORE
|
||
bne .9
|
||
|
||
ldy #S.DIR.PRODOS.REF
|
||
lda (ZPQuickPtr1),y
|
||
beq K.READDIRA.ROOT
|
||
jmp K.READDIRA.DIR
|
||
|
||
.9 lda #0
|
||
sec CS,A=0 no more entry
|
||
K.READDIRA.RTS rts
|
||
|
||
K.READDIRA.ROOT stz MLICALL.PARAMS+1 All Volumes
|
||
>LDYAI KrnBuffer256
|
||
>STYA MLICALL.PARAMS+2
|
||
>STYA ZPQuickPtr2 For PASS #2
|
||
>MLICALL MLIONLINE
|
||
bcs K.READDIRA.RTS
|
||
|
||
lda #1 +1 for Ending 0
|
||
sta BufSize
|
||
stz BufSize+1
|
||
|
||
ldy #0
|
||
|
||
.1 lda KrnBuffer256,y
|
||
and #$0F
|
||
beq .2
|
||
|
||
sec Add Filelen +1
|
||
adc BufSize
|
||
sta BufSize
|
||
bcc .11
|
||
inc BufSize+1
|
||
|
||
.11 lda #S.STAT
|
||
adc BufSize
|
||
sta BufSize
|
||
bcc .12
|
||
inc BufSize+1
|
||
|
||
.12 inx
|
||
|
||
.2 tya
|
||
clc
|
||
adc #16
|
||
tay
|
||
bcc .1 loop until 256 bytes scanned
|
||
|
||
txa
|
||
beq K.READDIRA.RTS A=0, CS no more DIRENT
|
||
|
||
sta EntryCount
|
||
|
||
>PUSHW BufSize
|
||
>PUSHBI S.MEM.F.INIT0
|
||
jsr K.GetMem
|
||
bcs K.READDIRA.RTS
|
||
stx hDIRENT
|
||
>STYA ZPQuickPtr3
|
||
>STYA ZPQuickPtr4
|
||
|
||
.3 lda (ZPQuickPtr2)
|
||
and #$0F
|
||
beq .88
|
||
tay
|
||
tax
|
||
sta (ZPQuickPtr3)
|
||
inc
|
||
sta VolName Build a string with leading / for GetFileInfo
|
||
|
||
.4 lda (ZPQuickPtr2),y
|
||
sta (ZPQuickPtr3),y
|
||
sta VolName+1,y
|
||
dey
|
||
bne .4
|
||
lda #'/'
|
||
sta VolName+1
|
||
|
||
txa
|
||
sec
|
||
adc ZPQuickPtr3
|
||
sta ZPQuickPtr3
|
||
bcc .41
|
||
inc ZPQuickPtr3+1
|
||
|
||
.41 >LDYAI VolName
|
||
>STYA MLICALL.PARAMS+1
|
||
>MLICALL MLIGETFILEINFO
|
||
bcs .80
|
||
|
||
lda MLICALL.PARAMS+S.FILEINFO.ACCESS
|
||
cmp #S.FILEINFO.ACCESS.FULL
|
||
bne .5
|
||
|
||
lda #S.STAT.MODE.XO+S.STAT.MODE.WO+S.STAT.MODE.RO
|
||
bra .6
|
||
|
||
.5 and #S.FILEINFO.ACCESS.R
|
||
beq .6
|
||
lda #S.STAT.MODE.XO+S.STAT.MODE.RO
|
||
|
||
.6 ldy #S.STAT.MODE
|
||
sta (ZPQuickPtr3),y
|
||
|
||
ldy #S.STAT.BLOCKS
|
||
lda MLICALL.PARAMS+S.FILEINFO.AUXTYPE
|
||
sta (ZPQuickPtr3),y
|
||
iny
|
||
lda MLICALL.PARAMS+S.FILEINFO.AUXTYPE
|
||
sta (ZPQuickPtr3),y
|
||
ldy #S.STAT.BLKSIZE+1
|
||
lda #2 Block size is $200 for ProDOS
|
||
sta (ZPQuickPtr3),y
|
||
|
||
.80 lda ZPQuickPtr3
|
||
clc
|
||
adc #S.STAT
|
||
sta ZPQuickPtr3
|
||
bcc .88
|
||
inc ZPQuickPtr3+1
|
||
|
||
.88 lda ZPQuickPtr2
|
||
clc
|
||
adc #16
|
||
sta ZPQuickPtr2
|
||
bcc .89
|
||
inc ZPQuickPtr2+1
|
||
.89 dec EntryCount
|
||
bne .3
|
||
|
||
lda #0
|
||
sta (ZPQuickPtr3) Ending 0
|
||
|
||
ldy #S.DIR.F
|
||
lda #S.DIR.F.NOMORE
|
||
sta (ZPQuickPtr1),y
|
||
|
||
ldx hDIRENT
|
||
>LDYA ZPQuickPtr4
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
K.READDIRA.DIR ldy #S.DIR.PRODOS.REF
|
||
lda (ZPQuickPtr1),y
|
||
sta MLICALL.PARAMS+1
|
||
|
||
>PUSHWI 512 Get a 512 bytes buffer for reading dir...
|
||
>PUSHBI 0
|
||
jsr K.GetMem
|
||
bcs .99
|
||
stx K.READDIRA.hMem
|
||
|
||
>STYA MLICALL.PARAMS+2 For reading
|
||
|
||
pha
|
||
tya
|
||
* clc CC from K.GetMem
|
||
adc #4 Skip 4 bytes linked list
|
||
tay
|
||
pla
|
||
adc #0
|
||
|
||
>STYA ZPQuickPtr2 PTR to Buffer for PASS #1
|
||
>STYA ZPQuickPtr3 PTR to Buffer for PASS #2
|
||
|
||
>LDYAI 512
|
||
>STYA MLICALL.PARAMS+4
|
||
>MLICALL MLIREAD Read A block from directory
|
||
bcs .98
|
||
|
||
ldy #S.DIR.PRODOS.EL Check if first run....
|
||
lda (ZPQuickPtr1),y
|
||
bne .2 no, we have all we need....
|
||
|
||
ldy #$23+3
|
||
.1 lda (ZPQuickPtr2),y Get EntryLength.... From Block
|
||
sta EntryLength-$23,y
|
||
dey
|
||
bpl .1
|
||
bra .4
|
||
|
||
.98 pha
|
||
lda K.READDIRA.hMem
|
||
jsr K.FreeMemA
|
||
pla
|
||
sec
|
||
.99 rts
|
||
|
||
.2 ldy #S.DIR.PRODOS.EL+3
|
||
|
||
.3 lda(ZPQuickPtr1),y get this session parameters from S.DIR
|
||
sta EntryLength-S.DIR.PRODOS.EL,y
|
||
dey
|
||
bpl .3
|
||
|
||
.4 ldx EntryCount
|
||
cpx EntryPerBlock
|
||
|
||
lda EntryCount+1
|
||
sbc #0
|
||
bcc .5 We have less than EPB to read
|
||
ldx EntryPerBlock
|
||
|
||
.5 stx EntryCountIB
|
||
stz EntryCount2Return
|
||
|
||
lda #1 For Ending 0
|
||
sta BufSize
|
||
stz BufSize+1
|
||
|
||
* pass #1 compute BufSize.....
|
||
|
||
.51 lda (ZPQuickPtr2) X = EntryCount In This Block
|
||
beq .7 Free slot....goto next
|
||
|
||
jsr S.READDIR.CHK
|
||
|
||
.7 lda ZPQuickPtr2
|
||
clc
|
||
adc EntryLength
|
||
sta ZPQuickPtr2
|
||
bcc .71
|
||
inc ZPQuickPtr2+1
|
||
|
||
.71 dex
|
||
bne .51
|
||
|
||
* pass #2 Fill Buffer...
|
||
|
||
>PUSHW BufSize Get a BufSize bytes buffer for storing results
|
||
>PUSHBI S.MEM.F.INIT0 make sure 0 fiiled
|
||
jsr K.GetMem
|
||
bcs .98
|
||
stx K.READDIRA.hDIR
|
||
>STYA ZPQuickPtr4
|
||
|
||
.72 jsr DecEntryCount
|
||
bcc .80 no more file to list...
|
||
|
||
lda (ZPQuickPtr3)
|
||
beq .78
|
||
|
||
jsr K.READDIRA.ADD
|
||
|
||
.78 lda ZPQuickPtr3
|
||
clc
|
||
adc EntryLength
|
||
sta ZPQuickPtr3
|
||
bcc .79
|
||
inc ZPQuickPtr3+1
|
||
|
||
.79 dec EntryCountIB
|
||
beq .72
|
||
|
||
.80
|
||
* lda #0 S.MEM.F.INIT0 already did this
|
||
* sta (ZPQuickPtr4) Ending 0
|
||
|
||
ldy #S.DIR.PRODOS.EL+3
|
||
.8 lda EntryLength-S.DIR.PRODOS.EL,y Store back this session prameters to S.DIR
|
||
sta (ZPQuickPtr1),y
|
||
dey
|
||
bpl .8
|
||
|
||
jsr .98 Discard READBUFFER
|
||
|
||
lda K.READDIRA.hDIR
|
||
tax
|
||
jsr K.GetMemPtrA
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
S.READDIR.CHK tay save LEN
|
||
|
||
and #$F0 get storage_type
|
||
cmp #$E0 directory header ?
|
||
bne .1
|
||
|
||
inc EntryCount2Return yes, return 2 ".."
|
||
lda #S.STAT+3 add "#.." string + S.STAT
|
||
jsr K.READDIRA.AddBufSize
|
||
bra .2 go add "." Entry
|
||
|
||
|
||
.1 cmp #$F0 Volume header ?
|
||
bne .3
|
||
|
||
.2 lda #S.STAT+2 add "#." string + S.STAT
|
||
bra .4
|
||
|
||
.3 tya
|
||
and #$F get filename len
|
||
sec Add 1 for LEN
|
||
adc #S.STAT
|
||
|
||
.4 jsr K.READDIRA.AddBufSize
|
||
inc EntryCount2Return
|
||
rts
|
||
*--------------------------------------
|
||
K.READDIRA.ADD and #$F0
|
||
cmp #$F0 Volume header ?
|
||
bne .10
|
||
|
||
lda #1
|
||
jsr K.READDIRA.AddToBuf
|
||
lda #'.'
|
||
jsr K.READDIRA.AddToBuf
|
||
|
||
ldy #$25 total_blocks
|
||
lda (ZPQuickPtr3),y
|
||
tax
|
||
iny
|
||
lda (ZPQuickPtr3),y
|
||
|
||
ldy #S.STAT.BLOCKS+1
|
||
sta (ZPQuickPtr4),y
|
||
dey
|
||
txa
|
||
sta (ZPQuickPtr4),y
|
||
|
||
.10 cmp #$E0 directory header ?
|
||
bne .20
|
||
|
||
lda #2
|
||
jsr K.READDIRA.AddToBuf
|
||
lda #'.'
|
||
jsr K.READDIRA.AddToBuf
|
||
jsr K.READDIRA.AddToBuf
|
||
|
||
|
||
|
||
|
||
.20 cmp #$D0 directory ?
|
||
bne .30
|
||
|
||
lda (ZPQuickPtr3)
|
||
and #$0F get filename len
|
||
tax
|
||
jsr K.READDIRA.AddToBuf
|
||
ldy #1
|
||
|
||
.21 lda (ZPQuickPtr3),y
|
||
jsr K.READDIRA.AddToBuf
|
||
iny
|
||
dex
|
||
bne .21
|
||
|
||
|
||
.30
|
||
|
||
.80 lda ZPQuickPtr4
|
||
clc
|
||
adc #S.STAT
|
||
sta ZPQuickPtr4
|
||
bcc .8
|
||
inc ZPQuickPtr4+1
|
||
.8 rts
|
||
*--------------------------------------
|
||
K.READDIRA.AddBufSize
|
||
clc
|
||
adc BufSize
|
||
sta BufSize
|
||
bcc .9
|
||
inc BufSize+1
|
||
.9 rts
|
||
*--------------------------------------
|
||
K.READDIRA.AddToBuf
|
||
sta (ZPQuickPtr4)
|
||
inc ZPQuickPtr4
|
||
bne .8
|
||
inc ZPQuickPtr4+1
|
||
.8 rts
|
||
*--------------------------------------
|
||
DecEntryCount lda EntryCount
|
||
sec
|
||
sbc #1
|
||
sta EntryCount
|
||
bcs .9 CS, 0 or more
|
||
lda EntryCount+1
|
||
sbc #0
|
||
sta EntryCount+1 CC, we reached $ffff
|
||
.9 rts
|
||
*--------------------------------------
|
||
K.READDIRA.hMem .BS 1
|
||
K.READDIRA.hDIR .BS 1
|
||
*--------------------------------------
|
||
* In :
|
||
* A = hDIR
|
||
*--------------------------------------
|
||
K.CLOSEDIRA jsr S.PFTCHECKDIRA
|
||
sta hDIR
|
||
jsr K.GetMemPtrA
|
||
>STYA ZPQuickPtr1
|
||
|
||
K.CLOSEDIRA.1 ldy #S.DIR.PRODOS.REF
|
||
lda (ZPQuickPtr1),y
|
||
beq .1
|
||
sta MLICALL.PARAMS+1
|
||
>MLICALL MLICLOSE
|
||
|
||
.1 ldy #S.DIR.PRODOS.IOBUF
|
||
lda (ZPQuickPtr1),y
|
||
beq .2
|
||
jsr K.FreeMemA
|
||
|
||
.2 lda hDIR
|
||
jsr K.FreeMemA
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
K.MKDIRYA jsr S.PFTCHECKPATHYA
|
||
>STYA MLICALL.PARAMS+1
|
||
lda #S.FILEINFO.ACCESS.FULL
|
||
sta MLICALL.PARAMS+S.FILEINFO.ACCESS
|
||
lda #S.FILEINFO.TYPE.DIR
|
||
sta MLICALL.PARAMS+S.FILEINFO.TYPE
|
||
lda #S.FILEINFO.STORETYPE.DIR
|
||
sta MLICALL.PARAMS+S.FILEINFO.STORETYPE
|
||
>MLICALL MLICREATE
|
||
rts
|
||
*--------------------------------------
|
||
hONLINE .BS 1
|
||
hDIRENT .BS 1
|
||
BufSize .BS 2
|
||
EntryLength .BS 1
|
||
EntryPerBlock .BS 1
|
||
EntryCount .BS 2
|
||
EntryCountIB .BS 1
|
||
EntryCount2Return .BS 1
|
||
|
||
VolName .BS 17
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE SYS/KERNEL.S.DIR
|
||
LOAD SYS/KERNEL.S
|
||
ASM
|