#include "psxbios.h"
#include "psxevents.h"
#include "../include/compiler_features.h"
+#include <assert.h>
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+#endif
R3000Acpu *psxCpu = NULL;
#ifdef DRC_DISABLE
#endif
int psxInit() {
+ 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) {
psxCpu = &psxInt;
void psxReset() {
boolean introBypassed = FALSE;
+ boolean oldhle = Config.HLE;
+
psxMemReset();
memset(&psxRegs, 0, sizeof(psxRegs));
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();
if (!Config.HLE) {
psxExecuteBios();
if (psxRegs.pc == 0x80030000 && !Config.SlowBoot) {
- BiosBootBypass();
- introBypassed = TRUE;
+ introBypassed = BiosBootBypass();
}
}
if (Config.HLE || introBypassed)
}
void psxBranchTest() {
- if ((psxRegs.cycle - psxNextsCounter) >= psxNextCounter)
+ if ((psxRegs.cycle - psxRegs.psxNextsCounter) >= psxRegs.psxNextCounter)
psxRcntUpdate();
irq_test(&psxRegs.CP0);
}
}
+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)