arcade: override core name with 'setname' node in MRA.
This commit is contained in:
@@ -708,6 +708,49 @@ static int xml_scan_rbf(XMLEvent evt, const XMLNode* node, SXML_CHAR* text, cons
|
||||
return true;
|
||||
}
|
||||
|
||||
static int xml_read_setname(XMLEvent evt, const XMLNode* node, SXML_CHAR* text, const int n, SAX_Data* sd)
|
||||
{
|
||||
(void)(sd);
|
||||
static int insetname = 0;
|
||||
|
||||
switch (evt)
|
||||
{
|
||||
case XML_EVENT_START_DOC:
|
||||
insetname = 0;
|
||||
break;
|
||||
|
||||
case XML_EVENT_START_NODE:
|
||||
|
||||
/* on the beginning of a rom tag, we need to reset the state*/
|
||||
if (!strcasecmp(node->tag, "setname"))
|
||||
{
|
||||
insetname = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case XML_EVENT_TEXT:
|
||||
if(insetname) user_io_name_override(text);
|
||||
break;
|
||||
|
||||
case XML_EVENT_END_NODE:
|
||||
if (!strcasecmp(node->tag, "setname"))
|
||||
{
|
||||
insetname = 0;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case XML_EVENT_ERROR:
|
||||
printf("XML parse: %s: ERROR %d\n", text, n);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static int arcade_type = 0;
|
||||
int is_arcade()
|
||||
{
|
||||
@@ -753,6 +796,15 @@ int arcade_send_rom(const char *xml)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void arcade_override_name(const char *xml)
|
||||
{
|
||||
SAX_Callbacks sax;
|
||||
SAX_Callbacks_init(&sax);
|
||||
|
||||
sax.all_event = xml_read_setname;
|
||||
XMLDoc_parse_file_SAX(xml, &sax, NULL);
|
||||
}
|
||||
|
||||
void arcade_check_error()
|
||||
{
|
||||
if (arcade_error_msg[0] != 0) {
|
||||
|
||||
@@ -32,5 +32,6 @@ sw_struct *arcade_sw();
|
||||
void arcade_sw_send();
|
||||
void arcade_sw_save();
|
||||
void arcade_sw_load();
|
||||
void arcade_override_name(const char *xml);
|
||||
|
||||
#endif
|
||||
|
||||
19
user_io.cpp
19
user_io.cpp
@@ -140,6 +140,12 @@ char *user_io_make_filepath(const char *path, const char *filename)
|
||||
return filepath_store;
|
||||
}
|
||||
|
||||
static char ovr_name[16 + 1] = {};
|
||||
void user_io_name_override(const char* name)
|
||||
{
|
||||
snprintf(ovr_name, sizeof(ovr_name), "%s", name);
|
||||
}
|
||||
|
||||
void user_io_set_core_name(const char *name)
|
||||
{
|
||||
strncpy(core_name, name, 17);
|
||||
@@ -281,11 +287,15 @@ static void user_io_read_core_name()
|
||||
core_name[0] = 0;
|
||||
|
||||
// get core name
|
||||
char *p = user_io_get_confstr(0);
|
||||
if (p && p[0]) strcpy(core_name, p);
|
||||
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);
|
||||
}
|
||||
|
||||
strncpy(core_dir, !strcasecmp(p, "minimig") ? "Amiga" : core_name, 1024);
|
||||
prefixGameDir(core_dir, 1024);
|
||||
strcpy(core_dir, !strcasecmp(core_name, "minimig") ? "Amiga" : core_name);
|
||||
prefixGameDir(core_dir, sizeof(core_dir));
|
||||
|
||||
printf("Core name is \"%s\"\n", core_name);
|
||||
}
|
||||
@@ -664,6 +674,7 @@ void user_io_init(const char *path, const char *xml)
|
||||
// not the RBF. The RBF will be in arcade, which the user shouldn't
|
||||
// browse
|
||||
strcpy(core_path, xml ? xml : path);
|
||||
if (xml) arcade_override_name(xml);
|
||||
|
||||
memset(sd_image, 0, sizeof(sd_image));
|
||||
|
||||
|
||||
@@ -222,6 +222,7 @@ char *user_io_make_filepath(const char *path, const char *filename);
|
||||
char *user_io_get_core_name();
|
||||
char *user_io_get_core_path();
|
||||
const char *user_io_get_core_name_ex();
|
||||
void user_io_name_override(const char* name);
|
||||
char has_menu();
|
||||
|
||||
const char *get_image_name(int i);
|
||||
|
||||
Reference in New Issue
Block a user