mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-26 13:49:18 +00:00
553 lines
11 KiB
Plaintext
553 lines
11 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 K.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 K.OPENDIRYA.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 K.OPENDIRYA.hDIR
|
||
clc
|
||
rts
|
||
|
||
.98 pha save MLI error
|
||
jsr K.CLOSEDIRA.1
|
||
pla get back MLI error
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
K.OPENDIRYA.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.hMem .BS 1
|
||
K.READDIRA.hDIRENT .BS 1
|
||
K.READDIRA.BufSize .BS 2
|
||
K.READDIRA.EL .BS 1
|
||
K.READDIRA.EBP .BS 1
|
||
K.READDIRA.EC .BS 2
|
||
K.READDIRA.ECIB .BS 1
|
||
K.READDIRA.EC2Return .BS 1
|
||
*--------------------------------------
|
||
K.READDIRA jsr K.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
|
||
rts
|
||
*--------------------------------------
|
||
K.READDIRA.ROOT stz MLICALL.PARAMS+1 All Volumes
|
||
|
||
>PUSHWI 256 Get a 256 bytes buffer for ONLINE call...
|
||
>PUSHBI 0
|
||
jsr K.GetMem
|
||
bcs .99
|
||
stx K.READDIRA.hMem
|
||
|
||
>STYA MLICALL.PARAMS+2
|
||
>STYA ZPQuickPtr2 For PASS #1 & #2
|
||
>MLICALL MLIONLINE
|
||
bcc .10
|
||
|
||
.98 jsr K.READDIRA.CLN
|
||
sec
|
||
.99 rts
|
||
* pass #1 compute BufSize.....
|
||
.10 lda #1 +1 for Ending 0
|
||
sta K.READDIRA.BufSize
|
||
stz K.READDIRA.BufSize+1
|
||
|
||
stz K.READDIRA.EC
|
||
|
||
ldy #0
|
||
|
||
.1 lda (ZPQuickPtr2),y
|
||
and #$0F
|
||
beq .2
|
||
|
||
inc K.READDIRA.EC increase entry count
|
||
|
||
sec Add Filelen +1
|
||
adc #S.STAT will ends with CC
|
||
adc K.READDIRA.BufSize
|
||
sta K.READDIRA.BufSize
|
||
bcc .2
|
||
inc K.READDIRA.BufSize+1
|
||
|
||
.2 tya
|
||
clc
|
||
adc #16
|
||
tay
|
||
bcc .1 loop until 256 bytes scanned
|
||
|
||
* pass #2 Fill Buffer...
|
||
jsr K.READDIRA.GetBuf
|
||
bcs .98
|
||
|
||
.3 lda (ZPQuickPtr2)
|
||
and #$0F
|
||
beq .88
|
||
|
||
tax
|
||
|
||
>LDYAI ZPQuickPtr4 Store actual PTR for MLIGETFILEINFO
|
||
>STYA MLICALL.PARAMS+1
|
||
|
||
txa
|
||
inc
|
||
jsr K.READDIRA.AddToBuf
|
||
lda #'/'
|
||
jsr K.READDIRA.AddToBuf
|
||
|
||
ldy #1
|
||
|
||
.4 lda (ZPQuickPtr2),y
|
||
jsr K.READDIRA.AddToBuf
|
||
iny
|
||
dex
|
||
bne .4
|
||
|
||
>MLICALL MLIGETFILEINFO
|
||
bcs .80
|
||
|
||
|
||
|
||
.80 jsr K.READDIRA.ADDSTAT
|
||
|
||
.88 lda ZPQuickPtr2
|
||
clc
|
||
adc #16
|
||
sta ZPQuickPtr2
|
||
bcc .89
|
||
inc ZPQuickPtr2+1
|
||
.89 dec K.READDIRA.EC
|
||
bne .3
|
||
|
||
* lda #0 done by S.MEM.F.INIT0
|
||
* sta (ZPQuickPtr4) Ending 0
|
||
|
||
ldy #S.DIR.F
|
||
lda #S.DIR.F.NOMORE
|
||
sta (ZPQuickPtr1),y
|
||
|
||
jsr K.READDIRA.CLN Discard ONLINE BUFFER
|
||
|
||
lda K.READDIRA.hDIRENT
|
||
tax
|
||
jmp K.GetMemPtrA
|
||
*--------------------------------------
|
||
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
|
||
sta ZPQuickPtr2 PTR to Buffer for PASS #1
|
||
sta ZPQuickPtr3 PTR to Buffer for PASS #2
|
||
|
||
pla
|
||
adc #0
|
||
sta ZPQuickPtr2+1 PTR to Buffer for PASS #1
|
||
sta ZPQuickPtr3+1 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 #$1f+3
|
||
ldx #3
|
||
|
||
.1 lda (ZPQuickPtr2),y Get K.READDIRA.EL.... From Block
|
||
sta K.READDIRA.EL,x
|
||
dey
|
||
dex
|
||
bpl .1
|
||
bra .4
|
||
|
||
.98 jsr K.READDIRA.CLN
|
||
sec
|
||
.99 rts
|
||
|
||
.2 ldy #S.DIR.PRODOS.EL+3
|
||
ldx #3
|
||
|
||
.3 lda (ZPQuickPtr1),y get this session parameters from S.DIR
|
||
sta K.READDIRA.EL,x
|
||
dey
|
||
dex
|
||
bpl .3
|
||
|
||
.4 ldx K.READDIRA.EC
|
||
cpx K.READDIRA.EBP
|
||
|
||
lda K.READDIRA.EC+1
|
||
sbc #0
|
||
bcc .5 We have less than EPB to read
|
||
ldx K.READDIRA.EBP
|
||
|
||
.5 stx K.READDIRA.ECIB
|
||
stz K.READDIRA.EC2Return
|
||
|
||
lda #1 For Ending 0
|
||
sta K.READDIRA.BufSize
|
||
stz K.READDIRA.BufSize+1
|
||
|
||
* pass #1 compute BufSize.....
|
||
K.READDIRA.DIR1 lda (ZPQuickPtr2) X = EntryCount In This Block
|
||
beq .7 Free slot....goto next
|
||
|
||
tay save LEN
|
||
|
||
and #$F0 get storage_type
|
||
cmp #$F0 Volume header ?
|
||
beq .1
|
||
|
||
cmp #$E0 directory header ?
|
||
beq .2
|
||
|
||
inc K.READDIRA.EC2Return regular DIR or File....
|
||
|
||
tya
|
||
and #$F get 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
|
||
adc K.READDIRA.BufSize
|
||
sta K.READDIRA.BufSize
|
||
bcc .7
|
||
inc K.READDIRA.BufSize+1
|
||
|
||
.7 lda ZPQuickPtr2
|
||
clc
|
||
adc K.READDIRA.EL
|
||
sta ZPQuickPtr2
|
||
bcc .8
|
||
inc ZPQuickPtr2+1
|
||
|
||
.8 dex
|
||
bne K.READDIRA.DIR1
|
||
|
||
* pass #2 Fill Buffer...
|
||
K.READDIRA.DIR2 jsr K.READDIRA.GetBuf
|
||
bcs .98
|
||
|
||
ldy #S.DIR.PRODOS.EL Check if first run....
|
||
lda (ZPQuickPtr1),y
|
||
bne .73
|
||
|
||
lda (ZPQuickPtr3)
|
||
and #$F0
|
||
cmp #$F0 Vol Header ?
|
||
bne .72
|
||
jsr K.READDIRA.ADD.
|
||
bra .78
|
||
|
||
.72 cmp #$E0 Dir Header ?
|
||
bne .73
|
||
jsr K.READDIRA.ADD.
|
||
jsr K.READDIRA.ADD..
|
||
bra .78
|
||
|
||
.73 lda K.READDIRA.EC
|
||
sec
|
||
sbc #1
|
||
sta K.READDIRA.EC
|
||
bcs .74
|
||
|
||
lda K.READDIRA.EC+1
|
||
sbc #0
|
||
sta K.READDIRA.EC+1 CC, we reached $ffff
|
||
bcc .80 no more file to list...
|
||
|
||
.74 lda (ZPQuickPtr3)
|
||
beq .78
|
||
|
||
and #$F0
|
||
cmp #$D0 Directory ?
|
||
bne .75
|
||
jsr K.READDIRA.ADDD
|
||
bra .78
|
||
|
||
.75 jsr K.READDIRA.ADDF
|
||
|
||
.78 lda ZPQuickPtr3
|
||
clc
|
||
adc K.READDIRA.EL
|
||
sta ZPQuickPtr3
|
||
bcc .79
|
||
inc ZPQuickPtr3+1
|
||
|
||
.79 dec K.READDIRA.ECIB
|
||
bne .72
|
||
|
||
.80
|
||
* lda #0 S.MEM.F.INIT0 already did this
|
||
* sta (ZPQuickPtr4) Ending 0
|
||
|
||
ldx #3
|
||
ldy #S.DIR.PRODOS.EL+3
|
||
|
||
.8 lda K.READDIRA.EL,x Store back this session prameters to S.DIR
|
||
sta (ZPQuickPtr1),y
|
||
dey
|
||
dex
|
||
bpl .8
|
||
|
||
jsr K.READDIRA.CLN Discard READBUFFER
|
||
|
||
lda K.READDIRA.hDIRENT
|
||
tax
|
||
jmp K.GetMemPtrA
|
||
|
||
.98 jsr K.READDIRA.CLN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
K.READDIRA.CLN pha
|
||
lda K.READDIRA.hMem
|
||
jsr K.FreeMemA
|
||
pla
|
||
rts
|
||
*--------------------------------------
|
||
K.READDIRA.GetBuf
|
||
>PUSHW K.READDIRA.BufSize Get a BufSize bytes buffer for storing results
|
||
>PUSHBI S.MEM.F.INIT0 make sure 0 filled
|
||
jsr K.GetMem
|
||
bcs .9
|
||
stx K.READDIRA.hDIRENT
|
||
>STYA ZPQuickPtr4
|
||
.9 rts
|
||
*--------------------------------------
|
||
K.READDIRA.ADD. lda #1
|
||
jsr K.READDIRA.AddToBuf
|
||
lda #'.' filename="1."
|
||
jsr K.READDIRA.AddToBuf
|
||
|
||
jsr K.READDIRA.ClrStat
|
||
|
||
lda #$0F
|
||
sta KrnBuf256+S.STAT.TYPE
|
||
|
||
ldy #$25 total_blocks
|
||
lda (ZPQuickPtr3),y
|
||
sta KrnBuf256+S.STAT.BLOCKS
|
||
iny
|
||
lda (ZPQuickPtr3),y
|
||
sta KrnBuf256+S.STAT.BLOCKS+1
|
||
|
||
bra K.READDIRA.ADDSTAT
|
||
*--------------------------------------
|
||
K.READDIRA.ADD..
|
||
lda #2
|
||
jsr K.READDIRA.AddToBuf
|
||
lda #'.' filename="2.."
|
||
jsr K.READDIRA.AddToBuf
|
||
jsr K.READDIRA.AddToBuf
|
||
|
||
jsr K.READDIRA.ClrStat
|
||
|
||
lda #$0F
|
||
sta KrnBuf256+S.STAT.TYPE
|
||
|
||
bra K.READDIRA.ADDSTAT
|
||
*--------------------------------------
|
||
K.READDIRA.ADDD jsr K.READDIRA.AddFNToBuf
|
||
|
||
jsr K.READDIRA.ClrStat
|
||
|
||
lda #$0F
|
||
sta KrnBuf256+S.STAT.TYPE
|
||
|
||
bra K.READDIRA.ADDSTAT
|
||
*--------------------------------------
|
||
K.READDIRA.ADDF jsr K.READDIRA.AddFNToBuf
|
||
|
||
jsr K.READDIRA.ClrStat
|
||
|
||
ldy #$10 type
|
||
lda (ZPQuickPtr3),y
|
||
sta KrnBuf256+S.STAT.TYPE
|
||
|
||
ldy #$1F auxtype
|
||
lda (ZPQuickPtr3),y
|
||
sta KrnBuf256+S.STAT.AUXTYPE
|
||
iny
|
||
lda (ZPQuickPtr3),y
|
||
sta KrnBuf256+S.STAT.AUXTYPE+1
|
||
|
||
*--------------------------------------
|
||
K.READDIRA.AddStat
|
||
ldy #S.STAT-1
|
||
|
||
.1 lda KrnBuf256,y
|
||
sta (ZPQuickPtr4),y
|
||
dey
|
||
bpl .1
|
||
|
||
lda ZPQuickPtr4
|
||
clc
|
||
adc #S.STAT
|
||
sta ZPQuickPtr4
|
||
bcc .8
|
||
inc ZPQuickPtr4+1
|
||
.8 rts
|
||
*--------------------------------------
|
||
K.READDIRA.ClrStat
|
||
ldx #S.STAT-1
|
||
|
||
.1 stz KrnBuf256,x
|
||
dey
|
||
bpl .1
|
||
rts
|
||
*--------------------------------------
|
||
K.READDIRA.AddFNToBuf
|
||
lda (ZPQuickPtr3)
|
||
and #$0F get filename len
|
||
tax
|
||
jsr K.READDIRA.AddToBuf
|
||
|
||
ldy #1
|
||
|
||
.1 lda (ZPQuickPtr3),y
|
||
jsr K.READDIRA.AddToBuf
|
||
iny
|
||
dex
|
||
bne .1
|
||
rts
|
||
*--------------------------------------
|
||
K.READDIRA.AddToBuf
|
||
sta (ZPQuickPtr4)
|
||
inc ZPQuickPtr4
|
||
bne .8
|
||
inc ZPQuickPtr4+1
|
||
.8 rts
|
||
*--------------------------------------
|
||
ldy #S.STAT.BLKSIZE+1
|
||
lda #2 Block size is $200 for ProDOS
|
||
sta (ZPQuickPtr3),y
|
||
*--------------------------------------
|
||
* In :
|
||
* A = hDIR
|
||
*--------------------------------------
|
||
K.CLOSEDIRA jsr K.PFTCheckDirA
|
||
pha
|
||
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 pla
|
||
jsr K.FreeMemA
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
K.MKDIRYA jsr K.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
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE SYS/KERNEL.S.DIR
|
||
LOAD SYS/KERNEL.S
|
||
ASM
|