X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libpcsxcore%2Fr3000a.c;h=0c29dba733141c9da50a5dba12b340d1c890e879;hb=HEAD;hp=f0a0ddce1c85d8476e06478b39b74e564a4408b3;hpb=9a0a61d27586bfb93aa443cc59d9588d2b9cf992;p=pcsx_rearmed.git diff --git a/libpcsxcore/r3000a.c b/libpcsxcore/r3000a.c index f0a0ddce..cfd1ab09 100644 --- a/libpcsxcore/r3000a.c +++ b/libpcsxcore/r3000a.c @@ -29,6 +29,11 @@ #include "psxbios.h" #include "psxevents.h" #include "../include/compiler_features.h" +#include + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) +#endif R3000Acpu *psxCpu = NULL; #ifdef DRC_DISABLE @@ -36,7 +41,8 @@ psxRegisters psxRegs; #endif int psxInit() { - SysPrintf(_("Running PCSX Version %s (%s).\n"), PCSX_VERSION, __DATE__); + assert(PSXINT_COUNT <= ARRAY_SIZE(psxRegs.intCycle)); + assert(ARRAY_SIZE(psxRegs.intCycle) == ARRAY_SIZE(psxRegs.event_cycles)); #ifndef DRC_DISABLE if (Config.Cpu == CPU_INTERPRETER) { @@ -56,6 +62,8 @@ int psxInit() { void psxReset() { boolean introBypassed = FALSE; + boolean oldhle = Config.HLE; + psxMemReset(); memset(&psxRegs, 0, sizeof(psxRegs)); @@ -69,6 +77,11 @@ void psxReset() { psxRegs.CP0.n.SR &= ~(1u << 22); // RAM exception vector } + if (Config.HLE != oldhle) { + // at least ari64 drc compiles differently so hard reset + psxCpu->Shutdown(); + psxCpu->Init(); + } psxCpu->ApplyConfig(); psxCpu->Reset(); @@ -78,8 +91,7 @@ void psxReset() { if (!Config.HLE) { psxExecuteBios(); if (psxRegs.pc == 0x80030000 && !Config.SlowBoot) { - BiosBootBypass(); - introBypassed = TRUE; + introBypassed = BiosBootBypass(); } } if (Config.HLE || introBypassed) @@ -129,7 +141,7 @@ void psxException(u32 cause, enum R3000Abdt bdt, psxCP0Regs *cp0) { } void psxBranchTest() { - if ((psxRegs.cycle - psxNextsCounter) >= psxNextCounter) + if ((psxRegs.cycle - psxRegs.psxNextsCounter) >= psxRegs.psxNextCounter) psxRcntUpdate(); irq_test(&psxRegs.CP0); @@ -169,11 +181,15 @@ void psxJumpTest() { } } +int psxExecuteBiosEnded(void) { + return (psxRegs.pc & 0xff800000) == 0x80000000; +} + void psxExecuteBios() { int i; for (i = 0; i < 5000000; i++) { - psxCpu->ExecuteBlock(EXEC_CALLER_BOOT); - if ((psxRegs.pc & 0xff800000) == 0x80000000) + psxCpu->ExecuteBlock(&psxRegs, EXEC_CALLER_BOOT); + if (psxExecuteBiosEnded()) break; } if (psxRegs.pc != 0x80030000)