e98a48e7f94d9ce0c5ba807773f74e9a6792784b
[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 f1005db..ebd1d4f 100644
3 --- a/libpcsxcore/new_dynarec/new_dynarec.c
4 +++ b/libpcsxcore/new_dynarec/new_dynarec.c
5 @@ -235,7 +235,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 @@ -471,6 +471,7 @@ int cycle_multiplier_old;
15  
16  static int CLOCK_ADJUST(int x)
17  {
18 +  return x * 2;
19    int m = cycle_multiplier_override && cycle_multiplier == CYCLE_MULT_DEFAULT
20          ? cycle_multiplier_override : cycle_multiplier;
21    int s=(x>>31)|1;
22 @@ -522,6 +523,9 @@ static int doesnt_expire_soon(void *tcaddr)
23  // This is called from the recompiled JR/JALR instructions
24  void noinline *get_addr(u_int vaddr)
25  {
26 +#ifdef DRC_DBG
27 +printf("get_addr %08x, pc=%08x\n", vaddr, psxRegs.pc);
28 +#endif
29    u_int page=get_page(vaddr);
30    u_int vpage=get_vpage(vaddr);
31    struct ll_entry *head;
32 @@ -6248,7 +6252,7 @@ void unneeded_registers(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 @@ -8794,6 +8798,7 @@ int new_recompile_block(u_int addr)
42  
43    // This allocates registers (if possible) one instruction prior
44    // to use, which can avoid a load-use penalty on certain CPUs.
45 +#if 0
46    for(i=0;i<slen-1;i++)
47    {
48      if (!i || !dops[i-1].is_jump)
49 @@ -8950,6 +8955,7 @@ int new_recompile_block(u_int addr)
50        }
51      }
52    }
53 +#endif
54  
55    /* Pass 6 - Optimize clean/dirty state */
56    clean_registers(0,slen-1,1);
57 @@ -9204,6 +9210,11 @@ int new_recompile_block(u_int addr)
58          load_regs(regs[i].regmap_entry,regs[i].regmap,INVCP,INVCP);
59  
60        ds = assemble(i, &regs[i], ccadj[i]);
61 +#ifdef DRC_DBG
62 +       // write-out non-consts, consts are likely different because of get_final_value()
63 +       if (!dops[i].is_jump)
64 +         wb_dirtys(regs[i].regmap,regs[i].dirty&~regs[i].loadedconst);
65 +#endif
66  
67        if (dops[i].is_ujump)
68          literal_pool(1024);
69 @@ -9439,6 +9450,10 @@ int new_recompile_block(u_int addr)
70    }
71  #ifdef ASSEM_PRINT
72    fflush(stdout);
73 +#endif
74 +#ifdef DRC_DBG
75 +printf("new_recompile_block done\n");
76 +fflush(stdout);
77  #endif
78    return 0;
79  }
80 diff --git a/libpcsxcore/new_dynarec/pcsxmem.c b/libpcsxcore/new_dynarec/pcsxmem.c
81 index bb471b6..8f68a3b 100644
82 --- a/libpcsxcore/new_dynarec/pcsxmem.c
83 +++ b/libpcsxcore/new_dynarec/pcsxmem.c
84 @@ -272,6 +272,8 @@ static void write_biu(u32 value)
85         if (address != 0xfffe0130)
86                 return;
87  
88 +extern u32 handler_cycle;
89 +handler_cycle = psxRegs.cycle;
90         switch (value) {
91         case 0x800: case 0x804:
92                 unmap_ram_write();
93 diff --git a/libpcsxcore/psxcounters.c b/libpcsxcore/psxcounters.c
94 index b2cc07b..f916580 100644
95 --- a/libpcsxcore/psxcounters.c
96 +++ b/libpcsxcore/psxcounters.c
97 @@ -378,9 +378,12 @@ void psxRcntUpdate()
98  
99  /******************************************************************************/
100  
101 +extern u32 handler_cycle;
102 +
103  void psxRcntWcount( u32 index, u32 value )
104  {
105      verboseLog( 2, "[RCNT %i] wcount: %x\n", index, value );
106 +handler_cycle = psxRegs.cycle;
107  
108      _psxRcntWcount( index, value );
109      psxRcntSet();
110 @@ -389,6 +392,7 @@ void psxRcntWcount( u32 index, u32 value )
111  void psxRcntWmode( u32 index, u32 value )
112  {
113      verboseLog( 1, "[RCNT %i] wmode: %x\n", index, value );
114 +handler_cycle = psxRegs.cycle;
115  
116      _psxRcntWmode( index, value );
117      _psxRcntWcount( index, 0 );
118 @@ -400,6 +404,7 @@ void psxRcntWmode( u32 index, u32 value )
119  void psxRcntWtarget( u32 index, u32 value )
120  {
121      verboseLog( 1, "[RCNT %i] wtarget: %x\n", index, value );
122 +handler_cycle = psxRegs.cycle;
123  
124      rcnts[index].target = value;
125  
126 @@ -412,6 +417,7 @@ void psxRcntWtarget( u32 index, u32 value )
127  u32 psxRcntRcount( u32 index )
128  {
129      u32 count;
130 +handler_cycle = psxRegs.cycle;
131  
132      count = _psxRcntRcount( index );
133