nyx: Move emummc cfg load function

This commit is contained in:
CTCaer 2020-04-27 09:18:31 +03:00
parent f35c18a0c2
commit 3fa537e54a
3 changed files with 42 additions and 41 deletions

View file

@ -47,6 +47,36 @@ extern hekate_config h_cfg;
extern bool sd_mount();
extern void sd_unmount(bool deinit);
void load_emummc_cfg(emummc_cfg_t *emu_info)
{
memset(emu_info, 0, sizeof(emummc_cfg_t));
// Parse emuMMC configuration.
LIST_INIT(ini_sections);
if (ini_parse(&ini_sections, "emuMMC/emummc.ini", false))
{
LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, &ini_sections, link)
{
if (!strcmp(ini_sec->name, "emummc"))
{
LIST_FOREACH_ENTRY(ini_kv_t, kv, &ini_sec->kvs, link)
{
if (!strcmp("enabled", kv->key))
emu_info->enabled = atoi(kv->val);
else if (!strcmp("sector", kv->key))
emu_info->sector = strtol(kv->val, NULL, 16);
else if (!strcmp("id", kv->key))
emu_info->id = strtol(kv->val, NULL, 16);
else if (!strcmp("path", kv->key))
emu_info->path = kv->val;
else if (!strcmp("nintendo_path", kv->key))
emu_info->nintendo_path = kv->val;
}
}
}
}
}
void save_emummc_cfg(u32 part_idx, u32 sector_start, const char *path)
{
sd_mount();

View file

@ -20,6 +20,16 @@
#include "gui.h"
typedef struct _emummc_cfg_t
{
int enabled;
u32 sector;
u16 id;
char *path;
char *nintendo_path;
} emummc_cfg_t;
void load_emummc_cfg(emummc_cfg_t *emu_info);
void save_emummc_cfg(u32 part_idx, u32 sector_start, const char *path);
void dump_emummc_file(emmc_tool_gui_t *gui);
void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start);

View file

@ -1025,49 +1025,10 @@ lv_res_t create_win_emummc_tools(lv_obj_t *btn)
emummc_tools = (void *)create_win_emummc_tools;
typedef struct _emummc_cfg_t
{
int enabled;
u32 sector;
u16 id;
char *path;
char *nintendo_path;
} emummc_cfg_t;
emummc_cfg_t emu_info;
sd_mount();
emu_info.enabled = 0;
emu_info.sector = 0;
emu_info.id = 0;
emu_info.path = NULL;
emu_info.nintendo_path = NULL;
// Parse emuMMC configuration.
LIST_INIT(ini_sections);
if (ini_parse(&ini_sections, "emuMMC/emummc.ini", false))
{
LIST_FOREACH_ENTRY(ini_sec_t, ini_sec, &ini_sections, link)
{
if (!strcmp(ini_sec->name, "emummc"))
{
LIST_FOREACH_ENTRY(ini_kv_t, kv, &ini_sec->kvs, link)
{
if (!strcmp("enabled", kv->key))
emu_info.enabled = atoi(kv->val);
else if (!strcmp("sector", kv->key))
emu_info.sector = strtol(kv->val, NULL, 16);
else if (!strcmp("id", kv->key))
emu_info.id = strtol(kv->val, NULL, 16);
else if (!strcmp("path", kv->key))
emu_info.path = kv->val;
else if (!strcmp("nintendo_path", kv->key))
emu_info.nintendo_path = kv->val;
}
}
}
}
emummc_cfg_t emu_info;
load_emummc_cfg(&emu_info);
sd_unmount(false);