set_vout_fb();
}
-static bool try_use_bios(const char *path)
+static bool try_use_bios(const char *path, bool preferred_only)
{
long size;
const char *name;
size = ftell(fp);
fclose(fp);
- if (size != 512 * 1024)
- return false;
-
name = strrchr(path, SLASH);
if (name++ == NULL)
name = path;
+
+ if (preferred_only && size != 512 * 1024)
+ return false;
+ if (size != 512 * 1024 && size != 4 * 1024 * 1024)
+ return false;
+ if (strstr(name, "unirom"))
+ return false;
+ // jp bios have an addidional region check
+ if (preferred_only && (strcasestr(name, "00.") || strcasestr(name, "j.bin")))
+ return false;
+
snprintf(Config.Bios, sizeof(Config.Bios), "%s", name);
return true;
}
static bool find_any_bios(const char *dirpath, char *path, size_t path_size)
{
- static const char *substrings[] = { "scph", "ps", "openbios" };
+ static const char *substr_pref[] = { "scph", "ps" };
+ static const char *substr_alt[] = { "scph", "ps", "openbios" };
DIR *dir;
struct dirent *ent;
bool ret = false;
if (dir == NULL)
return false;
- for (i = 0; i < (sizeof(substrings) / sizeof(substrings[0])); i++)
+ // try to find a "better" bios
+ while ((ent = readdir(dir)))
{
- const char *substr = substrings[i];
- size_t len = strlen(substr);
- rewinddir(dir);
- while ((ent = readdir(dir)))
+ for (i = 0; i < sizeof(substr_pref) / sizeof(substr_pref[0]); i++)
{
- if ((strncasecmp(ent->d_name, substr, len) != 0))
- continue;
- if (strstr(ent->d_name, "unirom"))
+ const char *substr = substr_pref[i];
+ if ((strncasecmp(ent->d_name, substr, strlen(substr)) != 0))
continue;
+ snprintf(path, path_size, "%s%c%s", dirpath, SLASH, ent->d_name);
+ ret = try_use_bios(path, true);
+ if (ret)
+ goto finish;
+ }
+ }
+ // another pass to look for anything fitting, even ps2 bios
+ rewinddir(dir);
+ while ((ent = readdir(dir)))
+ {
+ for (i = 0; i < sizeof(substr_alt) / sizeof(substr_alt[0]); i++)
+ {
+ const char *substr = substr_alt[i];
+ if ((strncasecmp(ent->d_name, substr, strlen(substr)) != 0))
+ continue;
snprintf(path, path_size, "%s%c%s", dirpath, SLASH, ent->d_name);
- ret = try_use_bios(path);
+ ret = try_use_bios(path, false);
if (ret)
- {
- closedir(dir);
- return ret;
- }
+ goto finish;
}
}
+
+
+finish:
closedir(dir);
return ret;
}
for (i = 0; i < sizeof(bios) / sizeof(bios[0]); i++)
{
snprintf(path, sizeof(path), "%s%c%s.bin", dir, SLASH, bios[i]);
- found_bios = try_use_bios(path);
+ found_bios = try_use_bios(path, true);
if (found_bios)
break;
}
#define DEFAULT_PSX_CLOCK_S "50"
#endif
-static const char *bioses[24];
+static const char *bioses[32];
static const char *gpu_plugins[16];
static const char *spu_plugins[16];
static const char *memcards[32];
continue;
snprintf(fname, sizeof(fname), "%s/%s", Config.BiosDir, ent->d_name);
- if (stat(fname, &st) != 0 || st.st_size != 512*1024) {
+ if (stat(fname, &st) != 0
+ || (st.st_size != 512*1024 && st.st_size != 4*1024*1024)) {
printf("bad BIOS file: %s\n", ent->d_name);
continue;
}