]> git.sur5r.net Git - cc65/blobdiff - libsrc/common/_fopen.s
The spans do now contain the size of a span, no longer the end offset.
[cc65] / libsrc / common / _fopen.s
index abf67dd21423498893d101e8ebe01748a22590fe..29f1c4cd92165ff1de2d1d4f03a522793a3c514c 100644 (file)
@@ -22,8 +22,8 @@
 
 .proc   __fopen
 
-        sta     f
-        stx     f+1             ; Save f
+        sta     file
+        stx     file+1          ; Save f
 
 ; Get a pointer to the mode string
 
 
 invmode:
         lda     #EINVAL
-        sta     __errno
-        lda     #0
-        sta     __errno+1
-        tax
+        jsr     __seterrno      ; Set __errno, returns zero in A
+        tax                     ; a/x = 0
         jmp     incsp4
 
 ; Mode string successfully parsed. Store the binary mode onto the stack in
-; the same place where the mode string pointer was before. The call open()
+; the same place where the mode string pointer was before. Then call open()
 
 modeok: ldy     #$00
         txa                     ; Mode -> A
@@ -97,15 +95,15 @@ modeok: ldy     #$00
 
 ; Open call succeeded
 
-openok: ldy     f
+openok: ldy     file
         sty     ptr1
-        ldy     f+1
+        ldy     file+1
         sty     ptr1+1
-        ldy     #_FILE_f_fd
-        sta     (ptr1),y        ; f->f_fd = fd;
-        ldy     #_FILE_f_flags
+        ldy     #_FILE::f_fd
+        sta     (ptr1),y        ; file->f_fd = fd;
+        ldy     #_FILE::f_flags
         lda     #_FOPEN
-        sta     (ptr1),y        ; f->f_flags = _FOPEN;
+        sta     (ptr1),y        ; file->f_flags = _FOPEN;
 
 ; Return the pointer to the file structure
 
@@ -119,6 +117,6 @@ openok: ldy     f
 ; Data
 
 .bss
-f:      .res    2
+file:   .res    2