Merge branch 'dev'
[picodrive.git] / cpu / fame / famec_opcodes.h
index 759c00f..5e09a92 100644 (file)
@@ -638,9 +638,7 @@ OPCODE(0x007C)
        }
        else
        {
-               u32 newPC = (u32)(PC) - BasePC;
-               SET_PC(newPC-2);
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
 #ifdef USE_CYCLONE_TIMING
                RET(0)
 #else
@@ -1298,9 +1296,7 @@ OPCODE(0x027C)
        }
        else
        {
-               u32 newPC = (u32)(PC) - BasePC;
-               SET_PC(newPC-2);
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(4)
        }
 RET(20)
@@ -1950,9 +1946,7 @@ OPCODE(0x0A7C)
        }
        else
        {
-               u32 newPC = (u32)(PC) - BasePC;
-               SET_PC(newPC-2);
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(0)
        }
 RET(20)
@@ -3832,7 +3826,7 @@ OPCODE(0x083A)
 
        FETCH_BYTE(src);
        src = 1 << (src & 7);
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -3849,7 +3843,7 @@ OPCODE(0x083B)
 
        FETCH_BYTE(src);
        src = 1 << (src & 7);
-       adr = (u32)(PC) - BasePC;
+       adr = (uptr)(PC) - BasePC;
        DECODE_EXT_WORD
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -4578,7 +4572,7 @@ OPCODE(0x013A)
 
        src = DREGu8((Opcode >> 9) & 7);
        src = 1 << (src & 7);
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -4595,7 +4589,7 @@ OPCODE(0x013B)
 
        src = DREGu8((Opcode >> 9) & 7);
        src = 1 << (src & 7);
