psxRegs.interrupt |= 0x4; \
psxRegs.intCycle[2 + 1] = eCycle; \
psxRegs.intCycle[2] = psxRegs.cycle; \
- new_dyna_set_event(0, psxRegs.cycle + eCycle); \
+ new_dyna_set_event(0, eCycle); \
}
#define CDREAD_INT(eCycle) { \
psxRegs.interrupt |= 0x40000; \
psxRegs.intCycle[2 + 16 + 1] = eCycle; \
psxRegs.intCycle[2 + 16] = psxRegs.cycle; \
- new_dyna_set_event(2, psxRegs.cycle + eCycle); \
+ new_dyna_set_event(2, eCycle); \
}
#define StartReading(type, eCycle) { \
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;
+
+#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
+}
- evprintf("ari64_gen_interupt\n");
- evprintf(" +ge %08x, %d->%d\n", psxRegs.pc, psxRegs.cycle, next_interupt);
+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 */
}
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)
psxRegs.interrupt |= 0x01000000; \
psxRegs.intCycle[3 + 24 + 1] = eCycle; \
psxRegs.intCycle[3 + 24] = psxRegs.cycle; \
- new_dyna_set_event(3, psxRegs.cycle + eCycle); \
+ new_dyna_set_event(3, eCycle); \
}
#define SPUDMA_INT(eCycle) { \
psxRegs.interrupt |= 0x04000000; \
psxRegs.intCycle[1 + 24 + 1] = eCycle; \
psxRegs.intCycle[1 + 24] = psxRegs.cycle; \
- new_dyna_set_event(5, psxRegs.cycle + eCycle); \
+ new_dyna_set_event(5, eCycle); \
}
#define MDECOUTDMA_INT(eCycle) { \
psxRegs.interrupt |= 0x02000000; \
psxRegs.intCycle[5 + 24 + 1] = eCycle; \
psxRegs.intCycle[5 + 24] = psxRegs.cycle; \
- new_dyna_set_event(4, psxRegs.cycle + eCycle); \
+ new_dyna_set_event(4, eCycle); \
}
void psxDma2(u32 madr, u32 bcr, u32 chcr);
extern u32 next_interupt;
#define new_dyna_set_event(e, c) { \
- u32 c_ = c; \
- event_cycles[e] = c_; \
- if (c_ < next_interupt) { \
- /*printf("%u: next_interupt %d -> %d\n", psxRegs.cycle, \
- next_interupt - psxRegs.cycle, c_ - psxRegs.cycle);*/ \
- next_interupt = c_; \
+ s32 c_ = c; \
+ u32 abs_ = psxRegs.cycle + c_; \
+ s32 odi_ = next_interupt - psxRegs.cycle; \
+ event_cycles[e] = abs_; \
+ if (c_ < odi_) { \
+ /*printf("%u: next_interupt %d -> %d (%u)\n", psxRegs.cycle, odi_, c_, abs_);*/ \
+ next_interupt = abs_; \
} \
}