A2osX/SYS/KERNEL.S.DIRENT.txt

613 lines
12 KiB
Plaintext
Raw Normal View History

2017-12-22 21:24:30 +00:00
NEW
PREFIX /A2OSX.BUILD
2017-12-22 21:24:30 +00:00
AUTO 4,1
*/--------------------------------------
2018-06-21 15:12:10 +00:00
* # OpenDir
2018-06-14 15:31:36 +00:00
* **In:**
* Y,A = PATH (C-String)
2018-06-14 15:31:36 +00:00
* **Out:**
* CC : success
* A = hDIR
* CS : error
* A = EC
*\--------------------------------------
2018-06-21 15:12:10 +00:00
K.OpenDir jsr PFT.CheckPathYA
2017-01-12 17:43:45 +00:00
>STYA ZPPtr2
jsr STDIO.SetMLIPathYA For GETFILEINFO,MLIOPEN
2016-08-28 20:48:01 +00:00
2018-07-10 15:33:13 +00:00
>LDYAI S.FD.DIR
2018-06-21 15:12:10 +00:00
jsr K.GetMem0
bcs .99
2016-09-01 15:42:38 +00:00
2017-01-12 17:43:45 +00:00
>STYA ZPPtr1
2017-09-29 06:36:27 +00:00
stx .8+1
2016-09-01 15:42:38 +00:00
2018-07-10 15:33:13 +00:00
ldy #S.FD.T Done by GetMem0
lda #S.FD.T.DIR
sta (ZPPtr1),y
ldy #1
lda (ZPPtr2),y One char ?
beq .8 No, Go open dir....
.7 >MLICALL MLIGETFILEINFO
bcs .98 file/dir does not exists....quit
lda K.MLI.PARAMS+4
cmp #$0F Directory ?
bne .98
jsr STDIO.SetIOBUF
2017-01-12 17:43:45 +00:00
2016-09-01 15:42:38 +00:00
bcs .98
>MLICALL MLIOPEN
bcs .98
lda K.MLI.PARAMS+5 get ref_num
2018-07-10 15:33:13 +00:00
ldy #S.FD.DIR.REF
2017-01-12 17:43:45 +00:00
sta (ZPPtr1),y
2016-08-24 15:42:33 +00:00
2017-09-29 06:36:27 +00:00
.8 lda #$ff Self Modified
2016-08-24 15:42:33 +00:00
clc
rts
2016-09-01 15:42:38 +00:00
.98 pha save MLI error
2017-09-29 06:36:27 +00:00
lda .8+1
2018-06-21 15:12:10 +00:00
jsr K.CloseDir
2016-09-01 15:42:38 +00:00
pla get back MLI error
sec
.99 rts
*/--------------------------------------
2018-06-21 15:12:10 +00:00
* # ReadDir
2018-06-14 15:31:36 +00:00
* **In:**
* A = hDIR
2018-06-14 15:31:36 +00:00
* **Out:**
* CC : success
* X = hDIRENT
* Y,A = PTR to S.DIRENT
* CS : error
* A = EC
* note : A = 0 means no more entry
*\--------------------------------------
2018-06-21 15:12:10 +00:00
K.ReadDir.hDir .BS 1
K.ReadDir.hMem .BS 1
K.ReadDir.BufSize .BS 2
K.ReadDir.ECIB .BS 1
*--S.DIR Cache ------------------------
2018-06-21 15:12:10 +00:00
K.ReadDir.EL .BS 1
K.ReadDir.EPB .BS 1
K.ReadDir.EC .BS 2
*--------------------------------------
2018-06-22 14:59:24 +00:00
K.ReadDir jsr PFT.CheckNodeA
2018-06-21 15:12:10 +00:00
sta K.ReadDir.hDir
jsr K.GetMemPtr
2017-01-12 17:43:45 +00:00
>STYA ZPPtr1
2016-09-02 15:14:24 +00:00
2018-07-10 15:33:13 +00:00
ldy #S.FD.DIR.REF
2017-01-12 17:43:45 +00:00
lda (ZPPtr1),y
2018-06-21 15:12:10 +00:00
beq K.ReadDir.ROOT
jmp K.ReadDir.DIR
2016-09-01 15:42:38 +00:00
2018-06-21 15:12:10 +00:00
K.ReadDir.NoMore
lda #0
2016-09-02 15:14:24 +00:00
sec CS,A=0 no more entry
rts
*--------------------------------------
2018-06-21 15:12:10 +00:00
K.ReadDir.ROOT
2018-07-10 15:33:13 +00:00
ldy #S.FD.DIR.FC did we already returned something ?
2017-01-12 17:43:45 +00:00
lda (ZPPtr1),y
2018-06-21 15:12:10 +00:00
bne K.ReadDir.NoMore
stz K.MLI.PARAMS+1 All Volumes
>LDYAI K.Buf256
>STYA K.MLI.PARAMS+2
2017-01-12 17:43:45 +00:00
>STYA ZPPtr2
2016-09-01 15:42:38 +00:00
>MLICALL MLIONLINE
bcc .10
2016-09-01 15:42:38 +00:00
sec
.99 rts
* pass #1 compute BufSize.....
.10 lda #1 +1 for Ending 0
2018-06-21 15:12:10 +00:00
sta K.ReadDir.BufSize
stz K.ReadDir.BufSize+1
2018-06-21 15:12:10 +00:00
stz K.ReadDir.EC
2016-09-01 15:42:38 +00:00
ldy #0
2017-01-12 17:43:45 +00:00
.1 lda (ZPPtr2),y
2016-09-01 15:42:38 +00:00
and #$0F
beq .2
2018-06-21 15:12:10 +00:00
inc K.ReadDir.EC increase entry count
2016-09-02 15:14:24 +00:00
sec Add Filelen +1
adc #S.STAT will ends with CC
2018-06-21 15:12:10 +00:00
adc K.ReadDir.BufSize
sta K.ReadDir.BufSize
bcc .2
2018-06-21 15:12:10 +00:00
inc K.ReadDir.BufSize+1
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
* pass #2 Fill Buffer...
2018-06-21 15:12:10 +00:00
jsr K.ReadDir.GetBuf
bcs .99
2016-09-02 06:09:44 +00:00
2017-01-12 17:43:45 +00:00
.3 lda (ZPPtr2)
2016-09-02 06:09:44 +00:00
and #$0F
2016-09-02 15:14:24 +00:00
beq .88
2016-09-02 15:14:24 +00:00
tax
inc
sta K.MLI.PATH
lda #'/'
sta K.MLI.PATH+1
ldy #1
2016-09-02 06:09:44 +00:00
2017-01-12 17:43:45 +00:00
.4 lda (ZPPtr2),y
sta K.MLI.PATH+1,y
2018-06-21 15:12:10 +00:00
jsr K.ReadDir.AddToBuf
iny
dex
2016-09-02 15:14:24 +00:00
bne .4
2016-09-01 15:42:38 +00:00
txa Add ending 0 for C String
2018-06-21 15:12:10 +00:00
jsr K.ReadDir.AddToBuf
2018-06-21 15:12:10 +00:00
jsr K.ReadDir.ClrStat
2017-01-12 17:43:45 +00:00
lda (ZPPtr2)
asl DRIVE in Carry
pha
lda #0
rol
inc
sta K.S.STAT+S.STAT.P.DRIVE
pla
lsr CC
lsr
lsr
lsr
lsr
sta K.S.STAT+S.STAT.P.SLOT
>LDYAI K.MLI.PATH
>STYA K.MLI.PARAMS+1
2016-09-02 15:14:24 +00:00
>MLICALL MLIGETFILEINFO
sta K.S.STAT+S.STAT.P.DEVSTATUS
2016-09-02 15:14:24 +00:00
bcs .80
>LDYA K.MLI.PARAMS+5 AUXTYPE=TOTAL BLOCKS
>STYA K.S.STAT+S.STAT.P.DEVBLOCKS
>LDYA K.MLI.PARAMS+8
>STYA K.S.STAT+S.STAT.BLOCKS
2016-09-02 15:14:24 +00:00
2018-06-21 15:12:10 +00:00
.80 jsr K.ReadDir.ADDSTAT
2018-06-21 15:12:10 +00:00
dec K.ReadDir.EC
beq .5
2016-09-02 15:14:24 +00:00
2017-01-12 17:43:45 +00:00
.88 lda ZPPtr2
2016-09-02 15:14:24 +00:00
clc
adc #16
2017-01-12 17:43:45 +00:00
sta ZPPtr2
bcc .3
2017-01-12 17:43:45 +00:00
inc ZPPtr2+1
bra .3
* lda #0 done by S.MEM.F.INIT0
2017-01-12 17:43:45 +00:00
* sta (ZPPtr4) Ending 0
2016-09-02 15:14:24 +00:00
2018-07-10 15:33:13 +00:00
.5 ldy #S.FD.DIR.FC
lda #16
sta (ZPPtr1),y Flag that we returned somthing for next time
2017-09-29 06:36:27 +00:00
2018-06-21 15:12:10 +00:00
jmp K.ReadDir.EXIT
*--------------------------------------
2018-06-21 15:12:10 +00:00
K.ReadDir.DIR sta K.MLI.PARAMS+1 A=#S.DIR.PRODOS.REF
2016-09-02 06:09:44 +00:00
>LDYAI 512 Get a 512 bytes buffer for reading dir...
2018-06-21 15:12:10 +00:00
jsr K.GetMem
bcs .99
2018-06-21 15:12:10 +00:00
stx K.ReadDir.hMem
2016-09-02 15:14:24 +00:00
>STYA K.MLI.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
sta ZPPtr2 PTR to Buffer for PASS #1
sta ZPPtr3 PTR to Buffer for PASS #2
pla
adc #0
sta ZPPtr2+1 PTR to Buffer for PASS #1
sta ZPPtr3+1 PTR to Buffer for PASS #2
>LDYAI 512
>STYA K.MLI.PARAMS+4
>MLICALL MLIREAD Read A block from directory
bcs .98
2018-07-10 15:33:13 +00:00
ldy #S.FD.DIR.EL Check if first run....
2017-01-12 17:43:45 +00:00
lda (ZPPtr1),y
bne .2 no, we have all we need....
2016-09-23 06:00:00 +00:00
ldy #$1f+3
ldx #3
2018-06-21 15:12:10 +00:00
.1 lda (ZPPtr2),y Get K.ReadDir.EL.... From Block
sta K.ReadDir.EL,x
dey
2016-09-23 06:00:00 +00:00
dex
bpl .1
2018-06-21 15:12:10 +00:00
inc K.ReadDir.EC Add one to EC because we include VOL/DIR Header
bne .4
2018-06-21 15:12:10 +00:00
inc K.ReadDir.EC+1 ...and ProDOS does NOT include header entry in EC
bra .4
2018-06-21 15:12:10 +00:00
.98 jsr K.ReadDir.CLN
sec
.99 rts
2018-07-10 15:33:13 +00:00
.2 ldy #S.FD.DIR.EL+3
ldx #3
2017-01-12 17:43:45 +00:00
.3 lda (ZPPtr1),y get this session parameters from S.DIR
2018-06-21 15:12:10 +00:00
sta K.ReadDir.EL,x
dey
dex
bpl .3
2018-06-21 15:12:10 +00:00
.4 lda K.ReadDir.EC
eor #$ff
tax
2018-06-21 15:12:10 +00:00
lda K.ReadDir.EC+1
eor #$ff
tay
inx Any entry remaining ?
bne .5
iny
beq .98 no...exit
* pass #1 compute BufSize...
2018-06-21 15:12:10 +00:00
.5 lda K.ReadDir.EPB
sta K.ReadDir.ECIB
lda #1 For Ending 0
2018-06-21 15:12:10 +00:00
sta K.ReadDir.BufSize
stz K.ReadDir.BufSize+1
2018-06-21 15:12:10 +00:00
K.ReadDir.DIR1 lda (ZPPtr2) X = EntryCount In This Block
beq .7 Free slot....goto next
and #$F0 get storage_type
cmp #$F0 Volume header ?
beq .1
cmp #$E0 directory header ?
beq .2
lda (ZPPtr2) regular DIR or File, get LEN
and #$F compute filename len
sec add "#<filename>" + S.STAT
adc #S.STAT
.HS 2C bit abs
.1 lda #2+S.STAT add "1." string + S.STAT
.HS 2C bit abs
.2 lda #2+S.STAT+3+S.STAT add "1." + S.STAT + "2.." + S.STAT...
clc
2018-06-21 15:12:10 +00:00
adc K.ReadDir.BufSize
sta K.ReadDir.BufSize
bcc .3
2018-06-21 15:12:10 +00:00
inc K.ReadDir.BufSize+1
.3 inx
bne .7
iny
2018-06-21 15:12:10 +00:00
bra K.ReadDir.DIR2 we reached last entry in whole DIR
2017-01-12 17:43:45 +00:00
.7 lda ZPPtr2
clc
2018-06-21 15:12:10 +00:00
adc K.ReadDir.EL
2017-01-12 17:43:45 +00:00
sta ZPPtr2
bcc .8
2017-01-12 17:43:45 +00:00
inc ZPPtr2+1
2018-06-21 15:12:10 +00:00
.8 dec K.ReadDir.ECIB
bne K.ReadDir.DIR1
2017-01-12 17:43:45 +00:00
* pass #2 Fill Buffer...(ZPPtr1 & Ptr2 can now be trashed)
2018-06-21 15:12:10 +00:00
K.ReadDir.DIR2 jsr K.ReadDir.GetBuf
bcs .9
2018-06-21 15:12:10 +00:00
lda K.ReadDir.EPB
sta K.ReadDir.ECIB
2017-01-12 17:43:45 +00:00
.1 lda (ZPPtr3)
beq .7 Empty slot, skip
and #$F0
cmp #$F0 Vol Header ?
bne .2
2018-06-21 15:12:10 +00:00
jsr K.ReadDir.ADD.
bra .6
.2 cmp #$E0 Dir Header ?
bne .3
2018-06-21 15:12:10 +00:00
jsr K.ReadDir.ADD.
jsr K.ReadDir.ADD..
bra .6
2018-06-21 15:12:10 +00:00
.3 jsr K.ReadDir.AddFNToBuf
jsr K.ReadDir.ClrStat
2017-01-12 17:43:45 +00:00
lda (ZPPtr3)
and #$F0
cmp #$D0 Directory ?
bne .5
2018-06-21 15:12:10 +00:00
jsr K.ReadDir.ADDD
bra .6
2018-06-21 15:12:10 +00:00
.5 jsr K.ReadDir.ADDF
2018-06-21 15:12:10 +00:00
.6 lda K.ReadDir.EC decrease global counter...
sec
sbc #1
2018-06-21 15:12:10 +00:00
sta K.ReadDir.EC
2018-06-21 15:12:10 +00:00
lda K.ReadDir.EC+1
sbc #0
2018-06-21 15:12:10 +00:00
sta K.ReadDir.EC+1
ora K.ReadDir.EC
beq .8 0! no more files in DIR
2018-06-21 15:12:10 +00:00
.7 dec K.ReadDir.ECIB 0! no more file in block
beq .8
2017-01-12 17:43:45 +00:00
lda ZPPtr3
clc
2018-06-21 15:12:10 +00:00
adc K.ReadDir.EL
2017-01-12 17:43:45 +00:00
sta ZPPtr3
bcc .1
2017-01-12 17:43:45 +00:00
inc ZPPtr3+1
bra .1
2018-06-21 15:12:10 +00:00
.9 jsr K.ReadDir.CLN
sec
rts
.8
* lda #0 S.MEM.F.INIT0 already did this
2017-09-29 06:36:27 +00:00
* sta (ZPPtr4) Ending 0
2018-06-21 15:12:10 +00:00
lda K.ReadDir.hDir Restore ZPPtr1 trashed by STR API calls
jsr K.GetMemPtr
2017-01-12 17:43:45 +00:00
>STYA ZPPtr1
ldx #3
2018-07-10 15:33:13 +00:00
ldy #S.FD.DIR.EL+3
2018-06-21 15:12:10 +00:00
.81 lda K.ReadDir.EL,x Store back this session prameters to S.DIR
2017-01-12 17:43:45 +00:00
sta (ZPPtr1),y
dey
dex
bpl .81
2018-06-21 15:12:10 +00:00
jsr K.ReadDir.CLN Discard READBUFFER
2018-06-21 15:12:10 +00:00
K.ReadDir.EXIT
2017-09-29 06:36:27 +00:00
ldx #$ff Self Modified : hDIRENT
txa
2018-06-21 15:12:10 +00:00
jmp K.GetMemPtr
*--------------------------------------
2018-06-21 15:12:10 +00:00
K.ReadDir.CLN pha
lda K.ReadDir.hMem
2018-06-22 06:24:35 +00:00
jsr K.FreeMem
pla
rts
*--------------------------------------
2018-06-21 15:12:10 +00:00
K.ReadDir.GetBuf
>LDYA K.ReadDir.BufSize Get a BufSize bytes buffer for storing results
jsr K.GetMem0 make sure 0 filled
bcs .9
2018-06-21 15:12:10 +00:00
stx K.ReadDir.EXIT+1
2017-01-12 17:43:45 +00:00
>STYA ZPPtr4
.9 rts
*--------------------------------------
2018-06-21 15:12:10 +00:00
K.ReadDir.ADD. ldx #1 filename="1."
.HS 2C bit abs
2018-06-21 15:12:10 +00:00
K.ReadDir.ADD..
ldx #2 filename="2.."
lda #'.'
2018-06-21 15:12:10 +00:00
.1 jsr K.ReadDir.AddToBuf Add X dot(s)
dex
bne .1
txa
2018-06-21 15:12:10 +00:00
jsr K.ReadDir.AddToBuf Add Ending 0
2018-06-21 15:12:10 +00:00
jsr K.ReadDir.ClrStat
* ldy #$25 total_blocks
2017-01-12 17:43:45 +00:00
* lda (ZPPtr3),y
* sta K.S.STAT+S.STAT.BLOCKS
* iny
2017-01-12 17:43:45 +00:00
* lda (ZPPtr3),y
* sta K.S.STAT+S.STAT.BLOCKS+1
*--------------------------------------
2018-06-21 15:12:10 +00:00
K.ReadDir.ADDD
lda #$0F
sta K.S.STAT+S.STAT.P.TYPE
lda /S.STAT.MODE.DIR
sta K.S.STAT+S.STAT.MODE+1
2018-06-21 15:12:10 +00:00
bra K.ReadDir.AddAccess
*--------------------------------------
2018-06-21 15:12:10 +00:00
K.ReadDir.ADDF
lda /S.STAT.MODE.REG
sta K.S.STAT+S.STAT.MODE+1
ldx #ADDF.DST-ADDF.SRC
.1 ldy ADDF.SRC-1,x
2017-01-12 17:43:45 +00:00
lda (ZPPtr3),y
ldy ADDF.DST-1,x
sta K.S.STAT,y
dex
bne .1
*--------------------------------------
2018-06-21 15:12:10 +00:00
K.ReadDir.AddAccess
ldy #$1E ProDOS Access
2017-01-12 17:43:45 +00:00
lda (ZPPtr3),y
ldx #0
bit #$01 ProDOS R
beq .2
ldx #S.STAT.MODE.RO
.2 bit #$C2 ProDOS D,Rn,W
beq .3
txa
ora #S.STAT.MODE.XO+S.STAT.MODE.WO
.HS 89 bit imm to skip txa
.3 txa
sta K.S.STAT+S.STAT.MODE
*--------------------------------------
2018-06-21 15:12:10 +00:00
K.ReadDir.AddTime
>PUSHWI K.S.STAT+S.STAT.CTIME
lda #$18 creation Date/time
2018-06-21 15:12:10 +00:00
jsr K.ReadDir.ConvertTime
>PUSHWI K.S.STAT+S.STAT.MTIME
lda #$21 mod Date/time
2018-06-21 15:12:10 +00:00
jsr K.ReadDir.ConvertTime
*--------------------------------------
2018-06-21 15:12:10 +00:00
K.ReadDir.AddStat
ldy #S.STAT-1
.1 lda K.S.STAT,y
2017-01-12 17:43:45 +00:00
sta (ZPPtr4),y
dey
bpl .1
2017-01-12 17:43:45 +00:00
lda ZPPtr4
2016-09-02 06:09:44 +00:00
clc
adc #S.STAT
2017-01-12 17:43:45 +00:00
sta ZPPtr4
bcc .8
2017-01-12 17:43:45 +00:00
inc ZPPtr4+1
.8 rts
*--------------------------------------
ADDF.SRC .HS 1013141516171f20
ADDF.DST .DA #S.STAT.P.TYPE,#S.STAT.BLOCKS,#S.STAT.BLOCKS+1
.DA #S.STAT.SIZE,#S.STAT.SIZE+1,#S.STAT.SIZE+2
.DA #S.STAT.P.AUXTYPE,#S.STAT.P.AUXTYPE+1
*--------------------------------------
2018-06-21 15:12:10 +00:00
K.ReadDir.ClrStat
ldx #S.STAT-1
.1 stz K.S.STAT,x
dex
bpl .1
rts
*--------------------------------------
2018-06-21 15:12:10 +00:00
K.ReadDir.AddFNToBuf
ldy #$1C version/min_version for lowercase bitmap
lda (ZPPtr3),y check bxxxxxxx.xxxxxxxx...
bpl .7 not set, no lowercase bitmap present
pha
iny
lda (ZPPtr3),y
pha
lda #$1
sta .2+1
ldy #15
.1 pla
.2 bit #$ff
pha
beq .3
lda (ZPPtr3),y
ora #$20 convert a-z to A-Z adding from $4x to $6x
sta (ZPPtr3),y
.3 asl .2+1
bne .4
rol .2+1
pla
.4 dey
bne .1
pla
.7 lda (ZPPtr3)
and #$0F get filename len
tax
ldy #1
.8 lda (ZPPtr3),y
2018-06-21 15:12:10 +00:00
jsr K.ReadDir.AddToBuf
iny
dex
bne .8
txa
2018-06-21 15:12:10 +00:00
jsr K.ReadDir.AddToBuf
rts
*--------------------------------------
2018-06-21 15:12:10 +00:00
K.ReadDir.AddToBuf
2017-01-12 17:43:45 +00:00
sta (ZPPtr4)
inc ZPPtr4
bne .8
2017-01-12 17:43:45 +00:00
inc ZPPtr4+1
.8 rts
2016-08-24 15:42:33 +00:00
*--------------------------------------
2018-06-21 15:12:10 +00:00
K.ReadDir.ConvertTime
clc
2017-01-12 17:43:45 +00:00
adc ZPPtr3
tay
2017-01-12 17:43:45 +00:00
lda ZPPtr3+1
adc #0
>PUSHYA
>SYSCALL PTime2Time
rts
*/-------------------------------------
2018-06-22 06:24:35 +00:00
* # CloseDir
2018-06-14 15:31:36 +00:00
* **In:**
* A = hDIR
2018-06-14 15:31:36 +00:00
* **Out:**
* none, always succeed.
*\-------------------------------------
2018-06-22 06:24:35 +00:00
K.CloseDir .EQ K.FClose
*--------------------------------------
2016-08-24 15:42:33 +00:00
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.DIRENT
LOAD /A2OSX.SRC/SYS/KERNEL.S
2016-08-24 15:42:33 +00:00
ASM