megacd: some improvements in navigation. Remove old CD while mounting new one.

This commit is contained in:
sorgelig
2019-11-20 17:24:25 +08:00
parent cdc8bddb36
commit 4bd14be5f2
3 changed files with 37 additions and 11 deletions

View File

@@ -1534,7 +1534,16 @@ void HandleUI(void)
if (p[1] >= '0' && p[1] <= '3') drive_num = p[1] - '0';
substrcpy(ext, p, 1);
while (strlen(ext) % 3) strcat(ext, " ");
SelectFile(ext, SCANO_DIR | SCANO_UMOUNT, MENU_8BIT_MAIN_IMAGE_SELECTED, MENU_8BIT_MAIN1);
if (is_megacd_core())
{
int len = strlen(SelectedPath);
if (len > 4 && !strcasecmp(SelectedPath + len - 4, ".cue"))
{
char *p = strrchr(SelectedPath, '/');
if (p) *p = 0;
}
}
SelectFile(ext, SCANO_DIR | SCANO_UMOUNT | (is_megacd_core() ? SCANO_NOENTER : 0), MENU_8BIT_MAIN_IMAGE_SELECTED, MENU_8BIT_MAIN1);
}
else if ((p[0] == 'O') || (p[0] == 'o'))
{
@@ -3265,9 +3274,27 @@ void HandleUI(void)
if (select)
{
if (flist_SelectedItem()->de.d_type == DT_DIR)
static char name[256];
char type = flist_SelectedItem()->de.d_type;
memcpy(name, flist_SelectedItem()->de.d_name, sizeof(name));
if (is_megacd_core() && type == DT_DIR && strcmp(flist_SelectedItem()->de.d_name, ".."))
{
changeDir(flist_SelectedItem()->de.d_name);
int len = strlen(SelectedPath);
strcat(SelectedPath, "/");
strcat(SelectedPath, name);
int num = ScanDirectory(SelectedPath, SCANF_INIT, fs_pFileExt, 0);
if (!num) SelectedPath[len] = 0;
else
{
type = flist_SelectedItem()->de.d_type;
memcpy(name, flist_SelectedItem()->de.d_name, sizeof(name));
}
}
if (type == DT_DIR)
{
changeDir(name);
menustate = MENU_FILE_SELECT1;
}
else
@@ -3281,7 +3308,7 @@ void HandleUI(void)
strcat(SelectedPath, "/");
}
strcat(SelectedPath, flist_SelectedItem()->de.d_name);
strcat(SelectedPath, name);
menustate = fs_MenuSelect;
}
}

View File

@@ -130,6 +130,10 @@ void mcd_set_image(int num, const char *filename)
{
(void)num;
cdd.Unload();
unloaded = 1;
cdd.status = CD_STAT_OPEN;
if (*filename) {
if (cdd.Load(filename) > 0) {
@@ -142,11 +146,6 @@ void mcd_set_image(int num, const char *filename)
cdd.status = CD_STAT_NO_DISC;
}
}
else {
cdd.Unload();
unloaded = 1;
cdd.status = CD_STAT_OPEN;
}
}

View File

@@ -73,7 +73,7 @@
#define UIO_SET_GAMMA 0x32 // Enable/disable Gamma correction
#define UIO_SET_GAMCURV 0x33 // Set Gamma curve
#define UIO_CD_GET 0x34
#define UIO_CD_SET 0x35
#define UIO_CD_SET 0x35
// codes as used by 8bit for file loading from OSD
#define UIO_FILE_TX 0x53
@@ -216,7 +216,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();
char is_megacd_core();
char is_megacd_core();
char has_menu();
const char *get_image_name(int i);