414c22156345a64fe9021d0a4e3ed44c1bf3bef4
[pcsx_rearmed.git] / libpcsxcore / new_dynarec / patches / trace_drc_chk
1 diff --git a/libpcsxcore/new_dynarec/new_dynarec.c b/libpcsxcore/new_dynarec/new_dynarec.c
2 index b160a4a..0d91999 100644
3 --- a/libpcsxcore/new_dynarec/new_dynarec.c
4 +++ b/libpcsxcore/new_dynarec/new_dynarec.c
5 @@ -285,7 +285,7 @@ static struct decoded_insn
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
14 @@ -532,6 +532,7 @@ static int cycle_multiplier_active;
15  
16  static int CLOCK_ADJUST(int x)
17  {
18 +  return x * 2;
19    int m = cycle_multiplier_active;
20    int s = (x >> 31) | 1;
21    return (x * m + s * 50) / 100;
22 @@ -662,6 +663,9 @@ static void *try_restore_block(u_int vaddr, u_int start_page, u_int end_page)
23  // This is called from the recompiled JR/JALR instructions
24  static void noinline *get_addr(u_int vaddr, int can_compile)
25  {
26 +#ifdef DRC_DBG
27 +printf("get_addr %08x, pc=%08x\n", vaddr, psxRegs.pc);
28 +#endif
29    u_int start_page = get_page_prev(vaddr);
30    u_int i, page, end_page = get_page(vaddr);
31    void *found_clean = NULL;
32 @@ -7046,7 +7050,7 @@ static noinline void pass2_unneeded_regs(int istart,int iend,int r)
33      // R0 is always unneeded
34      u|=1;
35      // Save it
36 -    unneeded_reg[i]=u;
37 +    unneeded_reg[i]=1;//u;
38      gte_unneeded[i]=gte_u;
39      /*
40      printf("ur (%d,%d) %x: ",istart,iend,start+i*4);
41 @@ -8236,6 +8240,7 @@ static noinline void pass5a_preallocate1(void)
42  static noinline void pass5b_preallocate2(void)
43  {
44    int i, hr;
45 + return;
46    for(i=0;i<slen-1;i++)
47    {
48      if (!i || !dops[i-1].is_jump)
49 @@ -9045,6 +9050,11 @@ static int new_recompile_block(u_int addr)
50          load_reg(regs[i].regmap_entry,regs[i].regmap,INVCP);
51  
52        ds = assemble(i, &regs[i], ccadj[i]);
53 +#ifdef DRC_DBG
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);
57 +#endif
58  
59        if (dops[i].is_ujump)
60          literal_pool(1024);
61 @@ -9236,6 +9246,10 @@ static int new_recompile_block(u_int addr)
62  
63  #ifdef ASSEM_PRINT
64    fflush(stdout);
65 +#endif
66 +#ifdef DRC_DBG
67 +printf("new_recompile_block done\n");
68 +fflush(stdout);
69  #endif
70    stat_inc(stat_bc_direct);
71    return 0;
72 diff --git a/libpcsxcore/new_dynarec/pcsxmem.c b/libpcsxcore/new_dynarec/pcsxmem.c
73 index bb471b6..8f68a3b 100644
74 --- a/libpcsxcore/new_dynarec/pcsxmem.c
75 +++ b/libpcsxcore/new_dynarec/pcsxmem.c
76 @@ -272,6 +272,8 @@ static void write_biu(u32 value)
77         if (address != 0xfffe0130)
78                 return;
79  
80 +extern u32 handler_cycle;
81 +handler_cycle = psxRegs.cycle;
82         switch (value) {
83         case 0x800: case 0x804:
84                 unmap_ram_write();
85 diff --git a/libpcsxcore/psxcounters.c b/libpcsxcore/psxcounters.c
86 index ff0efbc..4459644 100644
87 --- a/libpcsxcore/psxcounters.c
88 +++ b/libpcsxcore/psxcounters.c
89 @@ -379,9 +379,12 @@ void psxRcntUpdate()
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();
102 @@ -390,6 +393,7 @@ void psxRcntWcount( u32 index, u32 value )
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 );
110 @@ -401,6 +405,7 @@ void psxRcntWmode( u32 index, u32 value )
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  
118 @@ -413,6 +418,7 @@ void psxRcntWtarget( u32 index, u32 value )
119  u32 psxRcntRcount( u32 index )
120  {
121      u32 count;
122 +handler_cycle = psxRegs.cycle;
123  
124      count = _psxRcntRcount( index );
125  
126