From 3fa537e54af6623c715913b125d272022ae28cc3 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Mon, 27 Apr 2020 09:18:31 +0300 Subject: [PATCH] nyx: Move emummc cfg load function --- nyx/nyx_gui/frontend/fe_emummc_tools.c | 30 +++++++++++++++++ nyx/nyx_gui/frontend/fe_emummc_tools.h | 10 ++++++ nyx/nyx_gui/frontend/gui_emummc_tools.c | 43 ++----------------------- 3 files changed, 42 insertions(+), 41 deletions(-) diff --git a/nyx/nyx_gui/frontend/fe_emummc_tools.c b/nyx/nyx_gui/frontend/fe_emummc_tools.c index 8fb19aa..9d6a65e 100644 --- a/nyx/nyx_gui/frontend/fe_emummc_tools.c +++ b/nyx/nyx_gui/frontend/fe_emummc_tools.c @@ -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(); diff --git a/nyx/nyx_gui/frontend/fe_emummc_tools.h b/nyx/nyx_gui/frontend/fe_emummc_tools.h index 1685a42..6faab32 100644 --- a/nyx/nyx_gui/frontend/fe_emummc_tools.h +++ b/nyx/nyx_gui/frontend/fe_emummc_tools.h @@ -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); diff --git a/nyx/nyx_gui/frontend/gui_emummc_tools.c b/nyx/nyx_gui/frontend/gui_emummc_tools.c index 36747f9..a0dd4b0 100644 --- a/nyx/nyx_gui/frontend/gui_emummc_tools.c +++ b/nyx/nyx_gui/frontend/gui_emummc_tools.c @@ -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);