From b5ea246ffe003dc0e15bb32e751f3f5292d7ff9f Mon Sep 17 00:00:00 2001 From: Sorgelig Date: Wed, 8 Mar 2023 01:57:51 +0800 Subject: [PATCH] Add v option to CONF_STR. --- menu.cpp | 4 ++-- user_io.cpp | 25 +++++++++++++++++++------ user_io.h | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/menu.cpp b/menu.cpp index 0c4f6a4..0714204 100644 --- a/menu.cpp +++ b/menu.cpp @@ -2548,7 +2548,7 @@ void HandleUI(void) } else { - char *filename = user_io_create_config_name(); + char *filename = user_io_create_config_name(1); printf("Saving config to %s\n", filename); user_io_status_save(filename); if (is_x86() || is_pcxt()) x86_config_save(); @@ -5122,7 +5122,7 @@ void HandleUI(void) else { user_io_status_reset(); - char *filename = user_io_create_config_name(); + char *filename = user_io_create_config_name(1); printf("Saving config to %s\n", filename); user_io_status_save(filename); menustate = MENU_GENERIC_MAIN1; diff --git a/user_io.cpp b/user_io.cpp index fa582b2..3da0efa 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -115,7 +115,9 @@ unsigned char user_io_core_type() return core_type; } -char* user_io_create_config_name() +static char config_ver[10] = {}; + +char* user_io_create_config_name(int with_ver) { static char str[40]; str[0] = 0; @@ -123,6 +125,7 @@ char* user_io_create_config_name() if (p[0]) { strcpy(str, p); + if (with_ver) strcat(str, config_ver); strcat(str, ".CFG"); } return str; @@ -791,6 +794,15 @@ static void parse_config() OsdCoreNameSet(s); } + if (p[0] == 'v') + { + static char str[256]; + substrcpy(str, p, 1); + str[2] = 0; + int v = strtoul(str, 0, 10); + if(v) snprintf(config_ver, sizeof(config_ver), "_v%d", v); + } + if (p[0] == 'C') { use_cheats = 1; @@ -1363,7 +1375,7 @@ void user_io_init(const char *path, const char *xml) case CORE_TYPE_8BIT: // try to load config - name = user_io_create_config_name(); + name = user_io_create_config_name(1); if (strlen(name) > 0) { if (!is_st() && !is_minimig()) @@ -1383,6 +1395,7 @@ void user_io_init(const char *path, const char *xml) user_io_status_set("[0]", 1); } + name = user_io_create_config_name(); if (is_st()) { tos_config_load(0); @@ -1951,9 +1964,9 @@ int user_io_file_mount(const char *name, unsigned char index, char pre, int pre_ writable = FileCanWrite(name); ret = FileOpenEx(&sd_image[index], name, writable ? (O_RDWR | O_SYNC) : O_RDONLY); if (ret && len > 4) { - if (!strcasecmp(name + len - 4, ".d64") - || !strcasecmp(name + len - 4, ".g64") - || !strcasecmp(name + len - 4, ".d71") + if (!strcasecmp(name + len - 4, ".d64") + || !strcasecmp(name + len - 4, ".g64") + || !strcasecmp(name + len - 4, ".d71") || !strcasecmp(name + len - 4, ".g71")) { img_type = c64_openGCR(name, sd_image + index, index); @@ -1967,7 +1980,7 @@ int user_io_file_mount(const char *name, unsigned char index, char pre, int pre_ } } - if (ret && is_c128()) + if (ret && is_c128()) { printf("Disk image type: %d\n", img_type); user_io_set_aindex(img_type << 6 | index); diff --git a/user_io.h b/user_io.h index eb6f971..8f370a5 100644 --- a/user_io.h +++ b/user_io.h @@ -198,7 +198,7 @@ uint32_t user_io_get_uart_mode(); void user_io_mouse(unsigned char b, int16_t x, int16_t y, int16_t w); void user_io_kbd(uint16_t key, int press); -char* user_io_create_config_name(); +char* user_io_create_config_name(int with_ver = 0); int user_io_get_joy_transl(); void user_io_digital_joystick(unsigned char, uint32_t, int); void user_io_l_analog_joystick(unsigned char, char, char);