X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=libpcsxcore%2Fnew_dynarec%2Femu_if.c;h=22db5d118480955096706b57042017aefb88ebbc;hb=HEAD;hp=f71358729cea3fdc8b2e68bf89797bd559db4d61;hpb=45a1e89f9b213953b102c6217c97a2f8828f1a57;p=pcsx_rearmed.git diff --git a/libpcsxcore/new_dynarec/emu_if.c b/libpcsxcore/new_dynarec/emu_if.c index f7135872..6c1b48c5 100644 --- a/libpcsxcore/new_dynarec/emu_if.c +++ b/libpcsxcore/new_dynarec/emu_if.c @@ -9,9 +9,10 @@ #include "emu_if.h" #include "pcsxmem.h" -#include "events.h" #include "../psxhle.h" #include "../psxinterpreter.h" +#include "../psxcounters.h" +#include "../psxevents.h" #include "../r3000a.h" #include "../gte_arm.h" #include "../gte_neon.h" @@ -28,7 +29,9 @@ void pcsx_mtc0(u32 reg, u32 val) evprintf("MTC0 %d #%x @%08x %u\n", reg, val, psxRegs.pc, psxRegs.cycle); MTC0(&psxRegs, reg, val); gen_interupt(&psxRegs.CP0); - if (psxRegs.CP0.n.Cause & psxRegs.CP0.n.Status & 0x0300) // possible sw irq + + //if (psxRegs.CP0.n.Cause & psxRegs.CP0.n.SR & 0x0300) // possible sw irq + if ((psxRegs.pc & 0x803ffeff) == 0x80000080) pending_exception = 1; } @@ -38,19 +41,6 @@ void pcsx_mtc0_ds(u32 reg, u32 val) MTC0(&psxRegs, reg, val); } -static void new_dyna_restore(void) -{ - int i; - for (i = 0; i < PSXINT_COUNT; i++) - event_cycles[i] = psxRegs.intCycle[i].sCycle + psxRegs.intCycle[i].cycle; - - event_cycles[PSXINT_RCNT] = psxNextsCounter + psxNextCounter; - psxRegs.interrupt |= 1 << PSXINT_RCNT; - psxRegs.interrupt &= (1 << PSXINT_COUNT) - 1; - - new_dyna_pcsx_mem_load_state(); -} - void new_dyna_freeze(void *f, int mode) { const char header_save[8] = "ariblks"; @@ -69,7 +59,7 @@ void new_dyna_freeze(void *f, int mode) SaveFuncs.write(f, addrs, size); } else { - new_dyna_restore(); + new_dyna_pcsx_mem_load_state(); bytes = SaveFuncs.read(f, header, sizeof(header)); if (bytes != sizeof(header) || strcmp(header, header_save)) { @@ -238,7 +228,7 @@ static void ari64_reset() { new_dyna_pcsx_mem_reset(); new_dynarec_invalidate_all_pages(); - new_dyna_restore(); + new_dyna_pcsx_mem_load_state(); pending_exception = 1; } @@ -246,8 +236,6 @@ static void ari64_reset() // (HLE softcall exit and BIOS fastboot end) static void ari64_execute_until() { - schedule_timeslice(); - evprintf("ari64_execute %08x, %u->%u (%d)\n", psxRegs.pc, psxRegs.cycle, next_interupt, next_interupt - psxRegs.cycle); @@ -260,11 +248,24 @@ static void ari64_execute_until() static void ari64_execute() { while (!stop) { + schedule_timeslice(); ari64_execute_until(); evprintf("drc left @%08x\n", psxRegs.pc); } } +static void ari64_execute_block(enum blockExecCaller caller) +{ + if (caller == EXEC_CALLER_BOOT) + stop++; + + next_interupt = psxRegs.cycle + 1; + ari64_execute_until(); + + if (caller == EXEC_CALLER_BOOT) + stop--; +} + static void ari64_clear(u32 addr, u32 size) { size *= 4; /* PCSX uses DMA units (words) */ @@ -284,7 +285,9 @@ static void ari64_notify(enum R3000Anote note, void *data) { case R3000ACPU_NOTIFY_BEFORE_SAVE: break; case R3000ACPU_NOTIFY_AFTER_LOAD: - ari64_reset(); + if (data == NULL) + ari64_reset(); + psxInt.Notify(note, data); break; } } @@ -315,7 +318,7 @@ R3000Acpu psxRec = { ari64_init, ari64_reset, ari64_execute, - ari64_execute_until, + ari64_execute_block, ari64_clear, ari64_notify, ari64_apply_config, @@ -500,7 +503,9 @@ void do_insn_cmp(void) static u32 handler_cycle_intr; u32 *allregs_p = (void *)&psxRegs; u32 *allregs_e = (void *)&rregs; + u32 badregs_mask = 0; static u32 ppc, failcount; + static u32 badregs_mask_prev; int i, ret, bad = 0, fatal = 0, which_event = -1; u32 ev_cycles = 0; u8 code; @@ -580,18 +585,24 @@ void do_insn_cmp(void) if (allregs_p[i] != allregs_e[i]) { miss_log_add(i, allregs_p[i], allregs_e[i], psxRegs.pc, psxRegs.cycle); bad++; - if (i > 32+2) + if (i >= 32) fatal = 1; + else + badregs_mask |= 1u << i; } } - if (!fatal && psxRegs.pc == rregs.pc && bad < 6 && failcount < 32) { + if (badregs_mask_prev & badregs_mask) + failcount++; + else + failcount = 0; + + if (!fatal && psxRegs.pc == rregs.pc && bad < 6 && failcount < 24) { static int last_mcycle; if (last_mcycle != psxRegs.cycle >> 20) { printf("%u\n", psxRegs.cycle); last_mcycle = psxRegs.cycle >> 20; } - failcount++; goto ok; } @@ -610,6 +621,7 @@ void do_insn_cmp(void) ok: //psxRegs.cycle = rregs.cycle + 2; // sync timing ppc = psxRegs.pc; + badregs_mask_prev = badregs_mask; } #endif