X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cpu%2Ffame%2Ffamec_opcodes.h;h=96e467512cdc09c58f906f49de92003cd9992adb;hb=5ed2a20eaa264c72c1375943dd153c8c05403504;hp=215dbd605a3ed1023ff51bc40b4e62540020de84;hpb=80db44425aa5b46185fb9a64520f4b6f5d494ba5;p=picodrive.git diff --git a/cpu/fame/famec_opcodes.h b/cpu/fame/famec_opcodes.h index 215dbd6..96e4675 100644 --- a/cpu/fame/famec_opcodes.h +++ b/cpu/fame/famec_opcodes.h @@ -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,10 +1946,8 @@ OPCODE(0x0A7C) } else { - u32 newPC = (u32)(PC) - BasePC; - SET_PC(newPC-2); - execute_exception(M68K_PRIVILEGE_VIOLATION_EX); - RET(4) + SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + RET(0) } RET(20) } @@ -5213,7 +5207,11 @@ OPCODE(0x0108) READ_BYTE_F(adr + 2, src) DREGu16((Opcode >> 9) & 7) = (res << 8) | src; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(16) +#else RET(24) +#endif } // MOVEPLaD @@ -5237,7 +5235,11 @@ OPCODE(0x0148) READ_BYTE_F(adr, src) DREG((Opcode >> 9) & 7) = res | src; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(24) +#else RET(32) +#endif } // MOVEPWDa @@ -5253,7 +5255,11 @@ OPCODE(0x0188) WRITE_BYTE_F(adr + 0, res >> 8) WRITE_BYTE_F(adr + 2, res >> 0) POST_IO +#ifdef USE_CYCLONE_TIMING +RET(16) +#else RET(24) +#endif } // MOVEPLDa @@ -5274,7 +5280,11 @@ OPCODE(0x01C8) adr += 2; WRITE_BYTE_F(adr, res >> 0) POST_IO +#ifdef USE_CYCLONE_TIMING +RET(24) +#else RET(32) +#endif } // MOVEB @@ -5460,6 +5470,7 @@ OPCODE(0x1F00) RET(8) } +#if 0 // MOVEB OPCODE(0x1008) { @@ -5692,6 +5703,7 @@ OPCODE(0x1F08) */ RET(8) } +#endif // MOVEB OPCODE(0x1010) @@ -8279,7 +8291,7 @@ OPCODE(0x2F00) adr = AREG(7) - 4; AREG(7) = adr; PRE_IO - WRITE_LONG_F(adr, res) + WRITE_LONG_DEC_F(adr, res) POST_IO RET(12) } @@ -8462,7 +8474,7 @@ OPCODE(0x2F08) adr = AREG(7) - 4; AREG(7) = adr; PRE_IO - WRITE_LONG_F(adr, res) + WRITE_LONG_DEC_F(adr, res) POST_IO RET(12) } @@ -8657,7 +8669,7 @@ OPCODE(0x2F10) flag_N = res >> 24; adr = AREG(7) - 4; AREG(7) = adr; - WRITE_LONG_F(adr, res) + WRITE_LONG_DEC_F(adr, res) POST_IO RET(20) } @@ -8862,7 +8874,7 @@ OPCODE(0x2F18) flag_N = res >> 24; adr = AREG(7) - 4; AREG(7) = adr; - WRITE_LONG_F(adr, res) + WRITE_LONG_DEC_F(adr, res) POST_IO RET(20) } @@ -9067,7 +9079,7 @@ OPCODE(0x2F20) flag_N = res >> 24; adr = AREG(7) - 4; AREG(7) = adr; - WRITE_LONG_F(adr, res) + WRITE_LONG_DEC_F(adr, res) POST_IO RET(22) } @@ -9272,7 +9284,7 @@ OPCODE(0x2F28) flag_N = res >> 24; adr = AREG(7) - 4; AREG(7) = adr; - WRITE_LONG_F(adr, res) + WRITE_LONG_DEC_F(adr, res) POST_IO RET(24) } @@ -9477,7 +9489,7 @@ OPCODE(0x2F30) flag_N = res >> 24; adr = AREG(7) - 4; AREG(7) = adr; - WRITE_LONG_F(adr, res) + WRITE_LONG_DEC_F(adr, res) POST_IO RET(26) } @@ -9672,7 +9684,7 @@ OPCODE(0x2F38) flag_N = res >> 24; adr = AREG(7) - 4; AREG(7) = adr; - WRITE_LONG_F(adr, res) + WRITE_LONG_DEC_F(adr, res) POST_IO RET(24) } @@ -9867,7 +9879,7 @@ OPCODE(0x2F39) flag_N = res >> 24; adr = AREG(7) - 4; AREG(7) = adr; - WRITE_LONG_F(adr, res) + WRITE_LONG_DEC_F(adr, res) POST_IO RET(28) } @@ -10072,7 +10084,7 @@ OPCODE(0x2F3A) flag_N = res >> 24; adr = AREG(7) - 4; AREG(7) = adr; - WRITE_LONG_F(adr, res) + WRITE_LONG_DEC_F(adr, res) POST_IO RET(24) } @@ -10277,7 +10289,7 @@ OPCODE(0x2F3B) flag_N = res >> 24; adr = AREG(7) - 4; AREG(7) = adr; - WRITE_LONG_F(adr, res) + WRITE_LONG_DEC_F(adr, res) POST_IO RET(26) } @@ -10460,7 +10472,7 @@ OPCODE(0x2F3C) adr = AREG(7) - 4; AREG(7) = adr; PRE_IO - WRITE_LONG_F(adr, res) + WRITE_LONG_DEC_F(adr, res) POST_IO RET(20) } @@ -10665,7 +10677,7 @@ OPCODE(0x2F1F) flag_N = res >> 24; adr = AREG(7) - 4; AREG(7) = adr; - WRITE_LONG_F(adr, res) + WRITE_LONG_DEC_F(adr, res) POST_IO RET(20) } @@ -10870,7 +10882,7 @@ OPCODE(0x2F27) flag_N = res >> 24; adr = AREG(7) - 4; AREG(7) = adr; - WRITE_LONG_F(adr, res) + WRITE_LONG_DEC_F(adr, res) POST_IO RET(22) } @@ -16552,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) @@ -16583,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) @@ -16615,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) @@ -16647,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) @@ -16679,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) @@ -16711,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) @@ -16743,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) @@ -16774,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) @@ -16802,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) @@ -16838,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) @@ -16866,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) @@ -16898,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) @@ -16930,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) @@ -18306,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 @@ -18324,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 @@ -18342,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 @@ -18360,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 @@ -18378,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 @@ -18395,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 @@ -18412,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 @@ -18430,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 @@ -18448,35 +18529,41 @@ 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); -RET(4) + 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); -RET(4) + 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); -RET(4) + SET_PC(execute_exception(M68K_1111_EX, GET_PC-2, GET_SR)); +RET(0) // 4 already taken by exc. handler } // MOVEMaR @@ -19036,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) } @@ -19107,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); @@ -19125,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; @@ -19143,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 @@ -19169,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); @@ -19183,7 +19262,7 @@ OPCODE(0x4E72) AREG(7) = ASP; ASP = res; } - m68kcontext.execinfo |= M68K_HALTED; + m68kcontext.execinfo |= FM68K_HALTED; m68kcontext.io_cycle_counter = 0; RET(4) } @@ -19196,9 +19275,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 @@ -19213,7 +19290,7 @@ OPCODE(0x4E73) ASP = res; } POST_IO - m68kcontext.execinfo &= ~(M68K_EMULATE_GROUP_0|M68K_EMULATE_TRACE|M68K_DO_TRACE); + m68kcontext.execinfo &= ~(FM68K_EMULATE_GROUP_0|FM68K_EMULATE_TRACE|FM68K_DO_TRACE); CHECK_INT_TO_JUMP(20) RET(20) } @@ -19236,7 +19313,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) } @@ -19499,7 +19576,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) } @@ -19517,7 +19594,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) @@ -19537,7 +19614,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) @@ -19557,7 +19634,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) @@ -19577,7 +19654,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) @@ -19597,7 +19674,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) @@ -19616,7 +19693,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) @@ -19635,7 +19712,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) @@ -19655,7 +19732,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) @@ -19675,7 +19752,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) @@ -19692,7 +19769,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) @@ -19712,7 +19789,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) @@ -19732,7 +19809,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) @@ -23892,7 +23969,7 @@ OPCODE(0x5048) dst = AREGu32((Opcode >> 0) & 7); res = dst + src; AREG((Opcode >> 0) & 7) = res; -#ifdef USE_CYCLONE_TIMING_ // breaks Project-X +#ifdef USE_CYCLONE_TIMING RET(4) #else RET(8) @@ -26965,7 +27042,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 @@ -27013,7 +27090,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 @@ -27062,7 +27139,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 @@ -27111,7 +27188,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 @@ -27160,7 +27237,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 @@ -27209,7 +27286,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 @@ -27257,7 +27334,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 @@ -27305,7 +27382,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 @@ -27354,7 +27431,7 @@ OPCODE(0x80FA) 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 @@ -27403,7 +27480,7 @@ OPCODE(0x80FB) 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 @@ -27449,7 +27526,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 @@ -27498,7 +27575,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 @@ -27547,7 +27624,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 @@ -27593,7 +27670,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 @@ -27649,7 +27726,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 @@ -27706,7 +27783,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 @@ -27763,7 +27840,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 @@ -27820,7 +27897,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 @@ -27877,7 +27954,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 @@ -27933,7 +28010,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 @@ -27989,7 +28066,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 @@ -28046,7 +28123,7 @@ OPCODE(0x81FA) 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 @@ -28103,7 +28180,7 @@ OPCODE(0x81FB) 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 @@ -28157,7 +28234,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 @@ -28214,7 +28291,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 @@ -28271,7 +28348,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 @@ -28333,6 +28410,7 @@ RET(4) } // SUBaD +#if 0 OPCODE(0x9008) { u32 adr, res; @@ -28352,6 +28430,7 @@ OPCODE(0x9008) */ RET(4) } +#endif // SUBaD OPCODE(0x9010) @@ -30026,7 +30105,11 @@ OPCODE(0x90D0) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(12) +#else RET(10) +#endif } // SUBA @@ -30043,7 +30126,11 @@ OPCODE(0x90D8) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(12) +#else RET(10) +#endif } // SUBA @@ -30060,7 +30147,11 @@ OPCODE(0x90E0) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(14) +#else RET(12) +#endif } // SUBA @@ -30077,7 +30168,11 @@ OPCODE(0x90E8) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(16) +#else RET(14) +#endif } // SUBA @@ -30094,7 +30189,11 @@ OPCODE(0x90F0) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(18) +#else RET(16) +#endif } // SUBA @@ -30110,7 +30209,11 @@ OPCODE(0x90F8) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(16) +#else RET(14) +#endif } // SUBA @@ -30126,7 +30229,11 @@ OPCODE(0x90F9) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(20) +#else RET(18) +#endif } // SUBA @@ -30143,7 +30250,11 @@ OPCODE(0x90FA) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(16) +#else RET(14) +#endif } // SUBA @@ -30160,7 +30271,11 @@ OPCODE(0x90FB) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(18) +#else RET(16) +#endif } // SUBA @@ -30190,7 +30305,11 @@ OPCODE(0x90DF) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(12) +#else RET(10) +#endif } // SUBA @@ -30207,7 +30326,11 @@ OPCODE(0x90E7) res = dst - src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(14) +#else RET(12) +#endif } // SUBA @@ -30461,6 +30584,7 @@ RET(4) } // CMP +#if 0 OPCODE(0xB008) { u32 adr, res; @@ -30479,6 +30603,7 @@ OPCODE(0xB008) */ RET(4) } +#endif // CMP OPCODE(0xB010) @@ -34756,6 +34881,7 @@ RET(4) } // ADDaD +#if 0 OPCODE(0xD008) { u32 adr, res; @@ -34775,6 +34901,7 @@ OPCODE(0xD008) */ RET(4) } +#endif // ADDaD OPCODE(0xD010) @@ -36449,7 +36576,11 @@ OPCODE(0xD0D0) res = dst + src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(12) +#else RET(10) +#endif } // ADDA @@ -36466,7 +36597,11 @@ OPCODE(0xD0D8) res = dst + src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(12) +#else RET(10) +#endif } // ADDA @@ -36483,7 +36618,11 @@ OPCODE(0xD0E0) res = dst + src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(14) +#else RET(12) +#endif } // ADDA @@ -36500,7 +36639,11 @@ OPCODE(0xD0E8) res = dst + src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(16) +#else RET(14) +#endif } // ADDA @@ -36517,7 +36660,11 @@ OPCODE(0xD0F0) res = dst + src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(18) +#else RET(16) +#endif } // ADDA @@ -36533,7 +36680,11 @@ OPCODE(0xD0F8) res = dst + src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(16) +#else RET(14) +#endif } // ADDA @@ -36549,7 +36700,11 @@ OPCODE(0xD0F9) res = dst + src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(20) +#else RET(18) +#endif } // ADDA @@ -36566,7 +36721,11 @@ OPCODE(0xD0FA) res = dst + src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(16) +#else RET(14) +#endif } // ADDA @@ -36583,7 +36742,11 @@ OPCODE(0xD0FB) res = dst + src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(18) +#else RET(16) +#endif } // ADDA @@ -36613,7 +36776,11 @@ OPCODE(0xD0DF) res = dst + src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(12) +#else RET(10) +#endif } // ADDA @@ -36630,7 +36797,11 @@ OPCODE(0xD0E7) res = dst + src; AREG((Opcode >> 9) & 7) = res; POST_IO +#ifdef USE_CYCLONE_TIMING +RET(14) +#else RET(12) +#endif } // ADDA @@ -39790,3 +39961,99 @@ 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 = (u32)(PC) - BasePC; + s8 offs=Opcode; + newPC += offs; + SET_PC(newPC); + CHECK_BRANCH_EXCEPTION(offs) +#else + PC += ((s8)(Opcode & 0xFE)) >> 1; +#endif + UPDATE_IDLE_COUNT + m68kcontext.io_cycle_counter = 10; +RET(10) +} + +// BCC +OPCODE(0x6601_idle) +{ + if (flag_NotZ) + { + UPDATE_IDLE_COUNT + PC += ((s8)(Opcode & 0xFE)) >> 1; + m68kcontext.io_cycle_counter = 8; + } +RET(8) +} + +OPCODE(0x6701_idle) +{ + if (!flag_NotZ) + { + UPDATE_IDLE_COUNT + PC += ((s8)(Opcode & 0xFE)) >> 1; + m68kcontext.io_cycle_counter = 8; + } +RET(8) +} + + +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) + 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