mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-25 05:32:20 +00:00
378 lines
7.0 KiB
Plaintext
378 lines
7.0 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
*--------------------------------------
|
||
FS.OPEN.REG >MLICALL MLIGETFILEINFO
|
||
bcs .10
|
||
|
||
lda IO.Open.TYPE Already Exists
|
||
beq .2
|
||
|
||
cmp K.MLI.PARAMS+S.FI.T
|
||
beq .2
|
||
|
||
lda #MLI.E.INCFF
|
||
sec
|
||
rts
|
||
|
||
.10 bit IO.Open.FLAGS Create if not exists ?
|
||
bpl .9 No, return MLI error
|
||
|
||
ldx #2 Yes, Create...
|
||
|
||
.1 lda IO.Open.TYPE,x
|
||
sta K.MLI.PARAMS+4,x File type,Aux type
|
||
dex
|
||
bpl .1
|
||
|
||
lda #S.FI.ST.STD
|
||
jsr FS.CREATE
|
||
bcs .9
|
||
|
||
.2 lda #S.FD.T.REG
|
||
jsr DEV.MkFD
|
||
bcs .9
|
||
|
||
jsr FS.MLIOPEN
|
||
bcs FS.OPEN.ERR
|
||
|
||
lda IO.Open.FLAGS
|
||
bit #O.WRONLY
|
||
beq .5 Write mode ?
|
||
|
||
and #O.APPEND Append ?
|
||
bne .3 yes, go to end of file
|
||
|
||
stz K.MLI.PARAMS+2
|
||
stz K.MLI.PARAMS+3
|
||
stz K.MLI.PARAMS+4
|
||
>MLICALL MLISETEOF no, reset size to 0
|
||
bra .4
|
||
|
||
.3 >MLICALL MLIGETEOF
|
||
bcs FS.OPEN.ERR
|
||
|
||
>MLICALL MLISETMARK
|
||
.4 bcs FS.OPEN.ERR
|
||
|
||
.5 lda IO.Open.FLAGS
|
||
and #O.TEXT Text Mode ?
|
||
beq .8
|
||
|
||
lda #$FF
|
||
sta K.MLI.PARAMS+2
|
||
lda #C.CR
|
||
sta K.MLI.PARAMS+3
|
||
>MLICALL MLINEWLINE
|
||
bcs FS.OPEN.ERR
|
||
|
||
.8 lda IO.hFD
|
||
* clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
FS.OPEN.ERR pha Save Error Code
|
||
jsr FS.CLOSE.REGDIR
|
||
|
||
ldx IO.hFILE Cleanup what MkFD did
|
||
lda hFDs-1,x
|
||
stz hFDs-1,x
|
||
jsr K.FreeMem
|
||
|
||
pla
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
FS.OPEN.DIR lda #S.FD.T.DIR
|
||
jsr DEV.MkFD
|
||
bcs .9
|
||
|
||
lda K.MLI.PATH+2
|
||
beq .8 "/"
|
||
|
||
>MLICALL MLIGETFILEINFO
|
||
bcs .9
|
||
|
||
lda K.MLI.PARAMS+S.FI.T
|
||
cmp #S.FI.T.DIR
|
||
bne .99
|
||
|
||
jsr FS.MLIOPEN
|
||
bcs FS.OPEN.ERR
|
||
|
||
.8 lda IO.hFD
|
||
* clc
|
||
rts
|
||
|
||
.99 lda #MLI.E.UNSUPST
|
||
sec
|
||
.9 rts
|
||
*--------------------------------------
|
||
FS.CLOSE.REGDIR ldy #S.FD.REG.REF
|
||
lda (pFD),y
|
||
beq .1
|
||
|
||
sta K.MLI.PARAMS+1
|
||
>MLICALL MLICLOSE
|
||
* bcs FS.RTS
|
||
|
||
.1 ldy #S.FD.REG.IOBUF
|
||
lda (pFD),y
|
||
beq .8
|
||
|
||
jmp K.FreeMem
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
FS.READ.REG ldx #MLIREAD
|
||
.HS 2C BIT ABS
|
||
*--------------------------------------
|
||
FS.WRITE.REG ldx #MLIWRITE
|
||
|
||
ldy #S.FD.REG.REF
|
||
lda (pFD),y
|
||
sta K.MLI.PARAMS+1
|
||
>PULLW K.MLI.PARAMS+4
|
||
>PULLW K.MLI.PARAMS+2
|
||
|
||
lda #4 Param Count = 4 for MLIREAD & MLIWRITE
|
||
jsr GP.MLICall
|
||
bcs .9
|
||
|
||
>LDYA K.MLI.PARAMS+6
|
||
|
||
.9 inc pStack
|
||
|
||
rts
|
||
*--------------------------------------
|
||
FS.EOF.REG >MLICALL MLIGETMARK
|
||
bcs .9
|
||
ldy #2
|
||
.1 lda K.MLI.PARAMS+2,y
|
||
sta ACC32,y
|
||
dey
|
||
bpl .1
|
||
|
||
>MLICALL MLIGETEOF
|
||
bcs .9
|
||
|
||
ldy #2
|
||
.2 lda K.MLI.PARAMS+2,y
|
||
eor ACC32,y
|
||
bne .8 FALSE
|
||
dey
|
||
bpl .2
|
||
lda #$ff TRUE
|
||
* clc
|
||
rts
|
||
|
||
.8 lda #0
|
||
* clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
FS.CREATE sta K.MLI.PARAMS+7 Storage Type
|
||
ldx #3
|
||
|
||
.1 lda DATELO,x
|
||
sta K.MLI.PARAMS+8,x Create Date/Time
|
||
dex
|
||
bpl .1
|
||
|
||
lda #S.FI.A.FULL
|
||
sta K.MLI.PARAMS+3 Access
|
||
>MLICALL MLICREATE
|
||
rts
|
||
*--------------------------------------
|
||
FS.MLIOPEN >LDYAI 1024 get a ProDOS IOBUF
|
||
ldx #S.MEM.F.ALIGN
|
||
jsr MEM.GetMem.YAX
|
||
bcs .9
|
||
|
||
>STYA K.MLI.PARAMS+3 Save Ptr to IOBUF for MLIOPEN call
|
||
txa
|
||
ldy #S.FD.REG.IOBUF
|
||
sta (pFD),y
|
||
|
||
>MLICALL MLIOPEN
|
||
bcs .9
|
||
|
||
lda K.MLI.PARAMS+5 get ref_num
|
||
ldy #S.FD.REG.REF
|
||
sta (pFD),y
|
||
|
||
sta K.MLI.PARAMS+1 Next MLI Calls are REF_NUM based
|
||
|
||
* clc
|
||
|
||
.9
|
||
FS.RTS rts
|
||
*--------------------------------------
|
||
FS.Stat bit A2osX.FSID
|
||
bmi FS.Stat.FX
|
||
|
||
FS.Stat.203 >MLICALL MLIGETFILEINFO
|
||
bcs FS.RTS
|
||
|
||
jsr FS.ClrStat
|
||
|
||
lda K.MLI.PARAMS+S.FI.T
|
||
cmp #S.FI.T.DIR
|
||
bne .1
|
||
|
||
lda /S.STAT.MODE.DIR
|
||
sta K.S.STAT+S.STAT.MODE+1
|
||
|
||
.1 lda K.MLI.PARAMS+S.FI.A
|
||
sta K.S.STAT+S.STAT.P.ACCESS
|
||
|
||
ldx #FS.GFI.Cnt
|
||
|
||
.3 ldy FS.GFI.Src-1,x
|
||
lda K.MLI.PARAMS,y
|
||
ldy FS.Stat.Dst-1,x
|
||
sta K.S.STAT,y
|
||
dex
|
||
bne .3
|
||
|
||
>LDYAI K.MLI.PARAMS+S.FI.CDATE
|
||
ldx #K.S.STAT+S.STAT.CTIME
|
||
jsr FS.PTime2StatYAX
|
||
|
||
>LDYAI K.MLI.PARAMS+S.FI.MDATE
|
||
ldx #K.S.STAT+S.STAT.MTIME
|
||
jmp FS.PTime2StatYAX
|
||
*--------------------------------------
|
||
FS.Stat.FX >MLICALL MLIGETFILEINFOEX
|
||
bcc .1
|
||
|
||
cmp #MLI.E.BADCALL
|
||
beq FS.Stat.203 Apple WS CARD
|
||
rts
|
||
|
||
.1 >LDYAI K.MLI.PARAMS+3
|
||
>STYA ZPPtr3
|
||
*--------------------------------------
|
||
FS.DirEnt2Stat jsr FS.ClrStat
|
||
|
||
ldx #FS.DirEnt.Cnt
|
||
|
||
.1 ldy FS.DirEnt.Src-1,x
|
||
lda (ZPPtr3),y
|
||
ldy FS.Stat.Dst-1,x
|
||
sta K.S.STAT,y
|
||
dex
|
||
bne .1
|
||
|
||
ldy #S.FIEX.ACCESS
|
||
lda (ZPPtr3),y
|
||
sta K.S.STAT+S.STAT.P.ACCESS
|
||
|
||
lda (ZPPtr3)
|
||
and #$F0
|
||
cmp #$D0 Dir Hdr or Dir ?
|
||
bcc .3
|
||
|
||
cmp #$F0 Vol Hdr ?
|
||
bne .2
|
||
|
||
stz K.S.STAT+S.STAT.SIZE
|
||
|
||
ldy #S.FIEX.AUXTYPE
|
||
lda (ZPPtr3),y
|
||
sta K.S.STAT+S.STAT.BLOCKS
|
||
asl
|
||
sta K.S.STAT+S.STAT.SIZE+1
|
||
|
||
iny
|
||
|
||
lda (ZPPtr3),y
|
||
sta K.S.STAT+S.STAT.BLOCKS+1
|
||
rol
|
||
sta K.S.STAT+S.STAT.SIZE+2
|
||
|
||
lda #0
|
||
rol K.S.STAT+S.STAT.SIZE+3
|
||
|
||
.2 lda /S.STAT.MODE.DIR
|
||
tsb K.S.STAT+S.STAT.MODE+1
|
||
|
||
.3 ldy #S.FIEX.ACL
|
||
lda (ZPPtr3),y
|
||
cmp #$57
|
||
bne .7
|
||
|
||
iny
|
||
lda (ZPPtr3),y
|
||
bne .7
|
||
|
||
ldy #S.FIEX.ACL.UID
|
||
lda (ZPPtr3),y
|
||
sta K.S.STAT+S.STAT.UID
|
||
|
||
ldy #S.FIEX.ACL.GID
|
||
lda (ZPPtr3),y
|
||
sta K.S.STAT+S.STAT.GID
|
||
|
||
ldy #S.FIEX.ACL.MOD
|
||
lda (ZPPtr3),y
|
||
tsb K.S.STAT+S.STAT.MODE
|
||
iny
|
||
lda (ZPPtr3),y
|
||
tsb K.S.STAT+S.STAT.MODE+1
|
||
|
||
.7 lda #S.FIEX.CTIME
|
||
ldx #K.S.STAT+S.STAT.CTIME
|
||
jsr FS.PTime2StatAX
|
||
|
||
lda #S.FIEX.MTIME
|
||
ldx #K.S.STAT+S.STAT.MTIME
|
||
* jmp FS.PTime2StatAX
|
||
*--------------------------------------
|
||
FS.PTime2StatAX clc
|
||
adc ZPPtr3
|
||
tay
|
||
lda ZPPtr3+1
|
||
adc #0
|
||
FS.PTime2StatYAX
|
||
>PUSHYA
|
||
|
||
>PUSHB /K.S.STAT
|
||
txa
|
||
>PUSHA
|
||
>SYSCALL2 PTime2Time
|
||
|
||
clc ignore bad date error
|
||
|
||
rts
|
||
*--------------------------------------
|
||
FS.ClrStat ldx #S.STAT-1
|
||
|
||
.1 stz K.S.STAT,x
|
||
dex
|
||
bpl .1
|
||
|
||
lda A2osX.FSID
|
||
sta K.S.STAT+S.STAT.FSID
|
||
|
||
lda #2
|
||
sta K.S.STAT+S.STAT.BLKSIZE+1 = 512 bytes
|
||
|
||
rts
|
||
*--------------------------------------
|
||
FS.GFI.Src .DA #S.FI.T,#S.FI.AUXTYPE,#S.FI.AUXTYPE+1
|
||
.DA #S.FI.UBLKS,#S.FI.UBLKS+1
|
||
FS.GFI.Cnt .EQ *-FS.GFI.Src
|
||
*--------------------------------------
|
||
FS.DirEnt.Src .DA #S.FIEX.T,#S.FIEX.AUXTYPE,#S.FIEX.AUXTYPE+1
|
||
.DA #S.FIEX.BLKUSED,#S.FIEX.BLKUSED+1
|
||
.DA #S.FIEX.EOF,#S.FIEX.EOF+1,#S.FIEX.EOF+2
|
||
FS.DirEnt.Cnt .EQ *-FS.DirEnt.Src
|
||
*--------------------------------------
|
||
FS.Stat.Dst .DA #S.STAT.P.TYPE,#S.STAT.P.AUXTYPE,#S.STAT.P.AUXTYPE+1
|
||
.DA #S.STAT.BLOCKS,#S.STAT.BLOCKS+1
|
||
.DA #S.STAT.SIZE,#S.STAT.SIZE+1,#S.STAT.SIZE+2
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE usr/src/sys/kernel.s.fs
|
||
LOAD usr/src/sys/kernel.s
|
||
ASM
|