add a hack for Decap Attack
[picodrive.git] / cpu / sh2 / compiler.c
index 3b6b45a..aa41a84 100644 (file)
@@ -313,9 +313,9 @@ static const int reg_map_g2h[] = {
   xSI,-1, -1, -1,
   -1, -1, -1, -1,
   -1, -1, -1, -1,
-  -1, -1, -1, -1,
-  -1, -1, -1, xDI,
-  -1, -1, -1, -1,
+  -1, -1, -1, -1,  // r12 .. sp
+  -1, -1, -1, xDI, // SHR_PC,  SHR_PPC, SHR_PR,   SHR_SR,
+  -1, -1, -1, -1,  // SHR_GBR, SHR_VBR, SHR_MACH, SHR_MACL,
 };
 
 // ax, cx, dx are usually temporaries by convention
@@ -330,12 +330,21 @@ static temp_reg_t reg_temp[] = {
 #include "../drc/emit_x86.c"
 
 static const int reg_map_g2h[] = {
+#ifndef _WIN32
   -1, -1, -1, -1,
   -1, -1, -1, -1,
   -1, -1, -1, -1,
+  -1, -1, -1, -1,  // r12 .. sp
+  -1, -1, -1, xBX, // SHR_PC,  SHR_PPC, SHR_PR,   SHR_SR,
+  -1, -1, -1, -1,  // SHR_GBR, SHR_VBR, SHR_MACH, SHR_MACL,
+#else
+  xDI,-1, -1, -1,
   -1, -1, -1, -1,
-  -1, -1, -1, xBX,
   -1, -1, -1, -1,
+  -1, -1, -1, -1,  // r12 .. sp
+  -1, -1, -1, xBX, // SHR_PC,  SHR_PPC, SHR_PR,   SHR_SR,
+  -1, -1, -1, -1,  // SHR_GBR, SHR_VBR, SHR_MACH, SHR_MACL,
+#endif
 };
 
 // ax, cx, dx are usually temporaries by convention
@@ -344,7 +353,9 @@ static temp_reg_t reg_temp[] = {
   { xCX, },
   { xDX, },
   { xSI, },
+#ifndef _WIN32
   { xDI, },
+#endif
 };
 
 #else
@@ -1400,7 +1411,7 @@ static void emit_block_entry(void)
   emith_call(sh2_drc_log_entry);
   rcache_invalidate();
 #endif
-  emith_tst_r_r(RET_REG, RET_REG);
+  emith_tst_r_r_ptr(RET_REG, RET_REG);
   EMITH_SJMP_START(DCOND_EQ);
   emith_jump_reg_c(DCOND_NE, RET_REG);
   EMITH_SJMP_END(DCOND_EQ);
@@ -2901,8 +2912,10 @@ end_op:
     tcache_id, blkid_main,
     tcache_ptr - tcache_bases[tcache_id], tcache_sizes[tcache_id],
     insns_compiled, host_insn_count, (float)host_insn_count / insns_compiled);
-  if ((sh2->pc & 0xc6000000) == 0x02000000) // ROM
+  if ((sh2->pc & 0xc6000000) == 0x02000000) // ROM
     dbg(2, "  hash collisions %d/%d", hash_collisions, block_counts[tcache_id]);
+    Pico32x.emu_flags |= P32XF_DRC_ROM_C;
+  }
 /*
  printf("~~~\n");
  tcache_dsm_ptrs[tcache_id] = block_entry_ptr;
@@ -3281,6 +3294,7 @@ void sh2_drc_flush_all(void)
   flush_tcache(0);
   flush_tcache(1);
   flush_tcache(2);
+  Pico32x.emu_flags &= ~P32XF_DRC_ROM_C;
 }
 
 void sh2_drc_mem_setup(SH2 *sh2)