From c440e8b8e1ede24b1feb4359e6c94424ca22b376 Mon Sep 17 00:00:00 2001 From: David Marcec Date: Sat, 17 Nov 2018 14:01:16 +1100 Subject: Implemented CalculateStandardUserSystemClockDifferenceByUser Seems pokemon calls this sometimes and it caused "random crashes" --- src/core/hle/service/time/interface.cpp | 3 ++- src/core/hle/service/time/time.cpp | 15 +++++++++++++++ src/core/hle/service/time/time.h | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/hle/service/time/interface.cpp b/src/core/hle/service/time/interface.cpp index e3cbd7004..b3a196f65 100644 --- a/src/core/hle/service/time/interface.cpp +++ b/src/core/hle/service/time/interface.cpp @@ -23,7 +23,8 @@ Time::Time(std::shared_ptr time, const char* name) {300, nullptr, "CalculateMonotonicSystemClockBaseTimePoint"}, {400, &Time::GetClockSnapshot, "GetClockSnapshot"}, {401, nullptr, "GetClockSnapshotFromSystemClockContext"}, - {500, nullptr, "CalculateStandardUserSystemClockDifferenceByUser"}, + {500, &Time::CalculateStandardUserSystemClockDifferenceByUser, + "CalculateStandardUserSystemClockDifferenceByUser"}, {501, nullptr, "CalculateSpanBetween"}, }; RegisterHandlers(functions); diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index 85e7b1195..e561a0c52 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp @@ -299,6 +299,21 @@ void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) { ctx.WriteBuffer(&clock_snapshot, sizeof(ClockSnapshot)); } +void Module::Interface::CalculateStandardUserSystemClockDifferenceByUser( + Kernel::HLERequestContext& ctx) { + LOG_DEBUG(Service_Time, "called"); + + IPC::RequestParser rp{ctx}; + const auto snapshot_a = rp.PopRaw(); + const auto snapshot_b = rp.PopRaw(); + const u64 difference = + snapshot_b.user_clock_context.offset - snapshot_a.user_clock_context.offset; + + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(RESULT_SUCCESS); + rb.PushRaw(difference); +} + Module::Interface::Interface(std::shared_ptr time, const char* name) : ServiceFramework(name), time(std::move(time)) {} diff --git a/src/core/hle/service/time/time.h b/src/core/hle/service/time/time.h index 77871ae07..ea43fbea7 100644 --- a/src/core/hle/service/time/time.h +++ b/src/core/hle/service/time/time.h @@ -84,6 +84,7 @@ public: void GetTimeZoneService(Kernel::HLERequestContext& ctx); void GetStandardLocalSystemClock(Kernel::HLERequestContext& ctx); void GetClockSnapshot(Kernel::HLERequestContext& ctx); + void CalculateStandardUserSystemClockDifferenceByUser(Kernel::HLERequestContext& ctx); protected: std::shared_ptr time; -- cgit v1.2.3