From 281482170b92ad29f794faf2c155a634d88e311e Mon Sep 17 00:00:00 2001 From: Sorgelig Date: Sun, 19 Dec 2021 23:51:58 +0800 Subject: [PATCH] PSX: fix BIOS loading. --- support/psx/psx.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/support/psx/psx.cpp b/support/psx/psx.cpp index dd35bbe..5b2dc22 100644 --- a/support/psx/psx.cpp +++ b/support/psx/psx.cpp @@ -114,7 +114,14 @@ void psx_mount_cd(int f_index, int s_index, const char *filename) { static char last_dir[1024] = {}; - int same_game = *filename && *last_dir && !strncmp(last_dir, filename, strlen(last_dir)); + const char *p = strrchr(filename, '/'); + int cur_len = p ? p - filename : 0; + int old_len = strlen(last_dir); + + int name_len = strlen(filename); + int is_cue = (name_len > 4) && !strcasecmp(filename + name_len - 4, ".cue"); + + int same_game = old_len && (cur_len == old_len) && !strncmp(last_dir, filename, old_len); int loaded = 1; if (!same_game) @@ -124,8 +131,11 @@ void psx_mount_cd(int f_index, int s_index, const char *filename) strcpy(last_dir, filename); char *p = strrchr(last_dir, '/'); if (p) *p = 0; + else *last_dir = 0; strcpy(buf, last_dir); + if (!is_cue && buf[0]) strcat(buf, "/"); + p = strrchr(buf, '/'); if (p) { @@ -144,12 +154,10 @@ void psx_mount_cd(int f_index, int s_index, const char *filename) if (loaded) { - int len = strlen(filename); user_io_set_index(f_index); + process_ss(filename, name_len != 0); - process_ss(filename, len != 0); - - if (len > 4 && !strcasecmp(filename + len - 4, ".cue") && get_bin(filename)) + if (is_cue && get_bin(filename)) { user_io_file_mount(buf, s_index); }