A2osX/SYS/KERNEL.S.DIR.txt

630 lines
13 KiB
Plaintext
Raw Normal View History

2016-08-24 15:42:33 +00:00
PR#3
PREFIX /A2OSX.SRC
LOMEM $900
2016-08-24 15:42:33 +00:00
INC 1
AUTO 6
.LIST OFF
*/--------------------------------------
* #OpenDirYA
* ##In:
2016-08-24 15:42:33 +00:00
* Y,A = PATH (PSTR)
* ##Out:
* CC : success
* A = hDIR
* CS : error
* A = EC
*\--------------------------------------
K.OpenDirYA jsr PFT.CheckPathYA
2017-01-12 17:43:45 +00:00
>STYA ZPPtr2
>STYA MLICALL.PARAMS+1 For GETFILEINFO,MLIOPEN
2016-08-28 20:48:01 +00:00
>PUSHWI S.NODE.DIR
2016-09-01 15:42:38 +00:00
>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
2017-01-12 17:43:45 +00:00
>STYA ZPPtr1
stx K.ReadDirA.hDir
2016-09-01 15:42:38 +00:00
2017-01-12 17:43:45 +00:00
lda (ZPPtr2)
2016-09-01 15:42:38 +00:00
cmp #1 One char ?
bne .7 No, Go open dir....
tay Y=1
2017-01-12 17:43:45 +00:00
lda (ZPPtr2),y
2016-09-01 15:42:38 +00:00
cmp #'/' Root required ?
beq .8 Yes, Go for ONLINE Call (S.DIR.PRODOS.REF=0)
lda #SYSMGR.ERRSYN
sec
.9 rts
.7 >MLICALL MLIGETFILEINFO
bcs .98 file/dir does not exists....quit
lda MLICALL.PARAMS+4
cmp #$0F Directory ?
bne .98
2017-01-12 17:43:45 +00:00
jsr FILE.SetIOBUF
2016-09-01 15:42:38 +00:00
bcs .98
>MLICALL MLIOPEN
bcs .98
lda MLICALL.PARAMS+5 get ref_num
ldy #S.NODE.DIR.REF
2017-01-12 17:43:45 +00:00
sta (ZPPtr1),y
2016-08-24 15:42:33 +00:00
.8 lda K.ReadDirA.hDir
2016-08-24 15:42:33 +00:00
clc
rts
2016-09-01 15:42:38 +00:00
.98 pha save MLI error
jsr K.CloseDirA.1
2016-09-01 15:42:38 +00:00
pla get back MLI error
sec
.99 rts
*/--------------------------------------
* #ReadDirA
* ##In:
* A = hDIR
* ##Out:
* CC : success
* X = hDIRENT
* Y,A = PTR to S.DIRENT
* CS : error
* A = EC
* note : A = 0 means no more entry
*\--------------------------------------
K.ReadDirA.hDir .BS 1
K.ReadDirA.hMem .BS 1
K.ReadDirA.hDIRENT .BS 1
K.ReadDirA.BufSize .BS 2
K.ReadDirA.ECIB .BS 1
*--S.DIR Cache ------------------------
K.ReadDirA.EL .BS 1
K.ReadDirA.EPB .BS 1
K.ReadDirA.EC .BS 2
*--------------------------------------
K.ReadDirA jsr PFT.CheckNodeA
sta K.ReadDirA.hDir
2016-09-21 15:20:37 +00:00
jsr K.GetMemPtrA
2017-01-12 17:43:45 +00:00
>STYA ZPPtr1
2016-09-02 15:14:24 +00:00
ldy #S.NODE.DIR.REF
2017-01-12 17:43:45 +00:00
lda (ZPPtr1),y
beq K.ReadDirA.ROOT
jmp K.ReadDirA.DIR
2016-09-01 15:42:38 +00:00
K.ReadDirA.NoMore
lda #0
2016-09-02 15:14:24 +00:00
sec CS,A=0 no more entry
rts
*--------------------------------------
K.ReadDirA.ROOT ldy #S.NODE.DIR.FC did we already returned something ?
2017-01-12 17:43:45 +00:00
lda (ZPPtr1),y
bne K.ReadDirA.NoMore
stz MLICALL.PARAMS+1 All Volumes
>LDYAI KrnBuf256
2016-09-01 15:42:38 +00:00
>STYA MLICALL.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
sta K.ReadDirA.BufSize
stz K.ReadDirA.BufSize+1
stz K.ReadDirA.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
inc K.ReadDirA.EC increase entry count
2016-09-02 15:14:24 +00:00
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
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...
jsr K.ReadDirA.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
jsr K.ReadDirA.AddToBuf
inc
sta KrnOut256
lda #'/'
sta KrnOut256+1
ldy #1
2016-09-02 06:09:44 +00:00
2017-01-12 17:43:45 +00:00
.4 lda (ZPPtr2),y
sta KrnOut256+1,y
jsr K.ReadDirA.AddToBuf
iny
dex
2016-09-02 15:14:24 +00:00
bne .4
2016-09-01 15:42:38 +00:00
jsr K.ReadDirA.ClrStat
2017-01-12 17:43:45 +00:00
lda (ZPPtr2)
asl DRIVE in Carry
pha
lda #0
rol
inc
sta KrnSTAT+S.STAT.P.DRIVE
pla
lsr CC
lsr
lsr
lsr
lsr
sta KrnSTAT+S.STAT.P.SLOT
>LDYAI KrnOut256
>STYA MLICALL.PARAMS+1
2016-09-02 15:14:24 +00:00
>MLICALL MLIGETFILEINFO
sta KrnSTAT+S.STAT.P.DEVSTATUS
2016-09-02 15:14:24 +00:00
bcs .80
>LDYA MLICALL.PARAMS+5 AUXTYPE=TOTAL BLOCKS
>STYA KrnSTAT+S.STAT.P.DEVBLOCKS
>LDYA MLICALL.PARAMS+8
>STYA KrnSTAT+S.STAT.BLOCKS
2016-09-02 15:14:24 +00:00
.80 jsr K.ReadDirA.ADDSTAT
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
2016-09-02 15:14:24 +00:00
bcc .89
2017-01-12 17:43:45 +00:00
inc ZPPtr2+1
.89 dec K.ReadDirA.EC
2016-09-02 15:14:24 +00:00
bne .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
ldy #S.NODE.DIR.FC
lda #16
2017-01-12 17:43:45 +00:00
sta (ZPPtr1),y Flag that we returned somthing for next time
lda K.ReadDirA.hDIRENT
tax
jmp K.GetMemPtrA
*--------------------------------------
K.ReadDirA.DIR sta MLICALL.PARAMS+1 A=#S.DIR.PRODOS.REF
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
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
2017-01-12 17:43:45 +00:00
sta ZPPtr2 PTR to Buffer for PASS #1
sta ZPPtr3 PTR to Buffer for PASS #2
pla
adc #0
2017-01-12 17:43:45 +00:00
sta ZPPtr2+1 PTR to Buffer for PASS #1
sta ZPPtr3+1 PTR to Buffer for PASS #2
>LDYAI 512
>STYA MLICALL.PARAMS+4
>MLICALL MLIREAD Read A block from directory
bcs .98
ldy #S.NODE.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
2017-01-12 17:43:45 +00:00
.1 lda (ZPPtr2),y Get K.ReadDirA.EL.... From Block
sta K.ReadDirA.EL,x
dey
2016-09-23 06:00:00 +00:00
dex
bpl .1
inc K.ReadDirA.EC Add one to EC because we include VOL/DIR Header
bne .4
inc K.ReadDirA.EC+1 ...and ProDOS does NOT include header entry in EC
bra .4
.98 jsr K.ReadDirA.CLN
sec
.99 rts
.2 ldy #S.NODE.DIR.EL+3
ldx #3
2017-01-12 17:43:45 +00:00
.3 lda (ZPPtr1),y get this session parameters from S.DIR
sta K.ReadDirA.EL,x
dey
dex
bpl .3
.4 lda K.ReadDirA.EC
eor #$ff
tax
lda K.ReadDirA.EC+1
eor #$ff
tay
inx Any entry remaining ?
bne .5
iny
beq .98 no...exit
* pass #1 compute BufSize...
.5 lda K.ReadDirA.EPB
sta K.ReadDirA.ECIB
lda #1 For Ending 0
sta K.ReadDirA.BufSize
stz K.ReadDirA.BufSize+1
2017-01-12 17:43:45 +00:00
K.ReadDirA.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
2017-01-12 17:43:45 +00:00
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
adc K.ReadDirA.BufSize
sta K.ReadDirA.BufSize
bcc .3
inc K.ReadDirA.BufSize+1
.3 inx
bne .7
iny
bra K.ReadDirA.DIR2 we reached last entry in whole DIR
2017-01-12 17:43:45 +00:00
.7 lda ZPPtr2
clc
adc K.ReadDirA.EL
2017-01-12 17:43:45 +00:00
sta ZPPtr2
bcc .8
2017-01-12 17:43:45 +00:00
inc ZPPtr2+1
.8 dec K.ReadDirA.ECIB
bne K.ReadDirA.DIR1
2017-01-12 17:43:45 +00:00
* pass #2 Fill Buffer...(ZPPtr1 & Ptr2 can now be trashed)
K.ReadDirA.DIR2 jsr K.ReadDirA.GetBuf
bcs .9
lda K.ReadDirA.EPB
sta K.ReadDirA.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
jsr K.ReadDirA.ADD.
bra .6
.2 cmp #$E0 Dir Header ?
bne .3
jsr K.ReadDirA.ADD.
jsr K.ReadDirA.ADD..
bra .6
.3 jsr K.ReadDirA.AddFNToBuf
jsr K.ReadDirA.ClrStat
2017-01-12 17:43:45 +00:00
lda (ZPPtr3)
and #$F0
cmp #$D0 Directory ?
bne .5
jsr K.ReadDirA.ADDD
bra .6
.5 jsr K.ReadDirA.ADDF
.6 lda K.ReadDirA.EC decrease global counter...
sec
sbc #1
sta K.ReadDirA.EC
lda K.ReadDirA.EC+1
sbc #0
sta K.ReadDirA.EC+1
ora K.ReadDirA.EC
beq .8 0! no more files in DIR
.7 dec K.ReadDirA.ECIB 0! no more file in block
beq .8
2017-01-12 17:43:45 +00:00
lda ZPPtr3
clc
adc K.ReadDirA.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
.9 jsr K.ReadDirA.CLN
sec
rts
.8
* lda #0 S.MEM.F.INIT0 already did this
2017-01-12 17:43:45 +00:00
* sta (ZPPtr4) Ending 0
2017-01-12 17:43:45 +00:00
lda K.ReadDirA.hDir Restore ZPPtr1 trashed by STR API calls
jsr K.GetMemPtrA
2017-01-12 17:43:45 +00:00
>STYA ZPPtr1
ldx #3
ldy #S.NODE.DIR.EL+3
.81 lda K.ReadDirA.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
jsr K.ReadDirA.CLN Discard READBUFFER
lda K.ReadDirA.hDIRENT
tax
jmp K.GetMemPtrA
*--------------------------------------
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
2017-01-12 17:43:45 +00:00
>STYA ZPPtr4
.9 rts
*--------------------------------------
K.ReadDirA.ADD. ldx #1 filename="1."
.HS 2C bit abs
K.ReadDirA.ADD..
ldx #2 filename="2.."
txa
jsr K.ReadDirA.AddToBuf Add LEN
lda #'.'
.1 jsr K.ReadDirA.AddToBuf Add X dot(s)
dex
bne .1
jsr K.ReadDirA.ClrStat
* ldy #$25 total_blocks
2017-01-12 17:43:45 +00:00
* lda (ZPPtr3),y
* sta KrnSTAT+S.STAT.BLOCKS
* iny
2017-01-12 17:43:45 +00:00
* lda (ZPPtr3),y
* sta KrnSTAT+S.STAT.BLOCKS+1
*--------------------------------------
K.ReadDirA.ADDD lda #$0F
sta KrnSTAT+S.STAT.P.TYPE
lda /S.STAT.MODE.DIR
sta KrnSTAT+S.STAT.MODE+1
bra K.ReadDirA.AddAccess
*--------------------------------------
K.ReadDirA.ADDF lda /S.STAT.MODE.REG
sta KrnSTAT+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 KrnSTAT,y
dex
bpl .1
*--------------------------------------
K.ReadDirA.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 KrnSTAT+S.STAT.MODE
*--------------------------------------
K.ReadDirA.AddTime
>PUSHWI KrnSTAT+S.STAT.CTIME
lda #$18 creation Date/time
jsr K.ReadDirA.ConvertTime
>PUSHWI KrnSTAT+S.STAT.MTIME
lda #$21 mod Date/time
jsr K.ReadDirA.ConvertTime
*--------------------------------------
K.ReadDirA.AddStat
ldy #S.STAT-1
.1 lda KrnSTAT,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
*--------------------------------------
K.ReadDirA.ClrStat
ldx #S.STAT-1
.1 stz KrnSTAT,x
dex
bpl .1
rts
*--------------------------------------
K.ReadDirA.AddFNToBuf
2017-01-12 17:43:45 +00:00
lda (ZPPtr3)
and #$0F get filename len
tax
jsr K.ReadDirA.AddToBuf
ldy #1
2017-01-12 17:43:45 +00:00
.1 lda (ZPPtr3),y
jsr K.ReadDirA.AddToBuf
iny
dex
bne .1
rts
*--------------------------------------
K.ReadDirA.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
*--------------------------------------
K.ReadDirA.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
jmp K.PTime2Time Will destroy Ptr1 & Ptr2 !!!!
*--------------------------------------
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
*/-------------------------------------
* #CloseDirA
* ##In:
* A = hDIR
* ##Out:
* none, always succeed.
*\-------------------------------------
2017-01-12 17:43:45 +00:00
K.CloseDirA .EQ K.FCloseA
2016-09-01 15:42:38 +00:00
2017-01-12 17:43:45 +00:00
* jsr PFT.CheckNodeA
* sta K.ReadDirA.hDir
* jsr K.GetMemPtrA
* >STYA ZPPtr1
K.CloseDirA.1 .EQ K.FCloseA.1
* ldy #S.NODE.DIR.REF
* lda (ZPPtr1),y
* beq .1
* sta MLICALL.PARAMS+1
* >MLICALL MLICLOSE
*.1 ldy #S.NODE.DIR.IOBUF
* lda (ZPPtr1),y
* beq .2
* jsr K.FreeMemA
*
*.2 lda K.ReadDirA.hDir
* jmp K.FreeMemA
*/-------------------------------------
* #MKDirYA
* ##In:
* Y,A = DIR name
* ##Out:
* CC : success
* CS : error
* A = EC
*\-------------------------------------
K.MKDirYA jsr PFT.CheckPathYA
>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
* jsr DATETIME
ldx #3
.1 lda DATELO,x
sta MLICALL.PARAMS+8,x
dex
bpl .1
>MLICALL MLICREATE
rts
*--------------------------------------
2016-08-24 15:42:33 +00:00
MAN
SAVE SYS/KERNEL.S.DIR
LOAD SYS/KERNEL.S
ASM