NeoGeo: Display altname in ROM selector.
This commit is contained in:
187
file_io.cpp
187
file_io.cpp
@@ -28,6 +28,7 @@
|
||||
#include "miniz_zip.h"
|
||||
#include "scheduler.h"
|
||||
#include "video.h"
|
||||
#include "support.h"
|
||||
|
||||
#define MIN(a,b) (((a)<(b)) ? (a) : (b))
|
||||
|
||||
@@ -949,19 +950,37 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons
|
||||
if (mode == SCANF_INIT)
|
||||
{
|
||||
file_name[0] = 0;
|
||||
if (!isPathDirectory(path))
|
||||
if (is_neogeo_core() && !(options & (SCANO_CORES | SCANO_UMOUNT)))
|
||||
{
|
||||
bool isfile = isPathRegularFile(path);
|
||||
char *p = strrchr(path, '/');
|
||||
if (p)
|
||||
neogeo_scan_xml();
|
||||
uint32_t len = strlen(HomeDir);
|
||||
if (strlen(path) > len)
|
||||
{
|
||||
if (isfile) strcpy(file_name, p + 1);
|
||||
*p = 0;
|
||||
path[len] = 0;
|
||||
dirent *nde = neogeo_set_altname(path + len + 1);
|
||||
file_name[0] = 0;
|
||||
if (nde)
|
||||
{
|
||||
strcpy(file_name, nde->d_name);
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isPathDirectory(path))
|
||||
{
|
||||
if (isfile) strcpy(file_name, path);
|
||||
path[0] = 0;
|
||||
bool isfile = isPathRegularFile(path);
|
||||
char *p = strrchr(path, '/');
|
||||
if (p)
|
||||
{
|
||||
if (isfile) strcpy(file_name, p + 1);
|
||||
*p = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isfile) strcpy(file_name, path);
|
||||
path[0] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1058,82 +1077,95 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons
|
||||
}
|
||||
}
|
||||
|
||||
if (de->d_type == DT_DIR)
|
||||
if (is_neogeo_core() && !(options & (SCANO_CORES | SCANO_UMOUNT)))
|
||||
{
|
||||
if (de->d_type != DT_DIR) continue;
|
||||
if (!strcmp(de->d_name, ".")) continue;
|
||||
if (!strcmp(de->d_name, ".."))
|
||||
{
|
||||
if(!strlen(path)) continue;
|
||||
}
|
||||
if (!strcmp(de->d_name, "..")) continue;
|
||||
|
||||
if (!(options & SCANO_DIR))
|
||||
{
|
||||
if (de->d_name[0] != '_' && strcmp(de->d_name, "..")) continue;
|
||||
if (!(options & SCANO_CORES)) continue;
|
||||
}
|
||||
}
|
||||
else if (de->d_type == DT_REG)
|
||||
{
|
||||
//skip non-selectable files
|
||||
if (!strcasecmp(de->d_name, "menu.rbf")) continue;
|
||||
if (!strncasecmp(de->d_name, "menu_20",7)) continue;
|
||||
if (!strcasecmp(de->d_name, "boot.rom")) continue;
|
||||
|
||||
//check the prefix if given
|
||||
if (prefix && strncasecmp(prefix, de->d_name, strlen(prefix))) continue;
|
||||
|
||||
if (extlen > 0)
|
||||
{
|
||||
const char *ext = extension;
|
||||
int found = (has_trd && x2trd_ext_supp(de->d_name));
|
||||
if (!found && !strcasecmp(de->d_name + strlen(de->d_name) - 4, ".zip"))
|
||||
{
|
||||
// Fake that zip-file is a directory.
|
||||
de->d_type = DT_DIR;
|
||||
found = 1;
|
||||
}
|
||||
if (!found && is_minimig() && !memcmp(extension, "HDF", 3))
|
||||
{
|
||||
found = !strcasecmp(de->d_name + strlen(de->d_name) - 4, ".iso");
|
||||
}
|
||||
|
||||
char *fext = strrchr(de->d_name, '.');
|
||||
if(fext) fext++;
|
||||
while(!found && *ext && fext)
|
||||
{
|
||||
char e[4];
|
||||
memcpy(e, ext, 3);
|
||||
if (e[2] == ' ')
|
||||
{
|
||||
e[2] = 0;
|
||||
if (e[1] == ' ') e[1] = 0;
|
||||
}
|
||||
|
||||
e[3] = 0;
|
||||
found = 1;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (e[i] == '*') break;
|
||||
if (e[i] == '?' && fext[i]) continue;
|
||||
|
||||
if (tolower(e[i]) != tolower(fext[i])) found = 0;
|
||||
|
||||
if (!e[i] || !found) break;
|
||||
}
|
||||
if (found) break;
|
||||
|
||||
if (strlen(ext) < 3) break;
|
||||
ext += 3;
|
||||
}
|
||||
if (!found) continue;
|
||||
}
|
||||
dirent *nde = neogeo_set_altname(de->d_name);
|
||||
if(nde) DirItem.push_back(*nde);
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
if (de->d_type == DT_DIR)
|
||||
{
|
||||
if (!strcmp(de->d_name, ".")) continue;
|
||||
if (!strcmp(de->d_name, ".."))
|
||||
{
|
||||
if (!strlen(path)) continue;
|
||||
}
|
||||
|
||||
if (!(options & SCANO_DIR))
|
||||
{
|
||||
if (de->d_name[0] != '_' && strcmp(de->d_name, "..")) continue;
|
||||
if (!(options & SCANO_CORES)) continue;
|
||||
}
|
||||
}
|
||||
else if (de->d_type == DT_REG)
|
||||
{
|
||||
//skip non-selectable files
|
||||
if (!strcasecmp(de->d_name, "menu.rbf")) continue;
|
||||
if (!strncasecmp(de->d_name, "menu_20", 7)) continue;
|
||||
if (!strcasecmp(de->d_name, "boot.rom")) continue;
|
||||
|
||||
//check the prefix if given
|
||||
if (prefix && strncasecmp(prefix, de->d_name, strlen(prefix))) continue;
|
||||
|
||||
if (extlen > 0)
|
||||
{
|
||||
const char *ext = extension;
|
||||
int found = (has_trd && x2trd_ext_supp(de->d_name));
|
||||
if (!found && !strcasecmp(de->d_name + strlen(de->d_name) - 4, ".zip"))
|
||||
{
|
||||
// Fake that zip-file is a directory.
|
||||
de->d_type = DT_DIR;
|
||||
found = 1;
|
||||
}
|
||||
if (!found && is_minimig() && !memcmp(extension, "HDF", 3))
|
||||
{
|
||||
found = !strcasecmp(de->d_name + strlen(de->d_name) - 4, ".iso");
|
||||
}
|
||||
|
||||
char *fext = strrchr(de->d_name, '.');
|
||||
if (fext) fext++;
|
||||
while (!found && *ext && fext)
|
||||
{
|
||||
char e[4];
|
||||
memcpy(e, ext, 3);
|
||||
if (e[2] == ' ')
|
||||
{
|
||||
e[2] = 0;
|
||||
if (e[1] == ' ') e[1] = 0;
|
||||
}
|
||||
|
||||
e[3] = 0;
|
||||
found = 1;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (e[i] == '*') break;
|
||||
if (e[i] == '?' && fext[i]) continue;
|
||||
|
||||
if (tolower(e[i]) != tolower(fext[i])) found = 0;
|
||||
|
||||
if (!e[i] || !found) break;
|
||||
}
|
||||
if (found) break;
|
||||
|
||||
if (strlen(ext) < 3) break;
|
||||
ext += 3;
|
||||
}
|
||||
if (!found) continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
DirItem.push_back(*de);
|
||||
}
|
||||
DirItem.push_back(*de);
|
||||
}
|
||||
|
||||
if (z)
|
||||
{
|
||||
// Since zip files aren't actually folders the entry to
|
||||
@@ -1146,6 +1178,7 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons
|
||||
mz_zip_reader_end(z);
|
||||
delete z;
|
||||
}
|
||||
|
||||
if (d)
|
||||
{
|
||||
closedir(d);
|
||||
|
||||
9
menu.cpp
9
menu.cpp
@@ -3125,7 +3125,14 @@ void HandleUI(void)
|
||||
strcpy(SelectedDir, SelectedPath);
|
||||
strcat(SelectedPath, "/");
|
||||
}
|
||||
strcat(SelectedPath, flist_SelectedItem()->d_name);
|
||||
if (is_neogeo_core())
|
||||
{
|
||||
strcat(SelectedPath, neogeo_get_name(flist_SelectedItem()->d_ino));
|
||||
}
|
||||
else
|
||||
{
|
||||
strcat(SelectedPath, flist_SelectedItem()->d_name);
|
||||
}
|
||||
|
||||
menustate = fs_MenuSelect;
|
||||
}
|
||||
|
||||
@@ -25,9 +25,10 @@ void neogeo_osd_progress(const char* name, unsigned int progress) {
|
||||
memset(progress_buf, ' ', 30);
|
||||
memcpy(progress_buf, name, strlen(name));
|
||||
for (unsigned int i = 0; i < progress; i++)
|
||||
progress_buf[12 + i] = '#';
|
||||
progress_buf[12 + i] = 0x7f;
|
||||
progress_buf[30] = 0;
|
||||
|
||||
OsdWrite(OsdGetSize() - 2);
|
||||
OsdWrite(OsdGetSize() - 1, progress_buf, 0);
|
||||
}
|
||||
|
||||
@@ -123,6 +124,94 @@ int neogeo_file_tx(const char* romset, const char* name, unsigned char neo_file_
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct rom_info
|
||||
{
|
||||
char name[16];
|
||||
char altname[256];
|
||||
};
|
||||
|
||||
static rom_info roms[1000];
|
||||
static uint32_t rom_cnt = 0;
|
||||
|
||||
static int xml_scan(XMLEvent evt, const XMLNode* node, SXML_CHAR* text, const int n, SAX_Data* sd)
|
||||
{
|
||||
(void)(sd);
|
||||
|
||||
switch (evt)
|
||||
{
|
||||
case XML_EVENT_START_NODE:
|
||||
if (!strcasecmp(node->tag, "romset") && (rom_cnt < (sizeof(roms) / sizeof(roms[0]))))
|
||||
{
|
||||
memset(&roms[rom_cnt], 0, sizeof(rom_info));
|
||||
for (int i = 0; i < node->n_attributes; i++)
|
||||
{
|
||||
if (!strcasecmp(node->attributes[i].name, "name"))
|
||||
{
|
||||
strncpy(roms[rom_cnt].name, node->attributes[i].value, sizeof(roms[rom_cnt].name) - 1);
|
||||
strncpy(roms[rom_cnt].altname, node->attributes[i].value, sizeof(roms[rom_cnt].name) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < node->n_attributes; i++)
|
||||
{
|
||||
if (!strcasecmp(node->attributes[i].name, "altname"))
|
||||
{
|
||||
memset(roms[rom_cnt].altname, 0, sizeof(roms[rom_cnt].altname));
|
||||
strncpy(roms[rom_cnt].altname, node->attributes[i].value, sizeof(roms[rom_cnt].altname) - 1);
|
||||
}
|
||||
}
|
||||
rom_cnt++;
|
||||
}
|
||||
break;
|
||||
|
||||
case XML_EVENT_END_NODE:
|
||||
break;
|
||||
|
||||
case XML_EVENT_ERROR:
|
||||
printf("XML parse: %s: ERROR %d\n", text, n);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int neogeo_scan_xml()
|
||||
{
|
||||
static char full_path[1024];
|
||||
sprintf(full_path, "%s/neogeo/romsets.xml", getRootDir());
|
||||
SAX_Callbacks sax;
|
||||
SAX_Callbacks_init(&sax);
|
||||
|
||||
rom_cnt = 0;
|
||||
sax.all_event = xml_scan;
|
||||
XMLDoc_parse_file_SAX(full_path, &sax, 0);
|
||||
return rom_cnt;
|
||||
}
|
||||
|
||||
dirent *neogeo_set_altname(char *name)
|
||||
{
|
||||
static dirent de;
|
||||
for (uint32_t i = 0; i < rom_cnt; i++)
|
||||
{
|
||||
if (!strcasecmp(name, roms[i].name))
|
||||
{
|
||||
memcpy(de.d_name, roms[i].altname, sizeof(de.d_name));
|
||||
de.d_ino = i;
|
||||
de.d_type = DT_REG;
|
||||
return &de;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *neogeo_get_name(uint32_t num)
|
||||
{
|
||||
if (num < rom_cnt) return roms[num].name;
|
||||
return "";
|
||||
}
|
||||
|
||||
static int xml_check_files(XMLEvent evt, const XMLNode* node, SXML_CHAR* text, const int n, SAX_Data* sd)
|
||||
{
|
||||
const char* romset = (const char*)sd->user;
|
||||
@@ -286,12 +375,9 @@ int neogeo_romset_tx(char* name) {
|
||||
|
||||
// Look for the romset's file list in romsets.xml
|
||||
if (!(system_type & 2)) {
|
||||
// Get romset name from path (which should point to a .p1 or .ep1 file)
|
||||
// Get romset name from path
|
||||
char *p = strrchr(name, '/');
|
||||
if (!p) return 0;
|
||||
*p = 0;
|
||||
p = strrchr(name, '/');
|
||||
if (!p) return 0;
|
||||
strncpy(romset, p + 1, strlen(p + 1));
|
||||
|
||||
sprintf(full_path, "%s/neogeo/romsets.xml", getRootDir());
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../../file_io.h"
|
||||
#include "../../file_io.h"
|
||||
|
||||
#define NEO_FILE_RAW 0
|
||||
#define NEO_FILE_8BIT 1
|
||||
@@ -6,4 +6,7 @@
|
||||
#define NEO_FILE_SPR 3
|
||||
|
||||
extern bool checked_ok;
|
||||
int neogeo_romset_tx(char* name);
|
||||
int neogeo_romset_tx(char* name);
|
||||
int neogeo_scan_xml();
|
||||
dirent *neogeo_set_altname(char *name);
|
||||
const char *neogeo_get_name(uint32_t num);
|
||||
|
||||
Reference in New Issue
Block a user