Added autoboot. Place "autoboot.txt" in "/3ds/open_agb_firm".
Note: The autoboot path must be a single line starting with "sdmc:/".
This commit is contained in:
parent
d7baad122a
commit
37f3df4a52
|
@ -26,3 +26,4 @@
|
|||
Result fsQuickRead(const char *const path, void *const buf, u32 size);
|
||||
Result fsQuickWrite(const char *const path, const void *const buf, u32 size);
|
||||
Result fsMakePath(const char *const path);
|
||||
Result fsLoadPathFromFile(const char *const path, char outPath[512]);
|
||||
|
|
|
@ -87,3 +87,15 @@ Result fsMakePath(const char *const path)
|
|||
|
||||
return res;
|
||||
}
|
||||
|
||||
Result fsLoadPathFromFile(const char *const path, char outPath[512])
|
||||
{
|
||||
Result res = fsQuickRead(path, outPath, 511);
|
||||
if(res == RES_OK)
|
||||
{
|
||||
char *const invalidChar = strpbrk(outPath, "\n\r\t");
|
||||
if(invalidChar != NULL) *invalidChar = '\0';
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -559,7 +559,7 @@ static Result showFileBrowser(char romAndSavePath[512])
|
|||
do
|
||||
{
|
||||
// Get last ROM launch path.
|
||||
if((res = fsQuickRead("lastdir.bin", lastDir, 511)) != RES_OK)
|
||||
if((res = fsLoadPathFromFile("lastdir.txt", lastDir)) != FR_OK)
|
||||
{
|
||||
if(res == RES_FR_NO_FILE) strcpy(lastDir, "sdmc:/");
|
||||
else break;
|
||||
|
@ -583,7 +583,7 @@ static Result showFileBrowser(char romAndSavePath[512])
|
|||
{
|
||||
strncpy(lastDir, romAndSavePath, cmpLen);
|
||||
lastDir[cmpLen] = '\0';
|
||||
res = fsQuickWrite("lastdir.bin", lastDir, cmpLen + 1);
|
||||
res = fsQuickWrite("lastdir.txt", lastDir, cmpLen + 1);
|
||||
}
|
||||
}
|
||||
} while(0);
|
||||
|
@ -618,14 +618,18 @@ u8 oafGetBacklightConfig(void)
|
|||
Result oafInitAndRun(void)
|
||||
{
|
||||
Result res;
|
||||
char *const romAndSavePath = (char*)malloc(512);
|
||||
char *const romAndSavePath = (char*)calloc(512, 1);
|
||||
if(romAndSavePath != NULL)
|
||||
{
|
||||
do
|
||||
{
|
||||
if((res = showFileBrowser(romAndSavePath)) != RES_OK || *romAndSavePath == '\0') break;
|
||||
if((res = fsLoadPathFromFile("autoboot.txt", romAndSavePath)) == RES_FR_NO_FILE)
|
||||
{
|
||||
if((res = showFileBrowser(romAndSavePath)) != RES_OK || *romAndSavePath == '\0') break;
|
||||
ee_puts("Loading...");
|
||||
}
|
||||
else if(res != RES_OK) break;
|
||||
|
||||
ee_puts("Loading...");
|
||||
u32 romSize;
|
||||
if((res = loadGbaRom(romAndSavePath, &romSize)) != RES_OK) break;
|
||||
|
||||
|
|
Loading…
Reference in New Issue