A2osX/SYS/KERNEL.S.FIO.txt
2018-06-22 08:24:35 +02:00

184 lines
3.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.

NEW
PREFIX /A2OSX.BUILD
AUTO 4,1
*/--------------------------------------
* # LoadTxtFile
* Load TXT a file in memory (with ending 0)
* **In:**
* Y,A = File Path
* **Out:**
* Y,A = File Length (without ending 0)
* X = hMem of Loaded File
*\--------------------------------------
K.LoadTxtFile pha
>PUSHWI 0 Aux type
>PUSHBI 4 S.FI.T.TXT
>PUSHBI SYS.FOpen.R
pla
>PUSHYA
sec
.HS 90 BCC
*/--------------------------------------
* # LoadFile
* Load a file in memory
* **In:**
* PUSHW = AUXTYPE (Handled by....
* PUSHB = TYPE ...
* PUSHB = MODE ...
* PUSHW = PATH ...FOpen)
* **Out:**
* Y,A = File Length
* X = hMem of Loaded File
*\--------------------------------------
K.LoadFile clc
ror FIO.bTXT
jsr K.FOpen
bcs .9
sta FIO.hFile
jsr FIO.GetSize
bcs .99
>LDYA FIO.FSize
bit FIO.bTXT Add 1 to buffer size for ending 0
bpl .1
iny
bne .1
inc
bne .1
lda #K.E.FTB
bra .99
.1 jsr K.GetMem
bcs .99
>STYA FIO.Mem
stx .8+1
>PUSHW FIO.Mem
>PUSHW FIO.FSize
>PUSHB FIO.hFile
jsr K.FRead
bcs .98
sty .6+1
sta .7+1 Save Bytes read
jsr .99 close file
bit FIO.bTXT
bpl .6
clc set ending 0
lda .6+1
adc FIO.Mem
sta .5+1
lda .7+1
adc FIO.Mem+1
sta .5+2
.5 stz $ffff Self Modified
.6 ldy #$ff Self Modified
.7 lda #$ff Self Modified
.8 ldx #$ff Self Modified
clc
.9 rts
.98 pha
lda .8+1
jsr K.FreeMem
pla
.99 pha
lda FIO.hFile
jsr K.FClose
pla
sec
rts
*--------------------------------------
FIO.GetSize stz FIO.FPos
stz FIO.FPos+1
stz FIO.FPos+2
stz FIO.FPos+3
>PUSHWI FIO.FPos
>PUSHBI SYS.FSeek.END
>PUSHB FIO.hFile
jsr K.FSeek
bcs .99
>PUSHWI FIO.FPos
>PUSHB FIO.hFile
jsr K.FTell
bcs .99
lda FIO.FPos+2
ora FIO.FPos+3
bne .98 too big!
>LDYA FIO.FPos
>STYA FIO.FSize
stz FIO.FPos
stz FIO.FPos+1
>PUSHWI FIO.FPos
>PUSHBI SYS.FSeek.SET
>PUSHB FIO.hFile
jmp K.FSeek
.98 lda #K.E.FTB
.99 rts
*--------------------------------------
FIO.bTXT .BS 1
FIO.hFile .BS 1
FIO.FPos .BS 4
FIO.Mem .BS 2
FIO.FSize .BS 2
*/--------------------------------------
* # ChTyp
* **In:**
* PUSHB = TYPE
* PUSHW = PATH
*\--------------------------------------
K.ChTyp jsr PFT.CheckPathSTK
jsr STDIO.PullMLIPath
>PULLB .1+1
>MLICALL MLIGETFILEINFO
bcs .9
.1 lda #$ff
sta K.MLI.PARAMS+S.FI.T
>MLICALL MLISETFILEINFO
.9 rts
*/--------------------------------------
* # ChMod
* **In:**
* PUSHW = UID
* PUSHW = PATH
*\--------------------------------------
K.ChMod
*/--------------------------------------
* # ChOwn
* **In:**
* PUSHW = UID
* PUSHW = PATH
*\--------------------------------------
K.ChOwn
*/--------------------------------------
* # ChGrp
* **In:**
* PUSHW = GID
* PUSHW = PATH
*\--------------------------------------
K.ChGrp
sec
rts
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.FIO
LOAD /A2OSX.SRC/SYS/KERNEL.S
ASM