Skip to content

Commit

Permalink
Append content-specific config from saves
Browse files Browse the repository at this point in the history
  • Loading branch information
sonninnos committed Feb 22, 2024
1 parent 4e8b54d commit 5f683ae
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ If `puae_libretro_[model].uae` exists in RetroArch `saves` it will be appended t

If `puae_libretro_global.uae` exists in RetroArch `saves` it will be appended to the configuration.

If `[content].uae` exists in RetroArch `saves` it will be appended to the configuration.

The final generated configuration output is available in debug level log.

***Note that the use of configuration files is no longer encouraged or necessary. The core has been modified to always use the core options as a base, so that all custom configurations will be appended to the created configuration, effectively overriding the core options. The problem with this is that changing any core option while the core is running will reset all duplicate configurations. Therefore only add configurations which will require a restart or do not exist in the core options, if you must use a custom uae. If there is an option missing that is a must have, please make an issue about it.***
Expand Down
41 changes: 30 additions & 11 deletions libretro/libretro-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -5814,7 +5814,7 @@ static void retro_config_harddrives(void)
{
/* Detect RDB */
bool hdf_rdb = false;
FILE * hdf_fp;
FILE *hdf_fp;
char filebuf[4];
if ((hdf_fp = fopen(tmp_str, "r")))
{
Expand Down Expand Up @@ -6113,7 +6113,7 @@ static char* emu_config(int config)
{
log_cb(RETRO_LOG_INFO, "Appending model preset: '%s'\n", custom_config_path);

FILE * custom_config_fp;
FILE *custom_config_fp;
char filebuf[RETRO_PATH_MAX];
if ((custom_config_fp = fopen(custom_config_path, "r")))
{
Expand Down Expand Up @@ -7137,7 +7137,7 @@ static bool retro_create_config(void)
dc_reset(dc);

/* Iterate parsed file and append all rows to the temporary config */
FILE * configfile_custom;
FILE *configfile_custom;
char filebuf[RETRO_PATH_MAX];
if ((configfile_custom = fopen(full_path, "r")))
{
Expand Down Expand Up @@ -7276,19 +7276,38 @@ static bool retro_create_config(void)
}

/* Iterate global config file and append all rows to the temporary config */
char configfile_global_path[RETRO_PATH_MAX];
path_join(configfile_global_path, retro_save_directory, LIBRETRO_PUAE_PREFIX "_global.uae");
if (path_is_valid(configfile_global_path))
char configfile_path[RETRO_PATH_MAX];
path_join(configfile_path, retro_save_directory, LIBRETRO_PUAE_PREFIX "_global.uae");
if (path_is_valid(configfile_path))
{
log_cb(RETRO_LOG_INFO, "Appending global configuration: '%s'\n", configfile_global_path);
log_cb(RETRO_LOG_INFO, "Appending global configuration: '%s'\n", configfile_path);

FILE * configfile_global;
FILE *configfile;
char filebuf[RETRO_PATH_MAX];
if ((configfile_global = fopen(configfile_global_path, "r")))
if ((configfile = fopen(configfile_path, "r")))
{
while (fgets(filebuf, sizeof(filebuf), configfile_global))
while (fgets(filebuf, sizeof(filebuf), configfile))
retro_config_append(filebuf);
fclose(configfile_global);
fclose(configfile);
}
}

/* Append content-specific config */
tmp_str = utf8_to_local_string_alloc(full_path);
path_remove_extension(tmp_str);
snprintf(configfile_path, sizeof(configfile_path), "%s%s%s%s",
retro_save_directory, DIR_SEP_STR, path_basename(tmp_str), ".uae");
if (path_is_valid(configfile_path))
{
log_cb(RETRO_LOG_INFO, "Appending content configuration: '%s'\n", configfile_path);

FILE *configfile;
char filebuf[RETRO_PATH_MAX];
if ((configfile = fopen(configfile_path, "r")))
{
while (fgets(filebuf, sizeof(filebuf), configfile))
retro_config_append(filebuf);
fclose(configfile);
}
}

Expand Down

0 comments on commit 5f683ae

Please sign in to comment.