A2osX/SYS/KERNEL.S.FILE.txt

354 lines
7.5 KiB
Plaintext
Raw Normal View History

PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
*--------------------------------------
* For All SYS.xxxx calls, X = #SYSCall
* Must be kept in X before calling
2016-09-29 15:30:15 +00:00
* PFT.Check*
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.FOPEN
* In :
* PULLW = PATH (PSTR)
* PULLB = MODE
* SYS.FOPEN.R .EQ $01 if R and !exists -> ERROR
* SYS.FOPEN.W .EQ $02 if W and !exists -> CREATE
2016-08-28 20:48:01 +00:00
* SYS.FOPEN.A .EQ $04 Append
* SYS.FOPEN.T .EQ $08 Open/Append in Text mode
* SYS.FOPEN.X .EQ $80 Create if not exists
* PULLB = TYPE
* PULLW = AUXTYPE
* Out :
* CC : A = hFILE
* CS : A = EC
*--------------------------------------
2016-09-29 15:30:15 +00:00
K.FOPEN jsr PFT.CheckPathSTK
>PULLW MLICALL.PARAMS+1
2016-09-21 15:20:37 +00:00
>PULLB K.FOPEN.MODE
>PULLB K.FOPEN.TYPE
>PULLW K.FOPEN.AUXTYPE
2016-08-28 20:48:01 +00:00
>MLICALL MLIGETFILEINFO
bcc .10 Already Exists
2016-09-21 15:20:37 +00:00
bit K.FOPEN.MODE Create if not exists ?
2016-08-28 20:48:01 +00:00
bpl .9 No, return MLI error
lda #S.FILEINFO.ACCESS.FULL Yes, Create...
2016-08-28 20:48:01 +00:00
sta MLICALL.PARAMS+3 Access
2016-09-21 15:20:37 +00:00
lda K.FOPEN.TYPE
2016-08-28 20:48:01 +00:00
sta MLICALL.PARAMS+4 File type
2016-09-21 15:20:37 +00:00
>LDYA K.FOPEN.AUXTYPE
2016-08-28 20:48:01 +00:00
>STYA MLICALL.PARAMS+5 Aux type
lda #S.FILEINFO.STORETYPE.STD
2016-08-28 20:48:01 +00:00
sta MLICALL.PARAMS+7
>MLICALL MLICREATE
bcc .10
.9 rts
.10 >PUSHWI S.FILE.PRODOS
>PUSHBI S.MEM.F.INIT0
2016-09-21 15:20:37 +00:00
jsr K.GetMem
bcs .99
2016-08-28 20:48:01 +00:00
>STYA ZPQuickPtr1
stx hFILE
>PUSHWI 1024 get a ProDOS IOBUF
>PUSHBI S.MEM.F.ALIGN+S.MEM.F.NOMOVE
2016-09-21 15:20:37 +00:00
jsr K.GetMem
2016-09-01 15:42:38 +00:00
bcs .98
>STYA MLICALL.PARAMS+3 Save Ptr to IOBUF for MLIOPEN call
txa
ldy #S.FILE.PRODOS.IOBUF
sta (ZPQuickPtr1),y
>MLICALL MLIOPEN
2016-08-28 20:48:01 +00:00
bcs .98
2016-08-28 20:48:01 +00:00
lda MLICALL.PARAMS+5 get ref_num
ldy #S.FILE.PRODOS.REF
sta (ZPQuickPtr1),y
2016-08-28 20:48:01 +00:00
sta MLICALL.PARAMS+1 Next MLI Calls are REF_NUM based
2016-09-21 15:20:37 +00:00
lda K.FOPEN.MODE
2016-08-28 20:48:01 +00:00
and #SYS.FOPEN.A Append ?
beq .20
>MLICALL MLIGETEOF
bcs .98
2016-08-28 20:48:01 +00:00
>MLICALL MLISETMARK
bcs .98
2016-09-21 15:20:37 +00:00
.20 lda K.FOPEN.MODE
2016-08-28 20:48:01 +00:00
and #SYS.FOPEN.T Text Mode ?
beq .30
2016-08-28 20:48:01 +00:00
lda #$FF
sta MLICALL.PARAMS+2
lda #$0D
sta MLICALL.PARAMS+3
>MLICALL MLINEWLINE
2016-08-28 20:48:01 +00:00
.30 lda hFILE
clc
rts CC
.98 pha save MLI error
2016-09-21 15:20:37 +00:00
jsr K.FCLOSEA.1
pla get back MLI error
sec
.99 rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.FOPEN.MODE .BS 1
K.FOPEN.TYPE .BS 1
K.FOPEN.AUXTYPE .BS 2
hFILE .BS 1
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.FCLOSEA
* In :
* A = hFILE
*--------------------------------------
2016-09-29 15:30:15 +00:00
K.FCLOSEA jsr PFT.CheckFileA
2016-09-01 15:42:38 +00:00
sta hFILE
2016-09-21 15:20:37 +00:00
jsr K.GetMemPtrA
>STYA ZPQuickPtr1
2016-09-21 15:20:37 +00:00
K.FCLOSEA.1 ldy #S.FILE.PRODOS.REF
lda (ZPQuickPtr1),y
beq .1
sta MLICALL.PARAMS+1
>MLICALL MLICLOSE
.1 ldy #S.FILE.PRODOS.IOBUF
lda (ZPQuickPtr1),y
beq .2
2016-09-21 15:20:37 +00:00
jsr K.FreeMemA
.2 lda hFILE
2016-09-21 15:20:37 +00:00
jsr K.FreeMemA
rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.FREAD
* In :
* PULLB = hFILE
* PULLW = Bytes To Read
* PULLW = Dest Ptr
* Out :
* Y,A = Bytes Read
*--------------------------------------
2016-09-29 15:30:15 +00:00
K.FREAD jsr PFT.CheckFileSTK
ldx #MLIREAD
bra K.FREAD.1
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.FWRITE
* In :
* PULLB = hFILE
* PULLW = Bytes To Write
* PULLW = Src Ptr
* Out :
* Y,A = Bytes Written
*--------------------------------------
2016-09-29 15:30:15 +00:00
K.FWRITE jsr PFT.CheckFileSTK
ldx #MLIWRITE
K.FREAD.1 >PULLA
jsr FILE.SetupPrt1A
>PULLW MLICALL.PARAMS+4
>PULLW MLICALL.PARAMS+2
* >MLICALL MLIWRITE
lda #4 Param Count = 4 for MLIREAD & MLIWRITE
jsr A2osX.MLICALL
bcs .9
>LDYA MLICALL.PARAMS+6
.9 rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.FFLUSHA
* In :
* A = hFILE
*--------------------------------------
2016-09-29 15:30:15 +00:00
K.FFLUSHA jsr PFT.CheckFileA
2016-09-26 16:00:52 +00:00
jsr FILE.SetupPrt1A
>MLICALL MLIFLUSH
rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.FSEEK
* In :
* PULLB = hFILE
* PULLB = From
* PULLW = OffsetLo
* PULLW = OffsetHi
*--------------------------------------
2016-09-29 15:30:15 +00:00
K.FSEEK jsr PFT.CheckFileSTK
>PULLA
2016-09-26 16:00:52 +00:00
jsr FILE.SetupPrt1A
2016-09-21 15:20:37 +00:00
>PULLB K.FSEEK.FROM
>PULLW K.FSEEK.OFFSET
>PULLW K.FSEEK.OFFSET+2
2016-09-21 15:20:37 +00:00
lda K.FSEEK.FROM
* cmp #SYS.FSEEK.SET =0
bne .1
stz MLICALL.PARAMS+2
stz MLICALL.PARAMS+3
stz MLICALL.PARAMS+4
bra .8
.1 cmp #SYS.FSEEK.CUR
bne .2
>MLICALL MLIGETMARK
bcc .8
rts
.2 cmp #SYS.FSEEK.END
bne .98
>MLICALL MLIGETEOF
bcs .9
.8 lda MLICALL.PARAMS+2
2016-09-21 15:20:37 +00:00
adc K.FSEEK.OFFSET
sta MLICALL.PARAMS+2
lda MLICALL.PARAMS+3
2016-09-21 15:20:37 +00:00
adc K.FSEEK.OFFSET+1
sta MLICALL.PARAMS+3
lda MLICALL.PARAMS+4
2016-09-21 15:20:37 +00:00
adc K.FSEEK.OFFSET+2
sta MLICALL.PARAMS+4
bcs .99 Offset out of range!
>MLICALL MLISETMARK
.9 rts
.98 lda #SYSMGR.ERRSYN
.HS 2C bit abs
.99 lda #SYSMGR.ERRFTB
sec
rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.FSEEK.FROM .BS 1
K.FSEEK.OFFSET .BS 4
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.FTELLA
* In :
* A = hFILE
* Out :
* Y,A,X = Offset
*--------------------------------------
2016-09-29 15:30:15 +00:00
K.FTELLA jsr PFT.CheckFileA
2016-09-26 16:00:52 +00:00
K.FTELLA.1 jsr FILE.SetupPrt1A
>MLICALL MLIGETMARK
bcs .9
>LDYA MLICALL.PARAMS+2
ldx MLICALL.PARAMS+4
.9 rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.FEOFA
* In :
* A = hFILE
* Out :
* CC :
* A=0 EOF
* A !=0 NOT EOF
* CS :
*--------------------------------------
2016-09-29 15:30:15 +00:00
K.FEOFA jsr PFT.CheckFileA
2016-09-26 16:00:52 +00:00
jsr FILE.SetupPrt1A
2016-09-21 15:20:37 +00:00
jsr K.FTELLA.1
bcs .9
2016-09-21 15:20:37 +00:00
>STYA K.FEOFA.MARK
stx K.FEOFA.MARK+2
>MLICALL MLIGETEOF
bcs .9
sec
lda MLICALL.PARAMS+2
2016-09-21 15:20:37 +00:00
sbc K.FEOFA.MARK
bne .8
lda MLICALL.PARAMS+3
2016-09-21 15:20:37 +00:00
sbc K.FEOFA.MARK+1
bne .8
lda MLICALL.PARAMS+4
2016-09-21 15:20:37 +00:00
sbc K.FEOFA.MARK+2
.8 clc
.9 rts
2016-09-21 15:20:37 +00:00
K.FEOFA.MARK .BS 3
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.REMOVEYA
*--------------------------------------
2016-09-29 15:30:15 +00:00
K.REMOVEYA jsr PFT.CheckPathYA
>STYA MLICALL.PARAMS+1
>MLICALL MLIDESTROY
rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.RENAME
* In :
* PULLW = Old Name
* PULLW = New Name
*--------------------------------------
2016-09-29 15:30:15 +00:00
K.RENAME jsr PFT.CheckPathSTK
>PULLW MLICALL.PARAMS+1
2016-09-21 15:20:37 +00:00
>PULLW MLICALL.PARAMS+3
>MLICALL MLIRENAME
rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.STAT
* In :
* PULLW = PTR to Filename
* PULLW = PTR to S.STAT buffer
*--------------------------------------
2016-09-29 15:30:15 +00:00
K.STAT jsr PFT.CheckPathSTK
2016-09-21 15:20:37 +00:00
>PULLW MLICALL.PARAMS+1
>PULLW ZPQuickPtr2
>MLICALL MLIGETFILEINFO
bcs .9
jsr FILE.MLI2STAT
2016-09-26 16:00:52 +00:00
clc
2016-09-21 15:20:37 +00:00
.9 rts
*--------------------------------------
2016-09-26 16:00:52 +00:00
FILE.SetupPrt1A jsr K.GetMemPtrA
>STYA ZPQuickPtr1
ldy #S.FILE.PRODOS.REF
lda (ZPQuickPtr1),y
sta MLICALL.PARAMS+1
rts
2016-09-26 16:00:52 +00:00
*--------------------------------------
FILE.MLI2STAT
2016-09-26 16:00:52 +00:00
lda MLICALL.PARAMS+S.FILEINFO.ACCESS
cmp #S.FILEINFO.ACCESS.FULL
bne .1
lda #S.STAT.MODE.XO+S.STAT.MODE.WO+S.STAT.MODE.RO
bra .2
.1 and #S.FILEINFO.ACCESS.R
beq .2
lda #S.STAT.MODE.XO+S.STAT.MODE.RO
.2 ldy #S.STAT.MODE
sta (ZPQuickPtr2),y
2016-09-26 16:00:52 +00:00
ldx #2
ldy #S.STAT.PRODOS.TYPE+2
.3 lda MLICALL.PARAMS+S.FILEINFO.TYPE,x
sta (ZPQuickPtr2),y
dey
dex
bpl .3
2016-09-26 16:00:52 +00:00
rts
*--------------------------------------
MAN
2016-09-02 06:09:44 +00:00
SAVE SYS/KERNEL.S.FILE
LOAD SYS/KERNEL.S
ASM