A2osX/SYS/KERNEL.S.DIR.txt

517 lines
10 KiB
Plaintext
Raw Normal View History

2016-08-24 15:42:33 +00:00
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
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.OPENDIRYA jsr S.PFTCHECKPATHYA
2016-09-01 15:42:38 +00:00
>STYA ZPQuickPtr2
>STYA MLICALL.PARAMS+1 For MLIOPEN
2016-08-28 20:48:01 +00:00
2016-09-01 15:42:38 +00:00
>PUSHWI S.DIR.PRODOS
>PUSHBI S.MEM.F.INIT0
2016-09-21 15:20:37 +00:00
jsr K.GetMem
2016-09-01 15:42:38 +00:00
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
2016-09-21 15:20:37 +00:00
jsr K.GetMem
2016-09-01 15:42:38 +00:00
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
2016-08-24 15:42:33 +00:00
2016-09-01 15:42:38 +00:00
.8 lda hDIR
2016-08-24 15:42:33 +00:00
clc
rts
2016-09-01 15:42:38 +00:00
.98 pha save MLI error
2016-09-21 15:20:37 +00:00
jsr K.CLOSEDIRA.1
2016-09-01 15:42:38 +00:00
pla get back MLI error
sec
.99 rts
*--------------------------------------
hDIR .BS 1
2016-08-24 15:42:33 +00:00
*--------------------------------------
* In :
* A = hDIR
2016-08-24 15:42:33 +00:00
* Out :
2016-09-01 15:42:38 +00:00
* CC : X = hDIREND, Y,A = PTR to S.DIRENT
* CS : A = EC, A = 0 : no more entry
2016-08-24 15:42:33 +00:00
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.READDIRA jsr S.PFTCHECKDIRA
jsr K.GetMemPtrA
2016-09-01 15:42:38 +00:00
>STYA ZPQuickPtr1
2016-09-02 15:14:24 +00:00
ldy #S.DIR.F
lda (ZPQuickPtr1),y
and #S.DIR.F.NOMORE
bne .9
2016-09-01 15:42:38 +00:00
ldy #S.DIR.PRODOS.REF
lda (ZPQuickPtr1),y
2016-09-21 15:20:37 +00:00
beq K.READDIRA.ROOT
jmp K.READDIRA.DIR
2016-09-01 15:42:38 +00:00
2016-09-02 15:14:24 +00:00
.9 lda #0
sec CS,A=0 no more entry
2016-09-21 15:20:37 +00:00
K.READDIRA.RTS rts
2016-09-02 15:14:24 +00:00
2016-09-21 15:20:37 +00:00
K.READDIRA.ROOT stz MLICALL.PARAMS+1 All Volumes
2016-09-02 15:14:24 +00:00
>LDYAI KrnBuffer256
2016-09-01 15:42:38 +00:00
>STYA MLICALL.PARAMS+2
2016-09-02 15:14:24 +00:00
>STYA ZPQuickPtr2 For PASS #2
2016-09-01 15:42:38 +00:00
>MLICALL MLIONLINE
2016-09-21 15:20:37 +00:00
bcs K.READDIRA.RTS
2016-09-01 15:42:38 +00:00
2016-09-02 15:14:24 +00:00
lda #1 +1 for Ending 0
2016-09-01 15:42:38 +00:00
sta BufSize
stz BufSize+1
ldy #0
2016-09-02 15:14:24 +00:00
.1 lda KrnBuffer256,y
2016-09-01 15:42:38 +00:00
and #$0F
beq .2
2016-09-02 15:14:24 +00:00
sec Add Filelen +1
2016-09-01 15:42:38 +00:00
adc BufSize
sta BufSize
2016-09-02 15:14:24 +00:00
bcc .11
inc BufSize+1
2016-08-24 15:42:33 +00:00
2016-09-02 15:14:24 +00:00
.11 lda #S.STAT
2016-09-01 15:42:38 +00:00
adc BufSize
sta BufSize
2016-09-02 15:14:24 +00:00
bcc .12
inc BufSize+1
.12 inx
2016-09-01 15:42:38 +00:00
.2 tya
clc
2016-09-01 15:42:38 +00:00
adc #16
tay
2016-09-02 15:14:24 +00:00
bcc .1 loop until 256 bytes scanned
2016-09-01 15:42:38 +00:00
txa
2016-09-21 15:20:37 +00:00
beq K.READDIRA.RTS A=0, CS no more DIRENT
2016-09-01 15:42:38 +00:00
2016-09-02 15:14:24 +00:00
sta EntryCount
2016-09-01 15:42:38 +00:00
>PUSHW BufSize
2016-09-02 15:14:24 +00:00
>PUSHBI S.MEM.F.INIT0
2016-09-21 15:20:37 +00:00
jsr K.GetMem
bcs K.READDIRA.RTS
2016-09-02 15:14:24 +00:00
stx hDIRENT
2016-09-01 15:42:38 +00:00
>STYA ZPQuickPtr3
2016-09-02 06:09:44 +00:00
>STYA ZPQuickPtr4
2016-09-02 15:14:24 +00:00
.3 lda (ZPQuickPtr2)
2016-09-02 06:09:44 +00:00
and #$0F
2016-09-02 15:14:24 +00:00
beq .88
tay
tax
sta (ZPQuickPtr3)
inc
sta VolName Build a string with leading / for GetFileInfo
2016-09-02 06:09:44 +00:00
2016-09-02 15:14:24 +00:00
.4 lda (ZPQuickPtr2),y
sta (ZPQuickPtr3),y
sta VolName+1,y
dey
bne .4
lda #'/'
sta VolName+1
2016-09-01 15:42:38 +00:00
2016-09-02 15:14:24 +00:00
txa
2016-09-01 15:42:38 +00:00
sec
2016-09-02 15:14:24 +00:00
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
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.READDIRA.DIR ldy #S.DIR.PRODOS.REF
lda (ZPQuickPtr1),y
sta MLICALL.PARAMS+1
2016-09-02 06:09:44 +00:00
>PUSHWI 512 Get a 512 bytes buffer for reading dir...
>PUSHBI 0
2016-09-21 15:20:37 +00:00
jsr K.GetMem
bcs .99
2016-09-21 15:20:37 +00:00
stx K.READDIRA.hMem
2016-09-02 15:14:24 +00:00
>STYA MLICALL.PARAMS+2 For reading
pha
tya
2016-09-21 15:20:37 +00:00
* 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
2016-09-21 15:20:37 +00:00
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
2016-09-21 15:20:37 +00:00
jsr K.GetMem
bcs .98
2016-09-21 15:20:37 +00:00
stx K.READDIRA.hDIR
>STYA ZPQuickPtr4
.72 jsr DecEntryCount
bcc .80 no more file to list...
lda (ZPQuickPtr3)
beq .78
2016-09-21 15:20:37 +00:00
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
2016-09-21 15:20:37 +00:00
lda K.READDIRA.hDIR
tax
2016-09-21 15:20:37 +00:00
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
2016-09-21 15:20:37 +00:00
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
2016-09-21 15:20:37 +00:00
.4 jsr K.READDIRA.AddBufSize
inc EntryCount2Return
rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.READDIRA.ADD and #$F0
cmp #$F0 Volume header ?
bne .10
lda #1
2016-09-21 15:20:37 +00:00
jsr K.READDIRA.AddToBuf
lda #'.'
2016-09-21 15:20:37 +00:00
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
2016-09-21 15:20:37 +00:00
jsr K.READDIRA.AddToBuf
lda #'.'
2016-09-21 15:20:37 +00:00
jsr K.READDIRA.AddToBuf
jsr K.READDIRA.AddToBuf
.20 cmp #$D0 directory ?
bne .30
lda (ZPQuickPtr3)
and #$0F get filename len
tax
2016-09-21 15:20:37 +00:00
jsr K.READDIRA.AddToBuf
ldy #1
.21 lda (ZPQuickPtr3),y
2016-09-21 15:20:37 +00:00
jsr K.READDIRA.AddToBuf
2016-09-02 15:14:24 +00:00
iny
dex
bne .21
2016-09-02 15:14:24 +00:00
.30
.80 lda ZPQuickPtr4
2016-09-02 06:09:44 +00:00
clc
adc #S.STAT
sta ZPQuickPtr4
bcc .8
inc ZPQuickPtr4+1
.8 rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.READDIRA.AddBufSize
clc
adc BufSize
sta BufSize
bcc .9
inc BufSize+1
.9 rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
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
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.READDIRA.hMem .BS 1
K.READDIRA.hDIR .BS 1
2016-08-24 15:42:33 +00:00
*--------------------------------------
* In :
* A = hDIR
2016-08-24 15:42:33 +00:00
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.CLOSEDIRA jsr S.PFTCHECKDIRA
2016-09-01 15:42:38 +00:00
sta hDIR
2016-09-21 15:20:37 +00:00
jsr K.GetMemPtrA
2016-09-01 15:42:38 +00:00
>STYA ZPQuickPtr1
2016-09-21 15:20:37 +00:00
K.CLOSEDIRA.1 ldy #S.DIR.PRODOS.REF
2016-09-01 15:42:38 +00:00
lda (ZPQuickPtr1),y
beq .1
sta MLICALL.PARAMS+1
>MLICALL MLICLOSE
.1 ldy #S.DIR.PRODOS.IOBUF
lda (ZPQuickPtr1),y
beq .2
2016-09-21 15:20:37 +00:00
jsr K.FreeMemA
2016-09-01 15:42:38 +00:00
.2 lda hDIR
2016-09-21 15:20:37 +00:00
jsr K.FreeMemA
clc
2016-08-24 15:42:33 +00:00
rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
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
*--------------------------------------
2016-09-01 15:42:38 +00:00
hONLINE .BS 1
2016-09-02 15:14:24 +00:00
hDIRENT .BS 1
2016-09-01 15:42:38 +00:00
BufSize .BS 2
EntryLength .BS 1
EntryPerBlock .BS 1
EntryCount .BS 2
EntryCountIB .BS 1
EntryCount2Return .BS 1
2016-09-02 15:14:24 +00:00
VolName .BS 17
2016-08-24 15:42:33 +00:00
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.DIR
LOAD SYS/KERNEL.S
ASM