X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=libpcsxcore%2Fnew_dynarec%2Femu_if.c;h=9b20e5ca95404cdcf40a6827e39bcc5bc876eb26;hp=3df83e434ef4b4bfc61312e5981452bbc44bf47c;hb=4b421010647aba998fe2ebfc7d6f226623d47954;hpb=ae602c19f527fbc1f44cdb744cf824d04b8eceb1 diff --git a/libpcsxcore/new_dynarec/emu_if.c b/libpcsxcore/new_dynarec/emu_if.c index 3df83e43..9b20e5ca 100644 --- a/libpcsxcore/new_dynarec/emu_if.c +++ b/libpcsxcore/new_dynarec/emu_if.c @@ -25,30 +25,47 @@ void MTC0_() pending_exception = 1; /* FIXME? */ } -void gen_interupt() +static void schedule_timeslice(void) { - u32 c, min; - int i; + u32 i, c = psxRegs.cycle; + s32 min, dif; + + min = psxNextsCounter + psxNextCounter - c; + for (i = 0; i < ARRAY_SIZE(event_cycles); i++) { + dif = event_cycles[i] - c; + //evprintf(" ev %d\n", dif); + if (0 < dif && dif < min) + min = dif; + } + next_interupt = c + min; - evprintf("ari64_gen_interupt\n"); - evprintf(" +ge %08x, %d->%d\n", psxRegs.pc, psxRegs.cycle, next_interupt); +#if 0 + static u32 cnt, last_cycle; + static u64 sum; + if (last_cycle) { + cnt++; + sum += psxRegs.cycle - last_cycle; + if ((cnt & 0xff) == 0) + printf("%u\n", (u32)(sum / cnt)); + } + last_cycle = psxRegs.cycle; +#endif +} + +void gen_interupt() +{ + //evprintf("ari64_gen_interupt\n"); + evprintf(" +ge %08x, %u->%u\n", psxRegs.pc, psxRegs.cycle, next_interupt); #ifdef DRC_DBG psxRegs.cycle += 2; #endif psxBranchTest(); - min = psxNextsCounter + psxNextCounter; - for (i = 0; i < ARRAY_SIZE(event_cycles); i++) { - c = event_cycles[i]; - evprintf(" ev %d\n", c - psxRegs.cycle); - if (psxRegs.cycle < c && c < min) - min = c; - } - next_interupt = min; + schedule_timeslice(); - //next_interupt = psxNextsCounter + psxNextCounter; - evprintf(" -ge %08x, %d->%d\n", psxRegs.pc, psxRegs.cycle, next_interupt); + evprintf(" -ge %08x, %u->%u (%d)\n", psxRegs.pc, psxRegs.cycle, + next_interupt, next_interupt - psxRegs.cycle); pending_exception = 1; /* FIXME */ } @@ -143,22 +160,42 @@ static int ari64_init() static void ari64_reset() { - /* hmh */ printf("ari64_reset\n"); + invalidate_all_pages(); + pending_exception = 1; } static void ari64_execute() { - next_interupt = psxNextsCounter + psxNextCounter; + schedule_timeslice(); + + evprintf("ari64_execute %08x, %u->%u (%d)\n", psxRegs.pc, + psxRegs.cycle, next_interupt, next_interupt - psxRegs.cycle); - evprintf("psxNextsCounter %d, psxNextCounter %d\n", psxNextsCounter, psxNextCounter); - evprintf("ari64_execute %08x, %d->%d\n", psxRegs.pc, psxRegs.cycle, next_interupt); new_dyna_start(); - evprintf("ari64_execute end %08x, %d->%d\n", psxRegs.pc, psxRegs.cycle, next_interupt); + + evprintf("ari64_execute end %08x, %u->%u (%d)\n", psxRegs.pc, + psxRegs.cycle, next_interupt, next_interupt - psxRegs.cycle); } -static void ari64_clear(u32 Addr, u32 Size) +static void ari64_clear(u32 addr, u32 size) { + u32 start, end; + + evprintf("ari64_clear %08x %04x\n", addr, size); + + /* check for RAM mirrors */ + if ((start & ~0xe0000000) < 0x200000) { + start &= ~0xe0000000; + start |= 0x80000000; + } + + start = addr >> 12; + end = (addr + size) >> 12; + + for (; start <= end; start++) + if (!invalid_code[start]) + invalidate_block(start); } static void ari64_shutdown()