From 4274a3018f6cc161cbedc26558d1c774113c126a Mon Sep 17 00:00:00 2001 From: Sorgelig Date: Thu, 16 Dec 2021 04:31:00 +0800 Subject: [PATCH] OSD: support for options SC and FSC. --- menu.cpp | 38 +++++++++++++++++------ menu.h | 1 + user_io.cpp | 88 +++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 92 insertions(+), 35 deletions(-) diff --git a/menu.cpp b/menu.cpp index 2489c29..20b7e70 100644 --- a/menu.cpp +++ b/menu.cpp @@ -302,6 +302,11 @@ void StoreIdx_F(int idx, char *path) strcpy(Selected_F[idx], path); } +void StoreIdx_S(int idx, char *path) +{ + strcpy(Selected_S[idx], path); +} + static char selPath[1024] = {}; static int changeDir(char *dir) @@ -1954,12 +1959,13 @@ void HandleUI(void) ioctl_index = menusub + 1; int idx = 1; - if (p[1] == 'S') + if (p[idx] == 'S') { opensave = 1; idx++; } - else if (p[1] == 'C') + + if (p[idx] == 'C') { store_name = 1; idx++; @@ -1991,8 +1997,17 @@ void HandleUI(void) } else if (p[0] == 'S' && (select || recent)) { + store_name = 0; + int idx = 1; + + if (p[idx] == 'C') + { + store_name = 1; + idx++; + } + ioctl_index = 0; - if ((p[1] >= '0' && p[1] <= '9') || is_x86()) ioctl_index = p[1] - '0'; + if ((p[idx] >= '0' && p[idx] <= '9') || is_x86()) ioctl_index = p[idx] - '0'; substrcpy(ext, p, 1); while (strlen(ext) % 3) strcat(ext, " "); @@ -2006,12 +2021,10 @@ void HandleUI(void) if (is_pce() || is_megacd() || is_x86()) { - //if (!strncasecmp(fs_pFileExt, "CUE", 3)) - //{ - //look for CHD too - strcat(fs_pFileExt, "CHD"); - strcat(ext, "CHD"); - //} + //look for CHD too + strcat(fs_pFileExt, "CHD"); + strcat(ext, "CHD"); + int num = ScanDirectory(Selected_tmp, SCANF_INIT, fs_pFileExt, 0); memcpy(Selected_tmp, Selected_S[(int)ioctl_index], sizeof(Selected_tmp)); @@ -2200,6 +2213,13 @@ void HandleUI(void) case MENU_GENERIC_IMAGE_SELECTED: { + if (store_name) + { + char str[64]; + sprintf(str, "%s.s%d", user_io_get_core_name(), ioctl_index); + FileSaveConfig(str, selPath, sizeof(selPath)); + } + menustate = MENU_GENERIC_MAIN1; if (selPath[0] && !is_x86()) MenuHide(); diff --git a/menu.h b/menu.h index 2672cec..5dc47ba 100644 --- a/menu.h +++ b/menu.h @@ -27,5 +27,6 @@ int menu_lightgun_cb(int idx, uint16_t type, uint16_t code, int value); int menu_allow_cfg_switch(); void StoreIdx_F(int idx, char *path); +void StoreIdx_S(int idx, char *path); #endif diff --git a/user_io.cpp b/user_io.cpp index b0cab73..18e2df8 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -622,27 +622,73 @@ static void parse_config() use_cheats = 1; } - if (p[0] == 'F' && p[1] == 'C') + if (p[0] == 'F') { - static char str[1024]; - uint32_t load_addr = 0; - if (substrcpy(str, p, 3)) + int opensave = 0; + int idx = 1; + if (p[idx] == 'S') { - load_addr = strtoul(str, NULL, 16); - if (load_addr < 0x20000000 || load_addr >= 0x40000000) - { - printf("Loading address 0x%X is outside the supported range! Using normal load.\n", load_addr); - load_addr = 0; - } + opensave = 1; + idx++; } - sprintf(str, "%s.f%c", user_io_get_core_name(), p[2]); + if (p[idx] == 'C') + { + idx++; + static char str[1024]; + uint32_t load_addr = 0; + if (substrcpy(str, p, 3)) + { + load_addr = strtoul(str, NULL, 16); + if (load_addr < 0x20000000 || load_addr >= 0x40000000) + { + printf("Loading address 0x%X is outside the supported range! Using normal load.\n", load_addr); + load_addr = 0; + } + } + + sprintf(str, "%s.f%c", user_io_get_core_name(), p[idx]); + if (FileLoadConfig(str, str, sizeof(str)) && str[0]) + { + + idx = p[idx] - '0'; + StoreIdx_F(idx, str); + user_io_file_tx(str, idx, opensave, 0, 0, load_addr); + } + } + } + + if (p[0] == 'S' && p[1] == 'C') + { + static char str[1024]; + sprintf(str, "%s.s%c", user_io_get_core_name(), p[2]); + + static char ext[256]; + substrcpy(ext, p, 1); + while (strlen(ext) % 3) strcat(ext, " "); + if (FileLoadConfig(str, str, sizeof(str)) && str[0]) { - int idx = p[2] - '0'; - StoreIdx_F(idx, str); - user_io_file_tx(str, idx, 0, 0, 0, load_addr); + StoreIdx_S(idx, str); + if (is_x86()) + { + x86_set_image(idx, str); + } + else if (is_megacd()) + { + mcd_set_image(idx, str); + } + else if (is_pce()) + { + pcecd_set_image(idx, str); + cheats_init(str, 0); + } + else + { + user_io_set_index(user_io_ext_idx(str, ext) << 6 | idx); + user_io_file_mount(str, idx); + } } } } @@ -1621,19 +1667,9 @@ int user_io_file_mount(const char *name, unsigned char index, char pre) int ret = 0; int len = strlen(name); - if (index && is_psx()) + if ((index == 1) && is_psx() && len) { - if (len) - { - static char buf[1024]; - FileGenerateSavePath(name, buf); - user_io_file_mount(buf, 0, 1); - process_ss(name); - } - else - { - FileClose(&sd_image[0]); - } + process_ss(name); } sd_image_cangrow[index] = (pre != 0);