From: Toni Wilen Date: Sun, 12 Oct 2014 15:39:15 +0000 (+0300) Subject: Added tickcount to date conversions. X-Git-Tag: 3000~24 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=68e3d46dfae0cd656d2dd18f949946f2c17449bd;p=francis%2Fwinuae.git Added tickcount to date conversions. --- diff --git a/disk.cpp b/disk.cpp index 31ee02e9..43654f53 100644 --- a/disk.cpp +++ b/disk.cpp @@ -286,7 +286,7 @@ static void disk_date (uae_u8 *p) tv.tv_sec -= _timezone; mtv.tv_sec = tv.tv_sec; mtv.tv_usec = tv.tv_usec; - timeval_to_amiga (&mtv, &days, &mins, &ticks); + timeval_to_amiga (&mtv, &days, &mins, &ticks, 50); if (days == pdays && mins == pmins && ticks == pticks) { ticks++; if (ticks >= 50 * 60) { diff --git a/filesys.cpp b/filesys.cpp index 0dc130c9..a37ed61b 100644 --- a/filesys.cpp +++ b/filesys.cpp @@ -1375,7 +1375,7 @@ static TCHAR *bstr_cut (Unit *unit, uaecptr addr) static const uae_s64 msecs_per_day = 24 * 60 * 60 * 1000; static const uae_s64 diff = ((8 * 365 + 2) * (24 * 60 * 60)) * (uae_u64)1000; -void timeval_to_amiga (struct mytimeval *tv, int *days, int *mins, int *ticks) +void timeval_to_amiga (struct mytimeval *tv, int *days, int *mins, int *ticks, int tickcount) { /* tv.tv_sec is secs since 1-1-1970 */ /* days since 1-1-1978 */ @@ -1390,10 +1390,10 @@ void timeval_to_amiga (struct mytimeval *tv, int *days, int *mins, int *ticks) t -= *days * msecs_per_day; *mins = t / (60 * 1000); t -= *mins * (60 * 1000); - *ticks = t / (1000 / 50); + *ticks = t / (1000 / tickcount); } -void amiga_to_timeval (struct mytimeval *tv, int days, int mins, int ticks) +void amiga_to_timeval (struct mytimeval *tv, int days, int mins, int ticks, int tickcount) { uae_s64 t; @@ -1403,7 +1403,7 @@ void amiga_to_timeval (struct mytimeval *tv, int days, int mins, int ticks) days = 9900 * 365; // in future far enough? if (mins < 0 || mins >= 24 * 60) mins = 0; - if (ticks < 0 || ticks >= 60 * 50) + if (ticks < 0 || ticks >= 60 * tickcount) ticks = 0; t = ticks * 20; @@ -1564,7 +1564,7 @@ static void set_volume_name (Unit *unit, struct mytimeval *tv) put_byte (unit->volume + 45 + namelen, 0); if (tv && (tv->tv_sec || tv->tv_usec)) { int days, mins, ticks; - timeval_to_amiga (tv, &days, &mins, &ticks); + timeval_to_amiga (tv, &days, &mins, &ticks, 50); put_long (unit->volume + 16, days); put_long (unit->volume + 20, mins); put_long (unit->volume + 24, ticks); @@ -3795,7 +3795,7 @@ static void put_long (info + 124, statbuf.size > MAXFILESIZE32 ? MAXFILESIZE32 : (uae_u32)statbuf.size); } - timeval_to_amiga (&statbuf.mtime, &days, &mins, &ticks); + timeval_to_amiga (&statbuf.mtime, &days, &mins, &ticks, 50); put_long (info + 132, days); put_long (info + 136, mins); put_long (info + 140, ticks); @@ -4092,7 +4092,7 @@ static int exalldo (uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaec size2 += 4; } if (type >= 5) { - timeval_to_amiga (&statbuf.mtime, &days, &mins, &ticks); + timeval_to_amiga (&statbuf.mtime, &days, &mins, &ticks, 50); size2 += 12; } if (type >= 6) { @@ -5550,7 +5550,7 @@ static void handle_softlink (unit, packet, a); return; } - amiga_to_timeval (&tv, get_long (date), get_long (date + 4), get_long (date + 8)); + amiga_to_timeval (&tv, get_long (date), get_long (date + 4), get_long (date + 8), 50); //write_log (_T("%llu.%u (%d,%d,%d) %s\n"), tv.tv_sec, tv.tv_usec, get_long (date), get_long (date + 4), get_long (date + 8), a->nname); if (!my_utime (a->nname, &tv)) err = dos_errno (); diff --git a/include/zfile.h b/include/zfile.h index 7ca15e9d..f9c6b44e 100644 --- a/include/zfile.h +++ b/include/zfile.h @@ -148,7 +148,7 @@ struct mystat uae_u32 mode; struct mytimeval mtime; }; -extern void timeval_to_amiga (struct mytimeval *tv, int* days, int* mins, int* ticks); -extern void amiga_to_timeval (struct mytimeval *tv, int days, int mins, int ticks); +extern void timeval_to_amiga (struct mytimeval *tv, int* days, int* mins, int* ticks, int tickcount); +extern void amiga_to_timeval (struct mytimeval *tv, int days, int mins, int ticks, int tickcount); #endif // UAE_ZFILE_H diff --git a/od-win32/fsdb_mywin32.cpp b/od-win32/fsdb_mywin32.cpp index 0d41aedb..0e5c4daa 100644 --- a/od-win32/fsdb_mywin32.cpp +++ b/od-win32/fsdb_mywin32.cpp @@ -751,7 +751,7 @@ bool my_utime (const TCHAR *name, struct mytimeval *tv) tv2.tv_usec = tv->tv_usec; tolocal = 1; } - timeval_to_amiga (&tv2, &days, &mins, &ticks); + timeval_to_amiga (&tv2, &days, &mins, &ticks, 50); if (setfiletime (name, days, mins, ticks, tolocal)) return true; diff --git a/zfile_archive.cpp b/zfile_archive.cpp index dcd00d8e..aa8ccb8e 100644 --- a/zfile_archive.cpp +++ b/zfile_archive.cpp @@ -1238,7 +1238,7 @@ static void recurseadf (struct znode *zn, int root, TCHAR *name) size = 0; zai.size = size; zai.flags = gl (adf, bs - 48 * 4); - amiga_to_timeval (&zai.tv, gl (adf, bs - 23 * 4), gl (adf, bs - 22 * 4),gl (adf, bs - 21 * 4)); + amiga_to_timeval (&zai.tv, gl (adf, bs - 23 * 4), gl (adf, bs - 22 * 4),gl (adf, bs - 21 * 4), 50); if (secondary == -3) { struct znode *znnew = zvolume_addfile_abs (zv, &zai); znnew->offset = block;