mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-29 17:50:18 +00:00
272 lines
5.5 KiB
Plaintext
272 lines
5.5 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
*--------------------------------------
|
||
IO.OPEN.REG >MLICALL MLIGETFILEINFO
|
||
bcc IO.OPEN.REG.E Already Exists
|
||
|
||
bit IO.Open.FLAGS Create if not exists ?
|
||
bpl IO.OPEN.RTS 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 IO.MLI.CREATE
|
||
bcs IO.OPEN.RTS
|
||
|
||
IO.OPEN.REG.E ldx #0
|
||
jsr IO.MkFD
|
||
bcs IO.OPEN.RTS
|
||
|
||
jsr IO.MLI.OPEN
|
||
bcs UNISTD.Open.ERR
|
||
|
||
lda IO.Open.FLAGS
|
||
bit #O.WRONLY
|
||
beq .20 Write mode ?
|
||
|
||
and #O.APPEND Append ?
|
||
bne .11 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 .21
|
||
|
||
.11 >MLICALL MLIGETEOF
|
||
bcs UNISTD.Open.ERR
|
||
|
||
>MLICALL MLISETMARK
|
||
.21 bcs UNISTD.Open.ERR
|
||
|
||
.20 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 UNISTD.Open.ERR
|
||
|
||
.8 lda IO.hFD
|
||
IO.OPEN.RTS rts
|
||
|
||
UNISTD.Open.ERR pha Save Error Code
|
||
lda IO.hFD
|
||
jsr K.Close
|
||
pla
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
IO.READ.REG ldx #MLIREAD
|
||
.HS 2C BIT ABS
|
||
*--------------------------------------
|
||
IO.WRITE.REG ldx #MLIWRITE
|
||
|
||
ldy #S.FD.REG.REF
|
||
lda (pFD),y
|
||
sta K.MLI.PARAMS+1
|
||
>PULLW K.MLI.PARAMS+2
|
||
>PULLW K.MLI.PARAMS+4
|
||
|
||
lda #4 Param Count = 4 for MLIREAD & MLIWRITE
|
||
jsr GP.MLICall
|
||
bcs .9
|
||
>LDYA K.MLI.PARAMS+6
|
||
.9
|
||
IO.WRITE.REG.RTS
|
||
rts
|
||
*--------------------------------------
|
||
IO.CLOSE.REG
|
||
IO.CLOSE.DIR ldy #S.FD.REG.REF
|
||
lda (pFD),y
|
||
beq .1
|
||
sta K.MLI.PARAMS+1
|
||
>MLICALL MLICLOSE
|
||
|
||
.1 ldy #S.FD.REG.IOBUF
|
||
lda (pFD),y
|
||
beq .2
|
||
jsr K.FreeMem
|
||
.2 lda IO.hFD
|
||
jmp K.FreeMem
|
||
*--------------------------------------
|
||
IO.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
|
||
*--------------------------------------
|
||
IO.MLI.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
|
||
*--------------------------------------
|
||
IO.MLI.OPEN >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 rts
|
||
*--------------------------------------
|
||
SHARED.ClrStat ldx #S.STAT-1
|
||
|
||
.1 stz K.S.STAT,x
|
||
dex
|
||
bpl .1
|
||
|
||
lda CORE.FSID
|
||
sta K.S.STAT+S.STAT.FSID
|
||
|
||
rts
|
||
SHARED.ClrStat.RTS
|
||
*--------------------------------------
|
||
SHARED.DirEnt2Stat
|
||
jsr SHARED.ClrStat
|
||
|
||
lda (ZPPtr3)
|
||
and #$F0
|
||
cmp #$D0 Vol Hdr, Dir Hdr or Dir ?
|
||
bcc .1
|
||
|
||
lda /S.STAT.MODE.DIR
|
||
sta K.S.STAT+S.STAT.MODE+1
|
||
|
||
.1 ldx #SHARED.DirEnt.Cnt
|
||
|
||
.2 ldy SHARED.DirEnt.Src-1,x
|
||
lda (ZPPtr3),y
|
||
ldy SHARED.Stat.Dst-1,x
|
||
sta K.S.STAT,y
|
||
dex
|
||
bne .2
|
||
|
||
ldy #$1E ProDOS Access
|
||
lda (ZPPtr3),y
|
||
|
||
jsr SHARED.Access2Mode
|
||
|
||
lda #$18 creation Date/time
|
||
ldx #K.S.STAT+S.STAT.CTIME
|
||
jsr SHARED.PTime2StatAX
|
||
|
||
lda #$21 mod Date/time
|
||
ldx #K.S.STAT+S.STAT.MTIME
|
||
jmp SHARED.PTime2StatAX
|
||
*--------------------------------------
|
||
SHARED.Mode2Access
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
SHARED.Access2Mode
|
||
and #S.FI.A.FULL
|
||
cmp #S.FI.A.FULL
|
||
beq .7
|
||
tay
|
||
ldx #S.STAT.MODE.RO+S.STAT.MODE.RG+S.STAT.MODE.RU+S.STAT.MODE.XO+S.STAT.MODE.XG+S.STAT.MODE.XU
|
||
|
||
bit #S.FI.A.W
|
||
beq .1
|
||
txa
|
||
ora #S.STAT.MODE.WO
|
||
tax
|
||
tya
|
||
|
||
.1 asl D in C
|
||
|
||
bpl .2 RN in N
|
||
txa
|
||
ora #S.STAT.MODE.WG
|
||
tax
|
||
.2 txa
|
||
bcc .8
|
||
ora #S.STAT.MODE.WU
|
||
.HS 2C BIT ABS
|
||
.7 lda #S.STAT.MODE.FO+S.STAT.MODE.FG+S.STAT.MODE.FU rwxrwxrwx
|
||
.8 sta K.S.STAT+S.STAT.MODE
|
||
|
||
lda /S.STAT.MODE.RU ??????R??
|
||
ora K.S.STAT+S.STAT.MODE+1 preserve DIR
|
||
sta K.S.STAT+S.STAT.MODE+1
|
||
|
||
rts
|
||
*--------------------------------------
|
||
SHARED.PTime2StatAX
|
||
clc
|
||
adc ZPPtr3
|
||
tay
|
||
lda ZPPtr3+1
|
||
adc #0
|
||
SHARED.PTime2StatYAX
|
||
>PUSHYA
|
||
|
||
>PUSHB /K.S.STAT
|
||
txa
|
||
>PUSHA
|
||
>SYSCALL2 PTime2Time
|
||
rts
|
||
*--------------------------------------
|
||
SHARED.GFI.Src .DA #S.FI.T,#S.FI.AUXTYPE,#S.FI.AUXTYPE+1
|
||
.DA #S.FI.UBLKS,#S.FI.UBLKS+1
|
||
SHARED.GFI.Cnt .EQ *-SHARED.GFI.Src
|
||
*--------------------------------------
|
||
SHARED.DirEnt.Src
|
||
.HS 10.1f20.1314.151617
|
||
SHARED.DirEnt.Cnt .EQ *-SHARED.DirEnt.Src
|
||
*--------------------------------------
|
||
SHARED.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
|