ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/AmigaOS/timer_amiga.cpp
(Generate patch)

Comparing BasiliskII/src/AmigaOS/timer_amiga.cpp (file contents):
Revision 1.1 by cebix, 1999-10-03T14:16:25Z vs.
Revision 1.6 by cebix, 2001-07-06T17:36:07Z

# Line 1 | Line 1
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
# Line 30 | Line 30
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   */
# Line 44 | Line 39 | void Microseconds(uint32 &hi, uint32 &lo
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  
# Line 52 | Line 49 | void Microseconds(uint32 &hi, uint32 &lo
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  
# Line 131 | Line 125 | int32 timer_host2mac_time(tm_time_t host
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   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines