minor adjustments
[picodrive.git] / Pico / Sek.c
index 7ebb930..ac12580 100644 (file)
@@ -114,7 +114,7 @@ PICO_INTERNAL int SekInit()
     m68k_init();\r
     m68k_set_int_ack_callback(SekIntAckM68K);\r
     m68k_set_tas_instr_callback(SekTasCallback);\r
-    m68k_pulse_reset(); // Init cpu emulator\r
+    //m68k_pulse_reset();\r
     m68k_set_context(oldcontext);\r
   }\r
 #endif\r
@@ -193,3 +193,30 @@ PICO_INTERNAL void SekSetRealTAS(int use_real)
 #endif\r
 }\r
 \r
+#if defined(EMU_M68K) && M68K_INSTRUCTION_HOOK == OPT_SPECIFY_HANDLER\r
+static unsigned char op_flags[0x400000/2] = { 0, };\r
+static int atexit_set = 0;\r
+\r
+static void make_idc(void)\r
+{\r
+  FILE *f = fopen("idc.idc", "w");\r
+  int i;\r
+  if (!f) return;\r
+  fprintf(f, "#include <idc.idc>\nstatic main() {\n");\r
+  for (i = 0; i < 0x400000/2; i++)\r
+    if (op_flags[i] != 0)\r
+      fprintf(f, "  MakeCode(0x%06x);\n", i*2);\r
+  fprintf(f, "}\n");\r
+  fclose(f);\r
+}\r
+\r
+void instruction_hook(void)\r
+{\r
+  if (!atexit_set) {\r
+    atexit(make_idc);\r
+    atexit_set = 1;\r
+  }\r
+  if (REG_PC < 0x400000)\r
+    op_flags[REG_PC/2] = 1;\r
+}\r
+#endif\r