]> git.sur5r.net Git - cc65/commitdiff
Introduced constructor to raise the ProDOS 8 file level - and extended the destructor...
authorol.sc <ol.sc@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 29 Jan 2011 21:43:26 +0000 (21:43 +0000)
committerol.sc <ol.sc@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 29 Jan 2011 21:43:26 +0000 (21:43 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@4955 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/apple2/mli.inc
libsrc/apple2/open.s

index 26b40fdd7f55b6ca31091b80b66921e760cc7b77..5463a29fd7f7c86c933685cad421373f904a9003 100644 (file)
@@ -20,6 +20,9 @@ DESTROY_COUNT   = 1
 RENAME_CALL     = $C2
 RENAME_COUNT    = 2
 
+GET_INFO_CALL   = $C4
+GET_INFO_COUNT  = $A
+
 ON_LINE_CALL    = $C5
 ON_LINE_COUNT   = 2
 
@@ -72,6 +75,19 @@ EOF_COUNT       = 2
                                 PATHNAME        .addr
                                 NEW_PATHNAME    .addr
                         .endstruct
+                        .struct INFO
+                                PARAM_COUNT     .byte
+                                PATHNAME        .addr
+                                ACCESS          .byte
+                                FILE_TYPE       .byte
+                                AUX_TYPE        .word
+                                STORAGE_TYPE    .byte
+                                BLOCKS          .word
+                                MODE_DATE       .word
+                                MODE_TIME       .word
+                                CREATE_DATE     .word
+                                CREATE_TIME     .word
+                        .endstruct
                         .struct ON_LINE
                                 PARAM_COUNT     .byte
                                 UNIT_NUM        .byte
@@ -117,7 +133,8 @@ EOF_COUNT       = 2
 DEVNUM  :=      $BF30          ; Most recent accessed device
 DEVCNT  :=      $BF31          ; Number of on-line devices (minus 1)
 DEVLST  :=      $BF32          ; Up to 14 units may be active
-DATELO  :=      $BF90          ; Bits 15-9 = Year, 8-5 = Month, 4-0 = Day
-TIMELO  :=      $BF92          ; Bits 12-8 = Hour, 5-0 = Minute
+DATELO  :=      $BF90          ; Bits 15-9 = year, 8-5 = month, 4-0 = day
+TIMELO  :=      $BF92          ; Bits 12-8 = hour, 5-0 = minute
+LEVEL   :=      $BF94          ; File level: used in open, flush, close
 PFIXPTR :=      $BF9A          ; If = 0, no prefix active
 KVERSION:=      $BFFF           ; Kernel version number
index e7f603aa5ae872457522a81a6aeee2a6af84c9f6..078cfdd480e0f9d7cf6237ff6b81da92c7397f08 100644 (file)
@@ -3,15 +3,13 @@
 ;
 ; int open (const char* name, int flags, ...);
 ;
-; Be sure to keep the value priority of closeallfiles lower than that of
-; closeallstreams (which is the high level C file I/O counterpart and must be
-; called before closeallfiles).
 
         .export        _open, closedirect, freebuffer
         .export        __filetype, __auxtype
+        .constructor   raisefilelevel
         .destructor    closeallfiles, 5
 
-        .import                pushname, popname
+        .import                pushname, popname, __dos_type
         .import                iobuf_alloc, iobuf_free
         .import        addysp, incsp4, incaxy, pushax, popax
 
         .include       "mli.inc"
         .include       "filedes.inc"
 
+        .segment       "INIT"
+
+raisefilelevel:
+        ; Raise file level
+        lda    __dos_type
+        beq    :+
+        inc    LEVEL
+:       rts
+
+        .code
+
 _open:
         ; Throw away all parameters except name
         ; and flags occupying together 4 bytes
@@ -209,10 +218,6 @@ freebuffer:
         ldx    fdtab + FD::BUFFER+1,y
         jmp    iobuf_free
 
-closeallfiles:
-        ; All open files
-        lda    #$00
-
 closedirect:
         ; Set fd
         sta    mliparam + MLI::CLOSE::REF_NUM
@@ -222,6 +227,17 @@ closedirect:
         ldx    #CLOSE_COUNT
         jmp    callmli
 
+closeallfiles:
+        ; All open files with current level (or higher)
+        lda    #$00
+        jsr    closedirect
+
+        ; Restore original file level
+        lda    __dos_type
+        beq    :+
+        dec    LEVEL
+:       rts
+
         .data
 
 CREATE: .byte  %11000011       ; ACCESS:       Standard full access