Skip to content

Commit 954a27e

Browse files
Reduce the amount of system apps transferred over with "Clear NAND"
The current code breaks down currently for some NANDs (in particular Chinese and Korean NANDs) due to making some faulty assumptions. Instead of adding more code to handle these edge cases, I'm just opting to reduce the "Clear NAND" transfer to only the minimum core apps (System Menu, System Settings, and the various non-executable data files). With 51d92d3 (and later commits) if the user really wants to use these "fun" system apps for a movie (where Clear NAND is forced) they can do so by directly loading them as ROMs.
1 parent 5a83736 commit 954a27e

File tree

2 files changed

+10
-36
lines changed

2 files changed

+10
-36
lines changed

Assets/dll/melonDS.wbx.zst

-826 Bytes
Binary file not shown.

waterbox/melon/BizConsoleCreator.cpp

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -338,24 +338,18 @@ static const char* const BaseNandDirs[] =
338338
"0:/sys/log",
339339
"0:/ticket/0003000f", "0:/ticket/00030004", "0:/ticket/00030005", "0:/ticket/00030015", "0:/ticket/00030017",
340340
"0:/title/0003000f", "0:/title/00030004", "0:/title/00030005", "0:/title/00030015", "0:/title/00030017",
341-
"0:/title/0003000f/484e4341", "0:/title/0003000f/484e4841", "0:/title/00030005/484e4441", "0:/title/00030005/484e4541",
341+
"0:/title/0003000f/484e4341", "0:/title/0003000f/484e4841",
342342
"0:/title/0003000f/484e4341/content", "0:/title/0003000f/484e4341/data",
343343
"0:/title/0003000f/484e4841/content", "0:/title/0003000f/484e4841/data",
344-
"0:/title/00030005/484e4441/content", "0:/title/00030005/484e4441/data",
345-
"0:/title/00030005/484e4541/content", "0:/title/00030005/484e4541/data",
346344
"0:/tmp/es",
347345
"0:/tmp/es/write",
348346
};
349347

350348
static const char* const RegionalNandDirs[] =
351349
{
352-
"0:/title/0003000f/484e4c%x", "0:/title/00030005/484e49%x", "0:/title/00030005/484e4b%x",
353-
"0:/title/00030015/484e42%x", "0:/title/00030015/484e46%x", "0:/title/00030017/484e41%x",
350+
"0:/title/0003000f/484e4c%x", "0:/title/00030015/484e42%x", "0:/title/00030017/484e41%x",
354351
"0:/title/0003000f/484e4c%x/content", "0:/title/0003000f/484e4c%x/data",
355-
"0:/title/00030005/484e49%x/content", "0:/title/00030005/484e49%x/data",
356-
"0:/title/00030005/484e4b%x/content", "0:/title/00030005/484e4b%x/data",
357352
"0:/title/00030015/484e42%x/content", "0:/title/00030015/484e42%x/data",
358-
"0:/title/00030015/484e46%x/content", "0:/title/00030015/484e46%x/data",
359353
"0:/title/00030017/484e41%x/content", "0:/title/00030017/484e41%x/data",
360354
};
361355

@@ -368,46 +362,28 @@ static const std::pair<const char*, const u32> BaseNandFiles[] =
368362
std::make_pair("0:/sys/HWINFO_S.dat", 0x4000),
369363
std::make_pair("0:/ticket/0003000f/484e4341.tik", 0x2C4),
370364
std::make_pair("0:/ticket/0003000f/484e4841.tik", 0x2C4),
371-
std::make_pair("0:/ticket/00030005/484e4441.tik", 0x2C4),
372-
std::make_pair("0:/ticket/00030005/484e4541.tik", 0x2C4),
373365
};
374366

375367
static const std::pair<const char*, const u32> RegionalNandFiles[] =
376368
{
377369
std::make_pair("0:/ticket/0003000f/484e4c%x.tik", 0x2C4),
378-
std::make_pair("0:/ticket/00030005/484e49%x.tik", 0x2C4),
379-
std::make_pair("0:/ticket/00030005/484e4b%x.tik", 0x2C4),
380370
std::make_pair("0:/ticket/00030015/484e42%x.tik", 0x2C4),
381-
std::make_pair("0:/ticket/00030015/484e46%x.tik", 0x2C4),
382371
std::make_pair("0:/ticket/00030017/484e41%x.tik", 0x2C4),
383372
};
384373

385374
static const std::pair<const char*, const char*> BaseNandTitlePaths[] =
386375
{
387376
std::make_pair("0:/title/0003000f/484e4341/content/title.tmd", "0:/title/0003000f/484e4341/content/%08x.app"),
388377
std::make_pair("0:/title/0003000f/484e4841/content/title.tmd", "0:/title/0003000f/484e4841/content/%08x.app"),
389-
std::make_pair("0:/title/00030005/484e4441/content/title.tmd", "0:/title/00030005/484e4441/content/%08x.app"),
390-
std::make_pair("0:/title/00030005/484e4541/content/title.tmd", "0:/title/00030005/484e4541/content/%08x.app"),
391378
};
392379

