}
+extern int SekIsIdleReady(void);
extern int SekIsIdleCode(unsigned short *dst, int bytes);
extern int SekRegisterIdlePatch(unsigned int pc, int oldop, int newop, void *ctx);
OPCODE(idle_detector_bcc8)
{
- extern int idledet_start_frame;
- extern char Pico[];
int frame_count, cond_true, bytes, ret, newop;
u16 *dest_pc;
dest_pc = PC + (((s8)(Opcode & 0xFE)) >> 1);
- frame_count = *(int *)(Pico+0x22208+0x1c); // Pico.m.frame_count
- if (frame_count < idledet_start_frame)
+ if (!SekIsIdleReady())
goto end;
bytes = 0 - (s8)(Opcode & 0xFE) - 2;
\r
static unsigned short **idledet_ptrs = NULL;\r
static int idledet_count = 0, idledet_bads = 0;\r
-int idledet_start_frame = 0;\r
+static int idledet_start_frame = 0;\r
\r
#if 0\r
#define IDLE_STATS 1\r
#endif\r
}\r
\r
+int SekIsIdleReady(void)\r
+{\r
+ return (Pico.m.frame_count >= idledet_start_frame);\r
+}\r
+\r
int SekIsIdleCode(unsigned short *dst, int bytes)\r
{\r
// printf("SekIsIdleCode %04x %i\n", *dst, bytes);\r
return 1;\r
break;\r
case 4:\r
- if ( (*dst & 0xfff8) == 0x4a10 || // tst.b ($aX) // there should be no need to wait\r
- (*dst & 0xfff8) == 0x4a28 || // tst.b ($xxxx,a0) // for byte change anywhere\r
- (*dst & 0xff3f) == 0x4a38 || // tst.x ($xxxx.w); tas ($xxxx.w)\r
- (*dst & 0xc1ff) == 0x0038 || // move.x ($xxxx.w), dX\r
- (*dst & 0xf13f) == 0xb038) // cmp.x ($xxxx.w), dX\r
+ if ( (*dst & 0xff3f) == 0x4a38 || // tst.x ($xxxx.w); tas ($xxxx.w)\r
+ (*dst & 0xc1ff) == 0x0038 || // move.x ($xxxx.w), dX\r
+ (*dst & 0xf13f) == 0xb038) // cmp.x ($xxxx.w), dX\r
+ return 1;\r
+ if (PicoAHW & (PAHW_MCD|PAHW_32X))\r
+ break;\r
+ // with no addons, there should be no need to wait\r
+ // for byte change anywhere\r
+ if ( (*dst & 0xfff8) == 0x4a10 || // tst.b ($aX)\r
+ (*dst & 0xfff8) == 0x4a28) // tst.b ($xxxx,a0)\r
return 1;\r
break;\r
case 6:\r
return 1;\r
break;\r
case 12:\r
- if ((*dst & 0xf1f8) == 0x3010 && // move.w (aX), dX\r
+ if (PicoAHW & (PAHW_MCD|PAHW_32X))\r
+ break;\r
+ if ( (*dst & 0xf1f8) == 0x3010 && // move.w (aX), dX\r
(dst[1]&0xf100) == 0x0000 && // arithmetic\r
(dst[3]&0xf100) == 0x0000) // arithmetic\r
return 1;\r
is_main68k = ctx == &PicoCpuFM68k;\r
#endif\r
pc &= ~0xff000000;\r
+ if (!(newop&0x200))\r
elprintf(EL_IDLE, "idle: patch %06x %04x %04x %c %c #%i", pc, oldop, newop,\r
(newop&0x200)?'n':'y', is_main68k?'m':'s', idledet_count);\r
\r