Kernel 0.9.2

This commit is contained in:
Rémy GIBERT 2018-10-04 17:30:14 +02:00
parent 44ca048591
commit 66f6298626
14 changed files with 334 additions and 307 deletions

View File

@ -240,7 +240,7 @@ Change The type of a ProDOS File
# open # open
## C ## C
`hFD open(const char *pathname, int flags);` `hFD open(const char *pathname, short int flags);`
## ASM ## ASM
**In:** **In:**
@ -249,7 +249,7 @@ Change The type of a ProDOS File
`>SYSCALL open` `>SYSCALL open`
**Out:** **Out:**
A = hFD A = hFD
note : if file is created on ProDOS : T=TXT,X=$0000 REG File created on ProDOS : T=TXT,X=$0000
# close # close
@ -604,20 +604,22 @@ Print A (char) to hFILE
## ASM ## ASM
**In:** **In:**
A : character `>PUSHB character`
Y : stream `lda stream`
`>SYSCALL fputc`
**Out:** **Out:**
CC = success CC = success
# PutChar # PutChar
Print A (char) to StdOut
## C ## C
`int putchar ( int character );` `int putchar ( int character );`
## ASM ## ASM
Print A (char) to StdOut
**In:** **In:**
A : char to print `lda caracter`
`>SYSCALL putchar`
**Out:** **Out:**
CC = success CC = success
@ -793,20 +795,20 @@ A = Number of arguments filled.
Open a file Open a file
## C ## C
`hFILE fopen ( const char * filename, short int mode, short int ftype, int auxtype );` `hFILE fopen ( const char * filename, short int flags, short int ftype, int auxtype );`
**In:** **In:**
## ASM ## ASM
`>PUSHWI auxtype` `>PUSHWI auxtype`
`>PUSHBI ftype` `>PUSHBI ftype`
`>PUSHBI mode` `>PUSHBI flags`
+ O.RDONLY : if R and exists -> ERROR + O.RDONLY : if R and exists -> ERROR
+ O.WRONLY : if W and exists -> CREATE + O.WRONLY : if W and exists -> CREATE
+ O.TRUNC : Reset Size To 0 + O.TRUNC : Reset Size To 0
+ O.APPEND : Append + O.APPEND : Append
+ O.TEXT : Open/Append in Text mode + O.TEXT : Open/Append in Text mode
+ O.CREATE : Create if not exists + O.CREATE : Create if not exists
TODO: mode="w+,t=TYP,x=AUXTYPE" TODO: replace flags/ftype/auxtype with mode="w+,t=TYP,x=AUXTYPE"
+ r = O_RDONLY + r = O_RDONLY
+ r+ = O_RDWR + r+ = O_RDWR
+ w = O_WRONLY | O_CREAT | O_TRUNC + w = O_WRONLY | O_CREAT | O_TRUNC
@ -833,8 +835,12 @@ int fclose ( hFILE stream );
**Out:** **Out:**
# FRead # FRead
int fread (hFILE stream, void * ptr, int count );
Read bytes from file Read bytes from file
## C
int fread (hFILE stream, void * ptr, int count );
## ASM
**In:** **In:**
`>PUSHWI count` `>PUSHWI count`
`>PUSHW ptr` `>PUSHW ptr`
@ -938,10 +944,10 @@ Rename a file
# strtof # strtof
Convert String to 40 bits Float Convert String to 40 bits Float
##C ## C
`float strtof (const char* str, char** endptr);` `float strtof (const char* str, char** endptr);`
##ASM ## ASM
**In:** **In:**
`>PUSHWI EndPtr` `>PUSHWI EndPtr`
`>LDYA str` `>LDYA str`
@ -1132,7 +1138,7 @@ Get System Time in Buffer
## C ## C
`time_t time (S.TIME* timer);` `time_t time (S.TIME* timer);`
##ASM ## ASM
**In:** **In:**
Y,A = PTR to S.TIME Y,A = PTR to S.TIME
**Out:** **Out:**
@ -1144,7 +1150,7 @@ S.TIME filled with System date/time
## C ## C
`int PTime2Time (long* ptime, S.TIME* timer);` `int PTime2Time (long* ptime, S.TIME* timer);`
##ASM ## ASM
**In :** **In :**
`>PUSHW timer` `>PUSHW timer`
`>LDYA ptime` `>LDYA ptime`
@ -1157,7 +1163,7 @@ S.TIME filled with System date/time
## C ## C
`int CTime2Time (long* ctime, S.TIME* timer);` `int CTime2Time (long* ctime, S.TIME* timer);`
##ASM ## ASM
**In :** **In :**
`>PUSHW timer` `>PUSHW timer`
`>LDYA ctime` `>LDYA ctime`

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -105,11 +105,11 @@ SEEK.END .EQ $04
*-------------------------------------- *--------------------------------------
* .EQ $00 * .EQ $00
* .EQ $02 * .EQ $02
SYS.Stat .EQ $04 SYS.FStat .EQ $04
SYS.MKDir .EQ $06 SYS.Stat .EQ $06
SYS.MKNod .EQ $08 SYS.MKDir .EQ $08
SYS.MKFIFO .EQ $0A SYS.MKNod .EQ $0A
SYS.FStat .EQ $0C SYS.MKFIFO .EQ $0C
* .EQ $0E * .EQ $0E
SYS.OpenDir .EQ $10 SYS.OpenDir .EQ $10

