Skip to content

Commit

Permalink
Add an option to use current rom directory for config and saves
Browse files Browse the repository at this point in the history
  • Loading branch information
Exagone313 authored and profi200 committed Oct 28, 2024
1 parent 7a7190b commit 877f7c6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ General settings.
`bool useGbaDb` - Use `gba_db.bin` to get save types
* Default: `true`

`bool useSavesFolder` - Use `/3ds/open_agb_firm/saves` for save files instead of the ROM directory
* Default: `true`

### Video
Video-related settings.

Expand Down
1 change: 1 addition & 0 deletions include/arm11/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ typedef struct
u8 backlightSteps;
bool directBoot;
bool useGbaDb;
bool useSavesFolder;

// [video]
u8 scaler; // 0 = 1:1, 1 = bilinear (GPU) x1.5, 2 = matrix (hardware) x1.5.
Expand Down
6 changes: 5 additions & 1 deletion source/arm11/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"backlight=64\n" \
"backlightSteps=5\n" \
"directBoot=false\n" \
"useGbaDb=true\n\n" \
"useGbaDb=true\n" \
"useSavesFolder=true\n\n" \
"[video]\n" \
"scaler=2\n" \
"gbaGamma=2.2\n" \
Expand All @@ -55,6 +56,7 @@ OafConfig g_oafConfig =
5, // backlightSteps
false, // directBoot
true, // useGbaDb
true, // useSavesFolder

// [video]
2, // scaler
Expand Down Expand Up @@ -143,6 +145,8 @@ static int cfgIniCallback(void* user, const char* section, const char* name, con
config->directBoot = (strcmp(value, "false") == 0 ? false : true);
else if(strcmp(name, "useGbaDb") == 0)
config->useGbaDb = (strcmp(value, "true") == 0 ? true : false);
else if(strcmp(name, "useSavesFolder") == 0)
config->useSavesFolder = (strcmp(value, "true") == 0 ? true : false);
}
else if(strcmp(section, "video") == 0)
{
Expand Down
26 changes: 17 additions & 9 deletions source/arm11/open_agb_firm.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,23 @@ static Result showFileBrowser(char romAndSavePath[512])

static void rom2GameCfgPath(char romPath[512])
{
// Extract the file name and change the extension.
// For cfg2SavePath() we need to reserve 2 extra bytes/chars.
char tmpIniFileName[256];
safeStrcpy(tmpIniFileName, strrchr(romPath, '/') + 1, 256 - 2);
strcpy(tmpIniFileName + strlen(tmpIniFileName) - 4, ".ini");

// Construct the new path.
strcpy(romPath, OAF_SAVE_DIR "/");
strcat(romPath, tmpIniFileName);
if (g_oafConfig.useSavesFolder)
{
// Extract the file name and change the extension.
// For cfg2SavePath() we need to reserve 2 extra bytes/chars.
char tmpIniFileName[256];
safeStrcpy(tmpIniFileName, strrchr(romPath, '/') + 1, 256 - 2);
strcpy(tmpIniFileName + strlen(tmpIniFileName) - 4, ".ini");

// Construct the new path.
strcpy(romPath, OAF_SAVE_DIR "/");
strcat(romPath, tmpIniFileName);
}
else
{
// Change the extension to .ini.
strcpy(romPath + strlen(romPath) - 4, ".ini");
}
}

static void gameCfg2SavePath(char cfgPath[512], const u8 saveSlot)
Expand Down

0 comments on commit 877f7c6

Please sign in to comment.