drc: update according to interpreter
[pcsx_rearmed.git] / libpcsxcore / new_dynarec / patches / trace_drc_chk
CommitLineData
a151a8d8 1diff --git a/libpcsxcore/new_dynarec/new_dynarec.c b/libpcsxcore/new_dynarec/new_dynarec.c
a5cd72d0 2index 2821d466..b3c7ea2f 100644
a151a8d8 3--- a/libpcsxcore/new_dynarec/new_dynarec.c
4+++ b/libpcsxcore/new_dynarec/new_dynarec.c
a5cd72d0 5@@ -311,7 +311,7 @@ static struct decoded_insn
2330734f 6 int new_dynarec_hacks_old;
7 int new_dynarec_did_compile;
8
9- #define HACK_ENABLED(x) ((new_dynarec_hacks | new_dynarec_hacks_pergame) & (x))
10+ #define HACK_ENABLED(x) ((NDHACK_NO_STALLS) & (x))
11
12 extern int cycle_count; // ... until end of the timeslice, counts -N -> 0
13 extern int last_count; // last absolute target, often = next_interupt
a5cd72d0 14@@ -593,6 +593,7 @@ static int cycle_multiplier_active;
2330734f 15
16 static int CLOCK_ADJUST(int x)
17 {
18+ return x * 2;
55a695d9 19 int m = cycle_multiplier_active;
20 int s = (x >> 31) | 1;
21 return (x * m + s * 50) / 100;
a5cd72d0 22@@ -745,6 +746,9 @@ static void *try_restore_block(u_int vaddr, u_int start_page, u_int end_page)
a151a8d8 23 // This is called from the recompiled JR/JALR instructions
55a695d9 24 static void noinline *get_addr(u_int vaddr, int can_compile)
a151a8d8 25 {
26+#ifdef DRC_DBG
27+printf("get_addr %08x, pc=%08x\n", vaddr, psxRegs.pc);
28+#endif
55a695d9 29 u_int start_page = get_page_prev(vaddr);
30 u_int i, page, end_page = get_page(vaddr);
31 void *found_clean = NULL;
a5cd72d0 32@@ -7143,7 +7147,7 @@ static noinline void pass2_unneeded_regs(int istart,int iend,int r)
a151a8d8 33 // R0 is always unneeded
d1e4ebd9 34 u|=1;
a151a8d8 35 // Save it
36- unneeded_reg[i]=u;
37+ unneeded_reg[i]=1;//u;
a151a8d8 38 gte_unneeded[i]=gte_u;
39 /*
d1e4ebd9 40 printf("ur (%d,%d) %x: ",istart,iend,start+i*4);
a5cd72d0 41@@ -8292,6 +8296,7 @@ static noinline void pass5a_preallocate1(void)
55a695d9 42 static noinline void pass5b_preallocate2(void)
43 {
44 int i, hr;
45+ return;
a151a8d8 46 for(i=0;i<slen-1;i++)
47 {
37387d8b 48 if (!i || !dops[i-1].is_jump)
a5cd72d0 49@@ -9102,6 +9107,11 @@ static int new_recompile_block(u_int addr)
55a695d9 50 load_reg(regs[i].regmap_entry,regs[i].regmap,INVCP);
2330734f 51
52 ds = assemble(i, &regs[i], ccadj[i]);
a151a8d8 53+#ifdef DRC_DBG
37387d8b 54+ // write-out non-consts, consts are likely different because of get_final_value()
55+ if (!dops[i].is_jump)
56+ wb_dirtys(regs[i].regmap,regs[i].dirty&~regs[i].loadedconst);
a151a8d8 57+#endif
2330734f 58
37387d8b 59 if (dops[i].is_ujump)
a151a8d8 60 literal_pool(1024);
a5cd72d0 61@@ -9292,6 +9302,10 @@ static int new_recompile_block(u_int addr)
55a695d9 62
37387d8b 63 #ifdef ASSEM_PRINT
64 fflush(stdout);
65+#endif
a151a8d8 66+#ifdef DRC_DBG
67+printf("new_recompile_block done\n");
68+fflush(stdout);
37387d8b 69 #endif
55a695d9 70 stat_inc(stat_bc_direct);
a151a8d8 71 return 0;
2330734f 72diff --git a/libpcsxcore/new_dynarec/pcsxmem.c b/libpcsxcore/new_dynarec/pcsxmem.c
a5cd72d0 73index 190f8fc7..5feb7a02 100644
2330734f 74--- a/libpcsxcore/new_dynarec/pcsxmem.c
75+++ b/libpcsxcore/new_dynarec/pcsxmem.c
a5cd72d0 76@@ -289,6 +289,8 @@ static void write_biu(u32 value)
2330734f 77 return;
a5cd72d0 78 }
2330734f 79
80+extern u32 handler_cycle;
81+handler_cycle = psxRegs.cycle;
a5cd72d0 82 memprintf("write_biu %08x @%08x %u\n", value, psxRegs.pc, psxRegs.cycle);
83 psxRegs.biuReg = value;
84 }
2330734f 85diff --git a/libpcsxcore/psxcounters.c b/libpcsxcore/psxcounters.c
a5cd72d0 86index 18bd6a4e..bc2eb3f6 100644
2330734f 87--- a/libpcsxcore/psxcounters.c
88+++ b/libpcsxcore/psxcounters.c
a5cd72d0 89@@ -389,9 +389,12 @@ void psxRcntUpdate()
2330734f 90
91 /******************************************************************************/
92
93+extern u32 handler_cycle;
94+
95 void psxRcntWcount( u32 index, u32 value )
96 {
97 verboseLog( 2, "[RCNT %i] wcount: %x\n", index, value );
98+handler_cycle = psxRegs.cycle;
99
100 _psxRcntWcount( index, value );
101 psxRcntSet();
a5cd72d0 102@@ -400,6 +403,7 @@ void psxRcntWcount( u32 index, u32 value )
2330734f 103 void psxRcntWmode( u32 index, u32 value )
104 {
105 verboseLog( 1, "[RCNT %i] wmode: %x\n", index, value );
106+handler_cycle = psxRegs.cycle;
107
108 _psxRcntWmode( index, value );
109 _psxRcntWcount( index, 0 );
a5cd72d0 110@@ -411,6 +415,7 @@ void psxRcntWmode( u32 index, u32 value )
2330734f 111 void psxRcntWtarget( u32 index, u32 value )
112 {
113 verboseLog( 1, "[RCNT %i] wtarget: %x\n", index, value );
114+handler_cycle = psxRegs.cycle;
115
116 rcnts[index].target = value;
117
a5cd72d0 118@@ -423,6 +428,7 @@ void psxRcntWtarget( u32 index, u32 value )
2330734f 119 u32 psxRcntRcount( u32 index )
120 {
121 u32 count;
122+handler_cycle = psxRegs.cycle;
123
124 count = _psxRcntRcount( index );
125
a5cd72d0 126diff --git a/libpcsxcore/psxinterpreter.c b/libpcsxcore/psxinterpreter.c
127index e212d8a9..b98b694e 100644
128--- a/libpcsxcore/psxinterpreter.c
129+++ b/libpcsxcore/psxinterpreter.c
130@@ -237,7 +237,7 @@ static inline void addCycle(psxRegisters *regs)
131 {
132 assert(regs->subCycleStep >= 0x10000);
133 regs->subCycle += regs->subCycleStep;
134- regs->cycle += regs->subCycle >> 16;
135+ regs->cycle += 2; //regs->subCycle >> 16;
136 regs->subCycle &= 0xffff;
137 }
138
139@@ -1341,8 +1341,14 @@ static void intShutdown() {
140
141 // single step (may do several ops in case of a branch or load delay)
142 void execI(psxRegisters *regs) {
143+ extern int last_count;
144+ void do_insn_cmp(void);
145+ printf("execI %08x c %u, ni %u\n", regs->pc, regs->cycle, next_interupt);
146+ last_count = 0;
147 do {
148 execIbp(psxMemRLUT, regs);
149+ if (regs->dloadReg[0] || regs->dloadReg[1])
150+ do_insn_cmp();
151 } while (regs->dloadReg[0] || regs->dloadReg[1]);
152 }
153