diff options
author | german77 <juangerman-13@hotmail.com> | 2023-09-11 04:43:26 +0200 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2023-09-11 04:43:26 +0200 |
commit | 0cdc8b13b743e4d7256d9337c7f01296cb98b7bd (patch) | |
tree | 7ac4cd88f9d0d43f3e832939ba6fad8733d13815 /src | |
parent | Merge pull request #11450 from lat9nq/no-vk-device-fix (diff) | |
download | yuzu-0cdc8b13b743e4d7256d9337c7f01296cb98b7bd.tar yuzu-0cdc8b13b743e4d7256d9337c7f01296cb98b7bd.tar.gz yuzu-0cdc8b13b743e4d7256d9337c7f01296cb98b7bd.tar.bz2 yuzu-0cdc8b13b743e4d7256d9337c7f01296cb98b7bd.tar.lz yuzu-0cdc8b13b743e4d7256d9337c7f01296cb98b7bd.tar.xz yuzu-0cdc8b13b743e4d7256d9337c7f01296cb98b7bd.tar.zst yuzu-0cdc8b13b743e4d7256d9337c7f01296cb98b7bd.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/core/hle/service/mii/mii.cpp | 11 | ||||
-rw-r--r-- | src/core/hle/service/mii/mii_manager.cpp | 9 | ||||
-rw-r--r-- | src/core/hle/service/mii/mii_result.h | 20 | ||||
-rw-r--r-- | src/core/hle/service/mii/mii_util.h | 58 |
5 files changed, 89 insertions, 11 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 012648d69..e9095ac52 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -588,6 +588,8 @@ add_library(core STATIC hle/service/mii/mii.h hle/service/mii/mii_manager.cpp hle/service/mii/mii_manager.h + hle/service/mii/mii_result.h + hle/service/mii/mii_util.h hle/service/mii/raw_data.cpp hle/service/mii/raw_data.h hle/service/mii/types.h diff --git a/src/core/hle/service/mii/mii.cpp b/src/core/hle/service/mii/mii.cpp index 65c11a2f3..bf3ee5907 100644 --- a/src/core/hle/service/mii/mii.cpp +++ b/src/core/hle/service/mii/mii.cpp @@ -7,13 +7,12 @@ #include "core/hle/service/ipc_helpers.h" #include "core/hle/service/mii/mii.h" #include "core/hle/service/mii/mii_manager.h" +#include "core/hle/service/mii/mii_result.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" namespace Service::Mii { -constexpr Result ERROR_INVALID_ARGUMENT{ErrorModule::Mii, 1}; - class IDatabaseService final : public ServiceFramework<IDatabaseService> { public: explicit IDatabaseService(Core::System& system_) @@ -162,21 +161,21 @@ private: if (age > Age::All) { IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERROR_INVALID_ARGUMENT); + rb.Push(ResultInvalidArgument); LOG_ERROR(Service_Mii, "invalid age={}", age); return; } if (gender > Gender::All) { IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERROR_INVALID_ARGUMENT); + rb.Push(ResultInvalidArgument); LOG_ERROR(Service_Mii, "invalid gender={}", gender); return; } if (race > Race::All) { IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERROR_INVALID_ARGUMENT); + rb.Push(ResultInvalidArgument); LOG_ERROR(Service_Mii, "invalid race={}", race); return; } @@ -196,7 +195,7 @@ private: LOG_ERROR(Service_Mii, "invalid argument, index cannot be greater than 5 but is {:08X}", index); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ERROR_INVALID_ARGUMENT); + rb.Push(ResultInvalidArgument); return; } diff --git a/src/core/hle/service/mii/mii_manager.cpp b/src/core/hle/service/mii/mii_manager.cpp index dd632df50..392aa78da 100644 --- a/src/core/hle/service/mii/mii_manager.cpp +++ b/src/core/hle/service/mii/mii_manager.cpp @@ -10,14 +10,13 @@ #include "core/hle/service/acc/profile_manager.h" #include "core/hle/service/mii/mii_manager.h" +#include "core/hle/service/mii/mii_result.h" #include "core/hle/service/mii/raw_data.h" namespace Service::Mii { namespace { -constexpr Result ERROR_CANNOT_FIND_ENTRY{ErrorModule::Mii, 4}; - constexpr std::size_t DefaultMiiCount{RawData::DefaultMii.size()}; constexpr MiiStoreData::Name DefaultMiiName{u'n', u'o', u' ', u'n', u'a', u'm', u'e'}; @@ -410,11 +409,11 @@ u32 MiiManager::GetCount(SourceFlag source_flag) const { Result MiiManager::UpdateLatest(CharInfo* out_info, const CharInfo& info, SourceFlag source_flag) { if ((source_flag & SourceFlag::Database) == SourceFlag::None) { - return ERROR_CANNOT_FIND_ENTRY; + return ResultNotFound; } // TODO(bunnei): We don't implement the Mii database, so we can't have an entry - return ERROR_CANNOT_FIND_ENTRY; + return ResultNotFound; } CharInfo MiiManager::BuildRandom(Age age, Gender gender, Race race) { @@ -695,7 +694,7 @@ Result MiiManager::GetIndex([[maybe_unused]] const CharInfo& info, u32& index) { index = INVALID_INDEX; // TODO(bunnei): We don't implement the Mii database, so we can't have an index - return ERROR_CANNOT_FIND_ENTRY; + return ResultNotFound; } } // namespace Service::Mii diff --git a/src/core/hle/service/mii/mii_result.h b/src/core/hle/service/mii/mii_result.h new file mode 100644 index 000000000..021cb76da --- /dev/null +++ b/src/core/hle/service/mii/mii_result.h @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "core/hle/result.h" + +namespace Service::Mii { + +constexpr Result ResultInvalidArgument{ErrorModule::Mii, 1}; +constexpr Result ResultInvalidArgumentSize{ErrorModule::Mii, 2}; +constexpr Result ResultNotUpdated{ErrorModule::Mii, 3}; +constexpr Result ResultNotFound{ErrorModule::Mii, 4}; +constexpr Result ResultDatabaseFull{ErrorModule::Mii, 5}; +constexpr Result ResultInvalidCharInfo{ErrorModule::Mii, 100}; +constexpr Result ResultInvalidStoreData{ErrorModule::Mii, 109}; +constexpr Result ResultInvalidOperation{ErrorModule::Mii, 202}; +constexpr Result ResultPermissionDenied{ErrorModule::Mii, 203}; + +}; // namespace Service::Mii diff --git a/src/core/hle/service/mii/mii_util.h b/src/core/hle/service/mii/mii_util.h new file mode 100644 index 000000000..5eb6df317 --- /dev/null +++ b/src/core/hle/service/mii/mii_util.h @@ -0,0 +1,58 @@ +// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <random> + +#include "common/common_types.h" +#include "common/swap.h" +#include "common/uuid.h" +#include "core/hle/service/mii/mii_types.h" + +namespace Service::Mii { +class MiiUtil { +public: + static u16 CalculateCrc16(const void* data, std::size_t size) { + s32 crc{}; + for (std::size_t i = 0; i < size; i++) { + crc ^= static_cast<const u8*>(data)[i] << 8; + for (std::size_t j = 0; j < 8; j++) { + crc <<= 1; + if ((crc & 0x10000) != 0) { + crc = (crc ^ 0x1021) & 0xFFFF; + } + } + } + return Common::swap16(static_cast<u16>(crc)); + } + + static Common::UUID MakeCreateId() { + return Common::UUID::MakeRandomRFC4122V4(); + } + + static Common::UUID GetDeviceId() { + // This should be nn::settings::detail::GetMiiAuthorId() + return Common::UUID::MakeDefault(); + } + + template <typename T> + static T GetRandomValue(T min, T max) { + std::random_device device; + std::mt19937 gen(device()); + std::uniform_int_distribution<u64> distribution(static_cast<u64>(min), + static_cast<u64>(max)); + return static_cast<T>(distribution(gen)); + } + + template <typename T> + static T GetRandomValue(T max) { + return GetRandomValue<T>({}, max); + } + + static bool IsFontRegionValid(FontRegion font, std::span<const char16_t> text) { + // Todo:: This function needs to check against the font tables + return true; + } +}; +} // namespace Service::Mii |