+#ifdef PICODRIVE_HACK
+#define NOT_POLLING g_m68kcontext->not_polling = 1;
+#else
+#define NOT_POLLING
+#endif
+
// ORI
OPCODE(0x0000)
{
// CHK
OPCODE(0x4180)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
- src = DREGu16((Opcode >> 0) & 7);
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ src = DREGs16((Opcode >> 0) & 7);
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
// CHK
OPCODE(0x4190)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = AREG((Opcode >> 0) & 7);
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
// CHK
OPCODE(0x4198)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = AREG((Opcode >> 0) & 7);
AREG((Opcode >> 0) & 7) += 2;
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
// CHK
OPCODE(0x41A0)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = AREG((Opcode >> 0) & 7) - 2;
AREG((Opcode >> 0) & 7) = adr;
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
// CHK
OPCODE(0x41A8)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
FETCH_SWORD(adr);
adr += AREG((Opcode >> 0) & 7);
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
// CHK
OPCODE(0x41B0)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = AREG((Opcode >> 0) & 7);
DECODE_EXT_WORD
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
// CHK
OPCODE(0x41B8)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
FETCH_SWORD(adr);
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
// CHK
OPCODE(0x41B9)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
FETCH_LONG(adr);
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
// CHK
OPCODE(0x41BA)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = GET_SWORD + GET_PC;
PC++;
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
// CHK
OPCODE(0x41BB)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
// CHK
OPCODE(0x41BC)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
- FETCH_WORD(src);
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ FETCH_SWORD(src);
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
// CHK
OPCODE(0x419F)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = AREG(7);
AREG(7) += 2;
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
// CHK
OPCODE(0x41A7)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = AREG(7) - 2;
AREG(7) = adr;
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
res = DREGu16((Opcode >> 0) & 7);
res--;
DREGu16((Opcode >> 0) & 7) = res;
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if ((!flag_NotZ) || (flag_C & 0x100))
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (flag_NotZ && (!(flag_C & 0x100)))
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (flag_C & 0x100)
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (!(flag_C & 0x100))
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (!flag_NotZ)
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (flag_NotZ)
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (flag_V & 0x80)
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (!(flag_V & 0x80))
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (flag_N & 0x80)
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (!(flag_N & 0x80))
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if ((flag_N ^ flag_V) & 0x80)
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (!((flag_N ^ flag_V) & 0x80))
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if ((!flag_NotZ) || ((flag_N ^ flag_V) & 0x80))
{
res = DREGu16((Opcode >> 0) & 7);
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (flag_NotZ && (!((flag_N ^ flag_V) & 0x80)))
{
res = DREGu16((Opcode >> 0) & 7);
{
SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-RET(162)
+RET(152)
#else
RET(22)
#endif
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-RET(162)
+RET(152)
#else
RET(82)
#endif
DREGu32((Opcode >> 9) & 7) = res;
}
#ifdef USE_CYCLONE_TIMING_DIV
-RET(162)
+RET(152)
#else
RET(102)
#endif
{
SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
#ifdef USE_CYCLONE_TIMING_DIV
-RET(160)
+RET(150)
#else
RET(20)
#endif
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-RET(160)
+RET(150)
#else
RET(80)
#endif
DREGu32((Opcode >> 9) & 7) = res;
}
#ifdef USE_CYCLONE_TIMING_DIV
-RET(160)
+RET(150)
#else
RET(100)
#endif
}
+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;