2018-07-23 12:33:24 -04:00
|
|
|
// Copyright 2018 yuzu emulator team
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include "common/common_funcs.h"
|
2018-09-03 21:58:19 -04:00
|
|
|
#include "common/common_types.h"
|
2018-09-03 19:00:14 -04:00
|
|
|
#include "common/swap.h"
|
2018-07-23 12:33:24 -04:00
|
|
|
#include "core/file_sys/vfs.h"
|
|
|
|
|
|
|
|
namespace FileSys {
|
|
|
|
|
|
|
|
// A localized entry containing strings within the NACP.
|
|
|
|
// One for each language of type Language.
|
|
|
|
struct LanguageEntry {
|
|
|
|
std::array<char, 0x200> application_name;
|
|
|
|
std::array<char, 0x100> developer_name;
|
|
|
|
|
|
|
|
std::string GetApplicationName() const;
|
|
|
|
std::string GetDeveloperName() const;
|
|
|
|
};
|
|
|
|
static_assert(sizeof(LanguageEntry) == 0x300, "LanguageEntry has incorrect size.");
|
|
|
|
|
|
|
|
// The raw file format of a NACP file.
|
|
|
|
struct RawNACP {
|
|
|
|
std::array<LanguageEntry, 16> language_entries;
|
2018-12-06 20:25:55 -05:00
|
|
|
std::array<u8, 0x25> isbn;
|
|
|
|
u8 startup_user_account;
|
2019-06-16 05:06:33 -04:00
|
|
|
u8 user_account_switch_lock;
|
|
|
|
u8 addon_content_registration_type;
|
2018-12-06 20:25:55 -05:00
|
|
|
u32_le application_attribute;
|
|
|
|
u32_le supported_languages;
|
|
|
|
u32_le parental_control;
|
|
|
|
bool screenshot_enabled;
|
|
|
|
u8 video_capture_mode;
|
|
|
|
bool data_loss_confirmation;
|
|
|
|
INSERT_PADDING_BYTES(1);
|
2019-03-25 23:30:56 -04:00
|
|
|
u64_le presence_group_id;
|
2018-12-06 20:25:55 -05:00
|
|
|
std::array<u8, 0x20> rating_age;
|
2018-07-23 12:33:24 -04:00
|
|
|
std::array<char, 0x10> version_string;
|
|
|
|
u64_le dlc_base_title_id;
|
2019-03-25 23:30:56 -04:00
|
|
|
u64_le save_data_owner_id;
|
|
|
|
u64_le user_account_save_data_size;
|
|
|
|
u64_le user_account_save_data_journal_size;
|
|
|
|
u64_le device_save_data_size;
|
|
|
|
u64_le device_save_data_journal_size;
|
|
|
|
u64_le bcat_delivery_cache_storage_size;
|
|
|
|
char application_error_code_category[8];
|
2018-12-06 20:25:55 -05:00
|
|
|
std::array<u64_le, 0x8> local_communication;
|
|
|
|
u8 logo_type;
|
|
|
|
u8 logo_handling;
|
|
|
|
bool runtime_add_on_content_install;
|
|
|
|
INSERT_PADDING_BYTES(5);
|
2019-03-25 23:30:56 -04:00
|
|
|
u64_le seed_for_pseudo_device_id;
|
|
|
|
std::array<u8, 0x41> bcat_passphrase;
|
|
|
|
INSERT_PADDING_BYTES(7);
|
|
|
|
u64_le user_account_save_data_max_size;
|
|
|
|
u64_le user_account_save_data_max_journal_size;
|
|
|
|
u64_le device_save_data_max_size;
|
|
|
|
u64_le device_save_data_max_journal_size;
|
|
|
|
u64_le temporary_storage_size;
|
|
|
|
u64_le cache_storage_size;
|
|
|
|
u64_le cache_storage_journal_size;
|
|
|
|
u64_le cache_storage_data_and_journal_max_size;
|
|
|
|
u64_le cache_storage_max_index;
|
|
|
|
INSERT_PADDING_BYTES(0xE70);
|
2018-07-23 12:33:24 -04:00
|
|
|
};
|
|
|
|
static_assert(sizeof(RawNACP) == 0x4000, "RawNACP has incorrect size.");
|
|
|
|
|
|
|
|
// A language on the NX. These are for names and icons.
|
|
|
|
enum class Language : u8 {
|
|
|
|
AmericanEnglish = 0,
|
|
|
|
BritishEnglish = 1,
|
|
|
|
Japanese = 2,
|
|
|
|
French = 3,
|
|
|
|
German = 4,
|
|
|
|
LatinAmericanSpanish = 5,
|
|
|
|
Spanish = 6,
|
|
|
|
Italian = 7,
|
|
|
|
Dutch = 8,
|
|
|
|
CanadianFrench = 9,
|
|
|
|
Portugese = 10,
|
|
|
|
Russian = 11,
|
|
|
|
Korean = 12,
|
|
|
|
Taiwanese = 13,
|
|
|
|
Chinese = 14,
|
2018-09-03 19:00:14 -04:00
|
|
|
|
|
|
|
Default = 255,
|
2018-07-23 12:33:24 -04:00
|
|
|
};
|
|
|
|
|
2018-09-19 18:55:33 -04:00
|
|
|
extern const std::array<const char*, 15> LANGUAGE_NAMES;
|
2018-07-28 12:32:16 -04:00
|
|
|
|
2018-07-23 12:33:24 -04:00
|
|
|
// A class representing the format used by NX metadata files, typically named Control.nacp.
|
|
|
|
// These store application name, dev name, title id, and other miscellaneous data.
|
|
|
|
class NACP {
|
|
|
|
public:
|
2018-12-06 20:25:32 -05:00
|
|
|
explicit NACP();
|
2018-07-23 12:33:24 -04:00
|
|
|
explicit NACP(VirtualFile file);
|
2018-09-19 19:19:05 -04:00
|
|
|
~NACP();
|
|
|
|
|
2018-09-03 19:00:14 -04:00
|
|
|
const LanguageEntry& GetLanguageEntry(Language language = Language::Default) const;
|
|
|
|
std::string GetApplicationName(Language language = Language::Default) const;
|
|
|
|
std::string GetDeveloperName(Language language = Language::Default) const;
|
2018-07-23 12:33:24 -04:00
|
|
|
u64 GetTitleId() const;
|
2018-10-14 18:58:07 -04:00
|
|
|
u64 GetDLCBaseTitleId() const;
|
2018-07-23 12:33:24 -04:00
|
|
|
std::string GetVersionString() const;
|
2018-12-06 20:25:55 -05:00
|
|
|
u64 GetDefaultNormalSaveSize() const;
|
|
|
|
u64 GetDefaultJournalSaveSize() const;
|
2019-05-23 03:55:56 -04:00
|
|
|
u32 GetSupportedLanguages() const;
|
2018-10-28 14:55:32 -04:00
|
|
|
std::vector<u8> GetRawBytes() const;
|
2019-06-16 05:06:33 -04:00
|
|
|
bool GetUserAccountSwitchLock() const;
|
2020-04-14 13:53:45 -04:00
|
|
|
u64 GetDeviceSaveDataSize() const;
|
2018-07-23 12:33:24 -04:00
|
|
|
|
|
|
|
private:
|
2018-12-10 22:17:45 -05:00
|
|
|
RawNACP raw{};
|
2018-07-23 12:33:24 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace FileSys
|