Skip to content

Commit 487c2a0

Browse files
committed
Do not initialize the screens in the very common case where the user has only one payload, etc.
1 parent bd2b012 commit 487c2a0

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

arm9/source/firm.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ u32 loadNintendoFirm(FirmwareType *firmType, FirmwareSource nandType, bool loadF
239239
void loadHomebrewFirm(u32 pressed)
240240
{
241241
char path[10 + 255];
242-
bool found = !pressed ? payloadMenu(path) : findPayload(path, pressed);
242+
bool hasDisplayedMenu = false;
243+
bool found = !pressed ? payloadMenu(path, &hasDisplayedMenu) : findPayload(path, pressed);
243244

244245
if(!found) return;
245246

@@ -254,10 +255,12 @@ void loadHomebrewFirm(u32 pressed)
254255
else sprintf(absPath, "nand:/rw/luma/%s", path);
255256

256257
char *argv[2] = {absPath, (char *)fbs};
258+
bool wantsScreenInit = (firm->reserved2[0] & 1) != 0;
257259

258-
initScreens();
260+
if(!hasDisplayedMenu && wantsScreenInit)
261+
initScreens(); // Don't init the screens unless we have to, if not already done
259262

260-
launchFirm((firm->reserved2[0] & 1) ? 2 : 1, argv);
263+
launchFirm(wantsScreenInit ? 2 : 1, argv);
261264
}
262265

263266
static inline void mergeSection0(FirmwareType firmType, u32 firmVersion, bool loadFromStorage)

arm9/source/fs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,11 @@ bool findPayload(char *path, u32 pressed)
154154
return true;
155155
}
156156

157-
bool payloadMenu(char *path)
157+
bool payloadMenu(char *path, bool *hasDisplayedMenu)
158158
{
159159
DIR dir;
160160

161+
*hasDisplayedMenu = false;
161162
if(f_opendir(&dir, "payloads") != FR_OK) return false;
162163

163164
FILINFO info;
@@ -189,6 +190,7 @@ bool payloadMenu(char *path)
189190
if(payloadNum != 1)
190191
{
191192
initScreens();
193+
*hasDisplayedMenu = true;
192194

193195
drawString(true, 10, 10, COLOR_TITLE, "Luma3DS chainloader");
194196
drawString(true, 10, 10 + SPACING_Y, COLOR_TITLE, "Press A to select, START to quit");

arm9/source/fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ u32 getFileSize(const char *path);
3636
bool fileWrite(const void *buffer, const char *path, u32 size);
3737
bool fileDelete(const char *path);
3838
bool findPayload(char *path, u32 pressed);
39-
bool payloadMenu(char *path);
39+
bool payloadMenu(char *path, bool *hasDisplayedMenu);
4040
u32 firmRead(void *dest, u32 firmType);
4141
void findDumpFile(const char *folderPath, char *fileName);

0 commit comments

Comments
 (0)