A2osX/SYS/KERNEL.S.FIO.txt

185 lines
3.4 KiB
Plaintext
Raw Normal View History

2017-12-22 21:24:30 +00:00
NEW
PREFIX /A2OSX.BUILD
2017-12-22 21:24:30 +00:00
AUTO 4,1
*/--------------------------------------
* # LoadTxtFile.YA
* 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.YA
pha
>PUSHWI 0 Aux type
2017-10-27 14:56:46 +00:00
>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 ...
2017-01-12 17:43:45 +00:00
* PUSHW = PATH ...FOpen)
* ## Out:
* Y,A = File Length
* X = hMem of Loaded File
*\--------------------------------------
K.LoadFile clc
2017-10-27 14:56:46 +00:00
ror FIO.bTXT
jsr K.FOpen
bcs .9
2017-10-27 14:56:46 +00:00
sta FIO.hFile
2017-10-27 14:56:46 +00:00
jsr FIO.GetSize
bcs .99
2017-10-27 14:56:46 +00:00
>LDYA FIO.FSize
2017-10-27 14:56:46 +00:00
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.YA
bcs .99
2017-10-27 14:56:46 +00:00
>STYA FIO.Mem
2017-09-29 06:36:27 +00:00
stx .8+1
2017-10-27 14:56:46 +00:00
>PUSHW FIO.Mem
>PUSHW FIO.FSize
>PUSHB FIO.hFile
2017-01-12 17:43:45 +00:00
jsr K.FRead
bcs .98
sty .6+1
sta .7+1 Save Bytes read
jsr .99 close file
2016-09-21 15:20:37 +00:00
2017-10-27 14:56:46 +00:00
bit FIO.bTXT
bpl .6
clc set ending 0
lda .6+1
2017-10-27 14:56:46 +00:00
adc FIO.Mem
sta .5+1
lda .7+1
2017-10-27 14:56:46 +00:00
adc FIO.Mem+1
sta .5+2
.5 stz $ffff Self Modified
.6 ldy #$ff Self Modified
.7 lda #$ff Self Modified
2017-09-29 06:36:27 +00:00
.8 ldx #$ff Self Modified
clc
2016-09-21 15:20:37 +00:00
.9 rts
.98 pha
2017-09-29 06:36:27 +00:00
lda .8+1
jsr K.FreeMem.A
pla
2016-09-21 15:20:37 +00:00
.99 pha
2017-10-27 14:56:46 +00:00
lda FIO.hFile
jsr K.FClose.A
pla
sec
2016-09-21 15:20:37 +00:00
rts
*--------------------------------------
2017-10-27 14:56:46 +00:00
FIO.GetSize stz FIO.FPos
stz FIO.FPos+1
stz FIO.FPos+2
stz FIO.FPos+3
2017-10-27 14:56:46 +00:00
>PUSHWI FIO.FPos
>PUSHBI SYS.FSeek.END
2017-10-27 14:56:46 +00:00
>PUSHB FIO.hFile
jsr K.FSeek
bcs .99
2017-10-27 14:56:46 +00:00
>PUSHWI FIO.FPos
>PUSHB FIO.hFile
jsr K.FTell
bcs .99
2017-10-27 14:56:46 +00:00
lda FIO.FPos+2
ora FIO.FPos+3
bne .98 too big!
2017-10-27 14:56:46 +00:00
>LDYA FIO.FPos
>STYA FIO.FSize
2017-10-27 14:56:46 +00:00
stz FIO.FPos
stz FIO.FPos+1
2017-10-27 14:56:46 +00:00
>PUSHWI FIO.FPos
>PUSHBI SYS.FSeek.SET
2017-10-27 14:56:46 +00:00
>PUSHB FIO.hFile
jmp K.FSeek
.98 lda #K.E.FTB
.99 rts
*--------------------------------------
2017-10-27 14:56:46 +00:00
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
2017-10-04 15:12:03 +00:00
jsr STDIO.PullMLIPath
>PULLB .1+1
>MLICALL MLIGETFILEINFO
bcs .9
.1 lda #$ff
2017-10-27 14:56:46 +00:00
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
*--------------------------------------
2015-03-14 21:48:35 +00:00
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.FIO
LOAD /A2OSX.SRC/SYS/KERNEL.S
2015-03-14 21:48:35 +00:00
ASM