hle: service: mii: Rewrite service to properly support creation of random and default miis. #4292
Conversation
| @@ -0,0 +1,482 @@ | |||
| // Copyright 2018 yuzu emulator team | |||
ogniK5377
Jul 11, 2020
Contributor
Change to 2020
Change to 2020
| } | ||
|
|
||
| u16 GenerateCrc16(const void* data, std::size_t size) { | ||
| int crc{}; |
ogniK5377
Jul 11, 2020
Contributor
Suggested change
int crc{};
s32 crc{};
| int crc{}; | |
| s32 crc{}; |
|
|
||
| bool MiiManager::CheckAndResetUpdateCounter(SourceFlag source_flag, u64& current_update_counter) { | ||
| if ((source_flag & SourceFlag::Database) == SourceFlag::None) { | ||
| return {}; |
ogniK5377
Jul 11, 2020
Contributor
Suggested change
return {};
return false;
| return {}; | |
| return false; |
|
|
||
| bool MiiManager::IsFullDatabase() const { | ||
| // TODO(bunnei): We don't implement the Mii database, so it cannot be full | ||
| return {}; |
ogniK5377
Jul 11, 2020
Contributor
Suggested change
return {};
return false;
| return {}; | |
| return false; |
|
|
||
| bool CheckAndResetUpdateCounter(SourceFlag source_flag, u64& current_update_counter); | ||
| bool IsFullDatabase() const; | ||
| u32 GetCount(SourceFlag source_flag); |
ogniK5377
Jul 11, 2020
Contributor
Suggested change
u32 GetCount(SourceFlag source_flag);
u32 GetCount(SourceFlag source_flag) const;
| u32 GetCount(SourceFlag source_flag); | |
| u32 GetCount(SourceFlag source_flag) const; |
| return {}; | ||
| } | ||
|
|
||
| u32 MiiManager::GetCount(SourceFlag source_flag) { |
ogniK5377
Jul 11, 2020
Contributor
Suggested change
u32 MiiManager::GetCount(SourceFlag source_flag) {
u32 MiiManager::GetCount(SourceFlag source_flag) const {
| u32 MiiManager::GetCount(SourceFlag source_flag) { | |
| u32 MiiManager::GetCount(SourceFlag source_flag) const { |
| return count; | ||
| } | ||
|
|
||
| ResultVal<MiiInfo> MiiManager::UpdateLatest(const MiiInfo& /*info*/, SourceFlag source_flag) { |
ogniK5377
Jul 11, 2020
Contributor
Suggested change
ResultVal<MiiInfo> MiiManager::UpdateLatest(const MiiInfo& /*info*/, SourceFlag source_flag) {
ResultVal<MiiInfo> MiiManager::UpdateLatest([[maybe_unused]] const MiiInfo& /*info*/, SourceFlag source_flag) {
| ResultVal<MiiInfo> MiiManager::UpdateLatest(const MiiInfo& /*info*/, SourceFlag source_flag) { | |
| ResultVal<MiiInfo> MiiManager::UpdateLatest([[maybe_unused]] const MiiInfo& /*info*/, SourceFlag source_flag) { |
| return MakeResult<std::vector<MiiInfoElement>>(result); | ||
| } | ||
|
|
||
| ResultCode MiiManager::GetIndex(const MiiInfo& /*info*/, u32& index) { |
ogniK5377
Jul 11, 2020
Contributor
Suggested change
ResultCode MiiManager::GetIndex(const MiiInfo& /*info*/, u32& index) {
ResultCode MiiManager::GetIndex([[maybe_unused]] const MiiInfo& /*info*/, u32& index) {
| ResultCode MiiManager::GetIndex(const MiiInfo& /*info*/, u32& index) { | |
| ResultCode MiiManager::GetIndex([[maybe_unused]] const MiiInfo& /*info*/, u32& index) { |
| @@ -0,0 +1,331 @@ | |||
| // Copyright 2018 yuzu emulator team | |||
ogniK5377
Jul 11, 2020
Contributor
Suggested change
// Copyright 2018 yuzu emulator team
// Copyright 2020 yuzu emulator team
| // Copyright 2018 yuzu emulator team | |
| // Copyright 2020 yuzu emulator team |
| u32 read_size{}; | ||
| ctx.WriteBuffer(SerializeArray(&MiiManager::GetInfo, offsets[1], size, read_size)); | ||
| offsets[1] += read_size; | ||
| if (result->size()) { |
ogniK5377
Jul 11, 2020
Contributor
Suggested change
if (result->size()) {
if (result->size() > 0) {
| if (result->size()) { | |
| if (result->size() > 0) { |
| } | ||
|
|
||
| MiiInfo ConvertStoreDataToInfo(const MiiStoreData& data) { | ||
| MiiStoreBitFields bf{}; |
lioncash
Jul 11, 2020
Contributor
Suggested change
MiiStoreBitFields bf{};
MiiStoreBitFields bf;
Particularly given it's being memcpy'd into completely immediately on the next line.
| MiiStoreBitFields bf{}; | |
| MiiStoreBitFields bf; |
Particularly given it's being memcpy'd into completely immediately on the next line.
| std::vector<MiiInfoElement> result; | ||
|
|
||
| if ((source_flag & SourceFlag::Default) == SourceFlag::None) { | ||
| return MakeResult<std::vector<MiiInfoElement>>(result); |
lioncash
Jul 11, 2020
•
Contributor
Suggested change
return MakeResult<std::vector<MiiInfoElement>>(result);
return MakeResult(std::move(result));
| return MakeResult<std::vector<MiiInfoElement>>(result); | |
| return MakeResult(std::move(result)); |
| result.emplace_back(BuildDefault(index), Source::Default); | ||
| } | ||
|
|
||
| return MakeResult<std::vector<MiiInfoElement>>(result); |
lioncash
Jul 11, 2020
Contributor
Suggested change
return MakeResult<std::vector<MiiInfoElement>>(result);
return MakeResult(std::move(result));
| return MakeResult<std::vector<MiiInfoElement>>(result); | |
| return MakeResult(std::move(result)); |
|
|
||
| namespace Service::Mii::RawData { | ||
|
|
||
| static constexpr std::array<u8, 1728> DefaultMii{ |
lioncash
Jul 11, 2020
Contributor
These should be defined in a cpp file and be made extern const in the header, so that these don't copied entirely into every translation unit that may reference these identifiers.
These should be defined in a cpp file and be made extern const in the header, so that these don't copied entirely into every translation unit that may reference these identifiers.
|
Nice work on getting Mii support added. It would be appreciated if the appropriate license statements could be added to the top of those files as well. Otherwise the code looks fine |
…ndom and default miis.
|
@Thog thanks for taking a look. Yes, sorry, several of the enum definitions were from Ryujinx. However, these were largely unused, and considering we have not independently verified them, I have just gone ahead and removed these. |
This change rewrites our Mii services implementation. We've pretty much removed the old implementation, which included code to handle the Mii database (which was incomplete/incorrect, and based on assumptions from ~2 years ago). With the rewrite, we focus just on the basics that games need, which are:
This fixes Mario Kart 8 Deluxe, as well as the Mii Fighter mode in Super Smash Bros. Ultimate (screenshots below). These changes require a dump of the Mii system archive, which is used for the actual Mii models.
Credit to Ryujinx team for the Mii lookup tables used for generating random data, as well as the table of default Mii's that matches hardware (credit and copyright info is also cited in the source).