2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 19:04:56 +00:00
This commit is contained in:
Jack Andersen
2017-01-04 14:55:30 -10:00
4 changed files with 69 additions and 23 deletions

View File

@@ -11,7 +11,9 @@
#include <arpa/inet.h>
#include <string>
#include "hecl/hecl.hpp"
#if __APPLE__
#include <mach/mach_time.h>
#endif
namespace net
{
@@ -309,12 +311,21 @@ static u64 LastGCTick = 0;
static u64 TimeCmdSent = 0;
static bool Booted = false;
static u64 MachToDolphinNum;
static u64 MachToDolphinDenom;
static u64 SysToDolphinNum;
static u64 SysToDolphinDenom;
static u64 GetGCTicks()
{
return mach_absolute_time() * MachToDolphinNum / MachToDolphinDenom;
#if __APPLE__
return mach_absolute_time() * SysToDolphinNum / SysToDolphinDenom;
#elif __linux__
struct timespec tp;
clock_gettime(CLOCK_MONOTONIC, &tp);
return u64((tp.tv_sec * 1000000000ull) + tp.tv_nsec) * SysToDolphinNum / SysToDolphinDenom;
#else
return 0;
#endif
}
static constexpr u64 GetGCTicksPerSec()
@@ -1277,10 +1288,15 @@ void CGBASupport::StartLink()
int main(int argc, char** argv)
{
#if __APPLE__
mach_timebase_info_data_t timebase;
mach_timebase_info(&timebase);
MachToDolphinNum = GetGCTicksPerSec() * timebase.numer;
MachToDolphinDenom = 1000000000ull * timebase.denom;
SysToDolphinNum = GetGCTicksPerSec() * timebase.numer;
SysToDolphinDenom = 1000000000ull * timebase.denom;
#elif __linux__
SysToDolphinNum = GetGCTicksPerSec();
SysToDolphinDenom = 1000000000ull;
#endif
CGBASupport gba("client_pad.bin");
gba.Update(0.f);