Merge 89ea45016c
into 678cbd9ae3
This commit is contained in:
commit
460dfe79ce
|
@ -159,6 +159,9 @@ Options for advanced users. No pun intended.
|
|||
* `11`, `13`: Flash 1m
|
||||
* `14`: SRAM 256k
|
||||
* `15`: None
|
||||
|
||||
`bool mgbaSaveCompat` - Look for and place romName.sav and romName.ini in the ROM directory for compatibility with mGBA save behavior.
|
||||
* Default: `false`
|
||||
|
||||
## Patches
|
||||
open_agb_firm supports automatically applying IPS and UPS patches. To use a patch, rename the patch file to match the ROM file name (without the extension).
|
||||
|
|
|
@ -52,6 +52,7 @@ typedef struct
|
|||
// [advanced]
|
||||
bool saveOverride;
|
||||
u16 defaultSave;
|
||||
bool mgbaSaveCompat;
|
||||
} OafConfig;
|
||||
//static_assert(sizeof(OafConfig) == 76, "nope");
|
||||
|
||||
|
|
|
@ -43,7 +43,8 @@
|
|||
"volume=127\n\n" \
|
||||
"[advanced]\n" \
|
||||
"saveOverride=false\n" \
|
||||
"defaultSave=14"
|
||||
"defaultSave=14\n" \
|
||||
"mgbaSaveCompat=false"
|
||||
|
||||
|
||||
|
||||
|
@ -142,6 +143,8 @@ static int cfgIniCallback(void* user, const char* section, const char* name, con
|
|||
config->saveOverride = (strcmp(value, "false") == 0 ? false : true);
|
||||
if(strcmp(name, "defaultSave") == 0)
|
||||
config->defaultSave = (u16)strtoul(value, NULL, 10);
|
||||
if(strcmp(name, "mgbaSaveCompat") == 0)
|
||||
config->mgbaSaveCompat = (strcmp(value, "false") == 0 ? false : true);
|
||||
}
|
||||
else return 0; // Error.
|
||||
|
||||
|
|
|
@ -89,7 +89,8 @@ static OafConfig g_oafConfig =
|
|||
|
||||
// [advanced]
|
||||
false, // saveOverride
|
||||
14 // defaultSave
|
||||
14, // defaultSave
|
||||
false, // mgbaSaveCompat
|
||||
};
|
||||
static KHandle g_frameReadyEvent = 0;
|
||||
|
||||
|
@ -362,6 +363,27 @@ static Result showFileBrowser(char romAndSavePath[512])
|
|||
return res;
|
||||
}
|
||||
|
||||
static int getBasePathEnd(char path[512])
|
||||
{
|
||||
// Returns the index of the final "/"
|
||||
// Returns -1 on error or not found.
|
||||
int retval = -1;
|
||||
for (int i = 0; i < 512; i++)
|
||||
{
|
||||
char curChar = path[i];
|
||||
if (curChar == '\0')
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (curChar == '/')
|
||||
{
|
||||
retval = i;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void rom2GameCfgPath(char romPath[512])
|
||||
{
|
||||
// Extract the file name and change the extension.
|
||||
|
@ -370,11 +392,31 @@ static void rom2GameCfgPath(char romPath[512])
|
|||
safeStrcpy(tmpIniFileName, strrchr(romPath, '/') + 1, 256 - 2);
|
||||
strcpy(tmpIniFileName + strlen(tmpIniFileName) - 4, ".ini");
|
||||
|
||||
// Support swapping ini/save to be in rom directory
|
||||
char newSaveDir[512];
|
||||
strcpy(newSaveDir, OAF_SAVE_DIR "/");
|
||||
|
||||
if (g_oafConfig.mgbaSaveCompat)
|
||||
{
|
||||
// Get rom basepath end
|
||||
int baseEndIdx = getBasePathEnd(romPath);
|
||||
|
||||
// Safety check, baseEndIdx < 511 and > 0
|
||||
// On error or OoB, it will revert to original behavior
|
||||
if (baseEndIdx < 511 && baseEndIdx > 0)
|
||||
{
|
||||
// Replace the character after the trailing slash with null term
|
||||
safeStrcpy(newSaveDir, romPath, 512);
|
||||
newSaveDir[baseEndIdx + 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
// Construct the new path.
|
||||
strcpy(romPath, OAF_SAVE_DIR "/");
|
||||
strcpy(romPath, newSaveDir);
|
||||
strcat(romPath, tmpIniFileName);
|
||||
}
|
||||
|
||||
|
||||
static void gameCfg2SavePath(char cfgPath[512], const u8 saveSlot)
|
||||
{
|
||||
if(saveSlot > 9)
|
||||
|
|
Loading…
Reference in New Issue