X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cpu%2Ffame%2Ffamec_opcodes.h;h=e069e9ea177e58fab65ff20a50132f6132a6a01b;hb=7669591e0876778fc4f3977b145c012f2e3a12e9;hp=bd2efb022909095ea8ae6646370fb2c19f123e2c;hpb=f6aa2456a483b54566442d28d18a9f2fb2740125;p=picodrive.git diff --git a/cpu/fame/famec_opcodes.h b/cpu/fame/famec_opcodes.h index bd2efb0..e069e9e 100644 --- a/cpu/fame/famec_opcodes.h +++ b/cpu/fame/famec_opcodes.h @@ -1,6 +1,6 @@ #ifdef PICODRIVE_HACK -#define NOT_POLLING g_m68kcontext->not_polling = 1; +#define NOT_POLLING ctx->not_polling = 1; #else #define NOT_POLLING #endif @@ -644,7 +644,7 @@ OPCODE(0x007C) } else { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); #ifdef USE_CYCLONE_TIMING RET(0) #else @@ -1302,7 +1302,7 @@ OPCODE(0x027C) } else { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(4) } RET(20) @@ -1952,7 +1952,7 @@ OPCODE(0x0A7C) } else { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(0) } RET(20) @@ -5484,8 +5484,8 @@ OPCODE(0x1008) u32 src, dst; // can't read byte from Ax registers ! - m68kcontext.execinfo |= M68K_FAULTED; - m68kcontext.io_cycle_counter = 0; + ctx->execinfo |= M68K_FAULTED; + ctx->io_cycle_counter = 0; /* goto famec_Exec_End; flag_C = 0; @@ -5504,8 +5504,8 @@ OPCODE(0x1088) u32 src, dst; // can't read byte from Ax registers ! - m68kcontext.execinfo |= M68K_FAULTED; - m68kcontext.io_cycle_counter = 0; + ctx->execinfo |= M68K_FAULTED; + ctx->io_cycle_counter = 0; /* goto famec_Exec_End; flag_C = 0; @@ -5527,8 +5527,8 @@ OPCODE(0x10C8) u32 src, dst; // can't read byte from Ax registers ! - m68kcontext.execinfo |= M68K_FAULTED; - m68kcontext.io_cycle_counter = 0; + ctx->execinfo |= M68K_FAULTED; + ctx->io_cycle_counter = 0; /* goto famec_Exec_End; flag_C = 0; @@ -5551,8 +5551,8 @@ OPCODE(0x1108) u32 src, dst; // can't read byte from Ax registers ! - m68kcontext.execinfo |= M68K_FAULTED; - m68kcontext.io_cycle_counter = 0; + ctx->execinfo |= M68K_FAULTED; + ctx->io_cycle_counter = 0; /* goto famec_Exec_End; flag_C = 0; @@ -5575,8 +5575,8 @@ OPCODE(0x1148) u32 src, dst; // can't read byte from Ax registers ! - m68kcontext.execinfo |= M68K_FAULTED; - m68kcontext.io_cycle_counter = 0; + ctx->execinfo |= M68K_FAULTED; + ctx->io_cycle_counter = 0; /* goto famec_Exec_End; flag_C = 0; @@ -5599,8 +5599,8 @@ OPCODE(0x1188) u32 src, dst; // can't read byte from Ax registers ! - m68kcontext.execinfo |= M68K_FAULTED; - m68kcontext.io_cycle_counter = 0; + ctx->execinfo |= M68K_FAULTED; + ctx->io_cycle_counter = 0; /* goto famec_Exec_End; flag_C = 0; @@ -5623,8 +5623,8 @@ OPCODE(0x11C8) u32 src, dst; // can't read byte from Ax registers ! - m68kcontext.execinfo |= M68K_FAULTED; - m68kcontext.io_cycle_counter = 0; + ctx->execinfo |= M68K_FAULTED; + ctx->io_cycle_counter = 0; /* goto famec_Exec_End; flag_C = 0; @@ -5646,8 +5646,8 @@ OPCODE(0x13C8) u32 src, dst; // can't read byte from Ax registers ! - m68kcontext.execinfo |= M68K_FAULTED; - m68kcontext.io_cycle_counter = 0; + ctx->execinfo |= M68K_FAULTED; + ctx->io_cycle_counter = 0; /* goto famec_Exec_End; flag_C = 0; @@ -5669,8 +5669,8 @@ OPCODE(0x1EC8) u32 src, dst; // can't read byte from Ax registers ! - m68kcontext.execinfo |= M68K_FAULTED; - m68kcontext.io_cycle_counter = 0; + ctx->execinfo |= M68K_FAULTED; + ctx->io_cycle_counter = 0; /* goto famec_Exec_End; flag_C = 0; @@ -5693,8 +5693,8 @@ OPCODE(0x1F08) u32 src, dst; // can't read byte from Ax registers ! - m68kcontext.execinfo |= M68K_FAULTED; - m68kcontext.io_cycle_counter = 0; + ctx->execinfo |= M68K_FAULTED; + ctx->io_cycle_counter = 0; /* goto famec_Exec_End; flag_C = 0; @@ -16570,7 +16570,7 @@ OPCODE(0x46C0) } else { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(4) } RET(12) @@ -16599,7 +16599,7 @@ OPCODE(0x46D0) } else { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(4) } RET(16) @@ -16629,7 +16629,7 @@ OPCODE(0x46D8) } else { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(4) } RET(16) @@ -16659,7 +16659,7 @@ OPCODE(0x46E0) } else { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(4) } RET(18) @@ -16689,7 +16689,7 @@ OPCODE(0x46E8) } else { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(4) } RET(20) @@ -16719,7 +16719,7 @@ OPCODE(0x46F0) } else { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(4) } RET(22) @@ -16749,7 +16749,7 @@ OPCODE(0x46F8) } else { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(4) } RET(20) @@ -16778,7 +16778,7 @@ OPCODE(0x46F9) } else { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(4) } RET(24) @@ -16808,7 +16808,7 @@ OPCODE(0x46FA) } else { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(4) } RET(20) @@ -16838,7 +16838,7 @@ OPCODE(0x46FB) } else { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(4) } RET(22) @@ -16864,7 +16864,7 @@ OPCODE(0x46FC) } else { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(4) } RET(16) @@ -16894,7 +16894,7 @@ OPCODE(0x46DF) } else { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(4) } RET(16) @@ -16924,7 +16924,7 @@ OPCODE(0x46E7) } else { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(4) } RET(18) @@ -16936,18 +16936,20 @@ OPCODE(0x4800) u32 adr, res; u32 src, dst; - res = DREGu8((Opcode >> 0) & 7); - res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1); + dst = DREGu8((Opcode >> 0) & 7); + res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1); - if (res != 0x9a) + if (res != 0) { - if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; - res &= 0xFF; - DREGu8((Opcode >> 0) & 7) = res; + flag_V = res; + if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6; + res = (res + 0x9a) & 0xFF; + DREGu8((Opcode >> 0) & 7) = res; + flag_V &= ~res; flag_NotZ |= res; flag_X = flag_C = M68K_SR_C; } - else flag_X = flag_C = 0; + else flag_V = flag_X = flag_C = 0; flag_N = res; RET(6) } @@ -16960,18 +16962,20 @@ OPCODE(0x4810) adr = AREG((Opcode >> 0) & 7); PRE_IO - READ_BYTE_F(adr, res) - res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1); + READ_BYTE_F(adr, dst) + res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1); - if (res != 0x9a) + if (res != 0) { - if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; - res &= 0xFF; - WRITE_BYTE_F(adr, res) + flag_V = res; + if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6; + res = (res + 0x9a) & 0xFF; + WRITE_BYTE_F(adr, res) + flag_V &= ~res; flag_NotZ |= res; flag_X = flag_C = M68K_SR_C; } - else flag_X = flag_C = 0; + else flag_V = flag_X = flag_C = 0; flag_N = res; POST_IO RET(12) @@ -16986,18 +16990,20 @@ OPCODE(0x4818) adr = AREG((Opcode >> 0) & 7); AREG((Opcode >> 0) & 7) += 1; PRE_IO - READ_BYTE_F(adr, res) - res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1); + READ_BYTE_F(adr, dst) + res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1); - if (res != 0x9a) + if (res != 0) { - if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; - res &= 0xFF; - WRITE_BYTE_F(adr, res) + flag_V = res; + if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6; + res = (res + 0x9a) & 0xFF; + WRITE_BYTE_F(adr, res) + flag_V &= ~res; flag_NotZ |= res; flag_X = flag_C = M68K_SR_C; } - else flag_X = flag_C = 0; + else flag_V = flag_X = flag_C = 0; flag_N = res; POST_IO RET(12) @@ -17012,18 +17018,20 @@ OPCODE(0x4820) adr = AREG((Opcode >> 0) & 7) - 1; AREG((Opcode >> 0) & 7) = adr; PRE_IO - READ_BYTE_F(adr, res) - res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1); + READ_BYTE_F(adr, dst) + res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1); - if (res != 0x9a) + if (res != 0) { - if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; - res &= 0xFF; - WRITE_BYTE_F(adr, res) + flag_V = res; + if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6; + res = (res + 0x9a) & 0xFF; + WRITE_BYTE_F(adr, res) + flag_V &= ~res; flag_NotZ |= res; flag_X = flag_C = M68K_SR_C; } - else flag_X = flag_C = 0; + else flag_V = flag_X = flag_C = 0; flag_N = res; POST_IO RET(14) @@ -17038,18 +17046,20 @@ OPCODE(0x4828) FETCH_SWORD(adr); adr += AREG((Opcode >> 0) & 7); PRE_IO - READ_BYTE_F(adr, res) - res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1); + READ_BYTE_F(adr, dst) + res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1); - if (res != 0x9a) + if (res != 0) { - if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; - res &= 0xFF; - WRITE_BYTE_F(adr, res) + flag_V = res; + if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6; + res = (res + 0x9a) & 0xFF; + WRITE_BYTE_F(adr, res) + flag_V &= ~res; flag_NotZ |= res; flag_X = flag_C = M68K_SR_C; } - else flag_X = flag_C = 0; + else flag_V = flag_X = flag_C = 0; flag_N = res; POST_IO RET(16) @@ -17064,18 +17074,20 @@ OPCODE(0x4830) adr = AREG((Opcode >> 0) & 7); DECODE_EXT_WORD PRE_IO - READ_BYTE_F(adr, res) - res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1); + READ_BYTE_F(adr, dst) + res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1); - if (res != 0x9a) + if (res != 0) { - if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; - res &= 0xFF; - WRITE_BYTE_F(adr, res) + flag_V = res; + if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6; + res = (res + 0x9a) & 0xFF; + WRITE_BYTE_F(adr, res) + flag_V &= ~res; flag_NotZ |= res; flag_X = flag_C = M68K_SR_C; } - else flag_X = flag_C = 0; + else flag_V = flag_X = flag_C = 0; flag_N = res; POST_IO RET(18) @@ -17089,18 +17101,20 @@ OPCODE(0x4838) FETCH_SWORD(adr); PRE_IO - READ_BYTE_F(adr, res) - res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1); + READ_BYTE_F(adr, dst) + res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1); - if (res != 0x9a) + if (res != 0) { - if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; - res &= 0xFF; - WRITE_BYTE_F(adr, res) + flag_V = res; + if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6; + res = (res + 0x9a) & 0xFF; + WRITE_BYTE_F(adr, res) + flag_V &= ~res; flag_NotZ |= res; flag_X = flag_C = M68K_SR_C; } - else flag_X = flag_C = 0; + else flag_V = flag_X = flag_C = 0; flag_N = res; POST_IO RET(16) @@ -17114,18 +17128,20 @@ OPCODE(0x4839) FETCH_LONG(adr); PRE_IO - READ_BYTE_F(adr, res) - res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1); + READ_BYTE_F(adr, dst) + res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1); - if (res != 0x9a) + if (res != 0) { - if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; - res &= 0xFF; - WRITE_BYTE_F(adr, res) + flag_V = res; + if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6; + res = (res + 0x9a) & 0xFF; + WRITE_BYTE_F(adr, res) + flag_V &= ~res; flag_NotZ |= res; flag_X = flag_C = M68K_SR_C; } - else flag_X = flag_C = 0; + else flag_V = flag_X = flag_C = 0; flag_N = res; POST_IO RET(20) @@ -17140,18 +17156,20 @@ OPCODE(0x481F) adr = AREG(7); AREG(7) += 2; PRE_IO - READ_BYTE_F(adr, res) - res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1); + READ_BYTE_F(adr, dst) + res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1); - if (res != 0x9a) + if (res != 0) { - if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; - res &= 0xFF; - WRITE_BYTE_F(adr, res) + flag_V = res; + if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6; + res = (res + 0x9a) & 0xFF; + WRITE_BYTE_F(adr, res) + flag_V &= ~res; flag_NotZ |= res; flag_X = flag_C = M68K_SR_C; } - else flag_X = flag_C = 0; + else flag_V = flag_X = flag_C = 0; flag_N = res; POST_IO RET(12) @@ -17166,18 +17184,20 @@ OPCODE(0x4827) adr = AREG(7) - 2; AREG(7) = adr; PRE_IO - READ_BYTE_F(adr, res) - res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1); + READ_BYTE_F(adr, dst) + res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1); - if (res != 0x9a) + if (res != 0) { - if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10; - res &= 0xFF; - WRITE_BYTE_F(adr, res) + flag_V = res; + if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6; + res = (res + 0x9a) & 0xFF; + WRITE_BYTE_F(adr, res) + flag_V &= ~res; flag_NotZ |= res; flag_X = flag_C = M68K_SR_C; } - else flag_X = flag_C = 0; + else flag_V = flag_X = flag_C = 0; flag_N = res; POST_IO RET(14) @@ -17317,7 +17337,7 @@ OPCODE(0x4890) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(8) #else @@ -17349,7 +17369,7 @@ OPCODE(0x48A0) } while (res >>= 1); AREG((Opcode >> 0) & 7) = adr; POST_IO - m68kcontext.io_cycle_counter -= (dst - adr) * 2; + ctx->io_cycle_counter -= (dst - adr) * 2; RET(8) } @@ -17377,7 +17397,7 @@ OPCODE(0x48A8) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(12) #else @@ -17409,7 +17429,7 @@ OPCODE(0x48B0) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(14) #else @@ -17440,7 +17460,7 @@ OPCODE(0x48B8) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(12) #else @@ -17471,7 +17491,7 @@ OPCODE(0x48B9) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(16) #else @@ -17503,7 +17523,7 @@ OPCODE(0x48A7) } while (res >>= 1); AREG(7) = adr; POST_IO - m68kcontext.io_cycle_counter -= (dst - adr) * 2; + ctx->io_cycle_counter -= (dst - adr) * 2; RET(8) } @@ -17530,7 +17550,7 @@ OPCODE(0x48D0) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(8) #else @@ -17562,7 +17582,7 @@ OPCODE(0x48E0) } while (res >>= 1); AREG((Opcode >> 0) & 7) = adr; POST_IO - m68kcontext.io_cycle_counter -= (dst - adr) * 2; + ctx->io_cycle_counter -= (dst - adr) * 2; RET(8) } @@ -17590,7 +17610,7 @@ OPCODE(0x48E8) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(12) #else @@ -17622,7 +17642,7 @@ OPCODE(0x48F0) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(14) #else @@ -17653,7 +17673,7 @@ OPCODE(0x48F8) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(12) #else @@ -17684,7 +17704,7 @@ OPCODE(0x48F9) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(16) #else @@ -17716,7 +17736,7 @@ OPCODE(0x48E7) } while (res >>= 1); AREG(7) = adr; POST_IO - m68kcontext.io_cycle_counter -= (dst - adr) * 2; + ctx->io_cycle_counter -= (dst - adr) * 2; RET(8) } @@ -18299,7 +18319,7 @@ OPCODE(0x4AD0) flag_NotZ = res; flag_N = res; #ifdef PICODRIVE_HACK - if (g_m68kcontext == &PicoCpuFS68k) { + if (ctx == &PicoCpuFS68k) { res |= 0x80; WRITE_BYTE_F(adr, res); } @@ -18329,7 +18349,7 @@ OPCODE(0x4AD8) flag_N = res; #ifdef PICODRIVE_HACK - if (g_m68kcontext == &PicoCpuFS68k) { + if (ctx == &PicoCpuFS68k) { res |= 0x80; WRITE_BYTE_F(adr, res); } @@ -18359,7 +18379,7 @@ OPCODE(0x4AE0) flag_N = res; #ifdef PICODRIVE_HACK - if (g_m68kcontext == &PicoCpuFS68k) { + if (ctx == &PicoCpuFS68k) { res |= 0x80; WRITE_BYTE_F(adr, res); } @@ -18389,7 +18409,7 @@ OPCODE(0x4AE8) flag_N = res; #ifdef PICODRIVE_HACK - if (g_m68kcontext == &PicoCpuFS68k) { + if (ctx == &PicoCpuFS68k) { res |= 0x80; WRITE_BYTE_F(adr, res); } @@ -18419,7 +18439,7 @@ OPCODE(0x4AF0) flag_N = res; #ifdef PICODRIVE_HACK - if (g_m68kcontext == &PicoCpuFS68k) { + if (ctx == &PicoCpuFS68k) { res |= 0x80; WRITE_BYTE_F(adr, res); } @@ -18448,7 +18468,7 @@ OPCODE(0x4AF8) flag_N = res; #ifdef PICODRIVE_HACK - if (g_m68kcontext == &PicoCpuFS68k) { + if (ctx == &PicoCpuFS68k) { res |= 0x80; WRITE_BYTE_F(adr, res); } @@ -18477,7 +18497,7 @@ OPCODE(0x4AF9) flag_N = res; #ifdef PICODRIVE_HACK - if (g_m68kcontext == &PicoCpuFS68k) { + if (ctx == &PicoCpuFS68k) { res |= 0x80; WRITE_BYTE_F(adr, res); } @@ -18507,7 +18527,7 @@ OPCODE(0x4ADF) flag_N = res; #ifdef PICODRIVE_HACK - if (g_m68kcontext == &PicoCpuFS68k) { + if (ctx == &PicoCpuFS68k) { res |= 0x80; WRITE_BYTE_F(adr, res); } @@ -18537,7 +18557,7 @@ OPCODE(0x4AE7) flag_N = res; #ifdef PICODRIVE_HACK - if (g_m68kcontext == &PicoCpuFS68k) { + if (ctx == &PicoCpuFS68k) { res |= 0x80; WRITE_BYTE_F(adr, res); } @@ -18554,21 +18574,25 @@ RET(8) // ILLEGAL OPCODE(0x4AFC) { - SET_PC(execute_exception(M68K_ILLEGAL_INSTRUCTION_EX, GET_PC-2, GET_SR)); +#ifdef PICODRIVE_HACK + extern void SekFinishIdleDet(void); + SekFinishIdleDet(); +#endif + SET_PC(execute_exception(ctx, M68K_ILLEGAL_INSTRUCTION_EX, GET_PC-2, GET_SR)); RET(0) } // ILLEGAL A000-AFFF OPCODE(0xA000) { - SET_PC(execute_exception(M68K_1010_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_1010_EX, GET_PC-2, GET_SR)); RET(0) } // ILLEGAL F000-FFFF OPCODE(0xF000) { - SET_PC(execute_exception(M68K_1111_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_1111_EX, GET_PC-2, GET_SR)); RET(0) // 4 already taken by exc. handler } @@ -18595,7 +18619,7 @@ OPCODE(0x4C90) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(12) #else @@ -18627,7 +18651,7 @@ OPCODE(0x4C98) } while (res >>= 1); AREG((Opcode >> 0) & 7) = adr; POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; RET(12) } @@ -18655,7 +18679,7 @@ OPCODE(0x4CA8) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(16) #else @@ -18687,7 +18711,7 @@ OPCODE(0x4CB0) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(18) #else @@ -18718,7 +18742,7 @@ OPCODE(0x4CB8) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(16) #else @@ -18749,7 +18773,7 @@ OPCODE(0x4CB9) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(20) #else @@ -18781,7 +18805,7 @@ OPCODE(0x4CBA) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(16) #else @@ -18813,7 +18837,7 @@ OPCODE(0x4CBB) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(18) #else @@ -18845,7 +18869,7 @@ OPCODE(0x4C9F) } while (res >>= 1); AREG(7) = adr; POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; RET(12) } @@ -18872,7 +18896,7 @@ OPCODE(0x4CD0) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(12) #else @@ -18904,7 +18928,7 @@ OPCODE(0x4CD8) } while (res >>= 1); AREG((Opcode >> 0) & 7) = adr; POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; RET(12) } @@ -18932,7 +18956,7 @@ OPCODE(0x4CE8) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(16) #else @@ -18964,7 +18988,7 @@ OPCODE(0x4CF0) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(18) #else @@ -18995,7 +19019,7 @@ OPCODE(0x4CF8) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(16) #else @@ -19026,7 +19050,7 @@ OPCODE(0x4CF9) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(20) #else @@ -19058,7 +19082,7 @@ OPCODE(0x4CFA) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(16) #else @@ -19090,7 +19114,7 @@ OPCODE(0x4CFB) psrc++; } while (res >>= 1); POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; #ifdef USE_CYCLONE_TIMING RET(18) #else @@ -19122,14 +19146,14 @@ OPCODE(0x4CDF) } while (res >>= 1); AREG(7) = adr; POST_IO - m68kcontext.io_cycle_counter -= (adr - dst) * 2; + ctx->io_cycle_counter -= (adr - dst) * 2; RET(12) } // TRAP OPCODE(0x4E40) { - SET_PC(execute_exception(M68K_TRAP_BASE_EX + (Opcode & 0xF), GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_TRAP_BASE_EX + (Opcode & 0xF), GET_PC, GET_SR)); RET(4) } @@ -19200,7 +19224,7 @@ OPCODE(0x4E60) if (!flag_S) { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(4) } res = AREGu32((Opcode >> 0) & 7); @@ -19216,7 +19240,7 @@ OPCODE(0x4E68) if (!flag_S) { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(4) } res = ASP; @@ -19232,11 +19256,11 @@ OPCODE(0x4E70) if (!flag_S) { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(4) } PRE_IO - if (m68kcontext.reset_handler) m68kcontext.reset_handler(); + if (ctx->reset_handler) ctx->reset_handler(); // CPU->Reset_CallBack(); POST_IO RET(132) @@ -19256,7 +19280,7 @@ OPCODE(0x4E72) if (!flag_S) { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(4) } FETCH_WORD(res); @@ -19268,7 +19292,7 @@ OPCODE(0x4E72) AREG(7) = ASP; ASP = res; } - m68kcontext.execinfo |= FM68K_HALTED; + ctx->execinfo |= FM68K_HALTED; RET0() } @@ -19280,7 +19304,7 @@ OPCODE(0x4E73) if (!flag_S) { - SET_PC(execute_exception(M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); + SET_PC(execute_exception(ctx, M68K_PRIVILEGE_VIOLATION_EX, GET_PC-2, GET_SR)); RET(4) } PRE_IO @@ -19295,7 +19319,7 @@ OPCODE(0x4E73) ASP = res; } POST_IO - m68kcontext.execinfo &= ~(FM68K_EMULATE_GROUP_0|FM68K_EMULATE_TRACE|FM68K_DO_TRACE); + ctx->execinfo &= ~(FM68K_EMULATE_GROUP_0|FM68K_EMULATE_TRACE|FM68K_DO_TRACE); CHECK_INT_TO_JUMP(20) RET(20) } @@ -19318,7 +19342,7 @@ RET(16) OPCODE(0x4E76) { if (flag_V & 0x80) - SET_PC(execute_exception(M68K_TRAPV_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_TRAPV_EX, GET_PC, GET_SR)); RET(4) } @@ -19580,7 +19604,7 @@ OPCODE(0x4180) if ((res < 0) || (res > src)) { flag_N = res >> 8; - SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR)); } RET(10) } @@ -19598,7 +19622,7 @@ OPCODE(0x4190) if ((res < 0) || (res > src)) { flag_N = res >> 8; - SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR)); } POST_IO RET(14) @@ -19618,7 +19642,7 @@ OPCODE(0x4198) if ((res < 0) || (res > src)) { flag_N = res >> 8; - SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR)); } POST_IO RET(14) @@ -19638,7 +19662,7 @@ OPCODE(0x41A0) if ((res < 0) || (res > src)) { flag_N = res >> 8; - SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR)); } POST_IO RET(16) @@ -19658,7 +19682,7 @@ OPCODE(0x41A8) if ((res < 0) || (res > src)) { flag_N = res >> 8; - SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR)); } POST_IO RET(18) @@ -19678,7 +19702,7 @@ OPCODE(0x41B0) if ((res < 0) || (res > src)) { flag_N = res >> 8; - SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR)); } POST_IO RET(20) @@ -19697,7 +19721,7 @@ OPCODE(0x41B8) if ((res < 0) || (res > src)) { flag_N = res >> 8; - SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR)); } POST_IO RET(18) @@ -19716,7 +19740,7 @@ OPCODE(0x41B9) if ((res < 0) || (res > src)) { flag_N = res >> 8; - SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR)); } POST_IO RET(22) @@ -19736,7 +19760,7 @@ OPCODE(0x41BA) if ((res < 0) || (res > src)) { flag_N = res >> 8; - SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR)); } POST_IO RET(18) @@ -19756,7 +19780,7 @@ OPCODE(0x41BB) if ((res < 0) || (res > src)) { flag_N = res >> 8; - SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR)); } POST_IO RET(20) @@ -19773,7 +19797,7 @@ OPCODE(0x41BC) if ((res < 0) || (res > src)) { flag_N = res >> 8; - SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR)); } POST_IO RET(14) @@ -19793,7 +19817,7 @@ OPCODE(0x419F) if ((res < 0) || (res > src)) { flag_N = res >> 8; - SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR)); } POST_IO RET(14) @@ -19813,7 +19837,7 @@ OPCODE(0x41A7) if ((res < 0) || (res > src)) { flag_N = res >> 8; - SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR)); } POST_IO RET(16) @@ -25027,7 +25051,7 @@ OPCODE(0x6201) if (flag_NotZ && (!(flag_C & 0x100))) { PC += ((s8)(Opcode & 0xFE)) >> 1; - m68kcontext.io_cycle_counter -= 2; + ctx->io_cycle_counter -= 2; } RET(8) } @@ -25041,7 +25065,7 @@ OPCODE(0x6301) if ((!flag_NotZ) || (flag_C & 0x100)) { PC += ((s8)(Opcode & 0xFE)) >> 1; - m68kcontext.io_cycle_counter -= 2; + ctx->io_cycle_counter -= 2; } RET(8) } @@ -25055,7 +25079,7 @@ OPCODE(0x6401) if (!(flag_C & 0x100)) { PC += ((s8)(Opcode & 0xFE)) >> 1; - m68kcontext.io_cycle_counter -= 2; + ctx->io_cycle_counter -= 2; } RET(8) } @@ -25069,7 +25093,7 @@ OPCODE(0x6501) if (flag_C & 0x100) { PC += ((s8)(Opcode & 0xFE)) >> 1; - m68kcontext.io_cycle_counter -= 2; + ctx->io_cycle_counter -= 2; } RET(8) } @@ -25083,7 +25107,7 @@ OPCODE(0x6601) if (flag_NotZ) { PC += ((s8)(Opcode & 0xFE)) >> 1; - m68kcontext.io_cycle_counter -= 2; + ctx->io_cycle_counter -= 2; } RET(8) } @@ -25097,7 +25121,7 @@ OPCODE(0x6701) if (!flag_NotZ) { PC += ((s8)(Opcode & 0xFE)) >> 1; - m68kcontext.io_cycle_counter -= 2; + ctx->io_cycle_counter -= 2; } RET(8) } @@ -25111,7 +25135,7 @@ OPCODE(0x6801) if (!(flag_V & 0x80)) { PC += ((s8)(Opcode & 0xFE)) >> 1; - m68kcontext.io_cycle_counter -= 2; + ctx->io_cycle_counter -= 2; } RET(8) } @@ -25125,7 +25149,7 @@ OPCODE(0x6901) if (flag_V & 0x80) { PC += ((s8)(Opcode & 0xFE)) >> 1; - m68kcontext.io_cycle_counter -= 2; + ctx->io_cycle_counter -= 2; } RET(8) } @@ -25139,7 +25163,7 @@ OPCODE(0x6A01) if (!(flag_N & 0x80)) { PC += ((s8)(Opcode & 0xFE)) >> 1; - m68kcontext.io_cycle_counter -= 2; + ctx->io_cycle_counter -= 2; } RET(8) } @@ -25153,7 +25177,7 @@ OPCODE(0x6B01) if (flag_N & 0x80) { PC += ((s8)(Opcode & 0xFE)) >> 1; - m68kcontext.io_cycle_counter -= 2; + ctx->io_cycle_counter -= 2; } RET(8) } @@ -25167,7 +25191,7 @@ OPCODE(0x6C01) if (!((flag_N ^ flag_V) & 0x80)) { PC += ((s8)(Opcode & 0xFE)) >> 1; - m68kcontext.io_cycle_counter -= 2; + ctx->io_cycle_counter -= 2; } RET(8) } @@ -25181,7 +25205,7 @@ OPCODE(0x6D01) if ((flag_N ^ flag_V) & 0x80) { PC += ((s8)(Opcode & 0xFE)) >> 1; - m68kcontext.io_cycle_counter -= 2; + ctx->io_cycle_counter -= 2; } RET(8) } @@ -25195,7 +25219,7 @@ OPCODE(0x6E01) if (flag_NotZ && (!((flag_N ^ flag_V) & 0x80))) { PC += ((s8)(Opcode & 0xFE)) >> 1; - m68kcontext.io_cycle_counter -= 2; + ctx->io_cycle_counter -= 2; } RET(8) } @@ -25209,7 +25233,7 @@ OPCODE(0x6F01) if ((!flag_NotZ) || ((flag_N ^ flag_V) & 0x80)) { PC += ((s8)(Opcode & 0xFE)) >> 1; - m68kcontext.io_cycle_counter -= 2; + ctx->io_cycle_counter -= 2; } RET(8) } @@ -26933,19 +26957,19 @@ OPCODE(0x8100) { u32 adr, res; u32 src, dst; + u32 corf = 0; src = DREGu8((Opcode >> 0) & 7); dst = DREGu8((Opcode >> 9) & 7); res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1); - if (res > 9) res -= 6; + if (res > 0xF) corf = 6; res += (dst & 0xF0) - (src & 0xF0); - if (res > 0x99) - { - res += 0xA0; - flag_X = flag_C = M68K_SR_C; - } - else flag_X = flag_C = 0; - flag_NotZ |= res & 0xFF; + flag_V = res; + flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0; + if (res > 0xff) res += 0xA0; + res = (res - corf) & 0xFF; + flag_V &= ~res; + flag_NotZ |= res; flag_N = res; DREGu8((Opcode >> 9) & 7) = res; RET(6) @@ -26956,6 +26980,7 @@ OPCODE(0x8108) { u32 adr, res; u32 src, dst; + u32 corf = 0; adr = AREG((Opcode >> 0) & 7) - 1; AREG((Opcode >> 0) & 7) = adr; @@ -26965,15 +26990,14 @@ OPCODE(0x8108) AREG((Opcode >> 9) & 7) = adr; READ_BYTE_F(adr, dst) res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1); - if (res > 9) res -= 6; + if (res > 0xF) corf = 6; res += (dst & 0xF0) - (src & 0xF0); - if (res > 0x99) - { - res += 0xA0; - flag_X = flag_C = M68K_SR_C; - } - else flag_X = flag_C = 0; - flag_NotZ |= res & 0xFF; + flag_V = res; + flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0; + if (res > 0xff) res += 0xA0; + res = (res - corf) & 0xFF; + flag_V &= ~res; + flag_NotZ |= res; flag_N = res; WRITE_BYTE_F(adr, res) POST_IO @@ -26985,6 +27009,7 @@ OPCODE(0x810F) { u32 adr, res; u32 src, dst; + u32 corf = 0; adr = AREG(7) - 2; AREG(7) = adr; @@ -26994,15 +27019,14 @@ OPCODE(0x810F) AREG((Opcode >> 9) & 7) = adr; READ_BYTE_F(adr, dst) res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1); - if (res > 9) res -= 6; + if (res > 0xF) corf = 6; res += (dst & 0xF0) - (src & 0xF0); - if (res > 0x99) - { - res += 0xA0; - flag_X = flag_C = M68K_SR_C; - } - else flag_X = flag_C = 0; - flag_NotZ |= res & 0xFF; + flag_V = res; + flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0; + if (res > 0xff) res += 0xA0; + res = (res - corf) & 0xFF; + flag_V &= ~res; + flag_NotZ |= res; flag_N = res; WRITE_BYTE_F(adr, res) POST_IO @@ -27014,6 +27038,7 @@ OPCODE(0x8F08) { u32 adr, res; u32 src, dst; + u32 corf = 0; adr = AREG((Opcode >> 0) & 7) - 1; AREG((Opcode >> 0) & 7) = adr; @@ -27023,15 +27048,14 @@ OPCODE(0x8F08) AREG(7) = adr; READ_BYTE_F(adr, dst) res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1); - if (res > 9) res -= 6; + if (res > 0xF) corf = 6; res += (dst & 0xF0) - (src & 0xF0); - if (res > 0x99) - { - res += 0xA0; - flag_X = flag_C = M68K_SR_C; - } - else flag_X = flag_C = 0; - flag_NotZ |= res & 0xFF; + flag_V = res; + flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0; + if (res > 0xff) res += 0xA0; + res = (res - corf) & 0xFF; + flag_V &= ~res; + flag_NotZ |= res; flag_N = res; WRITE_BYTE_F(adr, res) POST_IO @@ -27043,6 +27067,7 @@ OPCODE(0x8F0F) { u32 adr, res; u32 src, dst; + u32 corf = 0; adr = AREG(7) - 2; AREG(7) = adr; @@ -27052,15 +27077,14 @@ OPCODE(0x8F0F) AREG(7) = adr; READ_BYTE_F(adr, dst) res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1); - if (res > 9) res -= 6; + if (res > 0xF) corf = 6; res += (dst & 0xF0) - (src & 0xF0); - if (res > 0x99) - { - res += 0xA0; - flag_X = flag_C = M68K_SR_C; - } - else flag_X = flag_C = 0; - flag_NotZ |= res & 0xFF; + flag_V = res; + flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0; + if (res > 0xff) res += 0xA0; + res = (res - corf) & 0xFF; + flag_V &= ~res; + flag_NotZ |= res; flag_N = res; WRITE_BYTE_F(adr, res) POST_IO @@ -27076,7 +27100,7 @@ OPCODE(0x80C0) src = DREGu16((Opcode >> 0) & 7); if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV RET(140) #else @@ -27124,7 +27148,7 @@ OPCODE(0x80D0) READ_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV RET(144) #else @@ -27173,7 +27197,7 @@ OPCODE(0x80D8) READ_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV RET(144) #else @@ -27222,7 +27246,7 @@ OPCODE(0x80E0) READ_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV RET(146) #else @@ -27271,7 +27295,7 @@ OPCODE(0x80E8) READ_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV RET(148) #else @@ -27320,7 +27344,7 @@ OPCODE(0x80F0) READ_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV RET(150) #else @@ -27368,7 +27392,7 @@ OPCODE(0x80F8) READ_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV RET(148) #else @@ -27416,7 +27440,7 @@ OPCODE(0x80F9) READ_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV RET(152) #else @@ -27465,7 +27489,7 @@ OPCODE(0x80FA) READ_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV RET(148) #else @@ -27514,7 +27538,7 @@ OPCODE(0x80FB) READ_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV RET(150) #else @@ -27560,7 +27584,7 @@ OPCODE(0x80FC) FETCH_WORD(src); if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV RET(144) #else @@ -27609,7 +27633,7 @@ OPCODE(0x80DF) READ_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV RET(144) #else @@ -27658,7 +27682,7 @@ OPCODE(0x80E7) READ_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV RET(146) #else @@ -27704,7 +27728,7 @@ OPCODE(0x81C0) src = (s32)DREGs16((Opcode >> 0) & 7); if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV goto end81C0; #endif @@ -27744,7 +27768,7 @@ goto end81C0; DREGu32((Opcode >> 9) & 7) = res; } #ifdef USE_CYCLONE_TIMING_DIV -end81C0: m68kcontext.io_cycle_counter -= 50; +end81C0: ctx->io_cycle_counter -= 50; #endif RET(108) } @@ -27760,7 +27784,7 @@ OPCODE(0x81D0) READSX_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV goto end81D0; #endif @@ -27800,7 +27824,7 @@ goto end81D0; DREGu32((Opcode >> 9) & 7) = res; } #ifdef USE_CYCLONE_TIMING_DIV -end81D0: m68kcontext.io_cycle_counter -= 50; +end81D0: ctx->io_cycle_counter -= 50; #endif RET(112) } @@ -27817,7 +27841,7 @@ OPCODE(0x81D8) READSX_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV goto end81D8; #endif @@ -27857,7 +27881,7 @@ goto end81D8; DREGu32((Opcode >> 9) & 7) = res; } #ifdef USE_CYCLONE_TIMING_DIV -end81D8: m68kcontext.io_cycle_counter -= 50; +end81D8: ctx->io_cycle_counter -= 50; #endif RET(112) } @@ -27874,7 +27898,7 @@ OPCODE(0x81E0) READSX_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV goto end81E0; #endif @@ -27914,7 +27938,7 @@ goto end81E0; DREGu32((Opcode >> 9) & 7) = res; } #ifdef USE_CYCLONE_TIMING_DIV -end81E0: m68kcontext.io_cycle_counter -= 50; +end81E0: ctx->io_cycle_counter -= 50; #endif RET(114) } @@ -27931,7 +27955,7 @@ OPCODE(0x81E8) READSX_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV goto end81E8; #endif @@ -27971,7 +27995,7 @@ goto end81E8; DREGu32((Opcode >> 9) & 7) = res; } #ifdef USE_CYCLONE_TIMING_DIV -end81E8: m68kcontext.io_cycle_counter -= 50; +end81E8: ctx->io_cycle_counter -= 50; #endif RET(116) } @@ -27988,7 +28012,7 @@ OPCODE(0x81F0) READSX_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV goto end81F0; #endif @@ -28028,7 +28052,7 @@ goto end81F0; DREGu32((Opcode >> 9) & 7) = res; } #ifdef USE_CYCLONE_TIMING_DIV -end81F0: m68kcontext.io_cycle_counter -= 50; +end81F0: ctx->io_cycle_counter -= 50; #endif RET(118) } @@ -28044,7 +28068,7 @@ OPCODE(0x81F8) READSX_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV goto end81F8; #endif @@ -28084,7 +28108,7 @@ goto end81F8; DREGu32((Opcode >> 9) & 7) = res; } #ifdef USE_CYCLONE_TIMING_DIV -end81F8: m68kcontext.io_cycle_counter -= 50; +end81F8: ctx->io_cycle_counter -= 50; #endif RET(116) } @@ -28100,7 +28124,7 @@ OPCODE(0x81F9) READSX_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV goto end81F9; #endif @@ -28140,7 +28164,7 @@ goto end81F9; DREGu32((Opcode >> 9) & 7) = res; } #ifdef USE_CYCLONE_TIMING_DIV -end81F9: m68kcontext.io_cycle_counter -= 50; +end81F9: ctx->io_cycle_counter -= 50; #endif RET(120) } @@ -28157,7 +28181,7 @@ OPCODE(0x81FA) READSX_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV goto end81FA; #endif @@ -28197,7 +28221,7 @@ goto end81FA; DREGu32((Opcode >> 9) & 7) = res; } #ifdef USE_CYCLONE_TIMING_DIV -end81FA: m68kcontext.io_cycle_counter -= 50; +end81FA: ctx->io_cycle_counter -= 50; #endif RET(116) } @@ -28214,7 +28238,7 @@ OPCODE(0x81FB) READSX_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV goto end81FB; #endif @@ -28254,7 +28278,7 @@ goto end81FB; DREGu32((Opcode >> 9) & 7) = res; } #ifdef USE_CYCLONE_TIMING_DIV -end81FB: m68kcontext.io_cycle_counter -= 50; +end81FB: ctx->io_cycle_counter -= 50; #endif RET(118) } @@ -28268,7 +28292,7 @@ OPCODE(0x81FC) FETCH_SWORD(src); if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV goto end81FC; #endif @@ -28308,7 +28332,7 @@ goto end81FC; DREGu32((Opcode >> 9) & 7) = res; } #ifdef USE_CYCLONE_TIMING_DIV -end81FC: m68kcontext.io_cycle_counter -= 50; +end81FC: ctx->io_cycle_counter -= 50; #endif RET(112) } @@ -28325,7 +28349,7 @@ OPCODE(0x81DF) READSX_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV goto end81DF; #endif @@ -28365,7 +28389,7 @@ goto end81DF; DREGu32((Opcode >> 9) & 7) = res; } #ifdef USE_CYCLONE_TIMING_DIV -end81DF: m68kcontext.io_cycle_counter -= 50; +end81DF: ctx->io_cycle_counter -= 50; #endif RET(112) } @@ -28382,7 +28406,7 @@ OPCODE(0x81E7) READSX_WORD_F(adr, src) if (src == 0) { - SET_PC(execute_exception(M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, M68K_ZERO_DIVIDE_EX, GET_PC, GET_SR)); #ifdef USE_CYCLONE_TIMING_DIV goto end81E7; #endif @@ -28422,7 +28446,7 @@ goto end81E7; DREGu32((Opcode >> 9) & 7) = res; } #ifdef USE_CYCLONE_TIMING_DIV -end81E7: m68kcontext.io_cycle_counter -= 50; +end81E7: ctx->io_cycle_counter -= 50; #endif RET(114) } @@ -28451,8 +28475,8 @@ OPCODE(0x9008) u32 src, dst; // can't read byte from Ax registers ! - m68kcontext.execinfo |= M68K_FAULTED; - m68kcontext.io_cycle_counter = 0; + ctx->execinfo |= M68K_FAULTED; + ctx->io_cycle_counter = 0; /* goto famec_Exec_End; dst = DREGu8((Opcode >> 9) & 7); @@ -30625,8 +30649,8 @@ OPCODE(0xB008) u32 src, dst; // can't read byte from Ax registers ! - m68kcontext.execinfo |= M68K_FAULTED; - m68kcontext.io_cycle_counter = 0; + ctx->execinfo |= M68K_FAULTED; + ctx->io_cycle_counter = 0; /* goto famec_Exec_End; dst = DREGu8((Opcode >> 9) & 7); @@ -34120,18 +34144,22 @@ OPCODE(0xC100) { u32 adr, res; u32 src, dst; + u32 corf = 0; src = DREGu8((Opcode >> 0) & 7); dst = DREGu8((Opcode >> 9) & 7); res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1); - if (res > 9) res += 6; + if (res > 9) corf = 6; res += (dst & 0xF0) + (src & 0xF0); - if (res > 0x99) + flag_V = ~res; + res += corf; + if (res > 0x9F) { res -= 0xA0; flag_X = flag_C = M68K_SR_C; } else flag_X = flag_C = 0; + flag_V &= res; flag_NotZ |= res & 0xFF; flag_N = res; DREGu8((Opcode >> 9) & 7) = res; @@ -34143,6 +34171,7 @@ OPCODE(0xC108) { u32 adr, res; u32 src, dst; + u32 corf = 0; adr = AREG((Opcode >> 0) & 7) - 1; AREG((Opcode >> 0) & 7) = adr; @@ -34152,14 +34181,17 @@ OPCODE(0xC108) AREG((Opcode >> 9) & 7) = adr; READ_BYTE_F(adr, dst) res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1); - if (res > 9) res += 6; + if (res > 9) corf = 6; res += (dst & 0xF0) + (src & 0xF0); - if (res > 0x99) + flag_V = ~res; + res += corf; + if (res > 0x9F) { res -= 0xA0; flag_X = flag_C = M68K_SR_C; } else flag_X = flag_C = 0; + flag_V &= res; flag_NotZ |= res & 0xFF; flag_N = res; WRITE_BYTE_F(adr, res) @@ -34172,6 +34204,7 @@ OPCODE(0xC10F) { u32 adr, res; u32 src, dst; + u32 corf = 0; adr = AREG(7) - 2; AREG(7) = adr; @@ -34181,14 +34214,17 @@ OPCODE(0xC10F) AREG((Opcode >> 9) & 7) = adr; READ_BYTE_F(adr, dst) res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1); - if (res > 9) res += 6; + if (res > 9) corf = 6; res += (dst & 0xF0) + (src & 0xF0); - if (res > 0x99) + flag_V = ~res; + res += corf; + if (res > 0x9F) { res -= 0xA0; flag_X = flag_C = M68K_SR_C; } else flag_X = flag_C = 0; + flag_V &= res; flag_NotZ |= res & 0xFF; flag_N = res; WRITE_BYTE_F(adr, res) @@ -34201,6 +34237,7 @@ OPCODE(0xCF08) { u32 adr, res; u32 src, dst; + u32 corf = 0; adr = AREG((Opcode >> 0) & 7) - 1; AREG((Opcode >> 0) & 7) = adr; @@ -34210,14 +34247,17 @@ OPCODE(0xCF08) AREG(7) = adr; READ_BYTE_F(adr, dst) res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1); - if (res > 9) res += 6; + if (res > 9) corf = 6; res += (dst & 0xF0) + (src & 0xF0); - if (res > 0x99) + flag_V = ~res; + res += corf; + if (res > 0x9F) { res -= 0xA0; flag_X = flag_C = M68K_SR_C; } else flag_X = flag_C = 0; + flag_V &= res; flag_NotZ |= res & 0xFF; flag_N = res; WRITE_BYTE_F(adr, res) @@ -34230,6 +34270,7 @@ OPCODE(0xCF0F) { u32 adr, res; u32 src, dst; + u32 corf = 0; adr = AREG(7) - 2; AREG(7) = adr; @@ -34239,14 +34280,17 @@ OPCODE(0xCF0F) AREG(7) = adr; READ_BYTE_F(adr, dst) res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1); - if (res > 9) res += 6; + if (res > 9) corf = 6; res += (dst & 0xF0) + (src & 0xF0); - if (res > 0x99) + flag_V = ~res; + res += corf; + if (res > 0x9F) { res -= 0xA0; flag_X = flag_C = M68K_SR_C; } else flag_X = flag_C = 0; + flag_V &= res; flag_NotZ |= res & 0xFF; flag_N = res; WRITE_BYTE_F(adr, res) @@ -34922,8 +34966,8 @@ OPCODE(0xD008) u32 src, dst; // can't read byte from Ax registers ! - m68kcontext.execinfo |= M68K_FAULTED; - m68kcontext.io_cycle_counter = 0; + ctx->execinfo |= M68K_FAULTED; + ctx->io_cycle_counter = 0; /* goto famec_Exec_End; dst = DREGu8((Opcode >> 9) & 7); @@ -37082,7 +37126,7 @@ OPCODE(0xE000) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = (s32)DREGs8((Opcode >> 0) & 7); flag_V = 0; flag_X = flag_C = src << ((M68K_SR_C_SFT + 1) - sft); @@ -37102,7 +37146,7 @@ OPCODE(0xE040) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = (s32)DREGs16((Opcode >> 0) & 7); flag_V = 0; flag_X = flag_C = src << ((M68K_SR_C_SFT + 1) - sft); @@ -37122,7 +37166,7 @@ OPCODE(0xE080) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = (s32)DREGs32((Opcode >> 0) & 7); flag_V = 0; flag_X = flag_C = src << ((M68K_SR_C_SFT + 1) - sft); @@ -37142,7 +37186,7 @@ OPCODE(0xE008) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu8((Opcode >> 0) & 7); flag_N = flag_V = 0; flag_X = flag_C = src << ((M68K_SR_C_SFT + 1) - sft); @@ -37161,7 +37205,7 @@ OPCODE(0xE048) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu16((Opcode >> 0) & 7); flag_N = flag_V = 0; flag_X = flag_C = src << ((M68K_SR_C_SFT + 1) - sft); @@ -37180,7 +37224,7 @@ OPCODE(0xE088) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu32((Opcode >> 0) & 7); flag_N = flag_V = 0; flag_X = flag_C = src << ((M68K_SR_C_SFT + 1) - sft); @@ -37199,7 +37243,7 @@ OPCODE(0xE010) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu8((Opcode >> 0) & 7); src |= (flag_X & M68K_SR_X) << 0; res = (src >> sft) | (src << (9 - sft)); @@ -37220,7 +37264,7 @@ OPCODE(0xE050) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu16((Opcode >> 0) & 7); src |= (flag_X & M68K_SR_X) << 8; res = (src >> sft) | (src << (17 - sft)); @@ -37241,7 +37285,7 @@ OPCODE(0xE090) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu32((Opcode >> 0) & 7); flag_C = src << ((M68K_SR_C_SFT + 1) - sft); if (sft == 1) res = (src >> 1) | ((flag_X & M68K_SR_X) << (32 - (M68K_SR_X_SFT + 1))); @@ -37263,7 +37307,7 @@ OPCODE(0xE018) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu8((Opcode >> 0) & 7); flag_V = 0; flag_C = src << ((M68K_SR_C_SFT + 1) - sft); @@ -37283,7 +37327,7 @@ OPCODE(0xE058) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu16((Opcode >> 0) & 7); flag_V = 0; flag_C = src << ((M68K_SR_C_SFT + 1) - sft); @@ -37303,7 +37347,7 @@ OPCODE(0xE098) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu32((Opcode >> 0) & 7); flag_V = 0; flag_C = src << ((M68K_SR_C_SFT + 1) - sft); @@ -37323,7 +37367,7 @@ OPCODE(0xE100) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu8((Opcode >> 0) & 7); if (sft < 8) { @@ -37362,7 +37406,7 @@ OPCODE(0xE140) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu16((Opcode >> 0) & 7); flag_X = flag_C = src >> (8 - sft); res = src << sft; @@ -37387,7 +37431,7 @@ OPCODE(0xE180) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu32((Opcode >> 0) & 7); flag_X = flag_C = src >> (24 - sft); res = src << sft; @@ -37412,7 +37456,7 @@ OPCODE(0xE108) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu8((Opcode >> 0) & 7); flag_V = 0; flag_X = flag_C = src << (0 + sft); @@ -37432,7 +37476,7 @@ OPCODE(0xE148) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu16((Opcode >> 0) & 7); flag_V = 0; flag_X = flag_C = src >> (8 - sft); @@ -37452,7 +37496,7 @@ OPCODE(0xE188) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu32((Opcode >> 0) & 7); flag_V = 0; flag_X = flag_C = src >> (24 - sft); @@ -37472,7 +37516,7 @@ OPCODE(0xE110) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu8((Opcode >> 0) & 7); src |= (flag_X & M68K_SR_X) << 0; res = (src << sft) | (src >> (9 - sft)); @@ -37493,7 +37537,7 @@ OPCODE(0xE150) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu16((Opcode >> 0) & 7); src |= (flag_X & M68K_SR_X) << 8; res = (src << sft) | (src >> (17 - sft)); @@ -37514,7 +37558,7 @@ OPCODE(0xE190) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu32((Opcode >> 0) & 7); flag_C = src >> ((32 - M68K_SR_C_SFT) - sft); if (sft == 1) res = (src << 1) | ((flag_X & M68K_SR_X) >> ((M68K_SR_X_SFT + 1) - 1)); @@ -37536,7 +37580,7 @@ OPCODE(0xE118) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu8((Opcode >> 0) & 7); flag_V = 0; flag_C = src << (0 + sft); @@ -37556,7 +37600,7 @@ OPCODE(0xE158) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu16((Opcode >> 0) & 7); flag_V = 0; flag_C = src >> (8 - sft); @@ -37576,7 +37620,7 @@ OPCODE(0xE198) u32 sft; sft = (((Opcode >> 9) - 1) & 7) + 1; - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; src = DREGu32((Opcode >> 0) & 7); flag_V = 0; flag_C = src >> (24 - sft); @@ -37599,7 +37643,7 @@ OPCODE(0xE020) src = (s32)DREGs8((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; if (sft < 8) { flag_V = 0; @@ -37652,7 +37696,7 @@ OPCODE(0xE060) src = (s32)DREGs16((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; if (sft < 16) { flag_V = 0; @@ -37710,7 +37754,7 @@ OPCODE(0xE0A0) src = (s32)DREGs32((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; if (sft < 32) { flag_V = 0; @@ -37764,7 +37808,7 @@ OPCODE(0xE028) src = DREGu8((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; if (sft <= 8) { flag_N = flag_V = 0; @@ -37803,7 +37847,7 @@ OPCODE(0xE068) src = DREGu16((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; if (sft <= 16) { flag_N = flag_V = 0; @@ -37847,7 +37891,7 @@ OPCODE(0xE0A8) src = DREGu32((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; if (sft < 32) { flag_N = flag_V = 0; @@ -37889,7 +37933,7 @@ OPCODE(0xE030) src = DREGu8((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; sft %= 9; src |= (flag_X & M68K_SR_X) << 0; @@ -37921,7 +37965,7 @@ OPCODE(0xE070) src = DREGu16((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; sft %= 17; src |= (flag_X & M68K_SR_X) << 8; @@ -37958,14 +38002,14 @@ OPCODE(0xE0B0) src = DREGu32((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; sft %= 33; if (sft != 0) { if (sft == 1) res = (src >> 1) | ((flag_X & M68K_SR_X) << (32 - (M68K_SR_X_SFT + 1))); else res = (src >> sft) | (src << (33 - sft)) | (((flag_X & M68K_SR_X) << (32 - (M68K_SR_X_SFT + 1))) >> (sft - 1)); - flag_X = (src >> (32 - sft)) << M68K_SR_X_SFT; + flag_X = (src >> (sft - 1)) << M68K_SR_X_SFT; } else res = src; flag_C = flag_X; @@ -37996,7 +38040,7 @@ OPCODE(0xE038) src = DREGu8((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; sft &= 0x07; flag_C = src << (M68K_SR_C_SFT - ((sft - 1) & 7)); @@ -38027,7 +38071,7 @@ OPCODE(0xE078) src = DREGu16((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; sft &= 0x0F; flag_C = (src >> ((sft - 1) & 15)) << M68K_SR_C_SFT; @@ -38063,7 +38107,7 @@ OPCODE(0xE0B8) src = DREGu32((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; sft &= 0x1F; flag_C = (src >> ((sft - 1) & 31)) << M68K_SR_C_SFT; @@ -38095,7 +38139,7 @@ OPCODE(0xE120) src = DREGu8((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; if (sft < 8) { flag_X = flag_C = (src << sft) >> 0; @@ -38143,7 +38187,7 @@ OPCODE(0xE160) src = DREGu16((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; if (sft < 16) { flag_X = flag_C = (src << sft) >> 8; @@ -38196,7 +38240,7 @@ OPCODE(0xE1A0) src = DREGu32((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; if (sft < 32) { flag_X = flag_C = (src >> (32 - sft)) << M68K_SR_C_SFT; @@ -38245,7 +38289,7 @@ OPCODE(0xE128) src = DREGu8((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; if (sft <= 8) { flag_X = flag_C = (src << sft) >> 0; @@ -38285,7 +38329,7 @@ OPCODE(0xE168) src = DREGu16((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; if (sft <= 16) { flag_X = flag_C = (src << sft) >> 8; @@ -38330,7 +38374,7 @@ OPCODE(0xE1A8) src = DREGu32((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; if (sft < 32) { flag_X = flag_C = (src >> (32 - sft)) << M68K_SR_C_SFT; @@ -38373,7 +38417,7 @@ OPCODE(0xE130) src = DREGu8((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; sft %= 9; src |= (flag_X & M68K_SR_X) << 0; @@ -38405,7 +38449,7 @@ OPCODE(0xE170) src = DREGu16((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; sft %= 17; src |= (flag_X & M68K_SR_X) << 8; @@ -38442,7 +38486,7 @@ OPCODE(0xE1B0) src = DREGu32((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; sft %= 33; if (sft != 0) @@ -38480,7 +38524,7 @@ OPCODE(0xE138) src = DREGu8((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; if (sft &= 0x07) { flag_C = (src << sft) >> 0; @@ -38518,7 +38562,7 @@ OPCODE(0xE178) src = DREGu16((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; if (sft &= 0x0F) { flag_C = (src << sft) >> 8; @@ -38561,7 +38605,7 @@ OPCODE(0xE1B8) src = DREGu32((Opcode >> 0) & 7); if (sft) { - m68kcontext.io_cycle_counter -= sft * 2; + ctx->io_cycle_counter -= sft * 2; if (sft &= 0x1F) { flag_C = (src >> (32 - sft)) << M68K_SR_C_SFT; @@ -40068,7 +40112,7 @@ OPCODE(idle_detector_bcc8) if ( Opcode & 0x0100) newop |= 0x400; // beq if (!(Opcode & 0x0f00)) newop |= 0xc00; // bra - ret = SekRegisterIdlePatch(GET_PC - 2, Opcode, newop, &m68kcontext); + ret = SekRegisterIdlePatch(GET_PC - 2, Opcode, newop, ctx); switch (ret) { case 0: PC[-1] = newop; break; @@ -40084,7 +40128,7 @@ end: if (cond_true) { PC = dest_pc; - m68kcontext.io_cycle_counter -= 2; + ctx->io_cycle_counter -= 2; } RET(8) }