summaryrefslogtreecommitdiff
path: root/src/core/hle/service/mii
diff options
context:
space:
mode:
authorGravatar german772023-09-10 23:17:50 -0600
committerGravatar german772023-09-10 23:18:08 -0600
commit36290f9a0ac953ce57a663b5ba817d7e3bb5a33c (patch)
tree1d659cf2a3e5033ccdff54c9b8af764707db031c /src/core/hle/service/mii
parentservice: mii: Move store data operations (diff)
downloadyuzu-36290f9a0ac953ce57a663b5ba817d7e3bb5a33c.tar.gz
yuzu-36290f9a0ac953ce57a663b5ba817d7e3bb5a33c.tar.xz
yuzu-36290f9a0ac953ce57a663b5ba817d7e3bb5a33c.zip
service: mii: move char info operations
Diffstat (limited to 'src/core/hle/service/mii')
-rw-r--r--src/core/hle/service/mii/mii_manager.cpp30
-rw-r--r--src/core/hle/service/mii/mii_types.h29
-rw-r--r--src/core/hle/service/mii/types/char_info.cpp478
-rw-r--r--src/core/hle/service/mii/types/char_info.h60
4 files changed, 576 insertions, 21 deletions
diff --git a/src/core/hle/service/mii/mii_manager.cpp b/src/core/hle/service/mii/mii_manager.cpp
index dd7af531e..2137a9af1 100644
--- a/src/core/hle/service/mii/mii_manager.cpp
+++ b/src/core/hle/service/mii/mii_manager.cpp
@@ -21,18 +21,10 @@ namespace {
21 21
22constexpr std::size_t DefaultMiiCount{RawData::DefaultMii.size()}; 22constexpr std::size_t DefaultMiiCount{RawData::DefaultMii.size()};
23 23
24constexpr Nickname DefaultMiiName{u'n', u'o', u' ', u'n', u'a', u'm', u'e'};
25
26template <typename T, std::size_t SourceArraySize, std::size_t DestArraySize>
27std::array<T, DestArraySize> ResizeArray(const std::array<T, SourceArraySize>& in) {
28 std::array<T, DestArraySize> out{};
29 std::memcpy(out.data(), in.data(), sizeof(T) * std::min(SourceArraySize, DestArraySize));
30 return out;
31}
32
33CharInfo ConvertStoreDataToInfo(const StoreData& data) { 24CharInfo ConvertStoreDataToInfo(const StoreData& data) {
34 // Next Commit Will fix this one 25 CharInfo char_info{};
35 return {}; 26 char_info.SetFromStoreData(data);
27 return char_info;
36} 28}
37 29
38StoreData BuildRandomStoreData(Age age, Gender gender, Race race, const Common::UUID& user_id) { 30StoreData BuildRandomStoreData(Age age, Gender gender, Race race, const Common::UUID& user_id) {
@@ -112,14 +104,14 @@ CharInfo MiiManager::ConvertV3ToCharInfo(const Ver3StoreData& mii_v3) const {
112 104
113NfpStoreDataExtension MiiManager::SetFromStoreData(const CharInfo& mii) const { 105NfpStoreDataExtension MiiManager::SetFromStoreData(const CharInfo& mii) const {
114 return { 106 return {
115 .faceline_color = static_cast<u8>(mii.faceline_color & 0xf), 107 .faceline_color = static_cast<u8>(mii.GetFacelineColor() & 0xf),
116 .hair_color = static_cast<u8>(mii.hair_color & 0x7f), 108 .hair_color = static_cast<u8>(mii.GetHairColor() & 0x7f),
117 .eye_color = static_cast<u8>(mii.eyebrow_color & 0x7f), 109 .eye_color = static_cast<u8>(mii.GetEyeColor() & 0x7f),
118 .eyebrow_color = static_cast<u8>(mii.eyebrow_color & 0x7f), 110 .eyebrow_color = static_cast<u8>(mii.GetEyebrowColor() & 0x7f),
119 .mouth_color = static_cast<u8>(mii.mouth_color & 0x7f), 111 .mouth_color = static_cast<u8>(mii.GetMouthColor() & 0x7f),
120 .beard_color = static_cast<u8>(mii.beard_color & 0x7f), 112 .beard_color = static_cast<u8>(mii.GetBeardColor() & 0x7f),
121 .glass_color = static_cast<u8>(mii.glasses_color & 0x7f), 113 .glass_color = static_cast<u8>(mii.GetGlassColor() & 0x7f),
122 .glass_type = static_cast<u8>(mii.glasses_type & 0x1f), 114 .glass_type = static_cast<u8>(mii.GetGlassType() & 0x1f),
123 }; 115 };
124} 116}
125 117
diff --git a/src/core/hle/service/mii/mii_types.h b/src/core/hle/service/mii/mii_types.h
index ff836dcf2..20d4e40ab 100644
--- a/src/core/hle/service/mii/mii_types.h
+++ b/src/core/hle/service/mii/mii_types.h
@@ -86,7 +86,34 @@ enum class SourceFlag : u32 {
86}; 86};
87DECLARE_ENUM_FLAG_OPERATORS(SourceFlag); 87DECLARE_ENUM_FLAG_OPERATORS(SourceFlag);
88 88
89using Nickname = std::array<char16_t, 10>; 89struct Nickname {
90 static constexpr std::size_t MaxNameSize = 10;
91 std::array<char16_t, MaxNameSize> data;
92
93 // Checks for null, non-zero terminated or dirty strings
94 bool IsValid() const {
95 if (data[0] == 0) {
96 return false;
97 }
98
99 if (data[MaxNameSize] != 0) {
100 return false;
101 }
102 std::size_t index = 1;
103 while (data[index] != 0) {
104 index++;
105 }
106 while (index < MaxNameSize && data[index] == 0) {
107 index++;
108 }
109 return index == MaxNameSize;
110 }
111
112 bool operator==(const Nickname& name) {
113 return data == name.data;
114 };
115};
116static_assert(sizeof(Nickname) == 0x14, "Nickname is an invalid size");
90 117
91struct NfpStoreDataExtension { 118struct NfpStoreDataExtension {
92 u8 faceline_color; 119 u8 faceline_color;
diff --git a/src/core/hle/service/mii/types/char_info.cpp b/src/core/hle/service/mii/types/char_info.cpp
index 250fad44b..e1d874860 100644
--- a/src/core/hle/service/mii/types/char_info.cpp
+++ b/src/core/hle/service/mii/types/char_info.cpp
@@ -2,5 +2,481 @@
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include "core/hle/service/mii/types/char_info.h" 4#include "core/hle/service/mii/types/char_info.h"
5#include "core/hle/service/mii/types/store_data.h"
5 6
6namespace Service::Mii {} // namespace Service::Mii 7namespace Service::Mii {
8
9void CharInfo::SetFromStoreData(const StoreData& store_data) {
10 name = store_data.GetNickname();
11 null_terminator = '\0';
12 create_id = store_data.GetCreateId();
13 font_region = static_cast<u8>(store_data.GetFontRegion());
14 favorite_color = store_data.GetFavoriteColor();
15 gender = store_data.GetGender();
16 height = store_data.GetHeight();
17 build = store_data.GetBuild();
18 type = store_data.GetType();
19 region_move = store_data.GetRegionMove();
20 faceline_type = store_data.GetFacelineType();
21 faceline_color = store_data.GetFacelineColor();
22 faceline_wrinkle = store_data.GetFacelineWrinkle();
23 faceline_make = store_data.GetFacelineMake();
24 hair_type = store_data.GetHairType();
25 hair_color = store_data.GetHairColor();
26 hair_flip = store_data.GetHairFlip();
27 eye_type = store_data.GetEyeType();
28 eye_color = store_data.GetEyeColor();
29 eye_scale = store_data.GetEyeScale();
30 eye_aspect = store_data.GetEyeAspect();
31 eye_rotate = store_data.GetEyeRotate();
32 eye_x = store_data.GetEyeX();
33 eye_y = store_data.GetEyeY();
34 eyebrow_type = store_data.GetEyebrowType();
35 eyebrow_color = store_data.GetEyebrowColor();
36 eyebrow_scale = store_data.GetEyebrowScale();
37 eyebrow_aspect = store_data.GetEyebrowAspect();
38 eyebrow_rotate = store_data.GetEyebrowRotate();
39 eyebrow_x = store_data.GetEyebrowX();
40 eyebrow_y = store_data.GetEyebrowY();
41 nose_type = store_data.GetNoseType();
42 nose_scale = store_data.GetNoseScale();
43 nose_y = store_data.GetNoseY();
44 mouth_type = store_data.GetMouthType();
45 mouth_color = store_data.GetMouthColor();
46 mouth_scale = store_data.GetMouthScale();
47 mouth_aspect = store_data.GetMouthAspect();
48 mouth_y = store_data.GetMouthY();
49 beard_color = store_data.GetBeardColor();
50 beard_type = store_data.GetBeardType();
51 mustache_type = store_data.GetMustacheType();
52 mustache_scale = store_data.GetMustacheScale();
53 mustache_y = store_data.GetMustacheY();
54 glasses_type = store_data.GetGlassType();
55 glasses_color = store_data.GetGlassColor();
56 glasses_scale = store_data.GetGlassScale();
57 glasses_y = store_data.GetGlassY();
58 mole_type = store_data.GetMoleType();
59 mole_scale = store_data.GetMoleScale();
60 mole_x = store_data.GetMoleX();
61 mole_y = store_data.GetMoleY();
62 padding = '\0';
63}
64
65u32 CharInfo::Verify() const {
66 if (!create_id.IsValid()) {
67 return 0x32;
68 }
69 if (!name.IsValid()) {
70 return 0x33;
71 }
72 if (3 < font_region) {
73 return 0x17;
74 }
75 if (0xb < favorite_color) {
76 return 0x16;
77 }
78 if (1 < gender) {
79 return 0x18;
80 }
81 if (height < 0) {
82 return 0x20;
83 }
84 if (build < 0) {
85 return 3;
86 }
87 if (1 < type) {
88 return 0x35;
89 }
90 if (3 < region_move) {
91 return 0x31;
92 }
93 if (0xb < faceline_type) {
94 return 0x15;
95 }
96 if (9 < faceline_color) {
97 return 0x12;
98 }
99 if (0xb < faceline_wrinkle) {
100 return 0x14;
101 }
102 if (0xb < faceline_make) {
103 return 0x13;
104 }
105 if (0x83 < hair_type) {
106 return 0x1f;
107 }
108 if (99 < hair_color) {
109 return 0x1d;
110 }
111 if (1 < hair_flip) {
112 return 0x1e;
113 }
114 if (0x3b < eye_type) {
115 return 8;
116 }
117 if (99 < eye_color) {
118 return 5;
119 }
120 if (7 < eye_scale) {
121 return 7;
122 }
123 if (6 < eye_aspect) {
124 return 4;
125 }
126 if (7 < eye_rotate) {
127 return 6;
128 }
129 if (0xc < eye_x) {
130 return 9;
131 }
132 if (0x12 < eye_y) {
133 return 10;
134 }
135 if (0x17 < eyebrow_type) {
136 return 0xf;
137 }
138 if (99 < eyebrow_color) {
139 return 0xc;
140 }
141 if (8 < eyebrow_scale) {
142 return 0xe;
143 }
144 if (6 < eyebrow_aspect) {
145 return 0xb;
146 }
147 if (0xb < eyebrow_rotate) {
148 return 0xd;
149 }
150 if (0xc < eyebrow_x) {
151 return 0x10;
152 }
153 if (0xf < eyebrow_y - 3) {
154 return 0x11;
155 }
156 if (0x11 < nose_type) {
157 return 0x2f;
158 }
159 if (nose_scale >= 9) {
160 return 0x2e;
161 }
162 if (0x12 < nose_y) {
163 return 0x30;
164 }
165 if (0x23 < mouth_type) {
166 return 0x28;
167 }
168 if (99 < mouth_color) {
169 return 0x26;
170 }
171 if (8 < mouth_scale) {
172 return 0x27;
173 }
174 if (6 < mouth_aspect) {
175 return 0x25;
176 }
177 if (0x12 < mouth_y) {
178 return 0x29;
179 }
180 if (99 < beard_color) {
181 return 1;
182 }
183 if (5 < beard_type) {
184 return 2;
185 }
186 if (5 < mustache_type) {
187 return 0x2b;
188 }
189 if (8 < mustache_scale) {
190 return 0x2a;
191 }
192 if (0x10 < mustache_y) {
193 return 0x2c;
194 }
195 if (0x13 < glasses_type) {
196 return 0x1b;
197 }
198 if (99 < glasses_color) {
199 return 0x19;
200 }
201 if (7 < glasses_scale) {
202 return 0x1a;
203 }
204 if (0x14 < glasses_y) {
205 return 0x1c;
206 }
207 if (mole_type >= 2) {
208 return 0x22;
209 }
210 if (8 < mole_scale) {
211 return 0x21;
212 }
213 if (mole_x >= 0x11) {
214 return 0x23;
215 }
216 if (0x1e < mole_y) {
217 return 0x24;
218 }
219 return 0;
220}
221
222Common::UUID CharInfo::GetCreateId() const {
223 return create_id;
224}
225
226Nickname CharInfo::GetNickname() const {
227 return name;
228}
229
230u8 CharInfo::GetFontRegion() const {
231 return font_region;
232}
233
234u8 CharInfo::GetFavoriteColor() const {
235 return favorite_color;
236}
237
238u8 CharInfo::GetGender() const {
239 return gender;
240}
241
242u8 CharInfo::GetHeight() const {
243 return height;
244}
245
246u8 CharInfo::GetBuild() const {
247 return build;
248}
249
250u8 CharInfo::GetType() const {
251 return type;
252}
253
254u8 CharInfo::GetRegionMove() const {
255 return region_move;
256}
257
258u8 CharInfo::GetFacelineType() const {
259 return faceline_type;
260}
261
262u8 CharInfo::GetFacelineColor() const {
263 return faceline_color;
264}
265
266u8 CharInfo::GetFacelineWrinkle() const {
267 return faceline_wrinkle;
268}
269
270u8 CharInfo::GetFacelineMake() const {
271 return faceline_make;
272}
273
274u8 CharInfo::GetHairType() const {
275 return hair_type;
276}
277
278u8 CharInfo::GetHairColor() const {
279 return hair_color;
280}
281
282u8 CharInfo::GetHairFlip() const {
283 return hair_flip;
284}
285
286u8 CharInfo::GetEyeType() const {
287 return eye_type;
288}
289
290u8 CharInfo::GetEyeColor() const {
291 return eye_color;
292}
293
294u8 CharInfo::GetEyeScale() const {
295 return eye_scale;
296}
297
298u8 CharInfo::GetEyeAspect() const {
299 return eye_aspect;
300}
301
302u8 CharInfo::GetEyeRotate() const {
303 return eye_rotate;
304}
305
306u8 CharInfo::GetEyeX() const {
307 return eye_x;
308}
309
310u8 CharInfo::GetEyeY() const {
311 return eye_y;
312}
313
314u8 CharInfo::GetEyebrowType() const {
315 return eyebrow_type;
316}
317
318u8 CharInfo::GetEyebrowColor() const {
319 return eyebrow_color;
320}
321
322u8 CharInfo::GetEyebrowScale() const {
323 return eyebrow_scale;
324}
325
326u8 CharInfo::GetEyebrowAspect() const {
327 return eyebrow_aspect;
328}
329
330u8 CharInfo::GetEyebrowRotate() const {
331 return eyebrow_rotate;
332}
333
334u8 CharInfo::GetEyebrowX() const {
335 return eyebrow_x;
336}
337
338u8 CharInfo::GetEyebrowY() const {
339 return eyebrow_y;
340}
341
342u8 CharInfo::GetNoseType() const {
343 return nose_type;
344}
345
346u8 CharInfo::GetNoseScale() const {
347 return nose_scale;
348}
349
350u8 CharInfo::GetNoseY() const {
351 return nose_y;
352}
353
354u8 CharInfo::GetMouthType() const {
355 return mouth_type;
356}
357
358u8 CharInfo::GetMouthColor() const {
359 return mouth_color;
360}
361
362u8 CharInfo::GetMouthScale() const {
363 return mouth_scale;
364}
365
366u8 CharInfo::GetMouthAspect() const {
367 return mouth_aspect;
368}
369
370u8 CharInfo::GetMouthY() const {
371 return mouth_y;
372}
373
374u8 CharInfo::GetBeardColor() const {
375 return beard_color;
376}
377
378u8 CharInfo::GetBeardType() const {
379 return beard_type;
380}
381
382u8 CharInfo::GetMustacheType() const {
383 return mustache_type;
384}
385
386u8 CharInfo::GetMustacheScale() const {
387 return mustache_scale;
388}
389
390u8 CharInfo::GetMustacheY() const {
391 return mustache_y;
392}
393
394u8 CharInfo::GetGlassType() const {
395 return glasses_type;
396}
397
398u8 CharInfo::GetGlassColor() const {
399 return glasses_color;
400}
401
402u8 CharInfo::GetGlassScale() const {
403 return glasses_scale;
404}
405
406u8 CharInfo::GetGlassY() const {
407 return glasses_y;
408}
409
410u8 CharInfo::GetMoleType() const {
411 return mole_type;
412}
413
414u8 CharInfo::GetMoleScale() const {
415 return mole_scale;
416}
417
418u8 CharInfo::GetMoleX() const {
419 return mole_x;
420}
421
422u8 CharInfo::GetMoleY() const {
423 return mole_y;
424}
425
426bool CharInfo::operator==(const CharInfo& info) {
427 bool is_identical = info.Verify() == 0;
428 is_identical &= name == info.GetNickname();
429 is_identical &= create_id == info.GetCreateId();
430 is_identical &= font_region == info.GetFontRegion();
431 is_identical &= favorite_color == info.GetFavoriteColor();
432 is_identical &= gender == info.GetGender();
433 is_identical &= height == info.GetHeight();
434 is_identical &= build == info.GetBuild();
435 is_identical &= type == info.GetType();
436 is_identical &= region_move == info.GetRegionMove();
437 is_identical &= faceline_type == info.GetFacelineType();
438 is_identical &= faceline_color == info.GetFacelineColor();
439 is_identical &= faceline_wrinkle == info.GetFacelineWrinkle();
440 is_identical &= faceline_make == info.GetFacelineMake();
441 is_identical &= hair_type == info.GetHairType();
442 is_identical &= hair_color == info.GetHairColor();
443 is_identical &= hair_flip == info.GetHairFlip();
444 is_identical &= eye_type == info.GetEyeType();
445 is_identical &= eye_color == info.GetEyeColor();
446 is_identical &= eye_scale == info.GetEyeScale();
447 is_identical &= eye_aspect == info.GetEyeAspect();
448 is_identical &= eye_rotate == info.GetEyeRotate();
449 is_identical &= eye_x == info.GetEyeX();
450 is_identical &= eye_y == info.GetEyeY();
451 is_identical &= eyebrow_type == info.GetEyebrowType();
452 is_identical &= eyebrow_color == info.GetEyebrowColor();
453 is_identical &= eyebrow_scale == info.GetEyebrowScale();
454 is_identical &= eyebrow_aspect == info.GetEyebrowAspect();
455 is_identical &= eyebrow_rotate == info.GetEyebrowRotate();
456 is_identical &= eyebrow_x == info.GetEyebrowX();
457 is_identical &= eyebrow_y == info.GetEyebrowY();
458 is_identical &= nose_type == info.GetNoseType();
459 is_identical &= nose_scale == info.GetNoseScale();
460 is_identical &= nose_y == info.GetNoseY();
461 is_identical &= mouth_type == info.GetMouthType();
462 is_identical &= mouth_color == info.GetMouthColor();
463 is_identical &= mouth_scale == info.GetMouthScale();
464 is_identical &= mouth_aspect == info.GetMouthAspect();
465 is_identical &= mouth_y == info.GetMouthY();
466 is_identical &= beard_color == info.GetBeardColor();
467 is_identical &= beard_type == info.GetBeardType();
468 is_identical &= mustache_type == info.GetMustacheType();
469 is_identical &= mustache_scale == info.GetMustacheScale();
470 is_identical &= mustache_y == info.GetMustacheY();
471 is_identical &= glasses_type == info.GetGlassType();
472 is_identical &= glasses_color == info.GetGlassColor();
473 is_identical &= glasses_scale == info.GetGlassScale();
474 is_identical &= glasses_y == info.GetGlassY();
475 is_identical &= mole_type == info.GetMoleType();
476 is_identical &= mole_scale == info.GetMoleScale();
477 is_identical &= mole_x == info.GetMoleX();
478 is_identical &= mole_y == info.GetMoleY();
479 return is_identical;
480}
481
482} // namespace Service::Mii
diff --git a/src/core/hle/service/mii/types/char_info.h b/src/core/hle/service/mii/types/char_info.h
index cdebb1c9d..4f70edc24 100644
--- a/src/core/hle/service/mii/types/char_info.h
+++ b/src/core/hle/service/mii/types/char_info.h
@@ -6,10 +6,70 @@
6#include "core/hle/service/mii/mii_types.h" 6#include "core/hle/service/mii/mii_types.h"
7 7
8namespace Service::Mii { 8namespace Service::Mii {
9class StoreData;
9 10
10// This is nn::mii::detail::CharInfoRaw 11// This is nn::mii::detail::CharInfoRaw
11class CharInfo { 12class CharInfo {
12public: 13public:
14 void SetFromStoreData(const StoreData& store_data_raw);
15
16 u32 Verify() const;
17
18 Common::UUID GetCreateId() const;
19 Nickname GetNickname() const;
20 u8 GetFontRegion() const;
21 u8 GetFavoriteColor() const;
22 u8 GetGender() const;
23 u8 GetHeight() const;
24 u8 GetBuild() const;
25 u8 GetType() const;
26 u8 GetRegionMove() const;
27 u8 GetFacelineType() const;
28 u8 GetFacelineColor() const;
29 u8 GetFacelineWrinkle() const;
30 u8 GetFacelineMake() const;
31 u8 GetHairType() const;
32 u8 GetHairColor() const;
33 u8 GetHairFlip() const;
34 u8 GetEyeType() const;
35 u8 GetEyeColor() const;
36 u8 GetEyeScale() const;
37 u8 GetEyeAspect() const;
38 u8 GetEyeRotate() const;
39 u8 GetEyeX() const;
40 u8 GetEyeY() const;
41 u8 GetEyebrowType() const;
42 u8 GetEyebrowColor() const;
43 u8 GetEyebrowScale() const;
44 u8 GetEyebrowAspect() const;
45 u8 GetEyebrowRotate() const;
46 u8 GetEyebrowX() const;
47 u8 GetEyebrowY() const;
48 u8 GetNoseType() const;
49 u8 GetNoseScale() const;
50 u8 GetNoseY() const;
51 u8 GetMouthType() const;
52 u8 GetMouthColor() const;
53 u8 GetMouthScale() const;
54 u8 GetMouthAspect() const;
55 u8 GetMouthY() const;
56 u8 GetBeardColor() const;
57 u8 GetBeardType() const;
58 u8 GetMustacheType() const;
59 u8 GetMustacheScale() const;
60 u8 GetMustacheY() const;
61 u8 GetGlassType() const;
62 u8 GetGlassColor() const;
63 u8 GetGlassScale() const;
64 u8 GetGlassY() const;
65 u8 GetMoleType() const;
66 u8 GetMoleScale() const;
67 u8 GetMoleX() const;
68 u8 GetMoleY() const;
69
70 bool operator==(const CharInfo& info);
71
72private:
13 Common::UUID create_id; 73 Common::UUID create_id;
14 Nickname name; 74 Nickname name;
15 u16 null_terminator; 75 u16 null_terminator;