View File

@ -13,23 +13,33 @@ A2osX.D1.S .EQ A2osX.D2-A2osX.D1
A2osX.D2.S .EQ A2osX.E0-A2osX.D2 A2osX.D2.S .EQ A2osX.E0-A2osX.D2
A2osX.E0.S .EQ A2osX.E0.E-A2osX.E0 A2osX.E0.S .EQ A2osX.E0.E-A2osX.E0
*-------------------------------------- *--------------------------------------
.LIST OFF
.DO A2osX.MAIN.S>$700 .DO A2osX.MAIN.S>$700
.LIST ON
* ERROR:MAIN too big * ERROR:MAIN too big
.LIST OFF
.FIN .FIN
.DO A2osX.AUX.S>$C00 .DO A2osX.AUX.S>$C00
.LIST ON
* ERROR:AUX too big * ERROR:AUX too big
.LIST OFF
.FIN .FIN
.DO A2osX.GP.SC>$1E0 .DO A2osX.GP.SC>$1E0
.LIST ON
* ERROR:GP too big * ERROR:GP too big
.LIST OFF
.FIN .FIN
.DO A2osX.D1.S>$1000 .DO A2osX.D1.S>$1000
.LIST ON
* ERROR:BNK1 too big * ERROR:BNK1 too big
.LIST OFF
.FIN .FIN
.DO A2osX.D2.S>$1000 .DO A2osX.D2.S>$1000
.LIST ON
* ERROR:BNK2 too big * ERROR:BNK2 too big
.LIST OFF
.FIN .FIN
*-------------------------------------- *--------------------------------------
.LIST OFF
MAN MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.CTRL SAVE /A2OSX.SRC/SYS/KERNEL.S.CTRL
LOAD /A2OSX.SRC/SYS/KERNEL.S LOAD /A2OSX.SRC/SYS/KERNEL.S

View File

@ -133,7 +133,7 @@ Kernel.Init3 sta SETALTZP
ldy #S.PS.hPREFIX ldy #S.PS.hPREFIX
lda (pPs),y lda (pPs),y
>SYSCALL GetMemPtr jsr K.GetMemPtr
>PUSHYA >PUSHYA
@ -166,7 +166,7 @@ Kernel.Init3 sta SETALTZP
bcs .9 bcs .9
pla pla
>SYSCALL FreeMem ...discard... jsr K.FreeMem ...discard...
>LDYAI MSG.Init3.OK >LDYAI MSG.Init3.OK
>SYSCALL puts >SYSCALL puts
@ -914,7 +914,7 @@ TskMgrInit >LDYAI MSG.TSK
>SYSCALL puts >SYSCALL puts
>LDYAI K.ENV.SIZE get a buffer for ENV >LDYAI K.ENV.SIZE get a buffer for ENV
>SYSCALL GetMem0 make sure blank!! jsr K.GetMem0 make sure blank!!
bcs .9 bcs .9
txa txa

View File

