diff options
author | german77 <juangerman-13@hotmail.com> | 2023-09-11 16:53:23 +0200 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2023-09-11 17:54:32 +0200 |
commit | ec25f847d8c066241d3aa9bb00bd11cb0c47b161 (patch) | |
tree | 0fb517718e80499316fcd1994e93355391844af3 /src/core/hle/service/mii | |
parent | mii: Prepare Interface for new implementation (diff) | |
download | yuzu-ec25f847d8c066241d3aa9bb00bd11cb0c47b161.tar yuzu-ec25f847d8c066241d3aa9bb00bd11cb0c47b161.tar.gz yuzu-ec25f847d8c066241d3aa9bb00bd11cb0c47b161.tar.bz2 yuzu-ec25f847d8c066241d3aa9bb00bd11cb0c47b161.tar.lz yuzu-ec25f847d8c066241d3aa9bb00bd11cb0c47b161.tar.xz yuzu-ec25f847d8c066241d3aa9bb00bd11cb0c47b161.tar.zst yuzu-ec25f847d8c066241d3aa9bb00bd11cb0c47b161.zip |
Diffstat (limited to 'src/core/hle/service/mii')
-rw-r--r-- | src/core/hle/service/mii/mii.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/service/mii/mii_manager.cpp | 6 | ||||
-rw-r--r-- | src/core/hle/service/mii/mii_manager.h | 9 | ||||
-rw-r--r-- | src/core/hle/service/mii/mii_types.h | 57 | ||||
-rw-r--r-- | src/core/hle/service/mii/mii_util.h | 3 | ||||
-rw-r--r-- | src/core/hle/service/mii/types/char_info.cpp | 112 | ||||
-rw-r--r-- | src/core/hle/service/mii/types/char_info.h | 2 | ||||
-rw-r--r-- | src/core/hle/service/mii/types/core_data.cpp | 12 | ||||
-rw-r--r-- | src/core/hle/service/mii/types/raw_data.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/service/mii/types/raw_data.h | 2 | ||||
-rw-r--r-- | src/core/hle/service/mii/types/ver3_store_data.cpp | 23 | ||||
-rw-r--r-- | src/core/hle/service/mii/types/ver3_store_data.h | 6 |
12 files changed, 133 insertions, 103 deletions
diff --git a/src/core/hle/service/mii/mii.cpp b/src/core/hle/service/mii/mii.cpp index 653c36740..3b83c5ed7 100644 --- a/src/core/hle/service/mii/mii.cpp +++ b/src/core/hle/service/mii/mii.cpp @@ -210,7 +210,7 @@ private: LOG_DEBUG(Service_Mii, "called"); s32 index{}; - const Result result = manager.GetIndex(metadata, info, index); + const auto result = manager.GetIndex(metadata, info, index); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(result); diff --git a/src/core/hle/service/mii/mii_manager.cpp b/src/core/hle/service/mii/mii_manager.cpp index 153a484c0..292d63777 100644 --- a/src/core/hle/service/mii/mii_manager.cpp +++ b/src/core/hle/service/mii/mii_manager.cpp @@ -37,10 +37,10 @@ bool MiiManager::IsFullDatabase() const { u32 MiiManager::GetCount(const DatabaseSessionMetadata& metadata, SourceFlag source_flag) const { u32 mii_count{}; - if ((source_flag & SourceFlag::Default) == SourceFlag::None) { + if ((source_flag & SourceFlag::Default) != SourceFlag::None) { mii_count += DefaultMiiCount; } - if ((source_flag & SourceFlag::Database) == SourceFlag::None) { + if ((source_flag & SourceFlag::Database) != SourceFlag::None) { // TODO(bunnei): We don't implement the Mii database, but when we do, update this } return mii_count; @@ -153,7 +153,7 @@ Result MiiManager::BuildDefault(std::span<CharInfo> out_char_info, u32& out_coun Result MiiManager::GetIndex(const DatabaseSessionMetadata& metadata, const CharInfo& char_info, s32& out_index) { - if (char_info.Verify() != 0) { + if (char_info.Verify() != ValidationResult::NoErrors) { return ResultInvalidCharInfo; } diff --git a/src/core/hle/service/mii/mii_manager.h b/src/core/hle/service/mii/mii_manager.h index 4f8be06c3..a2e7a6d73 100644 --- a/src/core/hle/service/mii/mii_manager.h +++ b/src/core/hle/service/mii/mii_manager.h @@ -38,15 +38,6 @@ public: s32& out_index); void SetInterfaceVersion(DatabaseSessionMetadata& metadata, u32 version); - struct MiiDatabase { - u32 magic{}; // 'NFDB' - std::array<StoreData, 0x64> miis{}; - INSERT_PADDING_BYTES(1); - u8 count{}; - u16 crc{}; - }; - static_assert(sizeof(MiiDatabase) == 0x1A98, "MiiDatabase has incorrect size."); - private: Result BuildDefault(std::span<CharInfoElement> out_elements, u32& out_count, SourceFlag source_flag); diff --git a/src/core/hle/service/mii/mii_types.h b/src/core/hle/service/mii/mii_types.h index b23ce477d..8fc827b5a 100644 --- a/src/core/hle/service/mii/mii_types.h +++ b/src/core/hle/service/mii/mii_types.h @@ -86,6 +86,61 @@ enum class SourceFlag : u32 { }; DECLARE_ENUM_FLAG_OPERATORS(SourceFlag); +enum class ValidationResult : u32 { + NoErrors = 0x0, + InvalidBeardColor = 0x1, + InvalidBeardType = 0x2, + InvalidBuild = 0x3, + InvalidEyeAspect = 0x4, + InvalidEyeColor = 0x5, + InvalidEyeRotate = 0x6, + InvalidEyeScale = 0x7, + InvalidEyeType = 0x8, + InvalidEyeX = 0x9, + InvalidEyeY = 0xa, + InvalidEyebrowAspect = 0xb, + InvalidEyebrowColor = 0xc, + InvalidEyebrowRotate = 0xd, + InvalidEyebrowScale = 0xe, + InvalidEyebrowType = 0xf, + InvalidEyebrowX = 0x10, + InvalidEyebrowY = 0x11, + InvalidFacelineColor = 0x12, + InvalidFacelineMake = 0x13, + InvalidFacelineWrinkle = 0x14, + InvalidFacelineType = 0x15, + InvalidColor = 0x16, + InvalidFont = 0x17, + InvalidGender = 0x18, + InvalidGlassColor = 0x19, + InvalidGlassScale = 0x1a, + InvalidGlassType = 0x1b, + InvalidGlassY = 0x1c, + InvalidHairColor = 0x1d, + InvalidHairFlip = 0x1e, + InvalidHairType = 0x1f, + InvalidHeight = 0x20, + InvalidMoleScale = 0x21, + InvalidMoleType = 0x22, + InvalidMoleX = 0x23, + InvalidMoleY = 0x24, + InvalidMouthAspect = 0x25, + InvalidMouthColor = 0x26, + InvalidMouthScale = 0x27, + InvalidMouthType = 0x28, + InvalidMouthY = 0x29, + InvalidMustacheScale = 0x2a, + InvalidMustacheType = 0x2b, + InvalidMustacheY = 0x2c, + InvalidNoseScale = 0x2e, + InvalidNoseType = 0x2f, + InvalidNoseY = 0x30, + InvalidRegionMove = 0x31, + InvalidCreateId = 0x32, + InvalidName = 0x33, + InvalidType = 0x35, +}; + struct Nickname { static constexpr std::size_t MaxNameSize = 10; std::array<char16_t, MaxNameSize> data; @@ -163,7 +218,7 @@ struct DefaultMii { u32 type{}; Nickname nickname; }; -static_assert(sizeof(DefaultMii) == 0xd8, "MiiStoreData has incorrect size."); +static_assert(sizeof(DefaultMii) == 0xd8, "DefaultMii has incorrect size."); struct DatabaseSessionMetadata { u32 interface_version; diff --git a/src/core/hle/service/mii/mii_util.h b/src/core/hle/service/mii/mii_util.h index 782ffe22f..ddb544c23 100644 --- a/src/core/hle/service/mii/mii_util.h +++ b/src/core/hle/service/mii/mii_util.h @@ -4,6 +4,7 @@ #pragma once #include <random> +#include <span> #include "common/common_types.h" #include "common/swap.h" @@ -51,7 +52,7 @@ public: } static bool IsFontRegionValid(FontRegion font, std::span<const char16_t> text) { - // Todo:: This function needs to check against the font tables + // TODO: This function needs to check against the font tables return true; } }; diff --git a/src/core/hle/service/mii/types/char_info.cpp b/src/core/hle/service/mii/types/char_info.cpp index 0f9c37b84..cd7154c91 100644 --- a/src/core/hle/service/mii/types/char_info.cpp +++ b/src/core/hle/service/mii/types/char_info.cpp @@ -62,161 +62,161 @@ void CharInfo::SetFromStoreData(const StoreData& store_data) { padding = '\0'; } -u32 CharInfo::Verify() const { +ValidationResult CharInfo::Verify() const { if (!create_id.IsValid()) { - return 0x32; + return ValidationResult::InvalidCreateId; } if (!name.IsValid()) { - return 0x33; + return ValidationResult::InvalidName; } if (3 < font_region) { - return 0x17; + return ValidationResult::InvalidFont; } if (0xb < favorite_color) { - return 0x16; + return ValidationResult::InvalidColor; } if (1 < gender) { - return 0x18; + return ValidationResult::InvalidGender; } - if (height < 0) { - return 0x20; + if (height > 0x7f) { + return ValidationResult::InvalidHeight; } - if (build < 0) { - return 3; + if (build > 0x7f) { + return ValidationResult::InvalidBuild; } if (1 < type) { - return 0x35; + return ValidationResult::InvalidType; } if (3 < region_move) { - return 0x31; + return ValidationResult::InvalidRegionMove; } if (0xb < faceline_type) { - return 0x15; + return ValidationResult::InvalidFacelineType; } if (9 < faceline_color) { - return 0x12; + return ValidationResult::InvalidFacelineColor; } if (0xb < faceline_wrinkle) { - return 0x14; + return ValidationResult::InvalidFacelineWrinkle; } if (0xb < faceline_make) { - return 0x13; + return ValidationResult::InvalidFacelineMake; } if (0x83 < hair_type) { - return 0x1f; + return ValidationResult::InvalidHairType; } if (99 < hair_color) { - return 0x1d; + return ValidationResult::InvalidHairColor; } if (1 < hair_flip) { - return 0x1e; + return ValidationResult::InvalidHairFlip; } if (0x3b < eye_type) { - return 8; + return ValidationResult::InvalidEyeType; } if (99 < eye_color) { - return 5; + return ValidationResult::InvalidEyeColor; } if (7 < eye_scale) { - return 7; + return ValidationResult::InvalidEyeScale; } if (6 < eye_aspect) { - return 4; + return ValidationResult::InvalidEyeAspect; } if (7 < eye_rotate) { - return 6; + return ValidationResult::InvalidEyeRotate; } if (0xc < eye_x) { - return 9; + return ValidationResult::InvalidEyeX; } if (0x12 < eye_y) { - return 10; + return ValidationResult::InvalidEyeY; } if (0x17 < eyebrow_type) { - return 0xf; + return ValidationResult::InvalidEyebrowType; } if (99 < eyebrow_color) { - return 0xc; + return ValidationResult::InvalidEyebrowColor; } if (8 < eyebrow_scale) { - return 0xe; + return ValidationResult::InvalidEyebrowScale; } if (6 < eyebrow_aspect) { - return 0xb; + return ValidationResult::InvalidEyebrowAspect; } if (0xb < eyebrow_rotate) { - return 0xd; + return ValidationResult::InvalidEyebrowRotate; } if (0xc < eyebrow_x) { - return 0x10; + return ValidationResult::InvalidEyebrowX; } if (0xf < eyebrow_y - 3) { - return 0x11; + return ValidationResult::InvalidEyebrowY; } if (0x11 < nose_type) { - return 0x2f; + return ValidationResult::InvalidNoseType; } if (nose_scale >= 9) { - return 0x2e; + return ValidationResult::InvalidNoseScale; } if (0x12 < nose_y) { - return 0x30; + return ValidationResult::InvalidNoseY; } if (0x23 < mouth_type) { - return 0x28; + return ValidationResult::InvalidMouthType; } if (99 < mouth_color) { - return 0x26; + return ValidationResult::InvalidMouthColor; } if (8 < mouth_scale) { - return 0x27; + return ValidationResult::InvalidMouthScale; } if (6 < mouth_aspect) { - return 0x25; + return ValidationResult::InvalidMouthAspect; } if (0x12 < mouth_y) { - return 0x29; + return ValidationResult::InvalidMoleY; } if (99 < beard_color) { - return 1; + return ValidationResult::InvalidBeardColor; } if (5 < beard_type) { - return 2; + return ValidationResult::InvalidBeardType; } if (5 < mustache_type) { - return 0x2b; + return ValidationResult::InvalidMustacheType; } if (8 < mustache_scale) { - return 0x2a; + return ValidationResult::InvalidMustacheScale; } if (0x10 < mustache_y) { - return 0x2c; + return ValidationResult::InvalidMustacheY; } if (0x13 < glasses_type) { - return 0x1b; + return ValidationResult::InvalidGlassType; } if (99 < glasses_color) { - return 0x19; + return ValidationResult::InvalidGlassColor; } if (7 < glasses_scale) { - return 0x1a; + return ValidationResult::InvalidGlassScale; } if (0x14 < glasses_y) { - return 0x1c; + return ValidationResult::InvalidGlassY; } if (mole_type >= 2) { - return 0x22; + return ValidationResult::InvalidMoleType; } if (8 < mole_scale) { - return 0x21; + return ValidationResult::InvalidMoleScale; } if (mole_x >= 0x11) { - return 0x23; + return ValidationResult::InvalidMoleX; } if (0x1e < mole_y) { - return 0x24; + return ValidationResult::InvalidMoleY; } - return 0; + return ValidationResult::NoErrors; } Common::UUID CharInfo::GetCreateId() const { @@ -424,7 +424,7 @@ u8 CharInfo::GetMoleY() const { } bool CharInfo::operator==(const CharInfo& info) { - bool is_identical = info.Verify() == 0; + bool is_identical = info.Verify() == ValidationResult::NoErrors; is_identical &= name.data == info.GetNickname().data; is_identical &= create_id == info.GetCreateId(); is_identical &= font_region == info.GetFontRegion(); diff --git a/src/core/hle/service/mii/types/char_info.h b/src/core/hle/service/mii/types/char_info.h index 4f70edc24..65a7707d3 100644 --- a/src/core/hle/service/mii/types/char_info.h +++ b/src/core/hle/service/mii/types/char_info.h @@ -13,7 +13,7 @@ class CharInfo { public: void SetFromStoreData(const StoreData& store_data_raw); - u32 Verify() const; + ValidationResult Verify() const; Common::UUID GetCreateId() const; Nickname GetNickname() const; diff --git a/src/core/hle/service/mii/types/core_data.cpp b/src/core/hle/service/mii/types/core_data.cpp index 9d7e604a9..de82481b0 100644 --- a/src/core/hle/service/mii/types/core_data.cpp +++ b/src/core/hle/service/mii/types/core_data.cpp @@ -26,10 +26,10 @@ void CoreData::BuildRandom(Age age, Gender gender, Race race) { data.build.Assign(64); if (age == Age::All) { - const auto temp{MiiUtil::GetRandomValue<int>(10)}; - if (temp >= 8) { + const auto random{MiiUtil::GetRandomValue<int>(10)}; + if (random >= 8) { age = Age::Old; - } else if (temp >= 4) { + } else if (random >= 4) { age = Age::Normal; } else { age = Age::Young; @@ -37,10 +37,10 @@ void CoreData::BuildRandom(Age age, Gender gender, Race race) { } if (race == Race::All) { - const auto temp{MiiUtil::GetRandomValue<int>(10)}; - if (temp >= 8) { + const auto random{MiiUtil::GetRandomValue<int>(10)}; + if (random >= 8) { race = Race::Black; - } else if (temp >= 4) { + } else if (random >= 4) { race = Race::White; } else { race = Race::Asian; diff --git a/src/core/hle/service/mii/types/raw_data.cpp b/src/core/hle/service/mii/types/raw_data.cpp index ef678c527..ed299521f 100644 --- a/src/core/hle/service/mii/types/raw_data.cpp +++ b/src/core/hle/service/mii/types/raw_data.cpp @@ -5,7 +5,7 @@ namespace Service::Mii::RawData { -constexpr std::array<u8, 0x10> FromVer3FacelineColorTable{ +constexpr std::array<u8, 16> FromVer3FacelineColorTable{ 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x0, 0x1, 0x5, 0x5, }; diff --git a/src/core/hle/service/mii/types/raw_data.h b/src/core/hle/service/mii/types/raw_data.h index 180f49fd0..8c910096f 100644 --- a/src/core/hle/service/mii/types/raw_data.h +++ b/src/core/hle/service/mii/types/raw_data.h @@ -10,7 +10,7 @@ namespace Service::Mii::RawData { struct RandomMiiValues { - std::array<u8, 0xbc> values{}; + std::array<u8, 188> values{}; }; static_assert(sizeof(RandomMiiValues) == 0xbc, "RandomMiiValues has incorrect size."); diff --git a/src/core/hle/service/mii/types/ver3_store_data.cpp b/src/core/hle/service/mii/types/ver3_store_data.cpp index 53a3fe44b..c7624520c 100644 --- a/src/core/hle/service/mii/types/ver3_store_data.cpp +++ b/src/core/hle/service/mii/types/ver3_store_data.cpp @@ -33,16 +33,7 @@ void Ver3StoreData::BuildToStoreData(StoreData& out_store_data) const { out_store_data.SetHeight(height); out_store_data.SetBuild(build); - // Copy name until string terminator - Nickname name = {}; - for (std::size_t index = 0; index < name.data.size() - 1; index++) { - name.data[index] = mii_name[index]; - if (name.data[index] == 0) { - break; - } - } - - out_store_data.SetNickname(name); + out_store_data.SetNickname(mii_name); out_store_data.SetFontRegion( static_cast<FontRegion>(static_cast<u8>(region_information.font_region))); @@ -108,15 +99,7 @@ void Ver3StoreData::BuildFromStoreData(const StoreData& store_data) { height = store_data.GetHeight(); build = store_data.GetBuild(); - // Copy name until string terminator - mii_name = {}; - for (std::size_t index = 0; index < store_data.GetNickname().data.size() - 1; index++) { - mii_name[index] = store_data.GetNickname().data[index]; - if (mii_name[index] == 0) { - break; - } - } - + mii_name = store_data.GetNickname(); region_information.font_region.Assign(static_cast<u8>(store_data.GetFontRegion())); appearance_bits1.faceline_type.Assign(store_data.GetFacelineType()); @@ -183,7 +166,7 @@ void Ver3StoreData::BuildFromStoreData(const StoreData& store_data) { u32 Ver3StoreData::IsValid() const { bool is_valid = version == 0 || version == 3; - is_valid = is_valid && (mii_name[0] != 0); + is_valid = is_valid && (mii_name.data[0] != 0); is_valid = is_valid && (mii_information.birth_month < 13); is_valid = is_valid && (mii_information.birth_day < 32); diff --git a/src/core/hle/service/mii/types/ver3_store_data.h b/src/core/hle/service/mii/types/ver3_store_data.h index 11caeb5c3..47907bf7d 100644 --- a/src/core/hle/service/mii/types/ver3_store_data.h +++ b/src/core/hle/service/mii/types/ver3_store_data.h @@ -47,7 +47,7 @@ public: u16_be mii_id; u64_be system_id; u32_be specialness_and_creation_date; - std::array<u8, 0x6> creator_mac; + std::array<u8, 6> creator_mac; u16_be padding; union { u16 raw; @@ -58,7 +58,7 @@ public: BitField<10, 4, u16> favorite_color; BitField<14, 1, u16> favorite; } mii_information; - std::array<char16_t, 0xA> mii_name; + Nickname mii_name; u8 height; u8 build; union { @@ -150,7 +150,7 @@ public: BitField<10, 5, u16> mole_y; } appearance_bits11; - std::array<u16_le, 0xA> author_name; + Nickname author_name; INSERT_PADDING_BYTES(0x2); u16_be crc; }; |