Support original core name and common arcade section in ini.
This commit is contained in:
10
audio.cpp
10
audio.cpp
@@ -198,14 +198,14 @@ void save_volume()
|
||||
FileSaveConfig("Volume.dat", &vol_att, 1);
|
||||
|
||||
static char cfg_name[128];
|
||||
sprintf(cfg_name, "%s_volume.cfg", user_io_get_core_name_ex());
|
||||
sprintf(cfg_name, "%s_volume.cfg", user_io_get_core_name());
|
||||
FileSaveConfig(cfg_name, &corevol_att, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void load_volume()
|
||||
{
|
||||
sprintf(filter_cfg_path, "%s_afilter.cfg", user_io_get_core_name_ex());
|
||||
sprintf(filter_cfg_path, "%s_afilter.cfg", user_io_get_core_name());
|
||||
if (!FileLoadConfig(filter_cfg_path, &filter_cfg, sizeof(filter_cfg) - 1) || filter_cfg[0] > 1)
|
||||
{
|
||||
memset(filter_cfg, 0, sizeof(filter_cfg));
|
||||
@@ -220,7 +220,7 @@ void load_volume()
|
||||
if (!is_menu())
|
||||
{
|
||||
static char cfg_name[128];
|
||||
sprintf(cfg_name, "%s_volume.cfg", user_io_get_core_name_ex());
|
||||
sprintf(cfg_name, "%s_volume.cfg", user_io_get_core_name());
|
||||
FileLoadConfig(cfg_name, &corevol_att, 1);
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ char* audio_get_filter()
|
||||
void audio_set_filter(char *name)
|
||||
{
|
||||
strcpy(filter_cfg + 1, name);
|
||||
sprintf(filter_cfg_path, "%s_afilter.cfg", user_io_get_core_name_ex());
|
||||
sprintf(filter_cfg_path, "%s_afilter.cfg", user_io_get_core_name());
|
||||
FileSaveConfig(filter_cfg_path, &filter_cfg, sizeof(filter_cfg));
|
||||
setFilter();
|
||||
}
|
||||
@@ -252,7 +252,7 @@ void audio_set_filter(char *name)
|
||||
void audio_set_filter_en(int n)
|
||||
{
|
||||
filter_cfg[0] = n ? 1 : 0;
|
||||
sprintf(filter_cfg_path, "%s_afilter.cfg", user_io_get_core_name_ex());
|
||||
sprintf(filter_cfg_path, "%s_afilter.cfg", user_io_get_core_name());
|
||||
FileSaveConfig(filter_cfg_path, &filter_cfg, sizeof(filter_cfg));
|
||||
setFilter();
|
||||
}
|
||||
|
||||
7
cfg.cpp
7
cfg.cpp
@@ -174,7 +174,10 @@ static int ini_get_section(char* buf)
|
||||
else buf[i] = toupper(buf[i]);
|
||||
}
|
||||
|
||||
if (!strcasecmp(buf, "MiSTer") || ((wc_pos >= 0) ? !strncasecmp(buf, user_io_get_core_name_ex(), wc_pos) : !strcasecmp(buf, user_io_get_core_name_ex())))
|
||||
if (!strcasecmp(buf, "MiSTer") ||
|
||||
(is_arcade() && !strcasecmp(buf, "arcade")) ||
|
||||
((wc_pos >= 0) ? !strncasecmp(buf, user_io_get_core_name(1), wc_pos) : !strcasecmp(buf, user_io_get_core_name(1))) ||
|
||||
((wc_pos >= 0) ? !strncasecmp(buf, user_io_get_core_name(0), wc_pos) : !strcasecmp(buf, user_io_get_core_name(0))))
|
||||
{
|
||||
ini_parser_debugf("Got SECTION '%s'", buf);
|
||||
return 1;
|
||||
@@ -271,7 +274,7 @@ static void ini_parse(int alt)
|
||||
int section = INI_SECTION_INVALID_ID;
|
||||
int line_status;
|
||||
|
||||
ini_parser_debugf("Start INI parser for core \"%s\".", user_io_get_core_name_ex());
|
||||
ini_parser_debugf("Start INI parser for core \"%s\"(%s).", user_io_get_core_name(0), user_io_get_core_name(1));
|
||||
|
||||
memset(&ini_file, 0, sizeof(ini_file));
|
||||
|
||||
|
||||
@@ -1134,7 +1134,7 @@ static char *get_map_name(int dev, int def)
|
||||
{
|
||||
static char name[128];
|
||||
if (def || is_menu()) sprintf(name, "input_%s_v3.map", input[dev].idstr);
|
||||
else sprintf(name, "%s_input_%s_v3.map", user_io_get_core_name_ex(), input[dev].idstr);
|
||||
else sprintf(name, "%s_input_%s_v3.map", user_io_get_core_name(), input[dev].idstr);
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -1173,7 +1173,7 @@ void finish_map_setting(int dismiss)
|
||||
void input_lightgun_save(int idx, uint16_t *cal)
|
||||
{
|
||||
static char name[128];
|
||||
sprintf(name, "%s_gun_cal_%04x_%04x.cfg", user_io_get_core_name_ex(), input[idx].vid, input[idx].pid);
|
||||
sprintf(name, "%s_gun_cal_%04x_%04x.cfg", user_io_get_core_name(), input[idx].vid, input[idx].pid);
|
||||
FileSaveConfig(name, cal, 4 * sizeof(uint16_t));
|
||||
memcpy(input[idx].guncal, cal, sizeof(input[idx].guncal));
|
||||
}
|
||||
@@ -1181,7 +1181,7 @@ void input_lightgun_save(int idx, uint16_t *cal)
|
||||
static void input_lightgun_load(int idx)
|
||||
{
|
||||
static char name[128];
|
||||
sprintf(name, "%s_gun_cal_%04x_%04x.cfg", user_io_get_core_name_ex(), input[idx].vid, input[idx].pid);
|
||||
sprintf(name, "%s_gun_cal_%04x_%04x.cfg", user_io_get_core_name(), input[idx].vid, input[idx].pid);
|
||||
FileLoadConfig(name, input[idx].guncal, 4 * sizeof(uint16_t));
|
||||
}
|
||||
|
||||
|
||||
24
menu.cpp
24
menu.cpp
@@ -983,7 +983,6 @@ void HandleUI(void)
|
||||
{
|
||||
case CORE_TYPE_8BIT:
|
||||
case CORE_TYPE_SHARPMZ:
|
||||
case CORE_TYPE_ARCHIE:
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1849,6 +1848,12 @@ void HandleUI(void)
|
||||
// set helptext with core display on top of basic info
|
||||
sprintf(helptext_custom, HELPTEXT_SPACER);
|
||||
strcat(helptext_custom, OsdCoreNameGet());
|
||||
if (is_arcade())
|
||||
{
|
||||
strcat(helptext_custom, " (");
|
||||
strcat(helptext_custom, user_io_get_core_name(1));
|
||||
strcat(helptext_custom, ")");
|
||||
}
|
||||
strcat(helptext_custom, helptexts[HELPTEXT_MAIN]);
|
||||
helptext_idx = HELPTEXT_CUSTOM;
|
||||
|
||||
@@ -2183,7 +2188,7 @@ void HandleUI(void)
|
||||
if (store_name)
|
||||
{
|
||||
char str[64];
|
||||
sprintf(str, "%s.f%d", user_io_get_core_name_ex(), ioctl_index);
|
||||
sprintf(str, "%s.f%d", user_io_get_core_name(), ioctl_index);
|
||||
FileSaveConfig(str, selPath, sizeof(selPath));
|
||||
}
|
||||
|
||||
@@ -2269,7 +2274,7 @@ void HandleUI(void)
|
||||
|
||||
MenuWrite(n++, " Core \x16", menusub == 0, 0);
|
||||
MenuWrite(n++);
|
||||
sprintf(s, " Define %s buttons ", is_menu() ? "System" : user_io_get_core_name_ex());
|
||||
sprintf(s, " Define %s buttons ", is_menu() ? "System" : user_io_get_core_name());
|
||||
s[27] = '\x16';
|
||||
s[28] = 0;
|
||||
MenuWrite(n++, s, menusub == 1, 0);
|
||||
@@ -2549,11 +2554,6 @@ void HandleUI(void)
|
||||
// go back to core requesting this menu
|
||||
switch (user_io_core_type())
|
||||
{
|
||||
case CORE_TYPE_ARCHIE:
|
||||
menusub = 0;
|
||||
menustate = MENU_ARCHIE_MAIN1;
|
||||
break;
|
||||
|
||||
case CORE_TYPE_8BIT:
|
||||
if (is_minimig())
|
||||
{
|
||||
@@ -2866,11 +2866,11 @@ void HandleUI(void)
|
||||
if (select)
|
||||
{
|
||||
int mode = GetUARTMode() | (GetMidiLinkMode() << 8);
|
||||
sprintf(s, "uartmode.%s", user_io_get_core_name_ex());
|
||||
sprintf(s, "uartmode.%s", user_io_get_core_name());
|
||||
FileSaveConfig(s, &mode, 4);
|
||||
uint64_t speeds = GetUARTbaud(3);
|
||||
speeds = (speeds << 32) | GetUARTbaud(1);
|
||||
sprintf(s, "uartspeed.%s", user_io_get_core_name_ex());
|
||||
sprintf(s, "uartspeed.%s", user_io_get_core_name());
|
||||
FileSaveConfig(s, &speeds, 8);
|
||||
menustate = MENU_COMMON1;
|
||||
menusub = 4;
|
||||
@@ -3177,10 +3177,6 @@ void HandleUI(void)
|
||||
// go back to core requesting this menu
|
||||
switch (user_io_core_type())
|
||||
{
|
||||
case CORE_TYPE_ARCHIE:
|
||||
menusub = 0;
|
||||
menustate = MENU_ARCHIE_MAIN1;
|
||||
break;
|
||||
case CORE_TYPE_8BIT:
|
||||
if (is_menu())
|
||||
{
|
||||
|
||||
@@ -1008,17 +1008,8 @@ static int xml_read_setname(XMLEvent evt, const XMLNode* node, SXML_CHAR* text,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static int arcade_type = 0;
|
||||
int is_arcade()
|
||||
{
|
||||
return arcade_type;
|
||||
}
|
||||
|
||||
int arcade_send_rom(const char *xml)
|
||||
{
|
||||
arcade_type = 1;
|
||||
|
||||
const char *p = strrchr(xml, '/');
|
||||
p = p ? p + 1 : xml;
|
||||
snprintf(switches.name, sizeof(switches.name), p);
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
int arcade_send_rom(const char *xml);
|
||||
int arcade_load(const char *xml);
|
||||
void arcade_check_error();
|
||||
int is_arcade();
|
||||
|
||||
struct dip_struct
|
||||
{
|
||||
|
||||
83
user_io.cpp
83
user_io.cpp
@@ -130,6 +130,9 @@ char* user_io_create_config_name()
|
||||
}
|
||||
|
||||
static char core_name[32] = {};
|
||||
static char ovr_name[32] = {};
|
||||
static char orig_name[32] = {};
|
||||
|
||||
static char filepath_store[1024];
|
||||
|
||||
char *user_io_make_filepath(const char *path, const char *filename)
|
||||
@@ -139,7 +142,6 @@ char *user_io_make_filepath(const char *path, const char *filename)
|
||||
return filepath_store;
|
||||
}
|
||||
|
||||
static char ovr_name[32] = {};
|
||||
void user_io_name_override(const char* name)
|
||||
{
|
||||
snprintf(ovr_name, sizeof(ovr_name), "%s", name);
|
||||
@@ -151,9 +153,9 @@ void user_io_set_core_name(const char *name)
|
||||
printf("Core name set to \"%s\"\n", core_name);
|
||||
}
|
||||
|
||||
char *user_io_get_core_name()
|
||||
char *user_io_get_core_name(int orig)
|
||||
{
|
||||
return core_name;
|
||||
return orig ? orig_name : core_name;
|
||||
}
|
||||
|
||||
char *user_io_get_core_path(const char *suffix, int recheck)
|
||||
@@ -172,21 +174,10 @@ char *user_io_get_core_path(const char *suffix, int recheck)
|
||||
return tmp;
|
||||
}
|
||||
|
||||
const char *user_io_get_core_name_ex()
|
||||
static char is_arcade_type = 0;
|
||||
char is_arcade()
|
||||
{
|
||||
switch (user_io_core_type())
|
||||
{
|
||||
case CORE_TYPE_ARCHIE:
|
||||
return "ARCHIE";
|
||||
|
||||
case CORE_TYPE_SHARPMZ:
|
||||
return "SHARPMZ";
|
||||
|
||||
case CORE_TYPE_8BIT:
|
||||
return core_name;
|
||||
}
|
||||
|
||||
return "";
|
||||
return is_arcade_type;
|
||||
}
|
||||
|
||||
static int is_menu_type = 0;
|
||||
@@ -255,7 +246,6 @@ char is_pce()
|
||||
static int is_archie_type = 0;
|
||||
char is_archie()
|
||||
{
|
||||
if (core_type == CORE_TYPE_ARCHIE) return 1;
|
||||
if (!is_archie_type) is_archie_type = strcasecmp(core_name, "ARCHIE") ? 2 : 1;
|
||||
return (is_archie_type == 1);
|
||||
}
|
||||
@@ -292,7 +282,7 @@ char has_menu()
|
||||
{
|
||||
if (disable_osd) return 0;
|
||||
|
||||
if (!is_no_type) is_no_type = user_io_get_core_name_ex()[0] ? 1 : 2;
|
||||
if (!is_no_type) is_no_type = user_io_get_core_name()[0] ? 1 : 2;
|
||||
return (is_no_type == 1);
|
||||
}
|
||||
|
||||
@@ -314,13 +304,12 @@ void user_io_read_core_name()
|
||||
is_st_type = 0;
|
||||
core_name[0] = 0;
|
||||
|
||||
char *p = user_io_get_confstr(0);
|
||||
if (p && p[0]) snprintf(orig_name, sizeof(orig_name), "%s", p);
|
||||
|
||||
// get core name
|
||||
if (ovr_name[0]) strcpy(core_name, ovr_name);
|
||||
else
|
||||
{
|
||||
char *p = user_io_get_confstr(0);
|
||||
if (p && p[0]) strcpy(core_name, p);
|
||||
}
|
||||
else if (orig_name[0]) strcpy(core_name, p);
|
||||
|
||||
printf("Core name is \"%s\"\n", core_name);
|
||||
}
|
||||
@@ -632,7 +621,7 @@ static void parse_config()
|
||||
if (p[0] == 'F' && p[1] == 'C')
|
||||
{
|
||||
static char str[1024];
|
||||
sprintf(str, "%s.f%c", user_io_get_core_name_ex(), p[2]);
|
||||
sprintf(str, "%s.f%c", user_io_get_core_name(), p[2]);
|
||||
if (FileLoadConfig(str, str, sizeof(str)))
|
||||
{
|
||||
user_io_file_tx(str, p[2] - '0');
|
||||
@@ -775,7 +764,7 @@ void SetUARTMode(int mode)
|
||||
spi_w(baud >> 16);
|
||||
DisableIO();
|
||||
|
||||
MakeFile("/tmp/CORENAME", user_io_get_core_name_ex());
|
||||
MakeFile("/tmp/CORENAME", user_io_get_core_name());
|
||||
|
||||
char data[20];
|
||||
sprintf(data, "%d", baud);
|
||||
@@ -1032,8 +1021,7 @@ void user_io_init(const char *path, const char *xml)
|
||||
core_type = CORE_TYPE_8BIT;
|
||||
}
|
||||
|
||||
if ((core_type != CORE_TYPE_ARCHIE) &&
|
||||
(core_type != CORE_TYPE_8BIT) &&
|
||||
if ((core_type != CORE_TYPE_8BIT) &&
|
||||
(core_type != CORE_TYPE_SHARPMZ))
|
||||
{
|
||||
core_type = CORE_TYPE_UNKNOWN;
|
||||
@@ -1052,7 +1040,11 @@ void user_io_init(const char *path, const char *xml)
|
||||
printf("Using default MRA: %s\n", xml);
|
||||
}
|
||||
|
||||
if (xml) arcade_override_name(xml);
|
||||
if (xml)
|
||||
{
|
||||
is_arcade_type = 1;
|
||||
arcade_override_name(xml);
|
||||
}
|
||||
|
||||
if (core_type == CORE_TYPE_8BIT)
|
||||
{
|
||||
@@ -1065,6 +1057,10 @@ void user_io_init(const char *path, const char *xml)
|
||||
// send a reset
|
||||
user_io_8bit_set_status(UIO_STATUS_RESET, UIO_STATUS_RESET);
|
||||
}
|
||||
else if (core_type == CORE_TYPE_SHARPMZ)
|
||||
{
|
||||
user_io_set_core_name("sharpmz");
|
||||
}
|
||||
|
||||
cfg_parse();
|
||||
if (cfg.bootcore[0] != '\0')
|
||||
@@ -1084,15 +1080,6 @@ void user_io_init(const char *path, const char *xml)
|
||||
printf("Unable to identify core (%x)!\n", core_type);
|
||||
break;
|
||||
|
||||
case CORE_TYPE_ARCHIE:
|
||||
puts("Identified Archimedes core");
|
||||
spi_uio_cmd16(UIO_SET_MEMSZ, sdram_sz(-1));
|
||||
send_rtc(1);
|
||||
user_io_set_core_name("Archie");
|
||||
archie_init();
|
||||
parse_buttons();
|
||||
break;
|
||||
|
||||
case CORE_TYPE_SHARPMZ:
|
||||
puts("Identified Sharp MZ Series core");
|
||||
user_io_set_core_name("sharpmz");
|
||||
@@ -1275,11 +1262,11 @@ void user_io_init(const char *path, const char *xml)
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(mainpath, "uartmode.%s", user_io_get_core_name_ex());
|
||||
sprintf(mainpath, "uartmode.%s", user_io_get_core_name());
|
||||
FileLoadConfig(mainpath, &mode, 4);
|
||||
|
||||
uint64_t speeds = 0;
|
||||
sprintf(mainpath, "uartspeed.%s", user_io_get_core_name_ex());
|
||||
sprintf(mainpath, "uartspeed.%s", user_io_get_core_name());
|
||||
FileLoadConfig(mainpath, &speeds, 8);
|
||||
|
||||
ValidateUARTbaud(1, speeds & 0xFFFFFFFF);
|
||||
@@ -1551,7 +1538,7 @@ int user_io_file_mount(const char *name, unsigned char index, char pre)
|
||||
|
||||
if (len)
|
||||
{
|
||||
if (!strcasecmp(user_io_get_core_name_ex(), "apple-ii"))
|
||||
if (!strcasecmp(user_io_get_core_name(), "apple-ii"))
|
||||
{
|
||||
ret = dsk2nib(name, sd_image + index);
|
||||
}
|
||||
@@ -2580,8 +2567,7 @@ static uint32_t res_timer = 0;
|
||||
|
||||
void user_io_poll()
|
||||
{
|
||||
if ((core_type != CORE_TYPE_ARCHIE) &&
|
||||
(core_type != CORE_TYPE_SHARPMZ) &&
|
||||
if ((core_type != CORE_TYPE_SHARPMZ) &&
|
||||
(core_type != CORE_TYPE_8BIT))
|
||||
{
|
||||
return; // no user io for the installed core
|
||||
@@ -2703,7 +2689,7 @@ void user_io_poll()
|
||||
{
|
||||
x86_poll();
|
||||
}
|
||||
else if ((core_type == CORE_TYPE_8BIT || core_type == CORE_TYPE_ARCHIE) && !is_menu() && !is_minimig())
|
||||
else if ((core_type == CORE_TYPE_8BIT) && !is_menu() && !is_minimig())
|
||||
{
|
||||
if (is_st()) tos_poll();
|
||||
|
||||
@@ -2950,7 +2936,7 @@ void user_io_poll()
|
||||
send_rtc(1);
|
||||
}
|
||||
|
||||
if (core_type == CORE_TYPE_ARCHIE || is_archie()) archie_poll();
|
||||
if (is_archie()) archie_poll();
|
||||
if (core_type == CORE_TYPE_SHARPMZ) sharpmz_poll();
|
||||
|
||||
static uint8_t leds = 0;
|
||||
@@ -3254,7 +3240,7 @@ static void send_keycode(unsigned short key, int press)
|
||||
return;
|
||||
}
|
||||
|
||||
if (core_type == CORE_TYPE_ARCHIE || is_archie())
|
||||
if (is_archie())
|
||||
{
|
||||
if (press > 1) return;
|
||||
|
||||
@@ -3409,10 +3395,6 @@ void user_io_mouse(unsigned char b, int16_t x, int16_t y, int16_t w)
|
||||
mouse_flags |= 0x08 | (b & 7);
|
||||
}
|
||||
return;
|
||||
|
||||
case CORE_TYPE_ARCHIE:
|
||||
archie_mouse(b, x, y);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3445,7 +3427,6 @@ void user_io_check_reset(unsigned short modifiers, char useKeys)
|
||||
else
|
||||
switch (core_type)
|
||||
{
|
||||
case CORE_TYPE_ARCHIE:
|
||||
case CORE_TYPE_8BIT:
|
||||
if(is_minimig()) minimig_reset();
|
||||
else kbd_reset = 1;
|
||||
|
||||
@@ -146,7 +146,6 @@
|
||||
// core type value should be unlikely to be returned by broken cores
|
||||
#define CORE_TYPE_UNKNOWN 0x55
|
||||
#define CORE_TYPE_8BIT 0xa4 // generic core
|
||||
#define CORE_TYPE_ARCHIE 0xa6 // Acorn Archimedes
|
||||
#define CORE_TYPE_SHARPMZ 0xa7 // Sharp MZ Series
|
||||
#define CORE_TYPE_8BIT2 0xa8 // generic core using dual SDRAM
|
||||
|
||||
@@ -197,9 +196,8 @@ int user_io_get_kbd_reset();
|
||||
uint32_t user_io_get_file_crc();
|
||||
int user_io_file_mount(const char *name, unsigned char index = 0, char pre = 0);
|
||||
char *user_io_make_filepath(const char *path, const char *filename);
|
||||
char *user_io_get_core_name();
|
||||
char *user_io_get_core_name(int orig = 0);
|
||||
char *user_io_get_core_path(const char *suffix = NULL, int recheck = 0);
|
||||
const char *user_io_get_core_name_ex();
|
||||
void user_io_name_override(const char* name);
|
||||
char has_menu();
|
||||
|
||||
@@ -278,6 +276,7 @@ char is_archie();
|
||||
char is_gba();
|
||||
char is_c64();
|
||||
char is_st();
|
||||
char is_arcade();
|
||||
|
||||
#define HomeDir(x) user_io_get_core_path(x)
|
||||
#define CoreName user_io_get_core_name()
|
||||
|
||||
@@ -313,7 +313,7 @@ void video_set_scaler_coeff(char *name)
|
||||
|
||||
static void loadScalerCfg()
|
||||
{
|
||||
sprintf(scaler_cfg, "%s_scaler.cfg", user_io_get_core_name_ex());
|
||||
sprintf(scaler_cfg, "%s_scaler.cfg", user_io_get_core_name());
|
||||
if (!FileLoadConfig(scaler_cfg, &scaler_flt_cfg, sizeof(scaler_flt_cfg) - 1) || scaler_flt_cfg[0]>4)
|
||||
{
|
||||
memset(scaler_flt_cfg, 0, sizeof(scaler_flt_cfg));
|
||||
@@ -424,7 +424,7 @@ void video_set_gamma_curve(char *name)
|
||||
|
||||
static void loadGammaCfg()
|
||||
{
|
||||
sprintf(gamma_cfg_path, "%s_gamma.cfg", user_io_get_core_name_ex());
|
||||
sprintf(gamma_cfg_path, "%s_gamma.cfg", user_io_get_core_name());
|
||||
if (!FileLoadConfig(gamma_cfg_path, &gamma_cfg, sizeof(gamma_cfg) - 1) || gamma_cfg[0]>1)
|
||||
{
|
||||
memset(gamma_cfg, 0, sizeof(gamma_cfg));
|
||||
|
||||
Reference in New Issue
Block a user