@ -4,7 +4,7 @@ AUTO 4,1
*/-------------------------------------- */--------------------------------------
* # open * # open
* ## C * ## C
* `hFD open(const char *pathname, int flags);` * `hFD open(const char *pathname, short int flags);`
* ## ASM * ## ASM
* **In:** * **In:**
* `>PUSHB flags` * `>PUSHB flags`
@ -12,32 +12,149 @@ AUTO 4,1
* `>SYSCALL open` * `>SYSCALL open`
* **Out:** * **Out:**
* A = hFD * A = hFD
* note : if file is created on ProDOS : T=TXT,X=$0000 * REG File created on ProDOS : T=TXT,X=$0000
*\-------------------------------------- *\--------------------------------------
K.Open jsr PFT.CheckPathYA check if not /mnt K.Open.FLAGS .BS 1
K.Open.TYPE .BS 1
K.Open.AUXTYPE .BS 2
*--------------------------------------
K.Open pha
>PULLB K.Open.FLAGS
pla
K.Open.I jsr STDIO.SetMLIPathYA local pathname... IO.Open.I jsr STDIO.SetMLIPathYA
>PULLB K.FOpen.MODE
lda #S.FI.T.TXT
sta K.Open.TYPE
stz K.Open.AUXTYPE
stz K.Open.AUXTYPE+1
ldx #5 $/DEV/ ldx #5 $/DEV/
cpx K.MLI.PATH cpx K.MLI.PATH
bcs K.Open.REG bcs .2
.1 lda K.MLI.PATH,x .1 lda K.MLI.PATH,x
cmp IO.DEVDIR,x cmp IO.DEVDIR,x
bne K.Open.REG bne .2
dex dex
bne .1 bne .1
*-------------------------------------- *--------------------------------------
K.Open.DEV >LDYAI K.MLI.PATH+6 skip $/DEV/ * CDEV,BDEV,DSOCK,SSOCK,PIPE
*--------------------------------------
.2 >LDYAI K.MLI.PATH+6 skip $/DEV/
jsr K.GetDevByName jsr K.GetDevByName
bcs .9 bcs IO.OPEN.RTS
>STYA pFD >STYA pFD
stx .1+1 DEVID stx .1+1 DEVID
jsr K.IOCTL.GetPDrv lda (pFD) #S.FD.T
tax
jmp (.3,x)
.3 .DA STDIO.IOERR REG
.DA STDIO.IOERR DIR
.DA IO.OPEN.CDEV
.DA STDIO.IOERR BDEV
.DA STDIO.IOERR LNK
.DA IO.OPEN.DSOCK
.DA IO.OPEN.SSOCK
.DA IO.OPEN.PIPE
IO.OPEN.9 sec
IO.OPEN.RTS rts
*--------------------------------------
IO.OPEN.REG >MLICALL MLIGETFILEINFO
bcc K.IO.OPEN.REG.E Already Exists
bit K.Open.FLAGS Create if not exists ?
bpl IO.OPEN.9 No, return MLI error
lda #S.FI.A.FULL Yes, Create...
sta K.MLI.PARAMS+3 Access
lda K.Open.TYPE
sta K.MLI.PARAMS+4 File type
>LDYA K.Open.AUXTYPE
>STYA K.MLI.PARAMS+5 Aux type
lda #S.FI.ST.STD
sta K.MLI.PARAMS+7
ldx #3
.1 lda DATELO,x
sta K.MLI.PARAMS+8,x
dex
bpl .1
>MLICALL MLICREATE
bcs IO.OPEN.RTS
K.IO.OPEN.REG.E >LDYAI S.FD.REG
ldx #S.MEM.F.INIT0+S.MEM.F.FD
jsr MEM.GetMem.YAX
bcs IO.OPEN.RTS
>STYA pFD
stx .8+1 save hFD
* ldy #S.FD.T Done by GetMem0
* lda #S.FD.T.REG
* sta (pFD),y
jsr STDIO.SetIOBUF
bcs .9
>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
lda K.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 .9
>MLICALL MLISETMARK
.21 bcs .9
.20 lda K.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 .9
.8 lda #$ff
rts
.9 pha
lda .8+1
pha
jsr IO.Close.I
pla
sec
rts
*--------------------------------------
IO.OPEN.CDEV jsr K.IOCTL.GetPDrv
.1 lda #$ff SELF MODIFIED pass A=DEVID To Driver .1 lda #$ff SELF MODIFIED pass A=DEVID To Driver
ldx #IOCTL.OPEN ldx #IOCTL.OPEN
@ -48,11 +165,13 @@ K.Open.DEV >LDYAI K.MLI.PATH+6 skip $/DEV/
lda Dev.Table.hFD,x lda Dev.Table.hFD,x
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
K.Open.REG lda #S.FI.T.TXT IO.OPEN.DSOCK
sta K.FOpen.TYPE *--------------------------------------
stz K.FOpen.AUXTYPE IO.OPEN.SSOCK
stz K.FOpen.AUXTYPE+1 *--------------------------------------
jmp K.FOpen.I IO.OPEN.PIPE
clc
rts
*/-------------------------------------- */--------------------------------------
* # close * # close
* ## C * ## C
@ -62,30 +181,26 @@ K.Open.REG lda #S.FI.T.TXT
* `lda fd` * `lda fd`
* `>SYSCALL close` * `>SYSCALL close`
*\-------------------------------------- *\--------------------------------------
K.Close jsr K.GetMemPtr K.Close pha save hFD
bcs .9 jsr K.GetMemPtr
>STYA pFD >STYA pFD
lda (pFD) #S.FD.T IO.Close.I lda (pFD) #S.FD.T
tax tax
pla
jmp (.1,x) jmp (.1,x)
.1 .DA IO.CLOSE.REG .1 .DA IO.CLOSE.REG
.DA IO.CLOSE.DIR .DA IO.CLOSE.DIR
.DA IO.CLOSE.CDEV .DA IO.CLOSE.CDEV
.DA STDIO.IOERR BDEV .DA IO.CLOSE.BDEV
.DA STDIO.IOERR LNK .DA STDIO.IOERR LNK
.DA IO.CLOSE.DSOCK .DA IO.CLOSE.DSOCK
.DA IO.CLOSE.SSOCK .DA IO.CLOSE.SSOCK
.DA IO.CLOSE.PIPE .DA IO.CLOSE.PIPE
.9 lda #MLI.E.NODEV
sec
rts
*-------------------------------------- *--------------------------------------
IO.CLOSE.REG IO.CLOSE.REG
IO.CLOSE.DIR IO.CLOSE.DIR pha save hFD
ldy #S.FD.REG.REF ldy #S.FD.REG.REF
lda (pFD),y lda (pFD),y
beq .1 beq .1
@ -94,14 +209,15 @@ IO.CLOSE.DIR
.1 ldy #S.FD.REG.IOBUF .1 ldy #S.FD.REG.IOBUF
lda (pFD),y lda (pFD),y
beq .8 beq .2
jsr K.FreeMem
.2 pla
jmp K.FreeMem jmp K.FreeMem
.8 clc
rts
*-------------------------------------- *--------------------------------------
IO.CLOSE.CDEV IO.CLOSE.CDEV
IO.CLOSE.BDEV
*-------------------------------------- *--------------------------------------
IO.CLOSE.DSOCK IO.CLOSE.DSOCK
IO.CLOSE.SSOCK IO.CLOSE.SSOCK

