mirror of
https://github.com/irmen/prog8.git
synced 2024-11-29 17:50:35 +00:00
diskio.f_readline() now also returns I/O status as secondary return value in A
This commit is contained in:
parent
484677b4b1
commit
69f953fd9b
@ -379,6 +379,7 @@ m_in_buffer sta $ffff
|
|||||||
; optimized for Commander X16 to use MACPTR block read kernal call
|
; optimized for Commander X16 to use MACPTR block read kernal call
|
||||||
sub f_read_all(uword bufferpointer) -> uword {
|
sub f_read_all(uword bufferpointer) -> uword {
|
||||||
; -- read the full contents of the file, returns number of bytes read.
|
; -- read the full contents of the file, returns number of bytes read.
|
||||||
|
; It is assumed the file size is less than 64 K.
|
||||||
; NOTE: cannot be used to load into VRAM. Use vload() or call cx16.MACPTR() yourself with the vera data register as address.
|
; NOTE: cannot be used to load into VRAM. Use vload() or call cx16.MACPTR() yourself with the vera data register as address.
|
||||||
if not iteration_in_progress
|
if not iteration_in_progress
|
||||||
return 0
|
return 0
|
||||||
@ -393,12 +394,12 @@ m_in_buffer sta $ffff
|
|||||||
return total_read
|
return total_read
|
||||||
}
|
}
|
||||||
|
|
||||||
asmsub f_readline(uword bufptr @AY) clobbers(X) -> ubyte @Y {
|
asmsub f_readline(uword bufptr @AY) clobbers(X) -> ubyte @Y, ubyte @A {
|
||||||
; Routine to read text lines from a text file. Lines must be less than 255 characters.
|
; Routine to read text lines from a text file. Lines must be less than 255 characters.
|
||||||
; Reads characters from the input file UNTIL a newline or return character (or EOF).
|
; Reads characters from the input file UNTIL a newline or return character (or EOF).
|
||||||
; The line read will be 0-terminated in the buffer (and not contain the end of line character).
|
; The line read will be 0-terminated in the buffer (and not contain the end of line character).
|
||||||
; The length of the line is returned in Y. Note that an empty line is okay and is length 0!
|
; The length of the line is returned in Y. Note that an empty line is okay and is length 0!
|
||||||
; I/O error status should be checked by the caller itself via READST() routine.
|
; The I/O error status byte is returned in A.
|
||||||
%asm {{
|
%asm {{
|
||||||
sta P8ZP_SCRATCH_W1
|
sta P8ZP_SCRATCH_W1
|
||||||
sty P8ZP_SCRATCH_W1+1
|
sty P8ZP_SCRATCH_W1+1
|
||||||
@ -415,7 +416,8 @@ _loop jsr cbm.CHRIN
|
|||||||
_line_end dey ; get rid of the trailing end-of-line char
|
_line_end dey ; get rid of the trailing end-of-line char
|
||||||
lda #0
|
lda #0
|
||||||
sta (P8ZP_SCRATCH_W1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
_end rts
|
_end jsr cbm.READST
|
||||||
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,6 +469,7 @@ _end rts
|
|||||||
|
|
||||||
sub f_write(uword bufferpointer, uword num_bytes) -> bool {
|
sub f_write(uword bufferpointer, uword num_bytes) -> bool {
|
||||||
; -- write the given number of bytes to the currently open file
|
; -- write the given number of bytes to the currently open file
|
||||||
|
; you can call this multiple times to append more data
|
||||||
if num_bytes!=0 {
|
if num_bytes!=0 {
|
||||||
reset_write_channel()
|
reset_write_channel()
|
||||||
do {
|
do {
|
||||||
|
@ -333,6 +333,7 @@ m_in_buffer sta $ffff
|
|||||||
|
|
||||||
sub f_read_all(uword bufferpointer) -> uword {
|
sub f_read_all(uword bufferpointer) -> uword {
|
||||||
; -- read the full contents of the file, returns number of bytes read.
|
; -- read the full contents of the file, returns number of bytes read.
|
||||||
|
; It is assumed the file size is less than 64 K.
|
||||||
if not iteration_in_progress
|
if not iteration_in_progress
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@ -346,12 +347,13 @@ m_in_buffer sta $ffff
|
|||||||
return total_read
|
return total_read
|
||||||
}
|
}
|
||||||
|
|
||||||
asmsub f_readline(uword bufptr @AY) clobbers(X) -> ubyte @Y {
|
asmsub f_readline(uword bufptr @AY) clobbers(X) -> ubyte @Y, ubyte @A {
|
||||||
; Routine to read text lines from a text file. Lines must be less than 255 characters.
|
; Routine to read text lines from a text file. Lines must be less than 255 characters.
|
||||||
; Reads characters from the input file UNTIL a newline or return character (or EOF).
|
; Reads characters from the input file UNTIL a newline or return character (or EOF).
|
||||||
; The line read will be 0-terminated in the buffer (and not contain the end of line character).
|
; The line read will be 0-terminated in the buffer (and not contain the end of line character).
|
||||||
; The length of the line is returned in Y. Note that an empty line is okay and is length 0!
|
; The length of the line is returned in Y. Note that an empty line is okay and is length 0!
|
||||||
; I/O error status should be checked by the caller itself via READST() routine.
|
; I/O error status should be checked by the caller itself via READST() routine.
|
||||||
|
; The I/O error status byte is returned in A.
|
||||||
%asm {{
|
%asm {{
|
||||||
sta P8ZP_SCRATCH_W1
|
sta P8ZP_SCRATCH_W1
|
||||||
sty P8ZP_SCRATCH_W1+1
|
sty P8ZP_SCRATCH_W1+1
|
||||||
@ -368,7 +370,8 @@ _loop jsr cbm.CHRIN
|
|||||||
_line_end dey ; get rid of the trailing end-of-line char
|
_line_end dey ; get rid of the trailing end-of-line char
|
||||||
lda #0
|
lda #0
|
||||||
sta (P8ZP_SCRATCH_W1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
_end rts
|
_end jsr cbm.READST
|
||||||
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,6 +408,7 @@ _end rts
|
|||||||
|
|
||||||
sub f_write(uword bufferpointer, uword num_bytes) -> bool {
|
sub f_write(uword bufferpointer, uword num_bytes) -> bool {
|
||||||
; -- write the given number of bytes to the currently open file
|
; -- write the given number of bytes to the currently open file
|
||||||
|
; you can call this multiple times to append more data
|
||||||
if num_bytes!=0 {
|
if num_bytes!=0 {
|
||||||
reset_write_channel()
|
reset_write_channel()
|
||||||
repeat num_bytes {
|
repeat num_bytes {
|
||||||
|
@ -72,6 +72,7 @@ diskio {
|
|||||||
|
|
||||||
sub f_read_all(uword bufferpointer) -> uword {
|
sub f_read_all(uword bufferpointer) -> uword {
|
||||||
; -- read the full contents of the file, returns number of bytes read.
|
; -- read the full contents of the file, returns number of bytes read.
|
||||||
|
; It is assumed the file size is less than 64 K.
|
||||||
txt.print("@TODO: f_read_all\n")
|
txt.print("@TODO: f_read_all\n")
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -81,7 +82,7 @@ diskio {
|
|||||||
; Reads characters from the input file UNTIL a newline or return character (or EOF).
|
; Reads characters from the input file UNTIL a newline or return character (or EOF).
|
||||||
; The line read will be 0-terminated in the buffer (and not contain the end of line character).
|
; The line read will be 0-terminated in the buffer (and not contain the end of line character).
|
||||||
; The length of the line is returned in Y. Note that an empty line is okay and is length 0!
|
; The length of the line is returned in Y. Note that an empty line is okay and is length 0!
|
||||||
; I/O error status should be checked by the caller itself via READST() routine.
|
; This routine is not able here to return the status as well in a secondary return value, so you have to do that yourself.
|
||||||
txt.print("@TODO: f_readline\n")
|
txt.print("@TODO: f_readline\n")
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -107,6 +108,7 @@ diskio {
|
|||||||
|
|
||||||
sub f_write(uword bufferpointer, uword num_bytes) -> bool {
|
sub f_write(uword bufferpointer, uword num_bytes) -> bool {
|
||||||
; -- write the given number of bytes to the currently open file
|
; -- write the given number of bytes to the currently open file
|
||||||
|
; you can call this multiple times to append more data
|
||||||
txt.print("@TODO: f_write\n")
|
txt.print("@TODO: f_write\n")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ TODO
|
|||||||
|
|
||||||
See open issues on github.
|
See open issues on github.
|
||||||
|
|
||||||
|
Re-generate the skeleons doc files.
|
||||||
|
|
||||||
IR: add SEC and CLC instructions in place of call to sys.set_carry() and sys.clear_carry(). (check more inline sub calls that should be a single instruction?)
|
IR: add SEC and CLC instructions in place of call to sys.set_carry() and sys.clear_carry(). (check more inline sub calls that should be a single instruction?)
|
||||||
|
|
||||||
optimize signed byte/word division by powers of 2 (and shift right?), it's now using divmod routine. (also % ?)
|
optimize signed byte/word division by powers of 2 (and shift right?), it's now using divmod routine. (also % ?)
|
||||||
|
Loading…
Reference in New Issue
Block a user