13 enum class NDSRegion : u8 {
19 enum class UnitCode : u8 {
30 u8 encryption_seed_select;
34 u16 ndsi_game_revision;
43 u32 arm9_entry_address;
47 u32 arm7_entry_address;
58 u32 normal_card_control_register_settings;
59 u32 secure_card_control_register_settings;
62 u16 secure_transfer_timeout;
69 u8 nintendo_logo[156];
70 u16 nintendo_logo_crc;
72 u8 reserved_debugger[32];
76 inline std::string GetGameTitle() {
77 return util::GetNonNullTerminatedCString(this->game_title);
80 inline void SetGameTitle(
const std::string &game_title_str) {
81 return util::SetNonNullTerminatedCString(this->game_title, game_title_str);
84 inline std::string GetGameCode() {
85 return util::GetNonNullTerminatedCString(this->game_code);
88 inline void SetGameCode(
const std::string &game_code_str) {
89 return util::SetNonNullTerminatedCString(this->game_code, game_code_str);
92 inline std::string GetMakerCode() {
93 return util::GetNonNullTerminatedCString(this->maker_code);
96 inline void SetMakerCode(
const std::string &maker_code_str) {
97 return util::SetNonNullTerminatedCString(this->maker_code, maker_code_str);
100 static_assert(
sizeof(
Header) == 0x180);
102 static constexpr u32 GameTitleLength = 128;
109 u8 icon_chr[gfx::IconCharSize];
110 u8 icon_plt[gfx::IconPaletteSize];
111 char16_t game_titles[
static_cast<u32
>(util::SystemLanguage::Count)][GameTitleLength];
113 inline std::u16string GetGameTitle(
const util::SystemLanguage lang) {
114 if(lang < util::SystemLanguage::Count) {
115 return util::GetNonNullTerminatedCString(this->game_titles[
static_cast<u32
>(lang)]);
120 inline void SetGameTitle(
const util::SystemLanguage lang,
const std::u16string &game_title_str) {
121 if(lang < util::SystemLanguage::Count) {
122 util::SetNonNullTerminatedCString(this->game_titles[
static_cast<u32
>(lang)], game_title_str);
133 bool GetAlignmentBetweenFileData(
size_t &out_align)
override {
138 size_t GetFatEntriesOffset()
override {
139 return this->header.fat_offset;
142 size_t GetFatEntryCount()
override {
143 return this->header.fat_size /
sizeof(nfs::FileAllocationTableEntry);
146 Result OnFileSystemWrite(fs::BinaryFile &w_bf,
const ssize_t size_diff)
override {
147 size_t actual_rom_size;
148 NTR_R_TRY(w_bf.GetAbsoluteOffset(actual_rom_size));
149 this->header.ntr_region_size += size_diff;
150 auto capacity_size = actual_rom_size;
151 capacity_size |= capacity_size >> 16;
152 capacity_size |= capacity_size >> 8;
153 capacity_size |= capacity_size >> 4;
154 capacity_size |= capacity_size >> 2;
155 capacity_size |= capacity_size >> 1;
157 if(capacity_size <= 0x20000) {
158 capacity_size = 0x20000;
161 while(capacity_size != 0) {
165 this->header.device_capacity = (capacity < 0) ? 0 : static_cast<u8>(capacity);
167 NTR_R_TRY(w_bf.SetAbsoluteOffset(0));
168 NTR_R_TRY(w_bf.Write(this->header));
170 NTR_R_TRY(w_bf.SetAbsoluteOffset(this->header.banner_offset));
171 NTR_R_TRY(w_bf.Write(this->banner));
176 Result ValidateImpl(
const std::string &path, std::shared_ptr<fs::FileHandle> file_handle,
const fs::FileCompression comp)
override;
177 Result ReadImpl(
const std::string &path, std::shared_ptr<fs::FileHandle> file_handle,
const fs::FileCompression comp)
override;