Skip to content

Commit 2a17f02

Browse files
committed
Hide emulator-related settings if emulator add-on is not installed
1 parent 7177671 commit 2a17f02

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

settings/arm9/source/main.cpp

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,13 @@ void begin_update(int opt)
543543
logPrint("\n");
544544
if (opt == 1) {
545545
// Slot-1 microSD > Console SD
546+
if (access("fat:/_nds/TWiLightMenu/addons/", F_OK) == 0) {
547+
logPrint("Copying addons from fat to sd\n");
548+
mkdir("sd:/_nds/TWiLightMenu/addons/", 0777);
549+
fcopy("fat:/_nds/TWiLightMenu/addons/Emulators", "sd:/_nds/TWiLightMenu/addons/Emulators");
550+
fcopy("fat:/_nds/TWiLightMenu/addons/Multimedia", "sd:/_nds/TWiLightMenu/addons/Multimedia");
551+
}
552+
546553
logPrint("Copying 3dssplash.srldr from fat to sd\n");
547554
fcopy("fat:/_nds/TWiLightMenu/3dssplash.srldr", "sd:/_nds/TWiLightMenu/3dssplash.srldr");
548555
logPrint("Copying imageview.srldr from fat to sd\n");
@@ -557,6 +564,13 @@ void begin_update(int opt)
557564
fcopy("fat:/_nds/TWiLightMenu/settings.srldr", "sd:/_nds/TWiLightMenu/settings.srldr");
558565
} else {
559566
// Console SD > Slot-1 microSD
567+
if (access("sd:/_nds/TWiLightMenu/addons/", F_OK) == 0) {
568+
logPrint("Copying addons from sd to fat\n");
569+
mkdir("fat:/_nds/TWiLightMenu/addons/", 0777);
570+
fcopy("sd:/_nds/TWiLightMenu/addons/Emulators", "fat:/_nds/TWiLightMenu/addons/Emulators");
571+
fcopy("sd:/_nds/TWiLightMenu/addons/Multimedia", "fat:/_nds/TWiLightMenu/addons/Multimedia");
572+
}
573+
560574
logPrint("Copying 3dssplash.srldr from sd to fat\n");
561575
fcopy("sd:/_nds/TWiLightMenu/3dssplash.srldr", "fat:/_nds/TWiLightMenu/3dssplash.srldr");
562576
logPrint("Copying imageview.srldr from sd to fat\n");
@@ -1004,6 +1018,7 @@ int settingsMode(void)
10041018
}
10051019

10061020
const bool gbaR3Found = (access(sys().isRunFromSD() ? "sd:/_nds/TWiLightMenu/emulators/GBARunner3.nds" : "fat:/_nds/TWiLightMenu/emulators/GBARunner3.nds", F_OK) == 0);
1021+
const bool emulatorsInstalled = (access(sys().isRunFromSD() ? "sd:/_nds/TWiLightMenu/addons/Emulators" : "fat:/_nds/TWiLightMenu/addons/Emulators", F_OK) == 0);
10071022

10081023
const bool sharedFound = (access("sd:/shared1", F_OK) == 0);
10091024

@@ -1419,27 +1434,29 @@ int settingsMode(void)
14191434
gamesPage.option(sdFound() ? ("S1SD: "+STR_GAMELOADER) : STR_GAMELOADER, STR_DESCRIPTION_GAMELOADER, Option::Bool(&ms().useBootstrap), {"nds-bootstrap", STR_KERNEL}, {true, false});
14201435
}
14211436

