2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2015-08-17 05:26:58 +00:00
|
|
|
|
2017-12-29 08:08:12 +00:00
|
|
|
#include <cstdint>
|
|
|
|
#include <cstdlib>
|
2016-10-09 21:41:23 +00:00
|
|
|
#include <chrono>
|
2015-08-17 05:26:58 +00:00
|
|
|
|
2019-09-22 21:52:05 +00:00
|
|
|
#include "Runtime/GCNTypes.hpp"
|
2015-08-17 20:33:58 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2015-08-17 22:05:00 +00:00
|
|
|
|
2016-10-09 21:41:23 +00:00
|
|
|
using OSTime = s64;
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct OSCalendarTime {
|
|
|
|
int x0_sec; // seconds after the minute [0, 61]
|
|
|
|
int x4_min; // minutes after the hour [0, 59]
|
|
|
|
int x8_hour; // hours since midnight [0, 23]
|
|
|
|
int xc_mday; // day of the month [1, 31]
|
|
|
|
int x10_mon; // month since January [0, 11]
|
|
|
|
int x14_year; // years in AD [1, ...]
|
|
|
|
int x18_wday; // days since Sunday [0, 6]
|
|
|
|
int x1c_yday; // days since January 1 [0, 365]
|
|
|
|
|
|
|
|
int x20_msec; // milliseconds after the second [0,999]
|
|
|
|
int x24_usec; // microseconds after the millisecond [0,999]
|
2016-12-23 06:41:39 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CBasics {
|
2015-08-17 05:26:58 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
static void Initialize();
|
2016-10-09 21:41:23 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static const u64 SECONDS_TO_2000;
|
|
|
|
static const u64 TICKS_PER_SECOND;
|
2016-10-09 21:41:23 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static OSTime ToWiiTime(std::chrono::system_clock::time_point time);
|
|
|
|
static std::chrono::system_clock::time_point FromWiiTime(OSTime wiiTime);
|
2016-12-23 06:41:39 +00:00
|
|
|
|
2022-01-30 20:07:24 +00:00
|
|
|
static OSTime GetTime() { return ToWiiTime(std::chrono::system_clock::now()); }
|
2018-12-08 05:30:43 +00:00
|
|
|
static u64 GetGCTicks();
|
|
|
|
static constexpr u64 GetGCTicksPerSec() { return 486000000ull; }
|
2017-01-01 06:46:52 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static OSCalendarTime ToCalendarTime(OSTime time) { return ToCalendarTime(FromWiiTime(time)); }
|
|
|
|
static OSCalendarTime ToCalendarTime(std::chrono::system_clock::time_point time);
|
2015-08-17 05:26:58 +00:00
|
|
|
};
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|