Do not initialize the screens in the very common case where the user has only one payload, etc.

This commit is contained in:
TuxSH 2021-01-26 13:38:06 +00:00
parent be6d64260c
commit b5b5db6e8c
3 changed files with 10 additions and 5 deletions

View File

@ -238,7 +238,8 @@ u32 loadNintendoFirm(FirmwareType *firmType, FirmwareSource nandType, bool loadF
void loadHomebrewFirm(u32 pressed) void loadHomebrewFirm(u32 pressed)
{ {
char path[10 + 255]; char path[10 + 255];
bool found = !pressed ? payloadMenu(path) : findPayload(path, pressed); bool hasDisplayedMenu = false;
bool found = !pressed ? payloadMenu(path, &hasDisplayedMenu) : findPayload(path, pressed);
if(!found) return; if(!found) return;
@ -253,10 +254,12 @@ void loadHomebrewFirm(u32 pressed)
else sprintf(absPath, "nand:/rw/luma/%s", path); else sprintf(absPath, "nand:/rw/luma/%s", path);
char *argv[2] = {absPath, (char *)fbs}; char *argv[2] = {absPath, (char *)fbs};
bool wantsScreenInit = (firm->reserved2[0] & 1) != 0;
initScreens(); if(!hasDisplayedMenu && wantsScreenInit)
initScreens(); // Don't init the screens unless we have to, if not already done
launchFirm((firm->reserved2[0] & 1) ? 2 : 1, argv); launchFirm(wantsScreenInit ? 2 : 1, argv);
} }
static inline void mergeSection0(FirmwareType firmType, u32 firmVersion, bool loadFromStorage) static inline void mergeSection0(FirmwareType firmType, u32 firmVersion, bool loadFromStorage)

View File

@ -154,10 +154,11 @@ bool findPayload(char *path, u32 pressed)
return true; return true;
} }
bool payloadMenu(char *path) bool payloadMenu(char *path, bool *hasDisplayedMenu)
{ {
DIR dir; DIR dir;
*hasDisplayedMenu = false;
if(f_opendir(&dir, "payloads") != FR_OK) return false; if(f_opendir(&dir, "payloads") != FR_OK) return false;
FILINFO info; FILINFO info;
@ -189,6 +190,7 @@ bool payloadMenu(char *path)
if(payloadNum != 1) if(payloadNum != 1)
{ {
initScreens(); initScreens();
*hasDisplayedMenu = true;
drawString(true, 10, 10, COLOR_TITLE, "Luma3DS chainloader"); drawString(true, 10, 10, COLOR_TITLE, "Luma3DS chainloader");
drawString(true, 10, 10 + SPACING_Y, COLOR_TITLE, "Press A to select, START to quit"); drawString(true, 10, 10 + SPACING_Y, COLOR_TITLE, "Press A to select, START to quit");

View File

@ -36,6 +36,6 @@ u32 getFileSize(const char *path);
bool fileWrite(const void *buffer, const char *path, u32 size); bool fileWrite(const void *buffer, const char *path, u32 size);
bool fileDelete(const char *path); bool fileDelete(const char *path);
bool findPayload(char *path, u32 pressed); bool findPayload(char *path, u32 pressed);
bool payloadMenu(char *path); bool payloadMenu(char *path, bool *hasDisplayedMenu);
u32 firmRead(void *dest, u32 firmType); u32 firmRead(void *dest, u32 firmType);
void findDumpFile(const char *folderPath, char *fileName); void findDumpFile(const char *folderPath, char *fileName);