Factorize file pointer check
This commit is contained in:
@@ -5,7 +5,8 @@
|
||||
;
|
||||
|
||||
.export _fgetc
|
||||
.import _read, pusha0, pushax, popptr1, incsp2, returnFFFF
|
||||
.import _read, checkferror
|
||||
.import pusha0, pushax, popptr1, incsp2, returnFFFF
|
||||
.importzp ptr1
|
||||
|
||||
.include "stdio.inc"
|
||||
@@ -16,16 +17,10 @@ _fgetc:
|
||||
stx ptr1+1
|
||||
jsr pushax ; Backup our ptr
|
||||
|
||||
ldy #_FILE::f_flags
|
||||
lda (ptr1),y
|
||||
tax
|
||||
and #_FOPEN ; Check for file open
|
||||
beq ret_eof
|
||||
txa
|
||||
and #(_FERROR|_FEOF); Check for error/eof
|
||||
jsr checkferror
|
||||
bne ret_eof
|
||||
|
||||
txa
|
||||
tax
|
||||
and #_FPUSHBACK ; Check for pushed back char
|
||||
beq do_read
|
||||
|
||||
|
||||
Reference in New Issue
Block a user