1 |
|
/* |
2 |
|
* timer_amiga.cpp - Time Manager emulation, AmigaOS specific stuff |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2001 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
30 |
|
#include "debug.h" |
31 |
|
|
32 |
|
|
33 |
– |
// Assembly functions |
34 |
– |
extern "C" ULONG TimevalTo64(struct timeval *, ULONG *); |
35 |
– |
extern "C" LONG TimevalToMacTime(struct timeval *); |
36 |
– |
|
37 |
– |
|
33 |
|
/* |
34 |
|
* Return microseconds since boot (64 bit) |
35 |
|
*/ |
39 |
|
D(bug("Microseconds\n")); |
40 |
|
struct timeval tv; |
41 |
|
GetSysTime(&tv); |
42 |
< |
lo = TimevalTo64(&tv, &hi); |
42 |
> |
uint64 tl = (uint64)tv.tv_secs * 1000000 + tv.tv_micro; |
43 |
> |
hi = tl >> 32; |
44 |
> |
lo = tl; |
45 |
|
} |
46 |
|
|
47 |
|
|
49 |
|
* Return local date/time in Mac format (seconds since 1.1.1904) |
50 |
|
*/ |
51 |
|
|
55 |
– |
const uint32 TIME_OFFSET = 0x8b31ef80; // Offset Mac->Amiga time in seconds |
56 |
– |
|
52 |
|
uint32 TimerDateTime(void) |
53 |
|
{ |
54 |
< |
ULONG secs; |
60 |
< |
ULONG mics; |
54 |
> |
ULONG secs, mics; |
55 |
|
CurrentTime(&secs, &mics); |
56 |
< |
return secs + TIME_OFFSET; |
56 |
> |
return secs + 0x8b31ef80; |
57 |
|
} |
58 |
|
|
59 |
|
|
125 |
|
{ |
126 |
|
if (hosttime.tv_secs < 0) |
127 |
|
return 0; |
128 |
< |
else |
129 |
< |
return TimevalToMacTime(&hosttime); |
128 |
> |
else { |
129 |
> |
uint64 t = (uint64)hosttime.tv_secs * 1000000 + hosttime.tv_micro; |
130 |
> |
if (t > 0x7fffffff) |
131 |
> |
return t / 1000; // Time in milliseconds |
132 |
> |
else |
133 |
> |
return -t; // Time in negative microseconds |
134 |
> |
} |
135 |
|
} |