From: cuz Date: Fri, 5 Jan 2007 16:16:34 +0000 (+0000) Subject: Update from Oliver Schmidt X-Git-Tag: V2.12.0~89 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=88aedc2e29a2d2ee07e5901ab5add892cb32f3cf;p=cc65 Update from Oliver Schmidt git-svn-id: svn://svn.cc65.org/cc65/trunk@3766 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/include/dirent.h b/include/dirent.h index 012ee82e9..fc582c1d1 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -43,10 +43,36 @@ 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__ */ + /*****************************************************************************/ diff --git a/libsrc/apple2/dir.h b/libsrc/apple2/dir.h index 997e63bcd..0faffd634 100644 --- a/libsrc/apple2/dir.h +++ b/libsrc/apple2/dir.h @@ -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; }; diff --git a/libsrc/apple2/mli.inc b/libsrc/apple2/mli.inc index a1a599723..6c29b275e 100644 --- a/libsrc/apple2/mli.inc +++ b/libsrc/apple2/mli.inc @@ -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 diff --git a/libsrc/apple2/readdir.c b/libsrc/apple2/readdir.c index f4653cfae..bc5647002 100644 --- a/libsrc/apple2/readdir.c +++ b/libsrc/apple2/readdir.c @@ -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]; } diff --git a/libsrc/apple2/systime.s b/libsrc/apple2/systime.s index 5711fccae..68ca00bb3 100644 --- a/libsrc/apple2/systime.s +++ b/libsrc/apple2/systime.s @@ -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 + jmp _mktime + +err: lda #$FF + tax + sta sreg + sta sreg+1 + rts ; Return -1 + + .bss + +TM: .tag tm \ No newline at end of file