A2osX/SYS/KERNEL.S.DIR.txt
Rémy GIBERT 6fea4ec153 Time API : Work In Progress,used in SHELL For Testing
Kernel : Dual Bank implemented
2016-09-05 18:00:11 +02:00

281 lines
5.4 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
*--------------------------------------
S.OPENDIRYA jsr S.PFTCHECKPATHYA
>STYA ZPQuickPtr2
>STYA MLICALL.PARAMS+1 For MLIOPEN
>PUSHWI S.DIR.PRODOS
>PUSHBI S.MEM.F.INIT0
jsr S.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 S.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 S.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
*--------------------------------------
S.READDIRA jsr S.PFTCHECKDIRA
jsr S.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 S.READDIRA.ROOT
jmp S.READDIRA.DIR
.9 lda #0
sec CS,A=0 no more entry
S.READDIRA.RTS rts
S.READDIRA.ROOT stz MLICALL.PARAMS+1 All Volumes
>LDYAI KrnBuffer256
>STYA MLICALL.PARAMS+2
>STYA ZPQuickPtr2 For PASS #2
>MLICALL MLIONLINE
bcs S.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 S.READDIRA.RTS A=0, CS no more DIRENT
sta EntryCount
>PUSHW BufSize
>PUSHBI S.MEM.F.INIT0
jsr S.GetMem
bcs S.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
S.READDIRA.DIR
ldx #3
ldy #S.STAT.TYPE
.7 lda MLICALL.PARAMS+S.FILEINFO.TYPE,x
sta (ZPQuickPtr3),y
iny
dex
bne .7
clc
rts
*--------------------------------------
* In :
* A = hDIR
*--------------------------------------
S.CLOSEDIRA jsr S.PFTCHECKDIRA
sta hDIR
jsr S.GetMemPtrA
>STYA ZPQuickPtr1
S.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 S.FreeMemA
.2 lda hDIR
jsr S.FreeMemA
clc
rts
*--------------------------------------
S.MKDIRYA jsr S.PFTCHECKPATHYA
>STYA MLICALL.PARAMS+1
lda #$C3
sta MLICALL.PARAMS+3 Access
lda #$0F
sta MLICALL.PARAMS+4 type=Directory
lda #$0D Storage=Linked List
sta MLICALL.PARAMS+7
>MLICALL MLICREATE
rts
*--------------------------------------
hONLINE .BS 1
hDIRENT .BS 1
BufSize .BS 2
EntryCount .BS 1
VolName .BS 17
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.DIR
LOAD SYS/KERNEL.S
ASM