Skip to content

Instantly share code, notes, and snippets.

@gricard
Created March 26, 2023 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gricard/5b175ce738a9878b3d6d2f5be269c02c to your computer and use it in GitHub Desktop.
Save gricard/5b175ce738a9878b3d6d2f5be269c02c to your computer and use it in GitHub Desktop.
open_agb_firm patch for loading save from rom directory
diff --git a/source/arm11/open_agb_firm.c b/source/arm11/open_agb_firm.c
index 9e447bd..31f9bf9 100644
--- a/source/arm11/open_agb_firm.c
+++ b/source/arm11/open_agb_firm.c
@@ -767,21 +767,32 @@ Result oafInitAndRun(void)
rom2GameCfgPath(filePath);
if((res = parseOafConfig(filePath, false)) != RES_OK && res != RES_FR_NO_FILE) break;
+ // use rom path for save path
+ char *const saveFilePath = (char*)calloc(strlen(filePath)+1, 1);
+ if(saveFilePath == NULL) { res = RES_OUT_OF_MEM; break; }
+ strcpy(saveFilePath, romFilePath);
+ debug_printf("romFilePath: %s\n", romFilePath);
+
// Adjust the path for the save file and get save type.
- gameCfg2SavePath(filePath, g_oafConfig.saveSlot);
+ gameCfg2SavePath(saveFilePath, g_oafConfig.saveSlot);
+ debug_printf("saveFilePath: %s\n", saveFilePath);
u16 saveType;
- if(g_oafConfig.saveType != 0xFF)
+ if(g_oafConfig.saveType != 0xFF) {
+ debug_printf("first saveType method\n");
saveType = g_oafConfig.saveType;
- else if(g_oafConfig.useGbaDb || g_oafConfig.saveOverride)
- saveType = getSaveType(romSize, filePath);
- else
- saveType = detectSaveType(romSize);
+ } else if(g_oafConfig.useGbaDb || g_oafConfig.saveOverride) {
+ debug_printf("second saveType method\n");
+ saveType = getSaveType(romSize, saveFilePath);
+ } else {
+ debug_printf("third saveType method\n");
+ saveType = detectSaveType(romSize);
+ }
patchRom(romFilePath, &romSize);
free(romFilePath);
// Prepare ARM9 for GBA mode + save loading.
- if((res = LGY_prepareGbaMode(g_oafConfig.directBoot, saveType, filePath)) == RES_OK)
+ if((res = LGY_prepareGbaMode(g_oafConfig.directBoot, saveType, saveFilePath)) == RES_OK)
{
#ifdef NDEBUG
// Force black and turn the backlight off on the bottom screen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment