drc: botched msb bit check
[pcsx_rearmed.git] / libpcsxcore / new_dynarec / emu_if.c
index 0569ceb..8c96504 100644 (file)
@@ -10,6 +10,7 @@
 #include "emu_if.h"
 #include "pcsxmem.h"
 #include "../psxhle.h"
+#include "../psxinterpreter.h"
 #include "../r3000a.h"
 #include "../cdrom.h"
 #include "../psxdma.h"
@@ -184,7 +185,8 @@ void new_dyna_freeze(void *f, int mode)
                if (bytes != size)
                        return;
 
-               new_dynarec_load_blocks(addrs, size);
+               if (psxCpu != &psxInt)
+                       new_dynarec_load_blocks(addrs, size);
        }
 
        //printf("drc: %d block info entries %s\n", size/8, mode ? "saved" : "loaded");
@@ -217,15 +219,6 @@ const char *gte_regnames[64] = {
        NULL  , NULL   , NULL   , NULL  , NULL , "GPF"  , "GPL"  , "NCCT", // 38
 };
 
-/* from gte.txt.. not sure if this is any good. */
-const char gte_cycletab[64] = {
-       /*   1   2   3   4   5   6   7   8   9   a   b   c   d   e   f */
-        0, 15,  0,  0,  0,  0,  8,  0,  0,  0,  0,  0,  6,  0,  0,  0,
-        8,  8,  8, 19, 13,  0, 44,  0,  0,  0,  0, 17, 11,  0, 14,  0,
-       30,  0,  0,  0,  0,  0,  0,  0,  5,  8, 17,  0,  0,  5,  6,  0,
-       23,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  5,  5, 39,
-};
-
 #define GCBIT(x) \
        (1ll << (32+x))
 #define GDBIT(x) \
@@ -338,7 +331,7 @@ static int ari64_init()
        scratch_buf_ptr = scratch_buf;
 
        SysPrintf("Mapped (RAM/scrp/ROM/LUTs/TC):\n");
-       SysPrintf("%08x/%08x/%08x/%08x/%08x\n",
+       SysPrintf("%p/%p/%p/%p/%p\n",
                psxM, psxH, psxR, mem_rtab, out);
 
        return 0;
@@ -362,7 +355,7 @@ static void ari64_execute_until()
        evprintf("ari64_execute %08x, %u->%u (%d)\n", psxRegs.pc,
                psxRegs.cycle, next_interupt, next_interupt - psxRegs.cycle);
 
-       new_dyna_start();
+       new_dyna_start(dynarec_local);
 
        evprintf("ari64_execute end %08x, %u->%u (%d)\n", psxRegs.pc,
                psxRegs.cycle, next_interupt, next_interupt - psxRegs.cycle);
@@ -395,7 +388,6 @@ static void ari64_clear(u32 addr, u32 size)
                        invalidate_block(start);
 }
 
-#ifdef ICACHE_EMULATION
 static void ari64_notify(int note, void *data) {
        /*
        Should be fixed when ARM dynarec has proper icache emulation.
@@ -411,7 +403,22 @@ static void ari64_notify(int note, void *data) {
        }
        */
 }
-#endif
+
+static void ari64_apply_config()
+{
+       intApplyConfig();
+
+       if (Config.DisableStalls)
+               new_dynarec_hacks |= NDHACK_NO_STALLS;
+       else
+               new_dynarec_hacks &= ~NDHACK_NO_STALLS;
+
+       if (cycle_multiplier != cycle_multiplier_old
+           || new_dynarec_hacks != new_dynarec_hacks_old)
+       {
+               new_dynarec_clear_full();
+       }
+}
 
 static void ari64_shutdown()
 {
@@ -425,9 +432,8 @@ R3000Acpu psxRec = {
        ari64_execute,
        ari64_execute_until,
        ari64_clear,
-#ifdef ICACHE_EMULATION
        ari64_notify,
-#endif
+       ari64_apply_config,
        ari64_shutdown
 };
 
@@ -438,6 +444,10 @@ int pending_exception, stop;
 unsigned int next_interupt;
 int new_dynarec_did_compile;
 int cycle_multiplier;
+int cycle_multiplier_override;
+int cycle_multiplier_old;
+int new_dynarec_hacks_pergame;
+int new_dynarec_hacks_old;
 int new_dynarec_hacks;
 void *psxH_ptr;
 void *zeromem_ptr;
@@ -446,7 +456,7 @@ unsigned char *out;
 void *mem_rtab;
 void *scratch_buf_ptr;
 void new_dynarec_init() {}
-void new_dyna_start() {}
+void new_dyna_start(void *context) {}
 void new_dynarec_cleanup() {}
 void new_dynarec_clear_full() {}
 void invalidate_all_pages() {}
@@ -489,6 +499,7 @@ static u32 memcheck_read(u32 a)
        return *(u32 *)(psxM + (a & 0x1ffffc));
 }
 
+#if 0
 void do_insn_trace(void)
 {
        static psxRegisters oldregs;
@@ -550,6 +561,7 @@ void do_insn_trace(void)
        }
 #endif
 }
+#endif
 
 static const char *regnames[offsetof(psxRegisters, intCycle) / 4] = {
        "r0",  "r1",  "r2",  "r3",  "r4",  "r5",  "r6",  "r7",
@@ -655,6 +667,8 @@ void do_insn_cmp(void)
                if (allregs_p[i] != allregs_e[i]) {
                        miss_log_add(i, allregs_p[i], allregs_e[i], psxRegs.pc, psxRegs.cycle);
                        bad++;
+                       if (i > 32+2)
+                               goto end;
                }
        }