diff options
Diffstat (limited to 'src/core/loader/smdh.h')
| -rw-r--r-- | src/core/loader/smdh.h | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/core/loader/smdh.h b/src/core/loader/smdh.h new file mode 100644 index 000000000..2011abda2 --- /dev/null +++ b/src/core/loader/smdh.h | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | // Copyright 2016 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <array> | ||
| 8 | #include <vector> | ||
| 9 | |||
| 10 | #include "common/common_funcs.h" | ||
| 11 | #include "common/common_types.h" | ||
| 12 | #include "common/swap.h" | ||
| 13 | |||
| 14 | namespace Loader { | ||
| 15 | |||
| 16 | /** | ||
| 17 | * Tests if data is a valid SMDH by its length and magic number. | ||
| 18 | * @param smdh_data data buffer to test | ||
| 19 | * @return bool test result | ||
| 20 | */ | ||
| 21 | bool IsValidSMDH(const std::vector<u8>& smdh_data); | ||
| 22 | |||
| 23 | /// SMDH data structure that contains titles, icons etc. See https://www.3dbrew.org/wiki/SMDH | ||
| 24 | struct SMDH { | ||
| 25 | u32_le magic; | ||
| 26 | u16_le version; | ||
| 27 | INSERT_PADDING_BYTES(2); | ||
| 28 | |||
| 29 | struct Title { | ||
| 30 | std::array<u16, 0x40> short_title; | ||
| 31 | std::array<u16, 0x80> long_title; | ||
| 32 | std::array<u16, 0x40> publisher; | ||
| 33 | }; | ||
| 34 | std::array<Title, 16> titles; | ||
| 35 | |||
| 36 | std::array<u8, 16> ratings; | ||
| 37 | u32_le region_lockout; | ||
| 38 | u32_le match_maker_id; | ||
| 39 | u64_le match_maker_bit_id; | ||
| 40 | u32_le flags; | ||
| 41 | u16_le eula_version; | ||
| 42 | INSERT_PADDING_BYTES(2); | ||
| 43 | float_le banner_animation_frame; | ||
| 44 | u32_le cec_id; | ||
| 45 | INSERT_PADDING_BYTES(8); | ||
| 46 | |||
| 47 | std::array<u8, 0x480> small_icon; | ||
| 48 | std::array<u8, 0x1200> large_icon; | ||
| 49 | |||
| 50 | /// indicates the language used for each title entry | ||
| 51 | enum class TitleLanguage { | ||
| 52 | Japanese = 0, | ||
| 53 | English = 1, | ||
| 54 | French = 2, | ||
| 55 | German = 3, | ||
| 56 | Italian = 4, | ||
| 57 | Spanish = 5, | ||
| 58 | SimplifiedChinese = 6, | ||
| 59 | Korean= 7, | ||
| 60 | Dutch = 8, | ||
| 61 | Portuguese = 9, | ||
| 62 | Russian = 10, | ||
| 63 | TraditionalChinese = 11 | ||
| 64 | }; | ||
| 65 | |||
| 66 | /** | ||
| 67 | * Gets game icon from SMDH | ||
| 68 | * @param large If true, returns large icon (48x48), otherwise returns small icon (24x24) | ||
| 69 | * @return vector of RGB565 data | ||
| 70 | */ | ||
| 71 | std::vector<u16> GetIcon(bool large) const; | ||
| 72 | |||
| 73 | /** | ||
| 74 | * Gets the short game title from SMDH | ||
| 75 | * @param language title language | ||
| 76 | * @return UTF-16 array of the short title | ||
| 77 | */ | ||
| 78 | std::array<u16, 0x40> GetShortTitle(Loader::SMDH::TitleLanguage language) const; | ||
| 79 | }; | ||
| 80 | static_assert(sizeof(SMDH) == 0x36C0, "SMDH structure size is wrong"); | ||
| 81 | |||
| 82 | } // namespace | ||