A2osX/SYS/KERNEL.S.FIO.txt
2019-01-04 13:17:31 +00:00

179 lines
3.3 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
AUTO 4,1
*/--------------------------------------
* # LoadTxtFile
* Load TXT a file in memory (with ending 0)
* ## C
* `int loadtxtfile ( const char * filename, short int flags, short int ftype, int auxtype );`
* ## ASM
* **In:**
* `>PUSHW auxtype`
* `>PUSHB ftype`
* `>PUSHB flags`
* `>LDYA filename`
* `>SYSCALL loadtxtfile`
* ## RETURN VALUE
* Y,A = File Length (without ending 0)
* X = hMem of Loaded File
*\--------------------------------------
.DUMMY
.OR ZPTMP
FIO.bTXT .BS 1
FIO.hFILE .BS 1
FIO.MemPtr .BS 2
FIO.hMem .BS 1
FIO.BytesRead .BS 2
FIO.ZPSIZE .EQ *
.ED
*--------------------------------------
K.LoadTxtFile sec
.HS 90 BCC
*/--------------------------------------
* # LoadFile
* Load a file in memory
* ## C
* `int loadfile ( const char * filename, short int flags, short int ftype, int auxtype );`
* ## ASM
* **In:**
* `>PUSHW auxtype`
* `>PUSHB ftype`
* `>PUSHB flags`
* `>LDYA filename`
* `>SYSCALL loadfile`
* ## RETURN VALUE
* Y,A = File Length
* X = hMem of Loaded File
*\--------------------------------------
K.LoadFile clc
ror FIO.bTXT
jsr K.FOpen
bcs .9
.12 sta FIO.hFILE
pha
>PUSHWI K.S.Stat
pla
jsr K.FStat
bcs .11
lda K.S.Stat+S.STAT.SIZE+3
ora K.S.Stat+S.STAT.SIZE+2
bne .10
>LDYA K.S.Stat+S.STAT.SIZE
bit FIO.bTXT Add 1 to buffer size for ending 0
bpl .1
iny
bne .1
inc
bne .1
.10 lda #E.FTB
.11 bra .99
.1 jsr K.GetMem
bcs .99
>STYA FIO.MemPtr
stx FIO.hMem
>PUSHW K.S.Stat+S.STAT.SIZE
>PUSHW FIO.MemPtr
lda FIO.hFILE
jsr K.FRead
bcc .2
pha
lda FIO.hMem
jsr K.FreeMem
pla
.99 pha
lda FIO.hFILE
jsr K.FClose
pla
sec
.9 rts
.2 >STYA FIO.BytesRead
bit FIO.bTXT
bpl .5
pha set ending 0
tya
* clc
adc FIO.MemPtr
sta .4+1
pla
adc FIO.MemPtr+1
sta .4+2
.4 stz $ffff Self Modified
.5 jsr .99 close file
>LDYA FIO.BytesRead
ldx FIO.hMem
clc
rts
*/--------------------------------------
* # ChTyp
* Change The type of a ProDOS File
* ## C
* `int chtyp(const char *filepath, const char filetype);`
* ## ASM
* **In:**
* `>PUSHBI filetype`
* `>LDYA filepath`
* `>SYSCALL chtyp`
* ## RETURN VALUE
*\--------------------------------------
K.ChTyp jsr PFT.CheckPathYA
bcs .99
>PULLB .1+1
>MLICALL MLIGETFILEINFO
bcs .9
.1 lda #$ff
sta K.MLI.PARAMS+S.FI.T
>MLICALL MLISETFILEINFO
.9 rts
.99 >RET 1 discard filetype
*/--------------------------------------
* # ChMod
* **In:**
* PUSHW = UID
* PUSHW = PATH
*\--------------------------------------
K.ChMod
*/--------------------------------------
* # ChOwn
* **In:**
* PUSHW = mod
* PUSHW = PATH
*\--------------------------------------
K.ChOwn
*/--------------------------------------
* # ChGrp
* **In:**
* PUSHW = GID
* PUSHW = PATH
*\--------------------------------------
K.ChGrp
sec
rts
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.FIO
LOAD USR/SRC/SYS/KERNEL.S
ASM