1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 19:29:37 +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;
#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__ */
/*****************************************************************************/

View 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;
};

View 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

View 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];
}

View 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