View File

@ -8,11 +8,11 @@ AUTO 4,1
*-------------------------------------- *--------------------------------------
K.SYSCALL.JMP .DA 0 $00 K.SYSCALL.JMP .DA 0 $00
.DA 0 .DA 0
.DA K.FStat
.DA K.Stat .DA K.Stat
.DA K.MKDir .DA K.MKDir
.DA K.MKNod .DA K.MKNod
.DA K.MKFIFO .DA K.MKFIFO
.DA K.FStat
.DA 0 .DA 0
.DA K.OpenDir $10 .DA K.OpenDir $10

View File

@ -3,7 +3,7 @@ PREFIX /A2OSX.BUILD
AUTO 4,1 AUTO 4,1
*-------------------------------------- *--------------------------------------
* # FStat * # FStat
* Return information about a hfile * Return information about a hFILE
* ## C * ## C
* `int fstat(short int hFILE, struct stat *statbuf);` * `int fstat(short int hFILE, struct stat *statbuf);`
* ## ASM * ## ASM
@ -14,38 +14,14 @@ AUTO 4,1
* **Out:** * **Out:**
*-------------------------------------- *--------------------------------------
K.FStat jsr PFT.CheckNodeA K.FStat jsr PFT.CheckNodeA
jsr STDIO.GetHFile
bcs .9
lda Nod.Table.hPath,x
jsr K.GetMemPtr jsr K.GetMemPtr
bra K.Stat.I
>STYA pFD .9 >RET 2 discard statbuf
lda #S.FD.REG
clc
adc pFD
tay
lda /S.FD.REG
adc pFD+1
jsr K.Stat.I
bcs .9
ldy #S.FD.REG.REF
lda (pFD),y
sta K.MLI.PARAMS+1
>MLICALL MLIGETEOF
bcs .9
ldy #S.STAT.SIZE+3
lda #0
sta (ZPPtr1),y
ldx #2
.1 dey
lda K.MLI.PARAMS+2,x
sta (ZPPtr1),y
dex
bpl .1
.9 rts
*/-------------------------------------- */--------------------------------------
* # Stat * # Stat
* Return information about a file * Return information about a file

