mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-26 16:52:46 +01:00
services: time: Implement CalculateSpanBetween.
- Used by Super Smash Bros. Ultimate.
This commit is contained in:
parent
e84b760016
commit
a60f34a850
3 changed files with 31 additions and 1 deletions
|
@ -30,7 +30,7 @@ Time::Time(std::shared_ptr<Module> module, Core::System& system, const char* nam
|
||||||
{400, &Time::GetClockSnapshot, "GetClockSnapshot"},
|
{400, &Time::GetClockSnapshot, "GetClockSnapshot"},
|
||||||
{401, &Time::GetClockSnapshotFromSystemClockContext, "GetClockSnapshotFromSystemClockContext"},
|
{401, &Time::GetClockSnapshotFromSystemClockContext, "GetClockSnapshotFromSystemClockContext"},
|
||||||
{500, nullptr, "CalculateStandardUserSystemClockDifferenceByUser"},
|
{500, nullptr, "CalculateStandardUserSystemClockDifferenceByUser"},
|
||||||
{501, nullptr, "CalculateSpanBetween"},
|
{501, &Time::CalculateSpanBetween, "CalculateSpanBetween"},
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
|
|
@ -308,6 +308,35 @@ void Module::Interface::GetClockSnapshotFromSystemClockContext(Kernel::HLEReques
|
||||||
ctx.WriteBuffer(&clock_snapshot, sizeof(Clock::ClockSnapshot));
|
ctx.WriteBuffer(&clock_snapshot, sizeof(Clock::ClockSnapshot));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Module::Interface::CalculateSpanBetween(Kernel::HLERequestContext& ctx) {
|
||||||
|
LOG_DEBUG(Service_Time, "called");
|
||||||
|
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
const auto snapshot_a = rp.PopRaw<Clock::ClockSnapshot>();
|
||||||
|
const auto snapshot_b = rp.PopRaw<Clock::ClockSnapshot>();
|
||||||
|
|
||||||
|
Clock::TimeSpanType time_span_type{};
|
||||||
|
s64 span{};
|
||||||
|
if (const ResultCode result{snapshot_a.steady_clock_time_point.GetSpanBetween(
|
||||||
|
snapshot_b.steady_clock_time_point, span)};
|
||||||
|
result != RESULT_SUCCESS) {
|
||||||
|
if (snapshot_a.network_time && snapshot_b.network_time) {
|
||||||
|
time_span_type =
|
||||||
|
Clock::TimeSpanType::FromSeconds(snapshot_b.network_time - snapshot_a.network_time);
|
||||||
|
} else {
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(ERROR_TIME_NOT_FOUND);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
time_span_type = Clock::TimeSpanType::FromSeconds(span);
|
||||||
|
}
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, (sizeof(s64) / 4) + 2};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
rb.PushRaw(time_span_type.nanoseconds);
|
||||||
|
}
|
||||||
|
|
||||||
void Module::Interface::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) {
|
void Module::Interface::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_Time, "called");
|
LOG_DEBUG(Service_Time, "called");
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
void CalculateMonotonicSystemClockBaseTimePoint(Kernel::HLERequestContext& ctx);
|
void CalculateMonotonicSystemClockBaseTimePoint(Kernel::HLERequestContext& ctx);
|
||||||
void GetClockSnapshot(Kernel::HLERequestContext& ctx);
|
void GetClockSnapshot(Kernel::HLERequestContext& ctx);
|
||||||
void GetClockSnapshotFromSystemClockContext(Kernel::HLERequestContext& ctx);
|
void GetClockSnapshotFromSystemClockContext(Kernel::HLERequestContext& ctx);
|
||||||
|
void CalculateSpanBetween(Kernel::HLERequestContext& ctx);
|
||||||
void GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx);
|
void GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue