aboutsummaryrefslogtreecommitdiff
path: root/libpcsxcore
diff options
context:
space:
mode:
authornotaz2010-12-07 00:06:21 +0200
committernotaz2010-12-14 15:24:50 +0200
commitae602c19f527fbc1f44cdb744cf824d04b8eceb1 (patch)
tree000d4051fb09ea2d8f4c35344dabbd40cc54213d /libpcsxcore
parent5067f3414032416f7112cd771ebe0a7aaf9eb7bf (diff)
downloadpcsx_rearmed-ae602c19f527fbc1f44cdb744cf824d04b8eceb1.tar.gz
pcsx_rearmed-ae602c19f527fbc1f44cdb744cf824d04b8eceb1.tar.bz2
pcsx_rearmed-ae602c19f527fbc1f44cdb744cf824d04b8eceb1.zip
improve event handling (still has problems though)
Diffstat (limited to 'libpcsxcore')
-rw-r--r--libpcsxcore/cdrom.c8
-rw-r--r--libpcsxcore/new_dynarec/emu_if.c21
-rw-r--r--libpcsxcore/psxdma.h3
-rw-r--r--libpcsxcore/psxmem.h13
-rw-r--r--libpcsxcore/sio.c1
5 files changed, 41 insertions, 5 deletions
diff --git a/libpcsxcore/cdrom.c b/libpcsxcore/cdrom.c
index 92e4b7f..0211865 100644
--- a/libpcsxcore/cdrom.c
+++ b/libpcsxcore/cdrom.c
@@ -94,12 +94,16 @@ static struct SubQ *subq;
#define CDR_INT(eCycle) { \
psxRegs.interrupt |= 0x4; \
psxRegs.intCycle[2 + 1] = eCycle; \
- psxRegs.intCycle[2] = psxRegs.cycle; }
+ psxRegs.intCycle[2] = psxRegs.cycle; \
+ new_dyna_set_event(0, psxRegs.cycle + eCycle); \
+}
#define CDREAD_INT(eCycle) { \
psxRegs.interrupt |= 0x40000; \
psxRegs.intCycle[2 + 16 + 1] = eCycle; \
- psxRegs.intCycle[2 + 16] = psxRegs.cycle; }
+ psxRegs.intCycle[2 + 16] = psxRegs.cycle; \
+ new_dyna_set_event(2, psxRegs.cycle + eCycle); \
+}
#define StartReading(type, eCycle) { \
cdr.Reading = type; \
diff --git a/libpcsxcore/new_dynarec/emu_if.c b/libpcsxcore/new_dynarec/emu_if.c
index 2560eb3..3df83e4 100644
--- a/libpcsxcore/new_dynarec/emu_if.c
+++ b/libpcsxcore/new_dynarec/emu_if.c
@@ -6,12 +6,15 @@
#include "../psxmem.h"
#include "../psxhle.h"
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+
//#define memprintf printf
#define memprintf(...)
//#define evprintf printf
#define evprintf(...)
char invalid_code[0x100000];
+u32 event_cycles[6];
void MTC0_()
{
@@ -24,6 +27,9 @@ void MTC0_()
void gen_interupt()
{
+ u32 c, min;
+ int i;
+
evprintf("ari64_gen_interupt\n");
evprintf(" +ge %08x, %d->%d\n", psxRegs.pc, psxRegs.cycle, next_interupt);
#ifdef DRC_DBG
@@ -32,7 +38,16 @@ void gen_interupt()
psxBranchTest();
- next_interupt = psxNextsCounter + psxNextCounter;
+ 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;
+
+ //next_interupt = psxNextsCounter + psxNextCounter;
evprintf(" -ge %08x, %d->%d\n", psxRegs.pc, psxRegs.cycle, next_interupt);
pending_exception = 1; /* FIXME */
@@ -110,7 +125,7 @@ static int ari64_init()
new_dynarec_init();
- for (i = 0; i < sizeof(readmem) / sizeof(readmem[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(readmem); i++) {
readmemb[i] = read_mem8;
readmemh[i] = read_mem16;
readmem[i] = read_mem32;
@@ -119,7 +134,7 @@ static int ari64_init()
writemem[i] = write_mem32;
}
- for (i = 0; i < sizeof(gte_handlers) / sizeof(gte_handlers[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(gte_handlers); i++)
if (psxCP2[i] != psxNULL)
gte_handlers[i] = psxCP2[i];
diff --git a/libpcsxcore/psxdma.h b/libpcsxcore/psxdma.h
index 0db6533..71a3eb0 100644
--- a/libpcsxcore/psxdma.h
+++ b/libpcsxcore/psxdma.h
@@ -33,18 +33,21 @@ extern "C" {
psxRegs.interrupt |= 0x01000000; \
psxRegs.intCycle[3 + 24 + 1] = eCycle; \
psxRegs.intCycle[3 + 24] = psxRegs.cycle; \
+ new_dyna_set_event(3, psxRegs.cycle + 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); \
}
#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); \
}
void psxDma2(u32 madr, u32 bcr, u32 chcr);
diff --git a/libpcsxcore/psxmem.h b/libpcsxcore/psxmem.h
index d9fee00..222e6fb 100644
--- a/libpcsxcore/psxmem.h
+++ b/libpcsxcore/psxmem.h
@@ -138,6 +138,19 @@ void psxMemWrite16(u32 mem, u16 value);
void psxMemWrite32(u32 mem, u32 value);
void *psxMemPointer(u32 mem);
+extern u32 event_cycles[6];
+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_; \
+ } \
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/libpcsxcore/sio.c b/libpcsxcore/sio.c
index 977c71d..230bfed 100644
--- a/libpcsxcore/sio.c
+++ b/libpcsxcore/sio.c
@@ -73,6 +73,7 @@ static inline void SIO_INT() {
psxRegs.interrupt |= 0x80;
psxRegs.intCycle[7 + 1] = 400;
psxRegs.intCycle[7] = psxRegs.cycle;
+ new_dyna_set_event(1, psxRegs.cycle + 400);
}
}