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__ */
+
/*****************************************************************************/
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;
};
WRITE_BLOCK_CALL= $81
RW_BLOCK_COUNT = 3
+GET_TIME_CALL = $82
+GET_TIME_COUNT = 0
+
CREATE_CALL = $C0
CREATE_COUNT = 7
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
struct dirent* __fastcall__ readdir (DIR* dir)
{
- char* entry;
+ unsigned char* entry;
/* Search for the next active directory entry */
do {
++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];
}
;
-; Ullrich von Bassewitz, 12.11.2002
+; Oliver Schmidt, 22.08.2006
;
; time_t _systime (void);
; /* Similar to time(), but:
; */
;
- .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