-       adr = (u32)(PC) - BasePC;
+       adr = (uptr)(PC) - BasePC;
        DECODE_EXT_WORD
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7122,7 +7116,7 @@ OPCODE(0x103A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7141,7 +7135,7 @@ OPCODE(0x10BA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7161,7 +7155,7 @@ OPCODE(0x10FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7182,7 +7176,7 @@ OPCODE(0x113A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7203,7 +7197,7 @@ OPCODE(0x117A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7224,7 +7218,7 @@ OPCODE(0x11BA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7245,7 +7239,7 @@ OPCODE(0x11FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7265,7 +7259,7 @@ OPCODE(0x13FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7285,7 +7279,7 @@ OPCODE(0x1EFA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7306,7 +7300,7 @@ OPCODE(0x1F3A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7327,7 +7321,7 @@ OPCODE(0x103B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = (uptr)(PC) - BasePC;
        DECODE_EXT_WORD
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7346,7 +7340,7 @@ OPCODE(0x10BB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = (uptr)(PC) - BasePC;
        DECODE_EXT_WORD
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7366,7 +7360,7 @@ OPCODE(0x10FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = (uptr)(PC) - BasePC;
        DECODE_EXT_WORD
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7387,7 +7381,7 @@ OPCODE(0x113B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = (uptr)(PC) - BasePC;
        DECODE_EXT_WORD
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7408,7 +7402,7 @@ OPCODE(0x117B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = (uptr)(PC) - BasePC;
        DECODE_EXT_WORD
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7429,7 +7423,7 @@ OPCODE(0x11BB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = (uptr)(PC) - BasePC;
        DECODE_EXT_WORD
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7450,7 +7444,7 @@ OPCODE(0x11FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = (uptr)(PC) - BasePC;
        DECODE_EXT_WORD
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7470,7 +7464,7 @@ OPCODE(0x13FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = (uptr)(PC) - BasePC;
        DECODE_EXT_WORD
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7490,7 +7484,7 @@ OPCODE(0x1EFB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = (uptr)(PC) - BasePC;
        DECODE_EXT_WORD
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -7511,7 +7505,7 @@ OPCODE(0x1F3B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = (uptr)(PC) - BasePC;
        DECODE_EXT_WORD
        PRE_IO
        READ_BYTE_F(adr, res)
@@ -9896,7 +9890,7 @@ OPCODE(0x203A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_LONG_F(adr, res)
@@ -9915,7 +9909,7 @@ OPCODE(0x20BA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_LONG_F(adr, res)
@@ -9935,7 +9929,7 @@ OPCODE(0x20FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_LONG_F(adr, res)
@@ -9956,7 +9950,7 @@ OPCODE(0x213A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_LONG_F(adr, res)
@@ -9977,7 +9971,7 @@ OPCODE(0x217A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_LONG_F(adr, res)
@@ -9998,7 +9992,7 @@ OPCODE(0x21BA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_LONG_F(adr, res)
@@ -10019,7 +10013,7 @@ OPCODE(0x21FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_LONG_F(adr, res)
@@ -10039,7 +10033,7 @@ OPCODE(0x23FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_LONG_F(adr, res)
@@ -10059,7 +10053,7 @@ OPCODE(0x2EFA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_LONG_F(adr, res)
@@ -10080,7 +10074,7 @@ OPCODE(0x2F3A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_LONG_F(adr, res)
@@ -10101,7 +10095,7 @@ OPCODE(0x203B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_LONG_F(adr, res)
@@ -10120,7 +10114,7 @@ OPCODE(0x20BB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_LONG_F(adr, res)
@@ -10140,7 +10134,7 @@ OPCODE(0x20FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_LONG_F(adr, res)
@@ -10161,7 +10155,7 @@ OPCODE(0x213B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_LONG_F(adr, res)
@@ -10182,7 +10176,7 @@ OPCODE(0x217B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_LONG_F(adr, res)
@@ -10203,7 +10197,7 @@ OPCODE(0x21BB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_LONG_F(adr, res)
@@ -10224,7 +10218,7 @@ OPCODE(0x21FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_LONG_F(adr, res)
@@ -10244,7 +10238,7 @@ OPCODE(0x23FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_LONG_F(adr, res)
@@ -10264,7 +10258,7 @@ OPCODE(0x2EFB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_LONG_F(adr, res)
@@ -10285,7 +10279,7 @@ OPCODE(0x2F3B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_LONG_F(adr, res)
@@ -11023,7 +11017,7 @@ OPCODE(0x207A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READSX_LONG_F(adr, res)
@@ -11038,7 +11032,7 @@ OPCODE(0x207B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READSX_LONG_F(adr, res)
@@ -12865,7 +12859,7 @@ OPCODE(0x303A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_WORD_F(adr, res)
@@ -12884,7 +12878,7 @@ OPCODE(0x30BA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_WORD_F(adr, res)
@@ -12904,7 +12898,7 @@ OPCODE(0x30FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_WORD_F(adr, res)
@@ -12925,7 +12919,7 @@ OPCODE(0x313A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_WORD_F(adr, res)
@@ -12946,7 +12940,7 @@ OPCODE(0x317A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_WORD_F(adr, res)
@@ -12967,7 +12961,7 @@ OPCODE(0x31BA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_WORD_F(adr, res)
@@ -12988,7 +12982,7 @@ OPCODE(0x31FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_WORD_F(adr, res)
@@ -13008,7 +13002,7 @@ OPCODE(0x33FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_WORD_F(adr, res)
@@ -13028,7 +13022,7 @@ OPCODE(0x3EFA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_WORD_F(adr, res)
@@ -13049,7 +13043,7 @@ OPCODE(0x3F3A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_WORD_F(adr, res)
@@ -13070,7 +13064,7 @@ OPCODE(0x303B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_WORD_F(adr, res)
@@ -13089,7 +13083,7 @@ OPCODE(0x30BB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_WORD_F(adr, res)
@@ -13109,7 +13103,7 @@ OPCODE(0x30FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_WORD_F(adr, res)
@@ -13130,7 +13124,7 @@ OPCODE(0x313B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_WORD_F(adr, res)
@@ -13151,7 +13145,7 @@ OPCODE(0x317B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_WORD_F(adr, res)
@@ -13172,7 +13166,7 @@ OPCODE(0x31BB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_WORD_F(adr, res)
@@ -13193,7 +13187,7 @@ OPCODE(0x31FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_WORD_F(adr, res)
@@ -13213,7 +13207,7 @@ OPCODE(0x33FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_WORD_F(adr, res)
@@ -13233,7 +13227,7 @@ OPCODE(0x3EFB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_WORD_F(adr, res)
@@ -13254,7 +13248,7 @@ OPCODE(0x3F3B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_WORD_F(adr, res)
@@ -13992,7 +13986,7 @@ OPCODE(0x307A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READSX_WORD_F(adr, res)
@@ -14007,7 +14001,7 @@ OPCODE(0x307B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READSX_WORD_F(adr, res)
@@ -16485,7 +16479,7 @@ OPCODE(0x44FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_WORD_F(adr, res)
@@ -16500,7 +16494,7 @@ OPCODE(0x44FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_WORD_F(adr, res)
@@ -16570,9 +16564,7 @@ OPCODE(0x46C0)
        }
        else
        {
-               u32 oldPC=GET_PC;
-               SET_PC(oldPC-2)
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(4)
        }
 RET(12)
@@ -16601,9 +16593,7 @@ OPCODE(0x46D0)
        }
        else
        {
-               u32 oldPC=GET_PC;
-               SET_PC(oldPC-2)
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(4)
        }
 RET(16)
@@ -16633,9 +16623,7 @@ OPCODE(0x46D8)
        }
        else
        {
-               u32 oldPC=GET_PC;
-               SET_PC(oldPC-2)
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(4)
        }
 RET(16)
@@ -16665,9 +16653,7 @@ OPCODE(0x46E0)
        }
        else
        {
-               u32 oldPC=GET_PC;
-               SET_PC(oldPC-2)
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(4)
        }
 RET(18)
@@ -16697,9 +16683,7 @@ OPCODE(0x46E8)
        }
        else
        {
-               u32 oldPC=GET_PC;
-               SET_PC(oldPC-2)
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(4)
        }
 RET(20)
@@ -16729,9 +16713,7 @@ OPCODE(0x46F0)
        }
        else
        {
-               u32 oldPC=GET_PC;
-               SET_PC(oldPC-2)
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(4)
        }
 RET(22)
@@ -16761,9 +16743,7 @@ OPCODE(0x46F8)
        }
        else
        {
-               u32 oldPC=GET_PC;
-               SET_PC(oldPC-2)
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(4)
        }
 RET(20)
@@ -16792,9 +16772,7 @@ OPCODE(0x46F9)
        }
        else
        {
-               u32 oldPC=GET_PC;
-               SET_PC(oldPC-2)
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(4)
        }
 RET(24)
@@ -16808,7 +16786,7 @@ OPCODE(0x46FA)
 
        if (flag_S)
        {
-               adr = GET_SWORD + ((u32)(PC) - BasePC);
+               adr = GET_SWORD + GET_PC;
                PC++;
                PRE_IO
                READ_WORD_F(adr, res)
@@ -16820,13 +16798,11 @@ OPCODE(0x46FA)
                        ASP = res;
                }
                POST_IO
-               CHECK_INT_TO_JUMP(24)
+               CHECK_INT_TO_JUMP(20)
        }
        else
        {
-               u32 oldPC=GET_PC;
-               SET_PC(oldPC-2)
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(4)
        }
 RET(20)
@@ -16840,7 +16816,7 @@ OPCODE(0x46FB)
 
        if (flag_S)
        {
-               adr = (u32)(PC) - BasePC;
+               adr = GET_PC;
                DECODE_EXT_WORD
                PRE_IO
                READ_WORD_F(adr, res)
@@ -16856,9 +16832,7 @@ OPCODE(0x46FB)
        }
        else
        {
-               u32 oldPC=GET_PC;
-               SET_PC(oldPC-2)
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(4)
        }
 RET(22)
@@ -16884,9 +16858,7 @@ OPCODE(0x46FC)
        }
        else
        {
-               u32 oldPC=GET_PC;
-               SET_PC(oldPC-2)
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(4)
        }
 RET(16)
@@ -16916,9 +16888,7 @@ OPCODE(0x46DF)
        }
        else
        {
-               u32 oldPC=GET_PC;
-               SET_PC(oldPC-2)
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(4)
        }
 RET(16)
@@ -16948,9 +16918,7 @@ OPCODE(0x46E7)
        }
        else
        {
-               u32 oldPC=GET_PC;
-               SET_PC(oldPC-2)
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(4)
        }
 RET(18)
@@ -17282,7 +17250,7 @@ OPCODE(0x487A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        PUSH_32_F(adr)
@@ -17296,7 +17264,7 @@ OPCODE(0x487B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        PUSH_32_F(adr)
@@ -18324,8 +18292,19 @@ OPCODE(0x4AD0)
        flag_V = 0;
        flag_NotZ = res;
        flag_N = res;
+#ifdef PICODRIVE_HACK
+       if (g_m68kcontext == &PicoCpuFS68k) {
+               res |= 0x80;
+               WRITE_BYTE_F(adr, res);
+       }
+#endif
+
        POST_IO
+#ifdef USE_CYCLONE_TIMING
+RET(18)
+#else
 RET(8)
+#endif
 }
 
 // TAS
@@ -18342,8 +18321,20 @@ OPCODE(0x4AD8)
        flag_V = 0;
        flag_NotZ = res;
        flag_N = res;
+
+#ifdef PICODRIVE_HACK
+       if (g_m68kcontext == &PicoCpuFS68k) {
+               res |= 0x80;
+               WRITE_BYTE_F(adr, res);
+       }
+#endif
+
        POST_IO
+#ifdef USE_CYCLONE_TIMING
+RET(18)
+#else
 RET(8)
+#endif
 }
 
 // TAS
@@ -18360,8 +18351,20 @@ OPCODE(0x4AE0)
        flag_V = 0;
        flag_NotZ = res;
        flag_N = res;
+
+#ifdef PICODRIVE_HACK
+       if (g_m68kcontext == &PicoCpuFS68k) {
+               res |= 0x80;
+               WRITE_BYTE_F(adr, res);
+       }
+#endif
+
        POST_IO
+#ifdef USE_CYCLONE_TIMING
+RET(20)
+#else
 RET(10)
+#endif
 }
 
 // TAS
@@ -18378,8 +18381,20 @@ OPCODE(0x4AE8)
        flag_V = 0;
        flag_NotZ = res;
        flag_N = res;
+
+#ifdef PICODRIVE_HACK
+       if (g_m68kcontext == &PicoCpuFS68k) {
+               res |= 0x80;
+               WRITE_BYTE_F(adr, res);
+       }
+#endif
+
        POST_IO
+#ifdef USE_CYCLONE_TIMING
+RET(22)
+#else
 RET(12)
+#endif
 }
 
 // TAS
@@ -18396,8 +18411,20 @@ OPCODE(0x4AF0)
        flag_V = 0;
        flag_NotZ = res;
        flag_N = res;
+
+#ifdef PICODRIVE_HACK
+       if (g_m68kcontext == &PicoCpuFS68k) {
+               res |= 0x80;
+               WRITE_BYTE_F(adr, res);
+       }
+#endif
+
        POST_IO
+#ifdef USE_CYCLONE_TIMING
+RET(24)
+#else
 RET(14)
+#endif
 }
 
 // TAS
@@ -18413,8 +18440,20 @@ OPCODE(0x4AF8)
        flag_V = 0;
        flag_NotZ = res;
        flag_N = res;
+
+#ifdef PICODRIVE_HACK
+       if (g_m68kcontext == &PicoCpuFS68k) {
+               res |= 0x80;
+               WRITE_BYTE_F(adr, res);
+       }
+#endif
+
        POST_IO
+#ifdef USE_CYCLONE_TIMING
+RET(22)
+#else
 RET(12)
+#endif
 }
 
 // TAS
@@ -18430,8 +18469,20 @@ OPCODE(0x4AF9)
        flag_V = 0;
        flag_NotZ = res;
        flag_N = res;
+
+#ifdef PICODRIVE_HACK
+       if (g_m68kcontext == &PicoCpuFS68k) {
+               res |= 0x80;
+               WRITE_BYTE_F(adr, res);
+       }
+#endif
+
        POST_IO
+#ifdef USE_CYCLONE_TIMING
+RET(26)
+#else
 RET(16)
+#endif
 }
 
 // TAS
@@ -18448,8 +18499,20 @@ OPCODE(0x4ADF)
        flag_V = 0;
        flag_NotZ = res;
        flag_N = res;
+
+#ifdef PICODRIVE_HACK
+       if (g_m68kcontext == &PicoCpuFS68k) {
+               res |= 0x80;
+               WRITE_BYTE_F(adr, res);
+       }
+#endif
+
        POST_IO
+#ifdef USE_CYCLONE_TIMING
+RET(18)
+#else
 RET(8)
+#endif
 }
 
 // TAS
@@ -18466,34 +18529,40 @@ OPCODE(0x4AE7)
        flag_V = 0;
        flag_NotZ = res;
        flag_N = res;
+
+#ifdef PICODRIVE_HACK
+       if (g_m68kcontext == &PicoCpuFS68k) {
+               res |= 0x80;
+               WRITE_BYTE_F(adr, res);
+       }
+#endif
+
        POST_IO
-RET(10)
+#ifdef USE_CYCLONE_TIMING
+RET(20)
+#else
+RET(8)
+#endif
 }
 
 // ILLEGAL
 OPCODE(0x4AFC)
 {
-       u32 oldPC=GET_PC;
-       SET_PC(oldPC-2)
-       execute_exception(M68K_ILLEGAL_INSTRUCTION_EX);
+       SET_PC(execute_exception(M68K_ILLEGAL_INSTRUCTION_EX, GET_PC-2, GET_SR));
 RET(0)
 }
 
 // ILLEGAL A000-AFFF
 OPCODE(0xA000)
 {
-       u32 oldPC=GET_PC;
-       SET_PC(oldPC-2)
-       execute_exception(M68K_1010_EX);
+       SET_PC(execute_exception(M68K_1010_EX, GET_PC-2, GET_SR));
 RET(0)
 }
 
 // ILLEGAL F000-FFFF
 OPCODE(0xF000)
 {
-       u32 oldPC=GET_PC;
-       SET_PC(oldPC-2)
-       execute_exception(M68K_1111_EX);
+       SET_PC(execute_exception(M68K_1111_EX, GET_PC-2, GET_SR));
 RET(0) // 4 already taken by exc. handler
 }
 
@@ -18691,7 +18760,7 @@ OPCODE(0x4CBA)
        s32 *psrc;
 
        FETCH_WORD(res);
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        psrc = &DREGs32(0);
        dst = adr;
@@ -18723,7 +18792,7 @@ OPCODE(0x4CBB)
        s32 *psrc;
 
        FETCH_WORD(res);
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        psrc = &DREGs32(0);
        dst = adr;
@@ -18968,7 +19037,7 @@ OPCODE(0x4CFA)
        u32 *psrc;
 
        FETCH_WORD(res);
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        psrc = &DREGu32(0);
        dst = adr;
@@ -19000,7 +19069,7 @@ OPCODE(0x4CFB)
        u32 *psrc;
 
        FETCH_WORD(res);
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        psrc = &DREGu32(0);
        dst = adr;
@@ -19054,7 +19123,7 @@ RET(12)
 // TRAP
 OPCODE(0x4E40)
 {
-       execute_exception(M68K_TRAP_BASE_EX + (Opcode & 0xF));
+       SET_PC(execute_exception(M68K_TRAP_BASE_EX + (Opcode & 0xF), GET_PC, GET_SR));
 RET(4)
 }
 
@@ -19125,9 +19194,7 @@ OPCODE(0x4E60)
 
        if (!flag_S)
        {
-               u32 oldPC=GET_PC;
-               SET_PC(oldPC-2)
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(4)
        }
        res = AREGu32((Opcode >> 0) & 7);
@@ -19143,9 +19210,7 @@ OPCODE(0x4E68)
 
        if (!flag_S)
        {
-               u32 oldPC=GET_PC;
-               SET_PC(oldPC-2)
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(4)
        }
        res = ASP;
@@ -19161,9 +19226,7 @@ OPCODE(0x4E70)
 
        if (!flag_S)
        {
-               u32 oldPC=GET_PC;
-               SET_PC(oldPC-2)
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(4)
        }
        PRE_IO
@@ -19187,9 +19250,7 @@ OPCODE(0x4E72)
 
        if (!flag_S)
        {
-               u32 oldPC=GET_PC;
-               SET_PC(oldPC-2)
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(4)
        }
        FETCH_WORD(res);
@@ -19202,8 +19263,7 @@ OPCODE(0x4E72)
                ASP = res;
        }
        m68kcontext.execinfo |= FM68K_HALTED;
-       m68kcontext.io_cycle_counter = 0;
-RET(4)
+RET0()
 }
 
 // RTE
@@ -19214,9 +19274,7 @@ OPCODE(0x4E73)
 
        if (!flag_S)
        {
-               u32 oldPC=GET_PC;
-               SET_PC(oldPC-2)
-               execute_exception(M68K_PRIVILEGE_VIOLATION_EX);
+               SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR));
                RET(4)
        }
        PRE_IO
@@ -19254,7 +19312,7 @@ RET(16)
 OPCODE(0x4E76)
 {
        if (flag_V & 0x80)
-               execute_exception(M68K_TRAPV_EX);
+               SET_PC(execute_exception(M68K_TRAPV_EX, GET_PC, GET_SR));
 RET(4)
 }
 
@@ -19284,7 +19342,7 @@ OPCODE(0x4E90)
        {
                u32 oldPC;
 
-               oldPC = (u32)(PC) - BasePC;
+               oldPC = GET_PC;
        PRE_IO
                PUSH_32_F(oldPC)
        }
@@ -19305,7 +19363,7 @@ OPCODE(0x4EA8)
        {
                u32 oldPC;
 
-               oldPC = (u32)(PC) - BasePC;
+               oldPC = GET_PC;
        PRE_IO
                PUSH_32_F(oldPC)
        }
@@ -19326,7 +19384,7 @@ OPCODE(0x4EB0)
        {
                u32 oldPC;
 
-               oldPC = (u32)(PC) - BasePC;
+               oldPC = GET_PC;
        PRE_IO
                PUSH_32_F(oldPC)
        }
@@ -19346,7 +19404,7 @@ OPCODE(0x4EB8)
        {
                u32 oldPC;
 
-               oldPC = (u32)(PC) - BasePC;
+               oldPC = GET_PC;
        PRE_IO
                PUSH_32_F(oldPC)
        }
@@ -19366,7 +19424,7 @@ OPCODE(0x4EB9)
        {
                u32 oldPC;
 
-               oldPC = (u32)(PC) - BasePC;
+               oldPC = GET_PC;
        PRE_IO
                PUSH_32_F(oldPC)
        }
@@ -19382,12 +19440,12 @@ OPCODE(0x4EBA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        {
                u32 oldPC;
 
-               oldPC = (u32)(PC) - BasePC;
+               oldPC = GET_PC;
        PRE_IO
                PUSH_32_F(oldPC)
        }
@@ -19403,12 +19461,12 @@ OPCODE(0x4EBB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        {
                u32 oldPC;
 
-               oldPC = (u32)(PC) - BasePC;
+               oldPC = GET_PC;
        PRE_IO
                PUSH_32_F(oldPC)
        }
@@ -19486,7 +19544,7 @@ OPCODE(0x4EFA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        SET_PC(adr)
        CHECK_BRANCH_EXCEPTION(adr)
@@ -19499,7 +19557,7 @@ OPCODE(0x4EFB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        SET_PC(adr)
        CHECK_BRANCH_EXCEPTION(adr)
@@ -19517,7 +19575,7 @@ OPCODE(0x4180)
        if (((s32)res < 0) || (res > src))
        {
                flag_N = res >> 8;
-               execute_exception(M68K_CHK_EX);
+               SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
        }
 RET(10)
 }
@@ -19535,7 +19593,7 @@ OPCODE(0x4190)
        if (((s32)res < 0) || (res > src))
        {
                flag_N = res >> 8;
-               execute_exception(M68K_CHK_EX);
+               SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
        }
        POST_IO
 RET(14)
@@ -19555,7 +19613,7 @@ OPCODE(0x4198)
        if (((s32)res < 0) || (res > src))
        {
                flag_N = res >> 8;
-               execute_exception(M68K_CHK_EX);
+               SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
        }
        POST_IO
 RET(14)
@@ -19575,7 +19633,7 @@ OPCODE(0x41A0)
        if (((s32)res < 0) || (res > src))
        {
                flag_N = res >> 8;
-               execute_exception(M68K_CHK_EX);
+               SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
        }
        POST_IO
 RET(16)
@@ -19595,7 +19653,7 @@ OPCODE(0x41A8)
        if (((s32)res < 0) || (res > src))
        {
                flag_N = res >> 8;
-               execute_exception(M68K_CHK_EX);
+               SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
        }
        POST_IO
 RET(18)
@@ -19615,7 +19673,7 @@ OPCODE(0x41B0)
        if (((s32)res < 0) || (res > src))
        {
                flag_N = res >> 8;
-               execute_exception(M68K_CHK_EX);
+               SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
        }
        POST_IO
 RET(20)
@@ -19634,7 +19692,7 @@ OPCODE(0x41B8)
        if (((s32)res < 0) || (res > src))
        {
                flag_N = res >> 8;
-               execute_exception(M68K_CHK_EX);
+               SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
        }
        POST_IO
 RET(18)
@@ -19653,7 +19711,7 @@ OPCODE(0x41B9)
        if (((s32)res < 0) || (res > src))
        {
                flag_N = res >> 8;
-               execute_exception(M68K_CHK_EX);
+               SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
        }
        POST_IO
 RET(22)
@@ -19665,7 +19723,7 @@ OPCODE(0x41BA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_WORD_F(adr, src)
@@ -19673,7 +19731,7 @@ OPCODE(0x41BA)
        if (((s32)res < 0) || (res > src))
        {
                flag_N = res >> 8;
-               execute_exception(M68K_CHK_EX);
+               SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
        }
        POST_IO
 RET(18)
@@ -19685,7 +19743,7 @@ OPCODE(0x41BB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_WORD_F(adr, src)
@@ -19693,7 +19751,7 @@ OPCODE(0x41BB)
        if (((s32)res < 0) || (res > src))
        {
                flag_N = res >> 8;
-               execute_exception(M68K_CHK_EX);
+               SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
        }
        POST_IO
 RET(20)
@@ -19710,7 +19768,7 @@ OPCODE(0x41BC)
        if (((s32)res < 0) || (res > src))
        {
                flag_N = res >> 8;
-               execute_exception(M68K_CHK_EX);
+               SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
        }
        POST_IO
 RET(14)
@@ -19730,7 +19788,7 @@ OPCODE(0x419F)
        if (((s32)res < 0) || (res > src))
        {
                flag_N = res >> 8;
-               execute_exception(M68K_CHK_EX);
+               SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
        }
        POST_IO
 RET(14)
@@ -19750,7 +19808,7 @@ OPCODE(0x41A7)
        if (((s32)res < 0) || (res > src))
        {
                flag_N = res >> 8;
-               execute_exception(M68K_CHK_EX);
+               SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
        }
        POST_IO
 RET(16)
@@ -19824,7 +19882,7 @@ OPCODE(0x41FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        res = adr;
        AREG((Opcode >> 9) & 7) = res;
@@ -19837,7 +19895,7 @@ OPCODE(0x41FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        res = adr;
        AREG((Opcode >> 9) & 7) = res;
@@ -23247,7 +23305,7 @@ OPCODE(0x51C8)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -23272,7 +23330,7 @@ OPCODE(0x52C8)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -23303,7 +23361,7 @@ OPCODE(0x53C8)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -23334,7 +23392,7 @@ OPCODE(0x54C8)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -23365,7 +23423,7 @@ OPCODE(0x55C8)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -23396,7 +23454,7 @@ OPCODE(0x56C8)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -23427,7 +23485,7 @@ OPCODE(0x57C8)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -23458,7 +23516,7 @@ OPCODE(0x58C8)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -23489,7 +23547,7 @@ OPCODE(0x59C8)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -23520,7 +23578,7 @@ OPCODE(0x5AC8)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -23551,7 +23609,7 @@ OPCODE(0x5BC8)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -23582,7 +23640,7 @@ OPCODE(0x5CC8)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -23613,7 +23671,7 @@ OPCODE(0x5DC8)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -23644,7 +23702,7 @@ OPCODE(0x5EC8)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -23675,7 +23733,7 @@ OPCODE(0x5FC8)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -25131,7 +25189,7 @@ OPCODE(0x6200)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -25151,7 +25209,7 @@ OPCODE(0x6300)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -25171,7 +25229,7 @@ OPCODE(0x6400)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -25191,7 +25249,7 @@ OPCODE(0x6500)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -25211,7 +25269,7 @@ OPCODE(0x6600)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -25231,7 +25289,7 @@ OPCODE(0x6700)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -25251,7 +25309,7 @@ OPCODE(0x6800)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -25271,7 +25329,7 @@ OPCODE(0x6900)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -25291,7 +25349,7 @@ OPCODE(0x6A00)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -25311,7 +25369,7 @@ OPCODE(0x6B00)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -25331,7 +25389,7 @@ OPCODE(0x6C00)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -25351,7 +25409,7 @@ OPCODE(0x6D00)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -25371,7 +25429,7 @@ OPCODE(0x6E00)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -25391,7 +25449,7 @@ OPCODE(0x6F00)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -25405,7 +25463,7 @@ RET(12)
 OPCODE(0x6001)
 {
 #ifdef FAMEC_CHECK_BRANCHES
-       u32 newPC = (u32)(PC) - BasePC;
+       u32 newPC = GET_PC;
        s8 offs=Opcode;
        newPC += offs;
        SET_PC(newPC);
@@ -25425,7 +25483,7 @@ OPCODE(0x6000)
        {
                u32 newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                newPC += GET_SWORD;
                SET_PC(newPC);
                CHECK_BRANCH_EXCEPTION(newPC)
@@ -25443,7 +25501,7 @@ OPCODE(0x6101)
 
        PRE_IO
 
-       oldPC = (u32)(PC) - BasePC;
+       oldPC = GET_PC;
        PUSH_32_F(oldPC)
 #ifdef FAMEC_CHECK_BRANCHES
        offs = Opcode;
@@ -25467,7 +25525,7 @@ OPCODE(0x6100)
        {
                u32 oldPC, newPC;
 
-               newPC = (u32)(PC) - BasePC;
+               newPC = GET_PC;
                oldPC = newPC + 2;
                PUSH_32_F(oldPC)
                newPC += GET_SWORD;
@@ -25658,7 +25716,7 @@ OPCODE(0x803A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_BYTE_F(adr, src)
@@ -25679,7 +25737,7 @@ OPCODE(0x803B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_BYTE_F(adr, src)
@@ -25920,7 +25978,7 @@ OPCODE(0x807A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_WORD_F(adr, src)
@@ -25941,7 +25999,7 @@ OPCODE(0x807B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_WORD_F(adr, src)
@@ -26182,7 +26240,7 @@ OPCODE(0x80BA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_LONG_F(adr, src)
@@ -26203,7 +26261,7 @@ OPCODE(0x80BB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_LONG_F(adr, src)
@@ -26983,7 +27041,7 @@ OPCODE(0x80C0)
        src = DREGu16((Opcode >> 0) & 7);
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 RET(140)
 #else
@@ -27031,7 +27089,7 @@ OPCODE(0x80D0)
        READ_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 RET(144)
 #else
@@ -27080,7 +27138,7 @@ OPCODE(0x80D8)
        READ_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 RET(144)
 #else
@@ -27129,7 +27187,7 @@ OPCODE(0x80E0)
        READ_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 RET(146)
 #else
@@ -27178,7 +27236,7 @@ OPCODE(0x80E8)
        READ_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 RET(148)
 #else
@@ -27227,7 +27285,7 @@ OPCODE(0x80F0)
        READ_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 RET(150)
 #else
@@ -27275,7 +27333,7 @@ OPCODE(0x80F8)
        READ_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 RET(148)
 #else
@@ -27323,7 +27381,7 @@ OPCODE(0x80F9)
        READ_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 RET(162)
 #else
@@ -27366,13 +27424,13 @@ OPCODE(0x80FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 RET(148)
 #else
@@ -27415,13 +27473,13 @@ OPCODE(0x80FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 RET(160)
 #else
@@ -27467,7 +27525,7 @@ OPCODE(0x80FC)
        FETCH_WORD(src);
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 RET(144)
 #else
@@ -27516,7 +27574,7 @@ OPCODE(0x80DF)
        READ_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 RET(144)
 #else
@@ -27565,7 +27623,7 @@ OPCODE(0x80E7)
        READ_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 RET(146)
 #else
@@ -27611,7 +27669,7 @@ OPCODE(0x81C0)
        src = (s32)DREGs16((Opcode >> 0) & 7);
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 goto end81C0;
 #endif
@@ -27667,7 +27725,7 @@ OPCODE(0x81D0)
        READSX_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 goto end81D0;
 #endif
@@ -27724,7 +27782,7 @@ OPCODE(0x81D8)
        READSX_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 goto end81D8;
 #endif
@@ -27781,7 +27839,7 @@ OPCODE(0x81E0)
        READSX_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 goto end81E0;
 #endif
@@ -27838,7 +27896,7 @@ OPCODE(0x81E8)
        READSX_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 goto end81E8;
 #endif
@@ -27895,7 +27953,7 @@ OPCODE(0x81F0)
        READSX_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 goto end81F0;
 #endif
@@ -27951,7 +28009,7 @@ OPCODE(0x81F8)
        READSX_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 goto end81F8;
 #endif
@@ -28007,7 +28065,7 @@ OPCODE(0x81F9)
        READSX_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 goto end81F9;
 #endif
@@ -28058,13 +28116,13 @@ OPCODE(0x81FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READSX_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 goto end81FA;
 #endif
@@ -28115,13 +28173,13 @@ OPCODE(0x81FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READSX_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 goto end81FB;
 #endif
@@ -28175,7 +28233,7 @@ OPCODE(0x81FC)
        FETCH_SWORD(src);
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 goto end81FC;
 #endif
@@ -28232,7 +28290,7 @@ OPCODE(0x81DF)
        READSX_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 goto end81DF;
 #endif
@@ -28289,7 +28347,7 @@ OPCODE(0x81E7)
        READSX_WORD_F(adr, src)
        if (src == 0)
        {
-               execute_exception(M68K_ZERO_DIVIDE_EX);
+               SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR));
 #ifdef USE_CYCLONE_TIMING_DIV
 goto end81E7;
 #endif
@@ -28516,7 +28574,7 @@ OPCODE(0x903A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_BYTE_F(adr, src)
@@ -28536,7 +28594,7 @@ OPCODE(0x903B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_BYTE_F(adr, src)
@@ -28781,7 +28839,7 @@ OPCODE(0x907A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_WORD_F(adr, src)
@@ -28801,7 +28859,7 @@ OPCODE(0x907B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_WORD_F(adr, src)
@@ -29055,7 +29113,7 @@ OPCODE(0x90BA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_LONG_F(adr, src)
@@ -29076,7 +29134,7 @@ OPCODE(0x90BB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_LONG_F(adr, src)
@@ -30046,7 +30104,11 @@ OPCODE(0x90D0)
        res = dst - src;
        AREG((Opcode >> 9) & 7) = res;
        POST_IO
+#ifdef USE_CYCLONE_TIMING
+RET(12)
+#else
 RET(10)
+#endif
 }
 
 // SUBA
@@ -30063,7 +30125,11 @@ OPCODE(0x90D8)
        res = dst - src;
        AREG((Opcode >> 9) & 7) = res;
        POST_IO
+#ifdef USE_CYCLONE_TIMING
+RET(12)
+#else
 RET(10)
+#endif
 }
 
 // SUBA
@@ -30080,7 +30146,11 @@ OPCODE(0x90E0)
        res = dst - src;
        AREG((Opcode >> 9) & 7) = res;
        POST_IO
+#ifdef USE_CYCLONE_TIMING
+RET(14)
+#else
 RET(12)
+#endif
 }
 
 // SUBA
@@ -30097,7 +30167,11 @@ OPCODE(0x90E8)
        res = dst - src;
        AREG((Opcode >> 9) & 7) = res;
        POST_IO
+#ifdef USE_CYCLONE_TIMING
+RET(16)
+#else
 RET(14)
+#endif
 }
 
 // SUBA
@@ -30114,7 +30188,11 @@ OPCODE(0x90F0)
        res = dst - src;
        AREG((Opcode >> 9) & 7) = res;
        POST_IO
+#ifdef USE_CYCLONE_TIMING
+RET(18)
+#else
 RET(16)
+#endif
 }
 
 // SUBA
@@ -30130,7 +30208,11 @@ OPCODE(0x90F8)
        res = dst - src;
        AREG((Opcode >> 9) & 7) = res;
        POST_IO
+#ifdef USE_CYCLONE_TIMING
+RET(16)
+#else
 RET(14)
+#endif
 }
 
 // SUBA
@@ -30146,7 +30228,11 @@ OPCODE(0x90F9)
        res = dst - src;
        AREG((Opcode >> 9) & 7) = res;
        POST_IO
+#ifdef USE_CYCLONE_TIMING
+RET(20)
+#else
 RET(18)
+#endif
 }
 
 // SUBA
@@ -30155,7 +30241,7 @@ OPCODE(0x90FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READSX_WORD_F(adr, src)
@@ -30163,7 +30249,11 @@ OPCODE(0x90FA)
        res = dst - src;
        AREG((Opcode >> 9) & 7) = res;
        POST_IO
+#ifdef USE_CYCLONE_TIMING
+RET(16)
+#else
 RET(14)
+#endif
 }
 
 // SUBA
@@ -30172,7 +30262,7 @@ OPCODE(0x90FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READSX_WORD_F(adr, src)
@@ -30180,7 +30270,11 @@ OPCODE(0x90FB)
        res = dst - src;
        AREG((Opcode >> 9) & 7) = res;
        POST_IO
+#ifdef USE_CYCLONE_TIMING
+RET(18)
+#else
 RET(16)
+#endif
 }
 
 // SUBA
@@ -30210,7 +30304,11 @@ OPCODE(0x90DF)
        res = dst - src;
        AREG((Opcode >> 9) & 7) = res;
        POST_IO
+#ifdef USE_CYCLONE_TIMING
+RET(12)
+#else
 RET(10)
+#endif
 }
 
 // SUBA
@@ -30227,7 +30325,11 @@ OPCODE(0x90E7)
        res = dst - src;
        AREG((Opcode >> 9) & 7) = res;
        POST_IO
+#ifdef USE_CYCLONE_TIMING
+RET(14)
+#else
 RET(12)
+#endif
 }
 
 // SUBA
@@ -30386,7 +30488,7 @@ OPCODE(0x91FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READSX_LONG_F(adr, src)
@@ -30403,7 +30505,7 @@ OPCODE(0x91FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READSX_LONG_F(adr, src)
@@ -30638,7 +30740,7 @@ OPCODE(0xB03A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_BYTE_F(adr, src)
@@ -30657,7 +30759,7 @@ OPCODE(0xB03B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_BYTE_F(adr, src)
@@ -30889,7 +30991,7 @@ OPCODE(0xB07A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_WORD_F(adr, src)
@@ -30908,7 +31010,7 @@ OPCODE(0xB07B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_WORD_F(adr, src)
@@ -31149,7 +31251,7 @@ OPCODE(0xB0BA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_LONG_F(adr, src)
@@ -31169,7 +31271,7 @@ OPCODE(0xB0BB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_LONG_F(adr, src)
@@ -32279,7 +32381,7 @@ OPCODE(0xB0FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READSX_WORD_F(adr, src)
@@ -32299,7 +32401,7 @@ OPCODE(0xB0FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READSX_WORD_F(adr, src)
@@ -32544,7 +32646,7 @@ OPCODE(0xB1FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READSX_LONG_F(adr, src)
@@ -32564,7 +32666,7 @@ OPCODE(0xB1FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READSX_LONG_F(adr, src)
@@ -32801,7 +32903,7 @@ OPCODE(0xC03A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_BYTE_F(adr, src)
@@ -32822,7 +32924,7 @@ OPCODE(0xC03B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_BYTE_F(adr, src)
@@ -33063,7 +33165,7 @@ OPCODE(0xC07A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_WORD_F(adr, src)
@@ -33084,7 +33186,7 @@ OPCODE(0xC07B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_WORD_F(adr, src)
@@ -33325,7 +33427,7 @@ OPCODE(0xC0BA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_LONG_F(adr, src)
@@ -33346,7 +33448,7 @@ OPCODE(0xC0BB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_LONG_F(adr, src)
@@ -34308,7 +34410,7 @@ OPCODE(0xC0FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_WORD_F(adr, src)
@@ -34332,7 +34434,7 @@ OPCODE(0xC0FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_WORD_F(adr, src)
@@ -34609,7 +34711,7 @@ OPCODE(0xC1FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READSX_WORD_F(adr, src)
@@ -34633,7 +34735,7 @@ OPCODE(0xC1FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READSX_WORD_F(adr, src)
@@ -34943,7 +35045,7 @@ OPCODE(0xD03A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_BYTE_F(adr, src)
@@ -34963,7 +35065,7 @@ OPCODE(0xD03B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_BYTE_F(adr, src)
@@ -35208,7 +35310,7 @@ OPCODE(0xD07A)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_WORD_F(adr, src)
@@ -35228,7 +35330,7 @@ OPCODE(0xD07B)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_WORD_F(adr, src)
@@ -35482,7 +35584,7 @@ OPCODE(0xD0BA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READ_LONG_F(adr, src)
@@ -35503,7 +35605,7 @@ OPCODE(0xD0BB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READ_LONG_F(adr, src)
@@ -36610,7 +36712,7 @@ OPCODE(0xD0FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READSX_WORD_F(adr, src)
@@ -36631,7 +36733,7 @@ OPCODE(0xD0FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READSX_WORD_F(adr, src)
@@ -36857,7 +36959,7 @@ OPCODE(0xD1FA)
        u32 adr, res;
        u32 src, dst;
 
-       adr = GET_SWORD + ((u32)(PC) - BasePC);
+       adr = GET_SWORD + GET_PC;
        PC++;
        PRE_IO
        READSX_LONG_F(adr, src)
@@ -36874,7 +36976,7 @@ OPCODE(0xD1FB)
        u32 adr, res;
        u32 src, dst;
 
-       adr = (u32)(PC) - BasePC;
+       adr = GET_PC;
        DECODE_EXT_WORD
        PRE_IO
        READSX_LONG_F(adr, src)
@@ -39858,3 +39960,98 @@ OPCODE(0xE7E7)
 RET(14)
 }
 
+#ifdef PICODRIVE_HACK
+#if 0
+#define UPDATE_IDLE_COUNT { \
+       extern int idle_hit_counter; \
+       idle_hit_counter++; \
+}
+#else
+#define UPDATE_IDLE_COUNT
+#endif
+
+// BRA
+OPCODE(0x6001_idle)
+{
+#ifdef FAMEC_CHECK_BRANCHES
+       u32 newPC = GET_PC;
+       s8 offs=Opcode;
+       newPC += offs;
+       SET_PC(newPC);
+       CHECK_BRANCH_EXCEPTION(offs)
+#else
+       PC += ((s8)(Opcode & 0xFE)) >> 1;
+#endif
+       UPDATE_IDLE_COUNT
+RET0()
+}
+
+// BCC
+OPCODE(0x6601_idle)
+{
+       if (flag_NotZ)
+       {
+               UPDATE_IDLE_COUNT
+               PC += ((s8)(Opcode & 0xFE)) >> 1;
+               //if (idle_hit)
+               RET0()
+       }
+RET(8)
+}
+
+OPCODE(0x6701_idle)
+{
+       if (!flag_NotZ)
+       {
+               UPDATE_IDLE_COUNT
+               PC += ((s8)(Opcode & 0xFE)) >> 1;
+               //if (idle_hit)
+               RET0()
+       }
+RET(8)
+}
+
+
+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)
+{
+       int frame_count, cond_true, bytes, ret, newop;
+       u16 *dest_pc;
+
+       dest_pc = PC + (((s8)(Opcode & 0xFE)) >> 1);
+
+       if (!SekIsIdleReady())
+               goto end;
+
+       bytes = 0 - (s8)(Opcode & 0xFE) - 2;
+       ret = SekIsIdleCode(dest_pc, bytes);
+       newop = (Opcode & 0xfe) | 0x7100;
+       if (!ret) newop |= 0x200;
+       if (  Opcode & 0x0100)  newop |= 0x400; // beq
+       if (!(Opcode & 0x0f00)) newop |= 0xc00; // bra
+
+       ret = SekRegisterIdlePatch(GET_PC - 2, Opcode, newop, &m68kcontext);
+       switch (ret)
+       {
+               case 0: PC[-1] = newop; break;
+               case 1: break;
+               case 2: JumpTable[Opcode] = (Opcode & 0x0f00) ?
+                               ((Opcode & 0x0100) ? CAST_OP(0x6701) : CAST_OP(0x6601)) :
+                               CAST_OP(0x6001); break;
+       }
+
+end:
+       if ((Opcode & 0xff00) == 0x6000) cond_true = 1;
+       else cond_true = (Opcode & 0x0100) ? !flag_NotZ : flag_NotZ; // beq?
+       if (cond_true)
+       {
+               PC = dest_pc;
+               m68kcontext.io_cycle_counter -= 2;
+       }
+RET(8)
+}
+
+#endif // PICODRIVE_HACK