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:
profi200 2021-12-18 23:45:51 +01:00
parent d7baad122a
commit 37f3df4a52
No known key found for this signature in database
GPG Key ID: 17B42AE5911139F3
3 changed files with 22 additions and 5 deletions

View File

@ -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]);

View File

@ -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;
}

View File

@ -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;