]> git.sur5r.net Git - cc65/blobdiff - libsrc/cbm/open.s
no TGI_ERR_NO_MEM or TGI_ERR_NO_IOCB anymore: replaced by TGI_ERR_NO_RES
[cc65] / libsrc / cbm / open.s
index 5f2d7b6274d15b0f6c36b8253c29e465da46f2fa..8678d358281b877410f132c1698ceebbc7d1a801 100644 (file)
@@ -13,7 +13,7 @@
 
         .import         SETLFS, OPEN, CLOSE
         .import         addysp, popax
-        .import         scratch, fnparse, fncomplete, fnset
+        .import         scratch, fnparse, fnaddmode, fncomplete, fnset
         .import         opencmdchannel, closecmdchannel, readdiskerror
         .import         __oserror
         .import         fnunit
@@ -30,8 +30,8 @@
 
 .proc   closeallfiles
 
-        ldx     #MAX_FDS
-loop:   lda     fdtab-1,x
+        ldx     #MAX_FDS-1
+loop:   lda     fdtab,x
         beq     next            ; Skip unused entries
 
 ; Close this file
@@ -46,7 +46,7 @@ loop:   lda     fdtab-1,x
 ; Next file
 
 next:   dex
-        bne     loop
+        bpl     loop
 
         rts
 
@@ -57,13 +57,14 @@ next:   dex
 
 .proc   _open
 
-       cpy     #4              ; correct # of arguments (bytes)?
-       beq     parmok          ; parameter count ok
-       tya                     ; parm count < 4 shouldn't be needed to be...
-               sec                     ; ...checked (it generates a c compiler warning)
-       sbc     #4
-       tay
-       jsr     addysp          ; fix stack, throw away unused parameters
+; Throw away any additional parameters passed through the ellipsis
+
+               dey                     ; Parm count < 4 shouldn't be needed to be...
+               dey                     ; ...checked (it generates a c compiler warning)
+        dey
+       dey
+       beq     parmok          ; Branch if parameter count ok
+       jsr     addysp          ; Fix stack, throw away unused parameters
 
 ; Parameters ok. Pop the flags and save them into tmp3
 
@@ -109,7 +110,7 @@ notrunc:
         bne     append          ; Branch if yes
         ldx     #'w'
 append: txa
-        jsr     fncomplete
+        jsr     fncomplete      ; Add type and mode to the name
 
 ; Setup the real open flags
 
@@ -119,7 +120,7 @@ append: txa
 ; Read bit is set. Add an 'r' to the name
 
 doread: lda     #'r'
-        jsr     fncomplete
+        jsr     fnaddmode       ; Add the mode to the name
         lda     #LFN_READ
 
 ; Common read/write code. Flags in A, handle in tmp2