1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-11 11:30:13 +00:00

Update from Oliver Schmidt

git-svn-id: svn://svn.cc65.org/cc65/trunk@3766 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2007-01-05 16:16:34 +00:00
parent 4846c27c77
commit 88aedc2e29
5 changed files with 111 additions and 15 deletions

View File

@ -43,10 +43,36 @@
typedef struct DIR DIR; 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 { struct dirent {
char d_name[1]; char d_name[1];
}; };
#endif /* __APPLE2__ or __APPLE2ENH__ */
/*****************************************************************************/ /*****************************************************************************/

View File

@ -51,7 +51,7 @@ struct DIR {
struct { struct {
unsigned prev_block; unsigned prev_block;
unsigned next_block; unsigned next_block;
char entries[1]; unsigned char entries[1];
} content; } content;
} block; } block;
}; };

View File

@ -8,6 +8,9 @@ READ_BLOCK_CALL = $80
WRITE_BLOCK_CALL= $81 WRITE_BLOCK_CALL= $81
RW_BLOCK_COUNT = 3 RW_BLOCK_COUNT = 3
GET_TIME_CALL = $82
GET_TIME_COUNT = 0
CREATE_CALL = $C0 CREATE_CALL = $C0
CREATE_COUNT = 7 CREATE_COUNT = 7
@ -113,5 +116,7 @@ EOF_COUNT = 2
ENTRY := $BF00 ; MLI call entry point ENTRY := $BF00 ; MLI call entry point
DEVNUM := $BF30 ; Most recent accessed device 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 PFIXPTR := $BF9A ; If = 0, no prefix active
KVERSION:= $BFFF ; Kernel version number KVERSION:= $BFFF ; Kernel version number

View File

@ -45,7 +45,7 @@
struct dirent* __fastcall__ readdir (DIR* dir) struct dirent* __fastcall__ readdir (DIR* dir)
{ {
char* entry; unsigned char* entry;
/* Search for the next active directory entry */ /* Search for the next active directory entry */
do { do {
@ -73,9 +73,18 @@ struct dirent* __fastcall__ readdir (DIR* dir)
++dir->current_entry; ++dir->current_entry;
} while (entry[0] == 0); } while (entry[0] == 0);
/* Zero-terminate name */ /* Move creation date/time to allow for next step below */
entry[1 + (entry[0] & 15)] = '\0'; *(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 success */
return (struct dirent*)&entry[1]; return (struct dirent*)&entry[0x01];
} }

View File

@ -1,5 +1,5 @@
; ;
; Ullrich von Bassewitz, 12.11.2002 ; Oliver Schmidt, 22.08.2006
; ;
; time_t _systime (void); ; time_t _systime (void);
; /* Similar to time(), but: ; /* Similar to time(), but:
@ -10,12 +10,68 @@
; ;
.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: __systime:
lda #$FF ; 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 tax
sta sreg sta sreg
sta sreg+1 sta sreg+1
rts ; Return -1 rts ; Return -1
.bss
TM: .tag tm