smdh.h 2.1 KB

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