Merge pull request #4279 from FearlessTobi/better-mii-stub

applets: stub mii selector to always return a standard mii
This commit is contained in:
Weiyi Wang 2018-12-01 19:41:21 -05:00 committed by GitHub
commit 76944ec0e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 94 additions and 14 deletions

View File

@ -55,17 +55,46 @@ ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& p
ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& parameter) { ResultCode MiiSelector::StartImpl(const Service::APT::AppletStartupParameter& parameter) {
is_running = true; is_running = true;
// TODO(Subv): Set the expected fields in the response buffer before resending it to the
// application.
// TODO(Subv): Reverse the parameter format for the Mii Selector // TODO(Subv): Reverse the parameter format for the Mii Selector
memcpy(&config, parameter.buffer.data(), parameter.buffer.size()); memcpy(&config, parameter.buffer.data(), parameter.buffer.size());
// TODO(Subv): Find more about this structure, result code 0 is enough to let most games // This data was obtained by writing the returned buffer in AppletManager::GlanceParameter of
// continue. // the LLEd Mii picker of version system version 11.8.0 to a file and then matching the values
// to the members of the MiiResult struct
MiiData mii_data;
mii_data.mii_id = 0x03001030;
mii_data.system_id = 0xD285B6B300C8850A;
mii_data.specialness_and_creation_date = 0x98391EE4;
mii_data.creator_mac = {0x40, 0xF4, 0x07, 0xB7, 0x37, 0x10};
mii_data.padding = 0x0;
mii_data.mii_information = 0xA600;
mii_data.mii_name = {'C', 'i', 't', 'r', 'a', 0x0, 0x0, 0x0, 0x0, 0x0};
mii_data.width_height = 0x4040;
mii_data.appearance_bits1.raw = 0x0;
mii_data.appearance_bits2.raw = 0x0;
mii_data.hair_style = 0x21;
mii_data.appearance_bits3.hair_color.Assign(0x1);
mii_data.appearance_bits3.flip_hair.Assign(0x0);
mii_data.unknown1 = 0x02684418;
mii_data.appearance_bits4.eyebrow_style.Assign(0x6);
mii_data.appearance_bits4.eyebrow_color.Assign(0x1);
mii_data.appearance_bits5.eyebrow_scale.Assign(0x4);
mii_data.appearance_bits5.eyebrow_yscale.Assign(0x3);
mii_data.appearance_bits6 = 0x4614;
mii_data.unknown2 = 0x81121768;
mii_data.allow_copying = 0x0D;
mii_data.unknown3 = {0x0, 0x0, 0x29, 0x0, 0x52, 0x48, 0x50};
mii_data.author_name = {'f', 'l', 'T', 'o', 'b', 'i', 0x0, 0x0, 0x0, 0x0};
MiiResult result; MiiResult result;
memset(&result, 0, sizeof(result)); result.return_code = 0x0;
result.return_code = 0; result.is_guest_mii_selected = 0x0;
result.selected_guest_mii_index = 0xFFFFFFFF;
result.selected_mii_data = mii_data;
result.unknown1 = 0x0;
result.mii_data_checksum = 0x056C;
result.guest_mii_name.fill(0x0);
// Let the application know that we're closing // Let the application know that we're closing
Service::APT::MessageParameter message; Service::APT::MessageParameter message;

View File

@ -40,15 +40,66 @@ ASSERT_REG_POSITION(initially_selected_mii_index, 0x90);
ASSERT_REG_POSITION(guest_mii_whitelist, 0x94); ASSERT_REG_POSITION(guest_mii_whitelist, 0x94);
#undef ASSERT_REG_POSITION #undef ASSERT_REG_POSITION
#pragma pack(push, 1)
struct MiiData {
u32_be mii_id;
u64_be system_id;
u32_be specialness_and_creation_date;
std::array<u8, 0x6> creator_mac;
u16_be padding;
u16_be mii_information;
std::array<u16_le, 0xA> mii_name;
u16_be width_height;
union {
u8 raw;
BitField<0, 1, u8> disable_sharing;
BitField<1, 4, u8> face_shape;
BitField<5, 3, u8> skin_color;
} appearance_bits1;
union {
u8 raw;
BitField<0, 4, u8> wrinkles;
BitField<4, 4, u8> makeup;
} appearance_bits2;
u8 hair_style;
union {
u8 raw;
BitField<0, 3, u8> hair_color;
BitField<3, 1, u8> flip_hair;
} appearance_bits3;
u32_be unknown1;
union {
u8 raw;
BitField<0, 5, u8> eyebrow_style;
BitField<5, 3, u8> eyebrow_color;
} appearance_bits4;
union {
u8 raw;
BitField<0, 4, u8> eyebrow_scale;
BitField<4, 3, u8> eyebrow_yscale;
} appearance_bits5;
u16_be appearance_bits6;
u32_be unknown2;
u8 allow_copying;
std::array<u8, 0x7> unknown3;
std::array<u16_le, 0xA> author_name;
};
static_assert(sizeof(MiiData) == 0x5C, "MiiData structure has incorrect size");
#pragma pack(pop)
struct MiiResult { struct MiiResult {
u32 return_code; u32_be return_code;
u32 is_guest_mii_selected; u32_be is_guest_mii_selected;
u32 selected_guest_mii_index; u32_be selected_guest_mii_index;
// TODO(mailwl): expand to Mii Format structure: https://www.3dbrew.org/wiki/Mii MiiData selected_mii_data;
u8 selected_mii_data[0x5C]; u16_be unknown1;
INSERT_PADDING_BYTES(2); u16_be mii_data_checksum;
u16 mii_data_checksum; std::array<u16_le, 0xC> guest_mii_name;
u16 guest_mii_name[0xC];
}; };
static_assert(sizeof(MiiResult) == 0x84, "MiiResult structure has incorrect size"); static_assert(sizeof(MiiResult) == 0x84, "MiiResult structure has incorrect size");
#define ASSERT_REG_POSITION(field_name, position) \ #define ASSERT_REG_POSITION(field_name, position) \