mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 15:40:44 +00:00
Add documentation
This commit is contained in:
parent
0570b4d11d
commit
1d689f69b8
62
content.c
62
content.c
@ -41,6 +41,14 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* patch_content:
|
||||
* @buf : buffer of the content file.
|
||||
* @size : size of the content file.
|
||||
*
|
||||
* Apply patch to the content file in-memory.
|
||||
*
|
||||
**/
|
||||
static void patch_content(uint8_t **buf, ssize_t *size)
|
||||
{
|
||||
size_t target_size;
|
||||
@ -137,6 +145,17 @@ error:
|
||||
free(patch_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* read_content_file:
|
||||
* @path : buffer of the content file.
|
||||
* @buf : size of the content file.
|
||||
*
|
||||
* Read the content file into memory. Also performs soft patching
|
||||
* (see patch_content function) in case soft patching has not been
|
||||
* blocked by the enduser.
|
||||
*
|
||||
* Returns: size of the content file that has been read from.
|
||||
**/
|
||||
static ssize_t read_content_file(const char *path, void **buf)
|
||||
{
|
||||
uint8_t *ret_buf = NULL;
|
||||
@ -195,16 +214,29 @@ error:
|
||||
RARCH_WARN("Failed ... Cannot recover save file.\n");
|
||||
}
|
||||
|
||||
struct sram_block
|
||||
{
|
||||
unsigned type;
|
||||
void *data;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
/**
|
||||
* save_state:
|
||||
* @path - path that saved state shall be written to.
|
||||
*
|
||||
* Save a state from memory to disk.
|
||||
*
|
||||
* Returns: true if successful, false otherwise.
|
||||
**/
|
||||
bool save_state(const char *path)
|
||||
{
|
||||
bool ret = false;
|
||||
size_t size;
|
||||
void *data = NULL;
|
||||
size_t size = pretro_serialize_size();
|
||||
|
||||
RARCH_LOG("Saving state: \"%s\".\n", path);
|
||||
|
||||
size = pretro_serialize_size();
|
||||
|
||||
if (size == 0)
|
||||
return false;
|
||||
|
||||
@ -230,13 +262,14 @@ bool save_state(const char *path)
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct sram_block
|
||||
{
|
||||
unsigned type;
|
||||
void *data;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
/**
|
||||
* load_state:
|
||||
* @path - path that state will be loaded from.
|
||||
*
|
||||
* Load a state from disk to memory.
|
||||
*
|
||||
* Returns: true if successful, false otherwise.
|
||||
**/
|
||||
bool load_state(const char *path)
|
||||
{
|
||||
unsigned i;
|
||||
@ -354,6 +387,15 @@ void save_ram_file(const char *path, int type)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* load_content:
|
||||
* @special : subsystem of content to be loaded. Can be NULL.
|
||||
* content :
|
||||
*
|
||||
* Load content file (for libretro core).
|
||||
*
|
||||
* Returns : true if successful, otherwise false.
|
||||
**/
|
||||
static bool load_content(const struct retro_subsystem_info *special,
|
||||
const struct string_list *content)
|
||||
{
|
||||
|
@ -41,9 +41,7 @@ static void core_info_list_resolve_all_extensions(
|
||||
}
|
||||
|
||||
if (all_ext_len)
|
||||
{
|
||||
core_info_list->all_ext = (char*)calloc(1, all_ext_len);
|
||||
}
|
||||
|
||||
if (core_info_list->all_ext)
|
||||
{
|
||||
@ -360,9 +358,9 @@ bool core_info_does_support_file(const core_info_t *core, const char *path)
|
||||
|
||||
const char *core_info_list_get_all_extensions(core_info_list_t *core_info_list)
|
||||
{
|
||||
if (core_info_list)
|
||||
return core_info_list->all_ext;
|
||||
return "";
|
||||
if (!core_info_list)
|
||||
return "";
|
||||
return core_info_list->all_ext;
|
||||
}
|
||||
|
||||
/* qsort_r() is not in standard C, sadly. */
|
||||
|
@ -78,12 +78,18 @@ void core_option_get(core_option_manager_t *opt, struct retro_variable *var)
|
||||
static bool parse_variable(core_option_manager_t *opt, size_t idx,
|
||||
const struct retro_variable *var)
|
||||
{
|
||||
char *value, *desc_end, *config_val = NULL;
|
||||
const char *val_start;
|
||||
size_t i;
|
||||
struct core_option *option = (struct core_option*)&opt->opts[idx];
|
||||
|
||||
if (!option)
|
||||
return false;
|
||||
|
||||
option->key = strdup(var->key);
|
||||
|
||||
char *value = strdup(var->value);
|
||||
char *desc_end = strstr(value, "; ");
|
||||
value = strdup(var->value);
|
||||
desc_end = strstr(value, "; ");
|
||||
|
||||
if (!desc_end)
|
||||
{
|
||||
@ -94,7 +100,7 @@ static bool parse_variable(core_option_manager_t *opt, size_t idx,
|
||||
*desc_end = '\0';
|
||||
option->desc = strdup(value);
|
||||
|
||||
const char *val_start = desc_end + 2;
|
||||
val_start = desc_end + 2;
|
||||
option->vals = string_split(val_start, "|");
|
||||
|
||||
if (!option->vals)
|
||||
@ -103,7 +109,6 @@ static bool parse_variable(core_option_manager_t *opt, size_t idx,
|
||||
return false;
|
||||
}
|
||||
|
||||
char *config_val = NULL;
|
||||
if (config_get_string(opt->conf, option->key, &config_val))
|
||||
{
|
||||
for (i = 0; i < option->vals->size; i++)
|
||||
@ -127,13 +132,12 @@ core_option_manager_t *core_option_new(const char *conf_path,
|
||||
const struct retro_variable *vars)
|
||||
{
|
||||
const struct retro_variable *var;
|
||||
size_t size = 0;
|
||||
core_option_manager_t *opt = (core_option_manager_t*)
|
||||
calloc(1, sizeof(*opt));
|
||||
if (!opt)
|
||||
return NULL;
|
||||
|
||||
size_t size = 0;
|
||||
|
||||
if (*conf_path)
|
||||
opt->conf = config_file_new(conf_path);
|
||||
if (!opt->conf)
|
||||
@ -180,39 +184,40 @@ void core_option_flush(core_option_manager_t *opt)
|
||||
for (i = 0; i < opt->size; i++)
|
||||
{
|
||||
struct core_option *option = (struct core_option*)&opt->opts[i];
|
||||
config_set_string(opt->conf, option->key, core_option_get_val(opt, i));
|
||||
if (option)
|
||||
config_set_string(opt->conf, option->key, core_option_get_val(opt, i));
|
||||
}
|
||||
config_file_write(opt->conf, opt->conf_path);
|
||||
}
|
||||
|
||||
size_t core_option_size(core_option_manager_t *opt)
|
||||
{
|
||||
if (opt)
|
||||
return opt->size;
|
||||
return 0;
|
||||
if (!opt)
|
||||
return 0;
|
||||
return opt->size;
|
||||
}
|
||||
|
||||
const char *core_option_get_desc(core_option_manager_t *opt, size_t idx)
|
||||
{
|
||||
if (opt)
|
||||
return opt->opts[idx].desc;
|
||||
return NULL;
|
||||
if (!opt)
|
||||
return NULL;
|
||||
return opt->opts[idx].desc;
|
||||
}
|
||||
|
||||
const char *core_option_get_val(core_option_manager_t *opt, size_t idx)
|
||||
{
|
||||
struct core_option *option = (struct core_option*)&opt->opts[idx];
|
||||
if (option)
|
||||
return option->vals->elems[option->index].data;
|
||||
return NULL;
|
||||
if (!option)
|
||||
return NULL;
|
||||
return option->vals->elems[option->index].data;
|
||||
}
|
||||
|
||||
struct string_list *core_option_get_vals(
|
||||
core_option_manager_t *opt, size_t idx)
|
||||
{
|
||||
if (opt)
|
||||
return opt->opts[idx].vals;
|
||||
return NULL;
|
||||
if (!opt)
|
||||
return NULL;
|
||||
return opt->opts[idx].vals;
|
||||
}
|
||||
|
||||
void core_option_set_val(core_option_manager_t *opt,
|
||||
@ -227,6 +232,13 @@ void core_option_set_val(core_option_manager_t *opt,
|
||||
opt->updated = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* core_option_prev:
|
||||
* @opt : pointer to core option manager object.
|
||||
* @idx : index of core option to be reset to defaults.
|
||||
*
|
||||
* Get next value for core option specified by @idx.
|
||||
**/
|
||||
void core_option_next(core_option_manager_t *opt, size_t idx)
|
||||
{
|
||||
struct core_option *option = (struct core_option*)&opt->opts[idx];
|
||||
@ -238,6 +250,13 @@ void core_option_next(core_option_manager_t *opt, size_t idx)
|
||||
opt->updated = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* core_option_prev:
|
||||
* @opt : pointer to core option manager object.
|
||||
* @idx : index of core option to be reset to defaults.
|
||||
*
|
||||
* Get previous value for core option specified by @idx.
|
||||
**/
|
||||
void core_option_prev(core_option_manager_t *opt, size_t idx)
|
||||
{
|
||||
struct core_option *option = (struct core_option*)&opt->opts[idx];
|
||||
@ -250,6 +269,13 @@ void core_option_prev(core_option_manager_t *opt, size_t idx)
|
||||
opt->updated = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* core_option_set_default:
|
||||
* @opt : pointer to core option manager object.
|
||||
* @idx : index of core option to be reset to defaults.
|
||||
*
|
||||
* Reset core option specified by @idx to be reset to default settings.
|
||||
**/
|
||||
void core_option_set_default(core_option_manager_t *opt, size_t idx)
|
||||
{
|
||||
if (!opt)
|
||||
@ -258,5 +284,3 @@ void core_option_set_default(core_option_manager_t *opt, size_t idx)
|
||||
opt->opts[idx].index = 0;
|
||||
opt->updated = true;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user