Merge pull request #292 from pcercuei/dfsound-big-endian
[pcsx_rearmed.git] / libpcsxcore / new_dynarec / new_dynarec.c
index b9e7c14..2673a6e 100644 (file)
@@ -592,8 +592,6 @@ static void do_clear_cache(void)
 
 #define NO_CYCLE_PENALTY_THR 12
 
-int cycle_multiplier = CYCLE_MULT_DEFAULT; // 100 for 1.0
-int cycle_multiplier_override;
 int cycle_multiplier_old;
 static int cycle_multiplier_active;
 
@@ -785,10 +783,10 @@ static void noinline *get_addr(u_int vaddr, int can_compile)
     return ndrc_get_addr_ht(vaddr);
 
   // generate an address error
-  Status|=2;
-  Cause=(vaddr<<31)|(4<<2);
-  EPC=(vaddr&1)?vaddr-5:vaddr;
-  BadVAddr=(vaddr&~1);
+  psxRegs.CP0.n.Status |= 2;
+  psxRegs.CP0.n.Cause = (vaddr<<31) | (4<<2);
+  psxRegs.CP0.n.EPC = (vaddr&1) ? vaddr-5 : vaddr;
+  psxRegs.CP0.n.BadVAddr = vaddr & ~1;
   return ndrc_get_addr_ht(0x80000080);
 }
 
@@ -3179,10 +3177,10 @@ static void do_invstub(int n)
 
   set_jump_target(stubs[n].addr, out);
   save_regs(reglist);
-  emit_readword(&inv_code_start, 2);
-  emit_readword(&inv_code_end, 3);
   if (addrr != 0 || ofs_start != 0)
     emit_addimm(addrr, ofs_start, 0);
+  emit_readword(&inv_code_start, 2);
+  emit_readword(&inv_code_end, 3);
   if (len != 0)
     emit_addimm(0, len + 4, (rightr = 1));
   emit_cmp(0, 2);
@@ -3502,7 +3500,7 @@ static void cop0_assemble(int i, const struct regstat *i_regs, int ccadj_)
       emit_loadreg(CCREG,HOST_CCREG); // TODO: do proper reg alloc
       emit_add(HOST_CCREG,HOST_TEMPREG,HOST_CCREG);
       emit_addimm(HOST_CCREG,ccadj_,HOST_CCREG);
-      emit_writeword(HOST_CCREG,&Count);
+      emit_writeword(HOST_CCREG,&psxRegs.cycle);
     }
     // What a mess.  The status register (12) can enable interrupts,
     // so needs a special case to handle a pending interrupt.
@@ -3534,7 +3532,7 @@ static void cop0_assemble(int i, const struct regstat *i_regs, int ccadj_)
     emit_movimm(copr,0);
     emit_far_call(pcsx_mtc0);
     if(copr==9||copr==11||copr==12||copr==13) {
-      emit_readword(&Count,HOST_CCREG);
+      emit_readword(&psxRegs.cycle,HOST_CCREG);
       emit_readword(&next_interupt,HOST_TEMPREG);
       emit_addimm(HOST_CCREG,-ccadj_,HOST_CCREG);
       emit_sub(HOST_CCREG,HOST_TEMPREG,HOST_CCREG);
@@ -3560,11 +3558,11 @@ static void cop0_assemble(int i, const struct regstat *i_regs, int ccadj_)
     assert(dops[i].opcode2==0x10);
     //if((source[i]&0x3f)==0x10) // RFE
     {
-      emit_readword(&Status,0);
+      emit_readword(&psxRegs.CP0.n.Status,0);
       emit_andimm(0,0x3c,1);
       emit_andimm(0,~0xf,0);
       emit_orrshr_imm(1,2,0);
-      emit_writeword(0,&Status);
+      emit_writeword(0,&psxRegs.CP0.n.Status);
     }
   }
 }
@@ -4152,7 +4150,7 @@ static void syscall_assemble(int i, const struct regstat *i_regs, int ccadj_)
 
 static void hlecall_assemble(int i, const struct regstat *i_regs, int ccadj_)
 {
-  void *hlefunc = psxNULL;
+  void *hlefunc = gteNULL;
   uint32_t hleCode = source[i] & 0x03ffffff;
   if (hleCode < ARRAY_SIZE(psxHLEt))
     hlefunc = psxHLEt[hleCode];
@@ -6233,7 +6231,7 @@ void new_dynarec_clear_full(void)
   stat_clear(stat_blocks);
   stat_clear(stat_links);
 
-  cycle_multiplier_old = cycle_multiplier;
+  cycle_multiplier_old = Config.cycle_multiplier;
   new_dynarec_hacks_old = new_dynarec_hacks;
 }
 
@@ -6303,7 +6301,6 @@ void new_dynarec_init(void)
   #endif
 #endif
   out = ndrc->translation_cache;
-  cycle_multiplier=200;
   new_dynarec_clear_full();
 #ifdef HOST_IMM8
   // Copy this into local area so we don't have to put it in every literal pool
@@ -6360,7 +6357,7 @@ static u_int *get_source_start(u_int addr, u_int *limit)
     (0xbfc00000 <= addr && addr < 0xbfc80000)))
   {
     // BIOS. The multiplier should be much higher as it's uncached 8bit mem,
-    // but timings in PCSX are too tied to the interpreter's BIAS
+    // but timings in PCSX are too tied to the interpreter's 2-per-insn assumption
     if (!HACK_ENABLED(NDHACK_OVERRIDE_CYCLE_M))
       cycle_multiplier_active = 200;
 
@@ -9031,8 +9028,8 @@ static int new_recompile_block(u_int addr)
     return 0;
   }
 
-  cycle_multiplier_active = cycle_multiplier_override && cycle_multiplier == CYCLE_MULT_DEFAULT
-    ? cycle_multiplier_override : cycle_multiplier;
+  cycle_multiplier_active = Config.cycle_multiplier_override && Config.cycle_multiplier == CYCLE_MULT_DEFAULT
+    ? Config.cycle_multiplier_override : Config.cycle_multiplier;
 
   source = get_source_start(start, &pagelimit);
   if (source == NULL) {