Support suffix for home dir.

This commit is contained in:
sorgelig
2020-05-14 17:19:29 +08:00
parent e118e4f3cb
commit b1a481f24c
8 changed files with 42 additions and 30 deletions

View File

@@ -314,6 +314,7 @@ static int changeDir(char *dir)
static void SelectFile(const char* path, const char* pFileExt, unsigned char Options, unsigned char MenuSelect, unsigned char MenuCancel)
{
printf("pFileExt = %s\n", pFileExt);
const char *suffix = NULL;
strncpy(selPath, path, sizeof(selPath) - 1);
selPath[sizeof(selPath) - 1] = 0;
@@ -333,13 +334,17 @@ static void SelectFile(const char* path, const char* pFileExt, unsigned char Opt
if(pFileExt == 0)
pFileExt = "TXT";
}
else if (strncasecmp(HomeDir, selPath, strlen(HomeDir)) || !strcasecmp(HomeDir, selPath))
else
{
Options &= ~SCANO_NOENTER;
strcpy(selPath, HomeDir);
if (is_pce() && !strncasecmp(pFileExt, "CUE", 3)) suffix = "CD";
if (strncasecmp(HomeDir(suffix), selPath, strlen(HomeDir(suffix))) || !strcasecmp(HomeDir(suffix), selPath))
{
Options &= ~SCANO_NOENTER;
strcpy(selPath, HomeDir(suffix));
}
}
if (!strcasecmp(HomeDir, selPath)) FileCreatePath(selPath);
if (!strcasecmp(HomeDir(suffix), selPath)) FileCreatePath(selPath);
ScanDirectory(selPath, SCANF_INIT, pFileExt, Options);
if (!flist_nDirEntries())
@@ -1638,7 +1643,7 @@ void HandleUI(void)
if (p[idx] >= '0' && p[idx] <= '9') ioctl_index = p[idx] - '0';
substrcpy(ext, p, 1);
if (is_gba() && FileExists(user_io_make_filepath(HomeDir, "goomba.rom"))) strcat(ext, "GB GBC");
if (is_gba() && FileExists(user_io_make_filepath(HomeDir(), "goomba.rom"))) strcat(ext, "GB GBC");
while (strlen(ext) % 3) strcat(ext, " ");
fs_Options = SCANO_DIR | (is_neogeo() ? SCANO_NEOGEO | SCANO_NOENTER : 0);

View File

@@ -196,7 +196,7 @@ void archie_init(void)
// set config defaults
config.system_ctrl = 0;
snprintf(config.rom_img, 1024, user_io_make_filepath(HomeDir, "RISCOS.ROM"));
snprintf(config.rom_img, 1024, user_io_make_filepath(HomeDir(), "RISCOS.ROM"));
// try to load config from card
int size = FileLoadConfig(CONFIG_FILENAME, 0, 0);
@@ -224,7 +224,7 @@ void archie_init(void)
// upload ext file
//user_io_file_tx("Archie/RISCOS.EXT", 2);
user_io_file_tx(user_io_make_filepath(HomeDir, "CMOS.DAT"), 3);
user_io_file_tx(user_io_make_filepath(HomeDir(), "CMOS.DAT"), 3);
user_io_8bit_set_status(0, UIO_STATUS_RESET);

View File

@@ -167,7 +167,7 @@ static void BootUploadLogo()
int i = 0;
int adr;
if (FileOpen(&file, user_io_make_filepath(HomeDir, LOGO_FILE)) || FileOpen(&file, LOGO_FILE)) {
if (FileOpen(&file, user_io_make_filepath(HomeDir(), LOGO_FILE)) || FileOpen(&file, LOGO_FILE)) {
FileReadSec(&file, buffer);
mem_upload_init(SCREEN_BPL1 + LOGO_OFFSET);
adr = SCREEN_BPL1 + LOGO_OFFSET;
@@ -226,7 +226,7 @@ static void BootUploadBall()
int i = 0;
int adr;
if (FileOpen(&file, user_io_make_filepath(HomeDir, BALL_FILE)) || FileOpen(&file, BALL_FILE))
if (FileOpen(&file, user_io_make_filepath(HomeDir(), BALL_FILE)) || FileOpen(&file, BALL_FILE))
{
FileReadSec(&file, buffer);
mem_upload_init(BALL_ADDRESS);
@@ -256,7 +256,7 @@ static void BootUploadCopper()
int i = 0;
int adr;
if (FileOpen(&file, user_io_make_filepath(HomeDir, COPPER_FILE)) || FileOpen(&file, COPPER_FILE))
if (FileOpen(&file, user_io_make_filepath(HomeDir(), COPPER_FILE)) || FileOpen(&file, COPPER_FILE))
{
FileReadSec(&file, buffer);
mem_upload_init(COPPER_ADDRESS);

View File

@@ -97,7 +97,7 @@ static char UploadKickstart(char *name)
int keysize = 0;
BootPrint("Checking for Amiga Forever key file:");
if (FileOpen(&file, user_io_make_filepath(HomeDir, "ROM.KEY")) || FileOpen(&file, "ROM.KEY")) {
if (FileOpen(&file, user_io_make_filepath(HomeDir(), "ROM.KEY")) || FileOpen(&file, "ROM.KEY")) {
keysize = file.size;
if (file.size<sizeof(romkey))
{
@@ -198,7 +198,7 @@ static char UploadKickstart(char *name)
static char UploadActionReplay()
{
fileTYPE file = {};
if(FileOpen(&file, user_io_make_filepath(HomeDir, "HRTMON.ROM")) || FileOpen(&file, "HRTMON.ROM"))
if(FileOpen(&file, user_io_make_filepath(HomeDir(), "HRTMON.ROM")) || FileOpen(&file, "HRTMON.ROM"))
{
int adr, data;
puts("Uploading HRTmon ROM... ");
@@ -348,7 +348,7 @@ static void ApplyConfiguration(char reloadkickstart)
spi_uio_cmd8(UIO_MM2_RST, rstval);
if (!UploadKickstart(minimig_config.kickstart))
{
snprintf(minimig_config.kickstart, 1024, "%s/%s", HomeDir, "KICK.ROM");
snprintf(minimig_config.kickstart, 1024, "%s/%s", HomeDir(), "KICK.ROM");
if (!UploadKickstart(minimig_config.kickstart))
{
strcpy(minimig_config.kickstart, "KICK.ROM");
@@ -451,7 +451,7 @@ int minimig_cfg_load(int num)
// set default configuration
memset((void*)&minimig_config, 0, sizeof(minimig_config)); // Finally found default config bug - params were reversed!
strncpy(minimig_config.id, config_id, sizeof(minimig_config.id));
snprintf(minimig_config.kickstart, 1024, "%s/%s", HomeDir, "KICK.ROM");
snprintf(minimig_config.kickstart, 1024, "%s/%s", HomeDir(), "KICK.ROM");
minimig_config.memory = 0x11;
minimig_config.cpu = 0;
minimig_config.chipset = 0;

View File

@@ -572,7 +572,7 @@ int neogeo_scan_xml(char *path)
{
static char full_path[1024];
sprintf(full_path, "%s/romsets.xml", path);
if(!FileExists(full_path)) sprintf(full_path, "%s/%s/romsets.xml", getRootDir(), HomeDir);
if(!FileExists(full_path)) sprintf(full_path, "%s/%s/romsets.xml", getRootDir(), HomeDir());
SAX_Callbacks sax;
SAX_Callbacks_init(&sax);
@@ -1140,7 +1140,7 @@ int neogeo_romset_tx(char* name)
char *p = strrchr(full_path, '/');
if (p) *p = 0;
strcat(full_path, "/romsets.xml");
if (!FileExists(full_path)) sprintf(full_path, "%s/%s/romsets.xml", getRootDir(), HomeDir);
if (!FileExists(full_path)) sprintf(full_path, "%s/%s/romsets.xml", getRootDir(), HomeDir());
}
printf("xml for %s: %s\n", name, full_path);
@@ -1162,31 +1162,31 @@ int neogeo_romset_tx(char* name)
if (strcmp(romset, "debug")) {
// Not loading the special 'debug' romset
if (!(system_type & 2)) {
sprintf(full_path, "%s/uni-bios.rom", HomeDir);
sprintf(full_path, "%s/uni-bios.rom", HomeDir());
if (!(mask & 0x8000) && FileExists(full_path)) {
// Autoload Unibios for cart systems if present
neogeo_tx(HomeDir, "uni-bios.rom", NEO_FILE_RAW, 0, 0, 0x20000);
neogeo_tx(HomeDir(), "uni-bios.rom", NEO_FILE_RAW, 0, 0, 0x20000);
} else {
// Otherwise load normal system roms
if (system_type == 0)
neogeo_tx(HomeDir, "neo-epo.sp1", NEO_FILE_RAW, 0, 0, 0x20000);
neogeo_tx(HomeDir(), "neo-epo.sp1", NEO_FILE_RAW, 0, 0, 0x20000);
else
neogeo_tx(HomeDir, "sp-s2.sp1", NEO_FILE_RAW, 0, 0, 0x20000);
neogeo_tx(HomeDir(), "sp-s2.sp1", NEO_FILE_RAW, 0, 0, 0x20000);
}
} else if (system_type == 2) {
// NeoGeo CD
neogeo_tx(HomeDir, "top-sp1.bin", NEO_FILE_RAW, 0, 0, 0x80000);
neogeo_tx(HomeDir(), "top-sp1.bin", NEO_FILE_RAW, 0, 0, 0x80000);
} else {
// NeoGeo CDZ
neogeo_tx(HomeDir, "neocd.bin", NEO_FILE_RAW, 0, 0, 0x80000);
neogeo_tx(HomeDir(), "neocd.bin", NEO_FILE_RAW, 0, 0, 0x80000);
}
}
//flush CROM if any.
neogeo_tx(NULL, NULL, 0, -1, 0, 0);
if (!(system_type & 2)) neogeo_tx(HomeDir, "sfix.sfix", NEO_FILE_FIX, 2, 0, 0);
neogeo_file_tx(HomeDir, "000-lo.lo", NEO_FILE_8BIT, 1, 0, 0x10000);
if (!(system_type & 2)) neogeo_tx(HomeDir(), "sfix.sfix", NEO_FILE_FIX, 2, 0, 0);
neogeo_file_tx(HomeDir(), "000-lo.lo", NEO_FILE_8BIT, 1, 0, 0x10000);
if (crom_start < 0x300000) crom_start = 0x300000;
uint32_t crom_max = crom_start + crom_sz_max;

View File

@@ -500,8 +500,8 @@ void x86_init()
{
user_io_8bit_set_status(UIO_STATUS_RESET, UIO_STATUS_RESET);
load_bios(user_io_make_filepath(HomeDir, "boot0.rom"), 0);
load_bios(user_io_make_filepath(HomeDir, "boot1.rom"), 1);
load_bios(user_io_make_filepath(HomeDir(), "boot0.rom"), 0);
load_bios(user_io_make_filepath(HomeDir(), "boot1.rom"), 1);
IOWR(PC_BUS_BASE, 0, 0x00FFF0EA);
IOWR(PC_BUS_BASE, 1, 0x000000F0);

View File

@@ -161,8 +161,15 @@ char *user_io_get_core_name()
return core_name;
}
char *user_io_get_core_path(void)
char *user_io_get_core_path(const char *suffix)
{
static char tmp[1024];
if (suffix)
{
strcpy(tmp, core_dir);
strcat(tmp, suffix);
return tmp;
}
return core_dir;
}
@@ -1804,7 +1811,7 @@ int user_io_file_tx(const char* name, unsigned char index, char opensave, char m
if ((index >> 6) == 1 || (index >> 6) == 2)
{
fileTYPE fg = {};
if (!FileOpen(&fg, user_io_make_filepath(HomeDir, "goomba.rom")))
if (!FileOpen(&fg, user_io_make_filepath(HomeDir(), "goomba.rom")))
{
dosend = 0;
Info("Cannot open goomba.rom!");

View File

@@ -201,7 +201,7 @@ 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_path();
char *user_io_get_core_path(const char *suffix = NULL);
const char *user_io_get_core_name_ex();
void user_io_name_override(const char* name);
char has_menu();
@@ -270,7 +270,7 @@ char is_gba();
char is_c64();
char is_st();
#define HomeDir (is_menu() ? "Scripts" : user_io_get_core_path())
#define HomeDir(x) (is_menu() ? "Scripts" : user_io_get_core_path(x))
#define CoreName (is_menu() ? "Scripts" : user_io_get_core_name())
#endif // USER_IO_H