View File

@ -18,22 +18,25 @@ BCDBUF .EQ ARG
* `int fputc ( hFILE stream , int character );` * `int fputc ( hFILE stream , int character );`
* ## ASM * ## ASM
* **In:** * **In:**
* A : character * `>PUSHB character`
* Y : stream * `lda stream`
* `>SYSCALL fputc`
* **Out:** * **Out:**
* CC = success * CC = success
*\-------------------------------------- *\--------------------------------------
K.FPutC sta K.IOBuf K.FPutC pha
tya >PULLB K.IOBuf
pla
bra K.PutChar.1 bra K.PutChar.1
*/-------------------------------------- */--------------------------------------
* # PutChar * # PutChar
* Print A (char) to StdOut
* ## C * ## C
* `int putchar ( int character );` * `int putchar ( int character );`
* ## ASM * ## ASM
* Print A (char) to StdOut
* **In:** * **In:**
* A : char to print * `lda caracter`
* `>SYSCALL putchar`
* **Out:** * **Out:**
* CC = success * CC = success
*\-------------------------------------- *\--------------------------------------
@ -43,14 +46,13 @@ K.PutChar sta K.IOBuf
lda (pPs),y lda (pPs),y
K.PutChar.1 jsr STDIO.GetHFile K.PutChar.1 jsr STDIO.GetHFile
bcs K.PutS.9 bcs K.PutS.RTS
ldx #1 ldy #1
K.PutChar.Y lda #0
K.PutChar.X >LDYAI K.IOBuf >PUSHYA
>STYA K.S.IOCTL+S.IOCTL.BUFPTR >PUSHWI K.IOBuf
stx K.S.IOCTL+S.IOCTL.BYTECNT
stz K.S.IOCTL+S.IOCTL.BYTECNT+1
jmp IO.Write.I jmp IO.Write.I
*/-------------------------------------- */--------------------------------------
* # PutS * # PutS
@ -64,21 +66,22 @@ K.PutChar.X >LDYAI K.IOBuf
* **Out:** * **Out:**
* CC = success * CC = success
*\-------------------------------------- *\--------------------------------------
K.PutS >STYA K.S.IOCTL+S.IOCTL.BUFPTR K.PutS >PUSHYA
>STYA ZPPtr1
ldy #S.PS.hStdOut ldy #S.PS.hStdOut
lda (pPs),y lda (pPs),y
jsr K.FPutS.I jsr K.FPutS
bcs K.PutS.9 bcs K.PutS.RTS
lda #13 lda #C.CR
sta K.IOBuf sta K.IOBuf
lda #10 lda #C.LF
sta K.IOBuf+1 sta K.IOBuf+1
ldx #2
bra K.PutChar.X ldy #2
K.PutS.9 rts bra K.PutChar.Y
K.PutS.RTS rts
*/-------------------------------------- */--------------------------------------
* # FPutS * # FPutS
* Write Str to FILE * Write Str to FILE
@ -92,34 +95,14 @@ K.PutS.9 rts
* **Out:** * **Out:**
* CC = success * CC = success
*\-------------------------------------- *\--------------------------------------
K.FPutS pha K.FPutS jsr STDIO.GetHFile
bcs K.PutS.RTS
>PULLA >PULLYA Get String
sta K.S.IOCTL+S.IOCTL.BUFPTR >STYA ZPPtr2 Save Buffer
sta ZPPtr1 >SYSCALL strlen Get String len in Y,A
>PULLA >PUSHYA push len
sta K.S.IOCTL+S.IOCTL.BUFPTR+1 >PUSHW ZPPtr2 push buffer
sta ZPPtr1+1
pla
K.FPutS.I jsr STDIO.GetHFile
bcs K.PutS.9
ldy #0
ldx #0
.1 lda (ZPPtr1),y
beq .2
iny
bne .1
inx
inc ZPPtr1+1
bra .1
.2 sty K.S.IOCTL+S.IOCTL.BYTECNT
stx K.S.IOCTL+S.IOCTL.BYTECNT+1
jmp IO.Write.I jmp IO.Write.I
*/-------------------------------------- */--------------------------------------
* # PrintF/SPrintF/FPrintF * # PrintF/SPrintF/FPrintF
@ -189,8 +172,8 @@ K.SPrintF >STYA pIOBuf Out Buffer
>PULLW ZPPtr1 format >PULLW ZPPtr1 format
bra K.PrintF.1 bra K.PrintF.1
K.FPrintF jsr K.GetMemPtr A = hFILE K.FPrintF jsr STDIO.GetHFile
>STYA pFD bcs K.PutS.RTS
>PULLW ZPPtr1 format >PULLW ZPPtr1 format
bra K.PrintF.0 bra K.PrintF.0
@ -199,15 +182,14 @@ K.PrintF >STYA ZPPtr1 format
ldy #S.PS.hStdOut ldy #S.PS.hStdOut
lda (pPs),y lda (pPs),y
jsr K.GetMemPtr jsr STDIO.GetHFile
>STYA pFD bcs K.PutS.RTS
K.PrintF.0 >LDYAI K.IOBuf K.PrintF.0 >LDYAI K.IOBuf
>STYA pIOBuf >STYA pIOBuf
>STYA K.S.IOCTL+S.IOCTL.BUFPTR
K.PrintF.1 stz K.S.IOCTL+S.IOCTL.BYTECNT K.PrintF.1 stz PrintF.Cnt
stz K.S.IOCTL+S.IOCTL.BYTECNT+1 stz PrintF.Cnt+1
stz PrintF.GetByte+1 stz PrintF.GetByte+1
@ -269,7 +251,10 @@ K.PrintF.1 stz K.S.IOCTL+S.IOCTL.BYTECNT
bcc .1 bcc .1
bcs .99 bcs .99
.8 jsr PrintF.Flush .8 lda pIOBuf+1
eor /K.IOBuf
bne .99
jsr PrintF.Flush
bra .99 bra .99
.10 cmp #'\' .10 cmp #'\'
@ -299,7 +284,11 @@ K.PrintF.1 stz K.S.IOCTL+S.IOCTL.BYTECNT
sta pStack CC sta pStack CC
pla pla
plp plp
rts bcs .9
>LDYA PrintF.Cnt
.9 rts
*-------------------------------------- *--------------------------------------
PrintF.ESC jmp (.1,x) PrintF.ESC jmp (.1,x)
.1 .DA PrintF.B,PrintF.BB .1 .DA PrintF.B,PrintF.BB
@ -646,9 +635,9 @@ PrintF.GetByte lda #$FF SELF MODIFIED LStack Ptr
*-------------------------------------- *--------------------------------------
PrintF.COut phy PrintF.COut phy
ldy K.S.IOCTL+S.IOCTL.BYTECNT ldy PrintF.Cnt
sta (pIOBuf),y sta (pIOBuf),y
inc K.S.IOCTL+S.IOCTL.BYTECNT inc PrintF.Cnt
bne .8 bne .8
lda pIOBuf+1 lda pIOBuf+1
@ -657,25 +646,29 @@ PrintF.COut phy
* we are printing to IObuf, flush! * we are printing to IObuf, flush!
lda K.S.IOCTL+S.IOCTL.BYTECNT+1 lda PrintF.Cnt+1
pha pha
lda #1 Flush $100 bytes lda #1 Flush $100 bytes
sta K.S.IOCTL+S.IOCTL.BYTECNT+1 sta PrintF.Cnt+1
jsr PrintF.Flush
pla pla
inc inc
sta K.S.IOCTL+S.IOCTL.BYTECNT+1 sta PrintF.Cnt+1
.7 inc pIOBuf+1 .7 inc pIOBuf+1
inc K.S.IOCTL+S.IOCTL.BYTECNT+1 inc PrintF.Cnt+1
.8 ply .8 ply
clc clc
rts rts
*-------------------------------------- *--------------------------------------
PrintF.Flush jmp IO.Write.I PrintF.Flush >PUSHW PrintF.Cnt
>PUSHWI K.IOBuf
jmp IO.Write.I
*--------------------------------------
PrintF.Cnt .BS 2
*/-------------------------------------- */--------------------------------------
* # FGetS * # FGetS
* read bytes from stream into the array * read bytes from stream into the array
@ -953,19 +946,19 @@ K.SScanF.Fwd tya Y=char count parsed
* # FOpen * # FOpen
* Open a file * Open a file
* ## C * ## C
* `hFILE fopen ( const char * filename, short int mode, short int ftype, int auxtype );` * `hFILE fopen ( const char * filename, short int flags, short int ftype, int auxtype );`
* **In:** * **In:**
* ## ASM * ## ASM
* `>PUSHWI auxtype` * `>PUSHWI auxtype`
* `>PUSHBI ftype` * `>PUSHBI ftype`
* `>PUSHBI mode` * `>PUSHBI flags`
* + O.RDONLY : if R and !exists -> ERROR * + O.RDONLY : if R and !exists -> ERROR
* + O.WRONLY : if W and !exists -> CREATE * + O.WRONLY : if W and !exists -> CREATE
* + O.TRUNC : Reset Size To 0 * + O.TRUNC : Reset Size To 0
* + O.APPEND : Append * + O.APPEND : Append
* + O.TEXT : Open/Append in Text mode * + O.TEXT : Open/Append in Text mode
* + O.CREATE : Create if not exists * + O.CREATE : Create if not exists
* TODO: mode="w+,t=TYP,x=AUXTYPE" * TODO: replace flags/ftype/auxtype with mode="w+,t=TYP,x=AUXTYPE"
* + r = O_RDONLY * + r = O_RDONLY
* + r+ = O_RDWR * + r+ = O_RDWR
* + w = O_WRONLY | O_CREAT | O_TRUNC * + w = O_WRONLY | O_CREAT | O_TRUNC
@ -979,110 +972,34 @@ K.SScanF.Fwd tya Y=char count parsed
* CC : A = hFILE * CC : A = hFILE
* CS : A = EC * CS : A = EC
*\-------------------------------------- *\--------------------------------------
K.FOpen.PATH .BS 2
*--------------------------------------
K.FOpen jsr PFT.CheckPathYA K.FOpen jsr PFT.CheckPathYA
>STYA K.FOpen.PATH >STYA K.FOpen.PATH
jsr STDIO.SetMLIPathYA pha
>PULLB K.FOpen.MODE >PULLB K.Open.FLAGS
>PULLB K.FOpen.TYPE >PULLB K.Open.TYPE
>PULLW K.FOpen.AUXTYPE >PULLW K.Open.AUXTYPE
K.FOpen.I >MLICALL MLIGETFILEINFO pla
bcc K.FOpen.10 Already Exists jsr IO.Open.I
bcs K.FOpen.RTS
bit K.FOpen.MODE Create if not exists ? sta .1+1 save hFD
bpl K.FOpen.9 No, return MLI error tax
lda #S.FI.A.FULL Yes, Create... >LDYA K.FOpen.PATH
sta K.MLI.PARAMS+3 Access
lda K.FOpen.TYPE
sta K.MLI.PARAMS+4 File type
>LDYA K.FOpen.AUXTYPE
>STYA K.MLI.PARAMS+5 Aux type
lda #S.FI.ST.STD
sta K.MLI.PARAMS+7
ldx #3
.1 lda DATELO,x
sta K.MLI.PARAMS+8,x
dex
bpl .1
>MLICALL MLICREATE
bcc K.FOpen.10
K.FOpen.9 rts
K.FOpen.10 >LDYAI S.FD.REG
ldx #S.MEM.F.INIT0+S.MEM.F.FD
jsr MEM.GetMem.YAX
bcs K.FOpen.9
>STYA pFD
stx .8+1
* ldy #S.FD.T Done by GetMem0
* lda #S.FD.T.REG
* sta (pFD),y
jsr STDIO.SetIOBUF
bcs .98
>MLICALL MLIOPEN
bcs .98
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
lda K.FOpen.MODE
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 .98
>MLICALL MLISETMARK
.21 bcs .98
.20 lda K.FOpen.MODE
and #O.TEXT Text Mode ?
beq .22
lda #$FF
sta K.MLI.PARAMS+2
lda #C.CR
sta K.MLI.PARAMS+3
>MLICALL MLINEWLINE
.22 >LDYA K.FOpen.PATH
.8 ldx #$ff Self Modified, hFD
jsr STDIO.NewHFileYAX jsr STDIO.NewHFileYAX
bcc .80 bcc K.FOpen.RTS
.98 pha save MLI error pha save MLI error
lda .8+1 .1 lda #$ff SELF MODIFIED
jsr K.Close jsr K.Close
pla get back MLI error pla get back MLI error
sec sec
.80 rts K.FOpen.RTS rts
*--------------------------------------
K.FOpen.PATH .BS 2
K.FOpen.MODE .BS 1
K.FOpen.TYPE .BS 1
K.FOpen.AUXTYPE .BS 2
*/-------------------------------------- */--------------------------------------
* # FClose * # FClose
* Close a file * Close a file
@ -1118,8 +1035,10 @@ K.FClose jsr PFT.CheckNodeA
rts rts
*/-------------------------------------- */--------------------------------------
* # FRead * # FRead
* int fread (hFILE stream, void * ptr, int count );
* Read bytes from file * Read bytes from file
* ## C
* int fread (hFILE stream, void * ptr, int count );
* ## ASM
* **In:** * **In:**
* `>PUSHWI count` * `>PUSHWI count`
* `>PUSHW ptr` * `>PUSHW ptr`

