]> git.sur5r.net Git - cc65/commitdiff
Update from Oliver Schmidt
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 5 Jan 2007 16:16:34 +0000 (16:16 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 5 Jan 2007 16:16:34 +0000 (16:16 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@3766 b7a2c559-68d2-44c3-8de9-860c34a00d81

include/dirent.h
libsrc/apple2/dir.h
libsrc/apple2/mli.inc
libsrc/apple2/readdir.c
libsrc/apple2/systime.s

index 012ee82e9ad0dd8e54f0c7662598786daccbdc55..fc582c1d128ec4ec87974a435c9575ab2bbcb8f6 100644 (file)
 
 typedef struct DIR DIR;
 
+#if defined(__APPLE2__) || defined(__APPLE2ENH__)
+
+struct dirent {
+    char          d_name[16];
+    unsigned      d_ino;
+    unsigned      d_blocks;
+    unsigned long d_size;
+    unsigned char d_type;
+    unsigned      d_cdate;
+    struct {
+       unsigned char mins;
+        unsigned char hours;
+    }             d_ctime;
+    unsigned char d_access;
+    unsigned      d_auxtype;
+    unsigned      d_mdate;
+    struct {
+       unsigned char mins;
+        unsigned char hours;
+    }             d_mtime;
+};
+
+#else  /* __APPLE2__ or __APPLE2ENH__ */
+
 struct dirent {
     char d_name[1];
 };
 
+#endif  /* __APPLE2__ or __APPLE2ENH__ */
+
 
 
 /*****************************************************************************/
index 997e63bcd4f9439a904f521980fd7894d5c14bb9..0faffd634e39162168aa00b012fd87f08b84c628 100644 (file)
@@ -49,9 +49,9 @@ struct DIR {
     union {
        unsigned char bytes[512];
        struct {
-           unsigned prev_block;
-           unsigned next_block;
-           char     entries[1];
+           unsigned      prev_block;
+           unsigned      next_block;
+           unsigned char entries[1];
        } content;
     } block;
 };
index a1a599723161a53c97b18fa74ba5bc50c2ee8e57..6c29b275e91bbc8c97071c8595b17288b4e0e907 100644 (file)
@@ -8,6 +8,9 @@ READ_BLOCK_CALL = $80
 WRITE_BLOCK_CALL= $81
 RW_BLOCK_COUNT  = 3
 
+GET_TIME_CALL   = $82
+GET_TIME_COUNT  = 0
+
 CREATE_CALL     = $C0
 CREATE_COUNT    = 7
 
@@ -113,5 +116,7 @@ EOF_COUNT       = 2
 
 ENTRY   :=      $BF00          ; MLI call entry point
 DEVNUM  :=      $BF30          ; Most recent accessed device
+DATELO  :=      $BF90          ; Bits 15-9 = Year, 8-5 = Month, 4-0 = Day
+TIMELO  :=      $BF92          ; Bits 12-8 = Hour, 5-0 = Minute
 PFIXPTR :=      $BF9A          ; If = 0, no prefix active
 KVERSION:=      $BFFF           ; Kernel version number
index f4653cfae42e17a749503ab7b1f5b7d350399b0f..bc5647002c300f1e244c570b570743d6a9dfc322 100644 (file)
@@ -45,7 +45,7 @@
 
 struct dirent* __fastcall__ readdir (DIR* dir)
 {
-    char* entry;
+    unsigned char* entry;
 
     /* Search for the next active directory entry */
     do {
@@ -73,9 +73,18 @@ struct dirent* __fastcall__ readdir (DIR* dir)
        ++dir->current_entry;
     } while (entry[0] == 0);
 
-    /* Zero-terminate name */
-    entry[1 + (entry[0] & 15)] = '\0';
+    /* Move creation date/time to allow for next step below */
+    *(unsigned long*)&entry[0x1A] = *(unsigned long*)&entry[0x18];
+
+    /* Feature unsigned long access to EOF by extending from 3 to 4 bytes */
+    entry[0x18] = 0;
+
+    /* Move file type to allow for next step below */
+    entry[0x19] = entry[0x10];
+
+    /* Zero-terminate file name */
+    entry[0x01 + (entry[0x00] & 0x0F)] = 0;
 
     /* Return success */
-    return (struct dirent*)&entry[1];
+    return (struct dirent*)&entry[0x01];
 }
index 5711fccaedc88119ac191a943ed066e23d9666bb..68ca00bb3237c7d62ae01e503043f94f20e6d3ae 100644 (file)
@@ -1,5 +1,5 @@
 ;
-; Ullrich von Bassewitz, 12.11.2002
+; Oliver Schmidt, 22.08.2006
 ;
 ; time_t _systime (void);
 ; /* Similar to time(), but:
@@ -9,13 +9,69 @@
 ;  */
 ;
 
-        .export                __systime
+       .export         __systime
+       .import         _mktime
 
-        .include       "zeropage.inc"
+       .include        "zeropage.inc"
+       .include        "mli.inc"
+
+        .struct tm
+               tm_sec      .word
+               tm_min      .word
+               tm_hour     .word
+               tm_mday     .word
+               tm_mon      .word
+               tm_year     .word
+               tm_wday     .word
+               tm_yday     .word
+               tm_isdst    .word
+        .endstruct
 
 __systime:
-        lda     #$FF
-        tax
-        sta     sreg
-        sta     sreg+1
-        rts                     ; Return -1
+       ; Update time
+       lda     #GET_TIME_CALL
+       ldx     #GET_TIME_COUNT
+       jsr     callmli
+       bcs     err
+
+       lda     DATELO+1
+       lsr
+       php                     ; Save month msb
+       cmp     #70             ; Year < 70?
+       bcs     :+              ; No, leave alone
+       adc     #100            ; Move 19xx to 20xx
+:      sta     TM + tm::tm_year
+       lda     DATELO
+       tax                     ; Save day
+       plp                     ; Restore month msb
+       ror
+       lsr
+       lsr
+       lsr
+       lsr
+       beq     err             ; [1..12] allows for validity check
+       tay
+       dey                     ; Move [1..12] to [0..11]
+       sty     TM + tm::tm_mon
+       txa                     ; Restore day
+       and     #%00011111
+       sta     TM + tm::tm_mday
+
+       lda     TIMELO+1
+       sta     TM + tm::tm_hour
+       lda     TIMELO
+       sta     TM + tm::tm_min
+
+       lda     #<TM
+       ldx     #>TM
+       jmp     _mktime
+
+err:   lda     #$FF
+       tax
+       sta     sreg
+       sta     sreg+1
+       rts                     ; Return -1
+
+       .bss
+
+TM:    .tag    tm
\ No newline at end of file