control_metadata.h 2.4 KB

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