1422-
gamesPage.option(STR_COL_EMULATOR, STR_DESCRIPTION_COL_EMULATOR, Option::Int((int *)&ms().colEmulator), {"S8DS", "ColecoDS"}, {TColSegaEmulator::EColSegaS8DS, TColSegaEmulator::EColSegaColecoDS});
1437+
if (emulatorsInstalled)
1438+
gamesPage.option(STR_COL_EMULATOR, STR_DESCRIPTION_COL_EMULATOR, Option::Int((int *)&ms().colEmulator), {"S8DS", "ColecoDS"}, {TColSegaEmulator::EColSegaS8DS, TColSegaEmulator::EColSegaColecoDS});
14231439
if (ms().consoleModel == 0 && sdFound() && !sys().arm7SCFGLocked())
14241440
gamesPage.option(STR_DSIWAREBOOTER, STR_DESCRIPTION_DSIWAREBOOTER, Option::Bool((bool *)&ms().dsiWareBooter), {"nds-bootstrap", "Unlaunch"}, {true, false});
14251441
if (sys().isRegularDS()) {
14261442
gamesPage
14271443
.option(STR_GBA_BOOTER, STR_DESCRIPTION_GBA_BOOTER, Option::Int((int *)&ms().gbaBooter), {gbaR3Found ? STR_NATIVE_GBARUNNER3 : STR_NATIVE_GBARUNNER2, gbaR3Found ? STR_GBARUNNER3_ONLY : STR_GBARUNNER2_ONLY}, {TGbaBooter::EGbaNativeGbar2, TGbaBooter::EGbaGbar2})
14281444
.option(STR_GBABORDER, STR_DESCRIPTION_GBABORDER, Option::Nul(opt_gba_border_select), {STR_PRESS_A}, {0});
14291445
}
1430-
if (!(isDSiMode() && sdFound() && sys().arm7SCFGLocked()))
1446+
if (emulatorsInstalled && !(isDSiMode() && sdFound() && sys().arm7SCFGLocked()))
14311447
gamesPage.option(STR_MD_EMULATOR, STR_DESCRIPTION_MD_EMULATOR, Option::Int((int *)&ms().mdEmulator), {"jEnesisDS", "PicoDriveTWL", STR_HYBRID}, {TMegaDriveEmulator::EMegaDriveJenesis, TMegaDriveEmulator::EMegaDrivePico, TMegaDriveEmulator::EMegaDriveHybrid});
14321448
gamesPage.option(STR_SG_EMULATOR, STR_DESCRIPTION_SG_EMULATOR, Option::Int((int *)&ms().sgEmulator), {"S8DS", "ColecoDS"}, {TColSegaEmulator::EColSegaS8DS, TColSegaEmulator::EColSegaColecoDS});
14331449
gamesPage.option(STR_CPC_EMULATOR, STR_DESCRIPTION_CPC_EMULATOR, Option::Int((int *)&ms().cpcEmulator), {"AmEDS", "CrocoDS"}, {TCpcEmulator::ECpcAmEDS, TCpcEmulator::ECpcCrocoDS});
14341450

14351451
if (isDSiMode() && sdFound() && !sys().arm7SCFGLocked()) {
1436-
gamesPage
1437-
.option((flashcardFound() ? STR_SYSSD_RUNFLUBBAEMUSIN : STR_RUNFLUBBAEMUSIN),
1438-
STR_DESCRIPTION_RUNFLUBBAEMUSIN,
1439-
Option::Bool(&ms().smsGgInRam),
1440-
{STR_DS_MODE, STR_DSI_MODE},
1441-
{true, false});
1442-
1452+
if (emulatorsInstalled) {
1453+
gamesPage
1454+
.option((flashcardFound() ? STR_SYSSD_RUNFLUBBAEMUSIN : STR_RUNFLUBBAEMUSIN),
1455+
STR_DESCRIPTION_RUNFLUBBAEMUSIN,
1456+
Option::Bool(&ms().smsGgInRam),
1457+
{STR_DS_MODE, STR_DSI_MODE},
1458+
{true, false});
1459+
}
14431460
if (ms().consoleModel == 0) {
14441461
gamesPage.option(STR_SLOT1LAUNCHMETHOD, STR_DESCRIPTION_SLOT1LAUNCHMETHOD_1, Option::Int((int *)&ms().slot1LaunchMethod), {STR_REBOOT, STR_DIRECT, "Unlaunch"}, {TSlot1LaunchMethod::EReboot, TSlot1LaunchMethod::EDirect, TSlot1LaunchMethod::EUnlaunch});
14451462
} else {

title/arm9/source/common/fileCopy.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int fcopy(const char *sourcePath, const char *destinationPath)
3333
}
3434

3535
FILE* destinationFile = fopen(destinationPath, "wb");
36-
if (!destinationFile) {
36+
if (fsize == 0 || !destinationFile) {
3737
fclose(sourceFile);
3838
fclose(destinationFile);
3939
return 1;
@@ -60,7 +60,6 @@ int fcopy(const char *sourcePath, const char *destinationPath)
6060
fclose(sourceFile);
6161
fclose(destinationFile);
6262
return 0;
63-
break;
6463
}
6564
}
6665

0 commit comments

Comments
 (0)