393380
static const std::pair<const char*, const char*> RegionalNandTitlePaths[] =
394381
{
395382
std::make_pair("0:/title/0003000f/484e4c%x/content/title.tmd", "0:/title/0003000f/484e4c%x/content/%08x.app"),
396-
std::make_pair("0:/title/00030005/484e49%x/content/title.tmd", "0:/title/00030005/484e49%x/content/%08x.app"),
397-
std::make_pair("0:/title/00030005/484e4b%x/content/title.tmd", "0:/title/00030005/484e4b%x/content/%08x.app"),
398383
std::make_pair("0:/title/00030015/484e42%x/content/title.tmd", "0:/title/00030015/484e42%x/content/%08x.app"),
399-
std::make_pair("0:/title/00030015/484e46%x/content/title.tmd", "0:/title/00030015/484e46%x/content/%08x.app"),
400384
std::make_pair("0:/title/00030017/484e41%x/content/title.tmd", "0:/title/00030017/484e41%x/content/%08x.app"),
401385
};
402386

403-
static const std::pair<const char*, const u32> NandSavPaths[] =
404-
{
405-
std::make_pair("0:/title/00030005/484e49%x/data/private.sav", 0x80000),
406-
std::make_pair("0:/title/00030005/484e4b%x/data/private.sav", 0x80000),
407-
std::make_pair("0:/title/00030015/484e46%x/data/private.sav", 0x4000),
408-
std::make_pair("0:/title/00030017/484e41%x/data/private.sav", 0x4000),
409-
};
410-
411387
static const char* const PhotoNandDirs[] =
412388
{
413389
"0:/photo",
@@ -818,12 +794,10 @@ static melonDS::DSi_NAND::NANDImage CreateNandImage(
818794
nandFiles.push_back(std::make_pair(std::move(shared2Sound), std::string("0:/shared2/0000")));
819795
}
820796

821-
// add in a few blank sav files (these aren't created automatically)
822-
// there are just 512KiB and 16KiB saves here as a note (so just hardcode things for such)
823-
for (auto nandSavPath : NandSavPaths)
797+
// add in a blank sav file for the System Menu (this isn't created automatically)
824798
{
825799
std::vector<u8> nandSav;
826-
nandSav.resize(nandSavPath.second);
800+
nandSav.resize(0x4000);
827801
memset(nandSav.data(), 0, nandSav.size());
828802

829803
// write VBR
@@ -837,11 +811,11 @@ static melonDS::DSi_NAND::NANDImage CreateNandImage(
837811
vbr->NumReservedSectors = 1;
838812
vbr->NumFATs = 2;
839813
vbr->MaxRootDirectoryEntries = 32;
840-
vbr->NumSectorsU16 = nandSav.size() == 0x80000 ? 0x3E8 : 0x1B;
814+
vbr->NumSectorsU16 = 0x1B;
841815
vbr->MediaDescriptor = 0xF8;
842-
vbr->SectorsPerFAT = nandSav.size() == 0x80000 ? 3 : 1;
843-
vbr->SectorsPerTrack = nandSav.size() == 0x80000 ? 10 : 3;
844-
vbr->NumHeads = nandSav.size() == 0x80000 ? 10 : 3;
816+
vbr->SectorsPerFAT = 1;
817+
vbr->SectorsPerTrack = 3;
818+
vbr->NumHeads = 3;
845819
vbr->NumHiddenSectors = 0;
846820
vbr->NumSectorsU32 = 0;
847821
vbr->DriveNumber = 2;
@@ -855,9 +829,9 @@ static melonDS::DSi_NAND::NANDImage CreateNandImage(
855829

856830
// init both FATs
857831
memcpy(&nandSav[(1 + 0) * 0x200], &INIT_FAT12, sizeof(INIT_FAT12));
858-
memcpy(&nandSav[(1 + vbr->SectorsPerFAT) * 0x200], &INIT_FAT12, sizeof(INIT_FAT12));
832+
memcpy(&nandSav[(1 + 1) * 0x200], &INIT_FAT12, sizeof(INIT_FAT12));
859833

860-
snprintf(nandPath, sizeof(nandPath), nandSavPath.first, regionIdChar);
834+
snprintf(nandPath, sizeof(nandPath), "0:/title/00030017/484e41%x/data/private.sav", regionIdChar);
861835
nandFiles.push_back(std::make_pair(std::move(nandSav), std::string(nandPath)));
862836
}
863837

0 commit comments

Comments
 (0)