Skip to content

Commit 54c03ae

Browse files
authored
Do not create dummy file anymore, no need to reset TWLCFG if region changing for jpn (#42)
1 parent ce4c29c commit 54c03ae

File tree

2 files changed

+1
-57
lines changed

2 files changed

+1
-57
lines changed

arm9/source/main.cpp

+1-57
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,6 @@ int main( int argc, char **argv) {
363363
iprintf("\n");
364364
if ((cursorPosition == 0) && (optionCount > 2)) {
365365
iprintf(" Change the SDNAND region.\n");
366-
if (regionChar == 'J') {
367-
iprintf(" System settings will be reset.\n");
368-
}
369366
iprintf(" \n");
370367
iprintf(" Original region: ");
371368
if (regionChar == 'J') {
@@ -461,71 +458,18 @@ int main( int argc, char **argv) {
461458
if (newRegion != oldRegion) {
462459
FILE* f_hwinfoS = fopen("sd:/sys/HWINFO_S.dat", "rb+");
463460
if (f_hwinfoS) {
464-
u32 supportedLangBitmask = 0x01; // JPN: Japanese
461+
u32 supportedLangBitmask = 0x3F; // Japanese, English, French, German, Italian, Spanish
465462
if (newRegion == 5) { // KOR
466463
supportedLangBitmask = 0x80; // Korean
467464
} else if (newRegion == 4) { // CHN
468465
supportedLangBitmask = 0x40; // Chinese
469-
} else if (newRegion == 3) { // AUS
470-
supportedLangBitmask = 0x02; // English
471-
} else if (newRegion == 2) { // EUR
472-
supportedLangBitmask = 0x3E; // English, French, German, Italian, Spanish
473-
} else if (newRegion == 1) { // USA
474-
supportedLangBitmask = 0x26; // English, French, Spanish
475466
}
476467
fseek(f_hwinfoS, 0x88, SEEK_SET);
477468
fwrite(&supportedLangBitmask, sizeof(u32), 1, f_hwinfoS);
478469
fseek(f_hwinfoS, 0x90, SEEK_SET);
479470
fwrite(&newRegion, 1, 1, f_hwinfoS);
480471
fclose(f_hwinfoS);
481472
}
482-
if (regionChar == 'J') {
483-
// Reset system settings to work around touch inputs not working
484-
remove("sd:/shared1/TWLCFG0.dat");
485-
remove("sd:/shared1/TWLCFG1.dat");
486-
}
487-
}
488-
489-
// Create dummy file
490-
// Check the free space
491-
struct statvfs st;
492-
statvfs("sd:/", &st);
493-
u32 freeSpace = st.f_bsize * st.f_bfree;
494-
u64 realFreeSpace = st.f_bsize * st.f_bfree;
495-
496-
// If the free space is bigger than 2GiB (using a u32 so always 0 - 4GiB)
497-
// or the free space is less than 20MiB (and the actual free space is over 4GiB)
498-
if(freeSpace > (2u << 30) || (freeSpace < (20u << 20) && realFreeSpace > (4u << 30))) {
499-
consoleDemoInit();
500-
size_t oldSize = 0;
501-
// Check old dummy file size to see if it can just be removed
502-
FILE *file = fopen("sd:/hiya/dummy.bin", "rb");
503-
if(file) {
504-
fseek(file, 0, SEEK_END);
505-
oldSize = ftell(file);
506-
fclose(file);
507-
}
508-
509-
// Check that dummy file is still needed
510-
if((freeSpace + oldSize) > (2u << 30) || (freeSpace + oldSize) < (20u << 20)) {
511-
// Make sure hiya directory exists and make the file
512-
mkdir("sd:/hiya", 0777);
513-
iprintf("Making new dummy file... ");
514-
515-
// Make sure the file exists
516-
file = fopen("sd:/hiya/dummy.bin", "wb");
517-
if(file)
518-
fclose(file);
519-
520-
// If free space is less than 20MiB, add free space + 2GiB + 10MiB
521-
// otherwise add free space - 2GiB + 10MiB
522-
truncate("sd:/hiya/dummy.bin", (freeSpace < (20u << 20) ? (freeSpace + (2 << 30)) : (freeSpace - (2 << 30))) + (10 << 20));
523-
iprintf("Done!\n");
524-
} else {
525-
iprintf("Removing old dummy file... ");
526-
remove("sd:/hiya/dummy.bin");
527-
iprintf("Done!\n");
528-
}
529473
}
530474

531475
if (!gotoSettings && (*(u32*)0x02000300 == 0x434E4C54)) {

template.7z

710 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)