control_metadata.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <array>
  6. #include <memory>
  7. #include <string>
  8. #include "common/common_funcs.h"
  9. #include "core/file_sys/vfs.h"
  10. namespace FileSys {
  11. // A localized entry containing strings within the NACP.
  12. // One for each language of type Language.
  13. struct LanguageEntry {
  14. std::array<char, 0x200> application_name;
  15. std::array<char, 0x100> developer_name;
  16. std::string GetApplicationName() const;
  17. std::string GetDeveloperName() const;
  18. };
  19. static_assert(sizeof(LanguageEntry) == 0x300, "LanguageEntry has incorrect size.");
  20. // The raw file format of a NACP file.
  21. struct RawNACP {
  22. std::array<LanguageEntry, 16> language_entries;
  23. INSERT_PADDING_BYTES(0x38);
  24. u64_le title_id;
  25. INSERT_PADDING_BYTES(0x20);
  26. std::array<char, 0x10> version_string;
  27. u64_le dlc_base_title_id;
  28. u64_le title_id_2;
  29. INSERT_PADDING_BYTES(0x28);
  30. u64_le product_code;
  31. u64_le title_id_3;
  32. std::array<u64_le, 0x7> title_id_array;
  33. INSERT_PADDING_BYTES(0x8);
  34. u64_le title_id_update;
  35. std::array<u8, 0x40> bcat_passphrase;
  36. INSERT_PADDING_BYTES(0xEC0);
  37. };
  38. static_assert(sizeof(RawNACP) == 0x4000, "RawNACP has incorrect size.");
  39. // A language on the NX. These are for names and icons.
  40. enum class Language : u8 {
  41. AmericanEnglish = 0,
  42. BritishEnglish = 1,
  43. Japanese = 2,
  44. French = 3,
  45. German = 4,
  46. LatinAmericanSpanish = 5,
  47. Spanish = 6,
  48. Italian = 7,
  49. Dutch = 8,
  50. CanadianFrench = 9,
  51. Portugese = 10,
  52. Russian = 11,
  53. Korean = 12,
  54. Taiwanese = 13,
  55. Chinese = 14,
  56. };
  57. static std::array<std::string, 15> LANGUAGE_NAMES = {
  58. "AmericanEnglish", "BritishEnglish", "Japanese",
  59. "French", "German", "LatinAmericanSpanish",
  60. "Spanish", "Italian", "Dutch",
  61. "CanadianFrench", "Portugese", "Russian",
  62. "Korean", "Taiwanese", "Chinese"};
  63. // A class representing the format used by NX metadata files, typically named Control.nacp.
  64. // These store application name, dev name, title id, and other miscellaneous data.
  65. class NACP {
  66. public:
  67. explicit NACP(VirtualFile file);
  68. const LanguageEntry& GetLanguageEntry(Language language = Language::AmericanEnglish) const;
  69. std::string GetApplicationName(Language language = Language::AmericanEnglish) const;
  70. std::string GetDeveloperName(Language language = Language::AmericanEnglish) const;
  71. u64 GetTitleId() const;
  72. std::string GetVersionString() const;
  73. private:
  74. VirtualFile file;
  75. std::unique_ptr<RawNACP> raw;
  76. };
  77. } // namespace FileSys