From 7b75929b9415646b25d9211975556f5466024a94 Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 11 Jul 2023 01:19:58 +0300 Subject: [PATCH] some openbios support slowboot isn't working yet, doesn't work at all with lightrec, openbios-fastboot doesn't work with ari64 --- frontend/libretro.c | 6 ------ frontend/menu.c | 7 ++++--- libpcsxcore/misc.c | 26 ++++++++++++++++---------- libpcsxcore/misc.h | 3 +++ libpcsxcore/psxcommon.c | 1 + libpcsxcore/psxcommon.h | 4 +--- libpcsxcore/r3000a.c | 15 +++++++++++++-- 7 files changed, 38 insertions(+), 24 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 84baeda8..5acaba8b 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -2708,12 +2708,6 @@ void retro_run(void) { rebootemu = 0; SysReset(); - if (!Config.HLE && !Config.SlowBoot) - { - // skip BIOS logos - psxRegs.pc = psxRegs.GPR.n.ra; - } - return; } print_internal_fps(); diff --git a/frontend/menu.c b/frontend/menu.c index 9ca87c60..f78d3d26 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -2011,9 +2011,6 @@ static int reset_game(void) ClosePlugins(); OpenPlugins(); SysReset(); - if (CheckCdrom() != -1) { - LoadCdrom(); - } return 0; } @@ -2042,13 +2039,17 @@ static int reload_plugins(const char *cdimg) static int run_bios(void) { + boolean origSlowBoot = Config.SlowBoot; + if (bios_sel == 0) return -1; ready_to_go = 0; if (reload_plugins(NULL) != 0) return -1; + Config.SlowBoot = 1; SysReset(); + Config.SlowBoot = origSlowBoot; ready_to_go = 1; return 0; diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c index 57d3959f..022ad6d9 100644 --- a/libpcsxcore/misc.c +++ b/libpcsxcore/misc.c @@ -22,6 +22,7 @@ */ #include +#include #include "misc.h" #include "cdrom.h" #include "mdec.h" @@ -154,7 +155,7 @@ static const unsigned int gpu_data_def[] = { 0x02000000, 0x00000000, 0x01ff03ff, }; -static void fake_bios_gpu_setup(void) +void BiosLikeGPUSetup() { int i; @@ -177,6 +178,14 @@ static void SetBootRegs(u32 pc, u32 gp, u32 sp) psxCpu->Notify(R3000ACPU_NOTIFY_AFTER_LOAD, NULL); } +void BiosBootBypass() { + assert(psxRegs.pc == 0x80030000); + + // skip BIOS logos and region check + psxCpu->Notify(R3000ACPU_NOTIFY_BEFORE_SAVE, NULL); + psxRegs.pc = psxRegs.GPR.n.ra; +} + int LoadCdrom() { EXE_HEADER tmpHead; struct iso_directory_record *dir; @@ -184,15 +193,10 @@ int LoadCdrom() { u8 mdir[4096]; char exename[256]; - // not the best place to do it, but since BIOS boot logo killer - // is just below, do it here - fake_bios_gpu_setup(); - - if (!Config.HLE && !Config.SlowBoot) { - // skip BIOS logos - psxCpu->Notify(R3000ACPU_NOTIFY_BEFORE_SAVE, NULL); - psxRegs.pc = psxRegs.GPR.n.ra; - return 0; + if (!Config.HLE) { + if (!BiosBooted) return 0; // custom BIOS + if (psxRegs.pc != 0x80030000) return 0; // BiosBootBypass'ed + if (Config.SlowBoot) return 0; } time[0] = itob(0); time[1] = itob(2); time[2] = itob(0x10); @@ -210,6 +214,7 @@ int LoadCdrom() { if (GetCdromFile(mdir, time, "SYSTEM.CNF;1") == -1) { // if SYSTEM.CNF is missing, start an existing PSX.EXE if (GetCdromFile(mdir, time, "PSX.EXE;1") == -1) return -1; + strcpy(exename, "PSX.EXE;1"); READTRACK(); } @@ -243,6 +248,7 @@ int LoadCdrom() { memcpy(&tmpHead, buf + 12, sizeof(EXE_HEADER)); + SysPrintf("manual booting '%s'\n", exename); SetBootRegs(SWAP32(tmpHead.pc0), SWAP32(tmpHead.gp0), SWAP32(tmpHead.s_addr)); tmpHead.t_size = SWAP32(tmpHead.t_size); diff --git a/libpcsxcore/misc.h b/libpcsxcore/misc.h index ae3fc81f..da99885a 100644 --- a/libpcsxcore/misc.h +++ b/libpcsxcore/misc.h @@ -56,6 +56,9 @@ typedef struct { extern char CdromId[10]; extern char CdromLabel[33]; +void BiosLikeGPUSetup(); +void BiosBootBypass(); + int LoadCdrom(); int LoadCdromFile(const char *filename, EXE_HEADER *head); int CheckCdrom(); diff --git a/libpcsxcore/psxcommon.c b/libpcsxcore/psxcommon.c index 8313304c..fcc3debf 100644 --- a/libpcsxcore/psxcommon.c +++ b/libpcsxcore/psxcommon.c @@ -26,6 +26,7 @@ PcsxConfig Config; boolean NetOpened = FALSE; +boolean BiosBooted = FALSE; int Log = 0; FILE *emuLog = NULL; diff --git a/libpcsxcore/psxcommon.h b/libpcsxcore/psxcommon.h index b621326c..67a0ae08 100644 --- a/libpcsxcore/psxcommon.h +++ b/libpcsxcore/psxcommon.h @@ -150,13 +150,11 @@ typedef struct { boolean cdr_read_timing; boolean gpu_slow_list_walking; } hacks; -#ifdef _WIN32 - char Lang[256]; -#endif } PcsxConfig; extern PcsxConfig Config; extern boolean NetOpened; +extern boolean BiosBooted; struct PcsxSaveFuncs { void *(*open)(const char *name, const char *mode); diff --git a/libpcsxcore/r3000a.c b/libpcsxcore/r3000a.c index 8b7cfbf7..53a5ebac 100644 --- a/libpcsxcore/r3000a.c +++ b/libpcsxcore/r3000a.c @@ -67,8 +67,14 @@ void psxReset() { psxHwReset(); psxBiosInit(); - if (!Config.HLE) + BiosLikeGPUSetup(); // a bit of a hack but whatever + + BiosBooted = FALSE; + if (!Config.HLE) { psxExecuteBios(); + if (psxRegs.pc == 0x80030000 && !Config.SlowBoot) + BiosBootBypass(); + } #ifdef EMU_LOG EMU_LOG("*BIOS END*\n"); @@ -237,7 +243,12 @@ void psxJumpTest() { } void psxExecuteBios() { - while (psxRegs.pc != 0x80030000) + int i; + for (i = 0; psxRegs.pc != 0x80030000 && i < 5000000; i++) psxCpu->ExecuteBlock(); + if (psxRegs.pc == 0x80030000) + BiosBooted = TRUE; + else + SysPrintf("BIOS boot timeout - custom BIOS?\n"); } -- 2.39.5