NDS: Try to fix mounting SD card failing

This commit is contained in:
UnknownShadow200 2024-09-02 19:27:43 +10:00
parent 0940ea13a1
commit 00eac312fe
2 changed files with 21 additions and 14 deletions

View File

@ -474,6 +474,7 @@ static void MenuOptionsScreen_Free(void* screen) {
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen; struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
Event_Unregister_(&UserEvents.HackPermsChanged, screen, MenuOptionsScreen_OnHacksChanged); Event_Unregister_(&UserEvents.HackPermsChanged, screen, MenuOptionsScreen_OnHacksChanged);
Event_Unregister_(&WorldEvents.LightingModeChanged, screen, MenuOptionsScreen_OnLightingModeServerChanged); Event_Unregister_(&WorldEvents.LightingModeChanged, screen, MenuOptionsScreen_OnLightingModeServerChanged);
MenuInputOverlay_Close(false);
} }
static void MenuOptionsScreen_Layout(void* screen) { static void MenuOptionsScreen_Layout(void* screen) {

View File

@ -232,7 +232,7 @@ static int LoadFatFilesystem(void* arg) {
return 0; return 0;
} }
static void InitFilesystem(void) { static void MountFilesystem(void) {
cothread_t thread = cothread_create(LoadFatFilesystem, NULL, 0, 0); cothread_t thread = cothread_create(LoadFatFilesystem, NULL, 0, 0);
// If running with DSi mode in melonDS and the internal SD card is enabled, then // If running with DSi mode in melonDS and the internal SD card is enabled, then
// fatInitDefault gets stuck in sdmmc_ReadSectors - because the fifoWaitValue32Async will never return // fatInitDefault gets stuck in sdmmc_ReadSectors - because the fifoWaitValue32Async will never return
@ -241,17 +241,23 @@ static void InitFilesystem(void) {
// and then giving up if it takes too long.. not the most elegant solution, but it does work // and then giving up if it takes too long.. not the most elegant solution, but it does work
if (thread == -1) { if (thread == -1) {
LoadFatFilesystem(NULL); LoadFatFilesystem(NULL);
} else { return;
}
for (int i = 0; i < 100; i++) for (int i = 0; i < 100; i++)
{ {
cothread_yield(); cothread_yield();
if (cothread_has_joined(thread)) break; if (cothread_has_joined(thread)) break;
swiDelay(2000); swiDelay(20000);
}
} }
Platform_LogConst("Gave up after 100 tries");
}
static void InitFilesystem(void) {
MountFilesystem();
char* dir = fatGetDefaultCwd(); char* dir = fatGetDefaultCwd();
if (dir) { if (dir) {
Platform_Log1("CWD: %c", dir); Platform_Log1("CWD: %c", dir);
root_path.buffer = dir; root_path.buffer = dir;