View File

@ -4,9 +4,9 @@ AUTO 4,1
*/-------------------------------------- */--------------------------------------
* # strtof * # strtof
* Convert String to 40 bits Float * Convert String to 40 bits Float
* ##C * ## C
* `float strtof (const char* str, char** endptr);` * `float strtof (const char* str, char** endptr);`
* ##ASM * ## ASM
* **In:** * **In:**
* `>PUSHWI EndPtr` * `>PUSHWI EndPtr`
* `>LDYA str` * `>LDYA str`

View File

@ -13,7 +13,7 @@ DAY0 .EQ 4 day 0 was a thursday
* Get System Time in Buffer * Get System Time in Buffer
* ## C * ## C
* `time_t time (S.TIME* timer);` * `time_t time (S.TIME* timer);`
* ##ASM * ## ASM
* **In:** * **In:**
* Y,A = PTR to S.TIME * Y,A = PTR to S.TIME
* **Out:** * **Out:**
@ -29,7 +29,7 @@ K.Time >STYA ZPPtr2
* Convert ProDOS Time To S.TIME * Convert ProDOS Time To S.TIME
* ## C * ## C
* `int PTime2Time (long* ptime, S.TIME* timer);` * `int PTime2Time (long* ptime, S.TIME* timer);`
* ##ASM * ## ASM
* **In :** * **In :**
* `>PUSHW timer` * `>PUSHW timer`
* `>LDYA ptime` * `>LDYA ptime`
@ -164,7 +164,7 @@ K.ComputeWDAY lda #3 Thursday : 4 (-1 for mod 7)
* Convert CTime Time To S.TIME * Convert CTime Time To S.TIME
* ## C * ## C
* `int CTime2Time (long* ctime, S.TIME* timer);` * `int CTime2Time (long* ctime, S.TIME* timer);`
* ##ASM * ## ASM
* **In :** * **In :**
* `>PUSHW timer` * `>PUSHW timer`
* `>LDYA ctime` * `>LDYA ctime`