From 1cf020531eeb56c5c7d77c278addf808cacea938 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Wed, 10 May 2023 08:55:56 +0200 Subject: [PATCH] early-access version 3576 --- README.md | 2 +- src/core/hle/service/nfc/common/device.cpp | 18 +++++++++++++----- src/core/hle/service/nfc/common/device.h | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index cb283a976..67f75580c 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3575. +This is the source code for early-access 3576. ## Legal Notice diff --git a/src/core/hle/service/nfc/common/device.cpp b/src/core/hle/service/nfc/common/device.cpp index 9b0685bdb..322bde2ed 100755 --- a/src/core/hle/service/nfc/common/device.cpp +++ b/src/core/hle/service/nfc/common/device.cpp @@ -48,9 +48,6 @@ NfcDevice::NfcDevice(Core::HID::NpadIdType npad_id_, Core::System& system_, }; is_controller_set = true; callback_key = npad_device->SetCallback(engine_callback); - - auto& standard_steady_clock{system.GetTimeManager().GetStandardSteadyClockCore()}; - current_posix_time = standard_steady_clock.GetCurrentTimePoint(system).time_point; } NfcDevice::~NfcDevice() { @@ -232,6 +229,7 @@ Result NfcDevice::GetTagInfo(NFP::TagInfo& tag_info, bool is_mifare) const { // Generate random UUID to bypass amiibo load limits if (Settings::values.random_amiibo_id) { Common::TinyMT rng{}; + rng.Initialize(static_cast(GetCurrentPosixTime())); rng.GenerateRandomBytes(uuid.data(), sizeof(UniqueSerialNumber)); uuid[3] = 0x88 ^ uuid[0] ^ uuid[1] ^ uuid[2]; } @@ -415,7 +413,7 @@ Result NfcDevice::Flush() { auto& settings = tag_data.settings; - const auto& current_date = GetAmiiboDate(current_posix_time); + const auto& current_date = GetAmiiboDate(GetCurrentPosixTime()); if (settings.write_date.raw_date != current_date.raw_date) { settings.write_date = current_date; UpdateSettingsCrc(); @@ -534,6 +532,7 @@ Result NfcDevice::GetModelInfo(NFP::ModelInfo& model_info) const { } const auto& model_info_data = encrypted_tag_data.user_memory.model_info; + model_info = { .character_id = model_info_data.character_id, .character_variant = model_info_data.character_variant, @@ -678,6 +677,7 @@ Result NfcDevice::DeleteRegisterInfo() { } Common::TinyMT rng{}; + rng.Initialize(static_cast(GetCurrentPosixTime())); rng.GenerateRandomBytes(&tag_data.owner_mii, sizeof(tag_data.owner_mii)); rng.GenerateRandomBytes(&tag_data.settings.amiibo_name, sizeof(tag_data.settings.amiibo_name)); rng.GenerateRandomBytes(&tag_data.unknown, sizeof(u8)); @@ -710,7 +710,7 @@ Result NfcDevice::SetRegisterInfoPrivate(const NFP::RegisterInfoPrivate& registe auto& settings = tag_data.settings; if (tag_data.settings.settings.amiibo_initialized == 0) { - settings.init_date = GetAmiiboDate(current_posix_time); + settings.init_date = GetAmiiboDate(GetCurrentPosixTime()); settings.write_date.raw_date = 0; } @@ -877,6 +877,7 @@ Result NfcDevice::SetApplicationArea(std::span data) { } Common::TinyMT rng{}; + rng.Initialize(static_cast(GetCurrentPosixTime())); std::memcpy(tag_data.application_area.data(), data.data(), data.size()); // Fill remaining data with random numbers rng.GenerateRandomBytes(tag_data.application_area.data() + data.size(), @@ -933,6 +934,7 @@ Result NfcDevice::RecreateApplicationArea(u32 access_id, std::span dat } Common::TinyMT rng{}; + rng.Initialize(static_cast(GetCurrentPosixTime())); std::memcpy(tag_data.application_area.data(), data.data(), data.size()); // Fill remaining data with random numbers rng.GenerateRandomBytes(tag_data.application_area.data() + data.size(), @@ -982,6 +984,7 @@ Result NfcDevice::DeleteApplicationArea() { } Common::TinyMT rng{}; + rng.Initialize(static_cast(GetCurrentPosixTime())); rng.GenerateRandomBytes(tag_data.application_area.data(), sizeof(NFP::ApplicationArea)); rng.GenerateRandomBytes(&tag_data.application_id, sizeof(u64)); rng.GenerateRandomBytes(&tag_data.application_area_id, sizeof(u32)); @@ -1198,6 +1201,11 @@ NFP::AmiiboDate NfcDevice::GetAmiiboDate(s64 posix_time) const { return amiibo_date; } +u64 NfcDevice::GetCurrentPosixTime() const { + auto& standard_steady_clock{system.GetTimeManager().GetStandardSteadyClockCore()}; + return standard_steady_clock.GetCurrentTimePoint(system).time_point; +} + u64 NfcDevice::RemoveVersionByte(u64 application_id) const { return application_id & ~(0xfULL << NFP::application_id_version_offset); } diff --git a/src/core/hle/service/nfc/common/device.h b/src/core/hle/service/nfc/common/device.h index 654eda98e..98e1945c1 100755 --- a/src/core/hle/service/nfc/common/device.h +++ b/src/core/hle/service/nfc/common/device.h @@ -105,6 +105,7 @@ private: NFP::AmiiboName GetAmiiboName(const NFP::AmiiboSettings& settings) const; void SetAmiiboName(NFP::AmiiboSettings& settings, const NFP::AmiiboName& amiibo_name); NFP::AmiiboDate GetAmiiboDate(s64 posix_time) const; + u64 GetCurrentPosixTime() const; u64 RemoveVersionByte(u64 application_id) const; void UpdateSettingsCrc(); void UpdateRegisterInfoCrc(); @@ -127,7 +128,6 @@ private: bool is_data_moddified{}; bool is_app_area_open{}; bool is_plain_amiibo{}; - s64 current_posix_time{}; NFP::MountTarget mount_target{NFP::MountTarget::None}; NFP::NTAG215File tag_data{};