From ab945e9e1baba5fbb691444b79b36930afb2a179 Mon Sep 17 00:00:00 2001 From: neonloop Date: Wed, 31 Mar 2021 16:46:23 +0000 Subject: Adds built-in BIOS support If an official BIOS exists in the right place, it will be used. Otherwise, the built-in BIOS will be used. --- frontend/main.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'frontend') diff --git a/frontend/main.c b/frontend/main.c index 35cb710..fb05708 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -296,6 +296,7 @@ fail: int main(int argc, char *argv[]) { + bool bios_loaded = false; char bios_filename[MAXPATHLEN]; char filename[MAXPATHLEN]; char path[MAXPATHLEN]; @@ -316,11 +317,30 @@ int main(int argc, char *argv[]) filename[0] = 0; } - getcwd(bios_filename, MAXPATHLEN); - strncat(bios_filename, "/gba_bios.bin", MAXPATHLEN - strlen(bios_filename)); - if (load_bios(bios_filename)) { - fprintf(stderr, "Could not load BIOS image file %s.\n", bios_filename); - return -1; + if (selected_bios == auto_detect || selected_bios == official_bios) { + bios_loaded = true; + getcwd(bios_filename, MAXPATHLEN); + strncat(bios_filename, "/gba_bios.bin", MAXPATHLEN - strlen(bios_filename)); + + if (load_bios(bios_filename)) { + if (selected_bios == official_bios) + printf("Could not load BIOS image file\n"); + bios_loaded = false; + } + + if (bios_loaded && bios_rom[0] != 0x18) { + if (selected_bios == official_bios) + printf("BIOS image seems incorrect\n"); + bios_loaded = false; + } + } + + if (bios_loaded) { + printf("Using official BIOS\n"); + } else { + /* Load the built-in BIOS */ + memcpy(bios_rom, open_gba_bios_rom, sizeof(bios_rom)); + printf("Using built-in BIOS\n"); } plat_get_root_dir(save_path, 512); @@ -345,7 +365,7 @@ int main(int argc, char *argv[]) init_sound(1); menu_init(); - #if defined(HAVE_DYNAREC) +#if defined(HAVE_DYNAREC) if (dynarec_enable) { #ifdef HAVE_MMAP -- cgit v1.2.3