+#ifdef PICODRIVE_HACK
+#define NOT_POLLING ctx->not_polling = 1;
+#else
+#define NOT_POLLING
+#endif
+
// ORI
OPCODE(0x0000)
{
}
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
}
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)
}
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)
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)
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)
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)
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)
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = (uptr)(PC) - BasePC;
DECODE_EXT_WORD
PRE_IO
READ_BYTE_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = (uptr)(PC) - BasePC;
DECODE_EXT_WORD
PRE_IO
READ_BYTE_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = (uptr)(PC) - BasePC;
DECODE_EXT_WORD
PRE_IO
READ_BYTE_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = (uptr)(PC) - BasePC;
DECODE_EXT_WORD
PRE_IO
READ_BYTE_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = (uptr)(PC) - BasePC;
DECODE_EXT_WORD
PRE_IO
READ_BYTE_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = (uptr)(PC) - BasePC;
DECODE_EXT_WORD
PRE_IO
READ_BYTE_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = (uptr)(PC) - BasePC;
DECODE_EXT_WORD
PRE_IO
READ_BYTE_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = (uptr)(PC) - BasePC;
DECODE_EXT_WORD
PRE_IO
READ_BYTE_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = (uptr)(PC) - BasePC;
DECODE_EXT_WORD
PRE_IO
READ_BYTE_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = (uptr)(PC) - BasePC;
DECODE_EXT_WORD
PRE_IO
READ_BYTE_F(adr, res)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_LONG_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_LONG_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_LONG_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_LONG_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_LONG_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_LONG_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_LONG_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_LONG_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_LONG_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_LONG_F(adr, res)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READSX_LONG_F(adr, res)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_WORD_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_WORD_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_WORD_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_WORD_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_WORD_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_WORD_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_WORD_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_WORD_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_WORD_F(adr, res)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_WORD_F(adr, res)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READSX_WORD_F(adr, res)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_WORD_F(adr, res)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
}
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)
if (flag_S)
{
- adr = GET_SWORD + ((u32)(PC) - BasePC);
+ adr = GET_SWORD + GET_PC;
PC++;
PRE_IO
READ_WORD_F(adr, res)
}
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)
if (flag_S)
{
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_WORD_F(adr, res)
}
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)
}
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)
}
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)
}
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)
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)
}
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)
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)
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)
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)
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)
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)
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)
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)
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)
u32 adr, res;
u32 src, dst;
- adr = GET_SWORD + ((u32)(PC) - BasePC);
+ adr = GET_SWORD + GET_PC;
PC++;
PRE_IO
PUSH_32_F(adr)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
PUSH_32_F(adr)
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
} 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)
}
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
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
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
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
} while (res >>= 1);
AREG(7) = adr;
POST_IO
- m68kcontext.io_cycle_counter -= (dst - adr) * 2;
+ ctx->io_cycle_counter -= (dst - adr) * 2;
RET(8)
}
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
} 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)
}
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
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
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
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
} while (res >>= 1);
AREG(7) = adr;
POST_IO
- m68kcontext.io_cycle_counter -= (dst - adr) * 2;
+ ctx->io_cycle_counter -= (dst - adr) * 2;
RET(8)
}
flag_NotZ = res;
flag_N = res;
#ifdef PICODRIVE_HACK
- if (g_m68kcontext == &PicoCpuFS68k) {
+ if (ctx == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
flag_N = res;
#ifdef PICODRIVE_HACK
- if (g_m68kcontext == &PicoCpuFS68k) {
+ if (ctx == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
flag_N = res;
#ifdef PICODRIVE_HACK
- if (g_m68kcontext == &PicoCpuFS68k) {
+ if (ctx == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
flag_N = res;
#ifdef PICODRIVE_HACK
- if (g_m68kcontext == &PicoCpuFS68k) {
+ if (ctx == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
flag_N = res;
#ifdef PICODRIVE_HACK
- if (g_m68kcontext == &PicoCpuFS68k) {
+ if (ctx == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
flag_N = res;
#ifdef PICODRIVE_HACK
- if (g_m68kcontext == &PicoCpuFS68k) {
+ if (ctx == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
flag_N = res;
#ifdef PICODRIVE_HACK
- if (g_m68kcontext == &PicoCpuFS68k) {
+ if (ctx == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
flag_N = res;
#ifdef PICODRIVE_HACK
- if (g_m68kcontext == &PicoCpuFS68k) {
+ if (ctx == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
flag_N = res;
#ifdef PICODRIVE_HACK
- if (g_m68kcontext == &PicoCpuFS68k) {
+ if (ctx == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
// 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
}
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
} 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)
}
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
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
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
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
s32 *psrc;
FETCH_WORD(res);
- adr = GET_SWORD + ((u32)(PC) - BasePC);
+ adr = GET_SWORD + GET_PC;
PC++;
psrc = &DREGs32(0);
dst = adr;
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
s32 *psrc;
FETCH_WORD(res);
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
psrc = &DREGs32(0);
dst = adr;
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
} while (res >>= 1);
AREG(7) = adr;
POST_IO
- m68kcontext.io_cycle_counter -= (adr - dst) * 2;
+ ctx->io_cycle_counter -= (adr - dst) * 2;
RET(12)
}
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
} 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)
}
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
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
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
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
u32 *psrc;
FETCH_WORD(res);
- adr = GET_SWORD + ((u32)(PC) - BasePC);
+ adr = GET_SWORD + GET_PC;
PC++;
psrc = &DREGu32(0);
dst = adr;
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
u32 *psrc;
FETCH_WORD(res);
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
psrc = &DREGu32(0);
dst = adr;
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
} 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)
}
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);
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;
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)
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);
AREG(7) = ASP;
ASP = res;
}
- m68kcontext.execinfo |= FM68K_HALTED;
- m68kcontext.io_cycle_counter = 0;
-RET(4)
+ ctx->execinfo |= FM68K_HALTED;
+RET0()
}
// RTE
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
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)
}
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)
}
{
u32 oldPC;
- oldPC = (u32)(PC) - BasePC;
+ oldPC = GET_PC;
PRE_IO
PUSH_32_F(oldPC)
}
{
u32 oldPC;
- oldPC = (u32)(PC) - BasePC;
+ oldPC = GET_PC;
PRE_IO
PUSH_32_F(oldPC)
}
{
u32 oldPC;
- oldPC = (u32)(PC) - BasePC;
+ oldPC = GET_PC;
PRE_IO
PUSH_32_F(oldPC)
}
{
u32 oldPC;
- oldPC = (u32)(PC) - BasePC;
+ oldPC = GET_PC;
PRE_IO
PUSH_32_F(oldPC)
}
{
u32 oldPC;
- oldPC = (u32)(PC) - BasePC;
+ oldPC = GET_PC;
PRE_IO
PUSH_32_F(oldPC)
}
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)
}
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)
}
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
SET_PC(adr)
CHECK_BRANCH_EXCEPTION(adr)
// CHK
OPCODE(0x4180)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
- src = DREGu16((Opcode >> 0) & 7);
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ src = DREGs16((Opcode >> 0) & 7);
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
}
RET(10)
}
// CHK
OPCODE(0x4190)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = AREG((Opcode >> 0) & 7);
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
}
POST_IO
RET(14)
// CHK
OPCODE(0x4198)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = AREG((Opcode >> 0) & 7);
AREG((Opcode >> 0) & 7) += 2;
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
}
POST_IO
RET(14)
// CHK
OPCODE(0x41A0)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = AREG((Opcode >> 0) & 7) - 2;
AREG((Opcode >> 0) & 7) = adr;
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
}
POST_IO
RET(16)
// CHK
OPCODE(0x41A8)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
FETCH_SWORD(adr);
adr += AREG((Opcode >> 0) & 7);
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
}
POST_IO
RET(18)
// CHK
OPCODE(0x41B0)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = AREG((Opcode >> 0) & 7);
DECODE_EXT_WORD
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
}
POST_IO
RET(20)
// CHK
OPCODE(0x41B8)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
FETCH_SWORD(adr);
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
}
POST_IO
RET(18)
// CHK
OPCODE(0x41B9)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
FETCH_LONG(adr);
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
}
POST_IO
RET(22)
// CHK
OPCODE(0x41BA)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
- adr = GET_SWORD + ((u32)(PC) - BasePC);
+ adr = GET_SWORD + GET_PC;
PC++;
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
}
POST_IO
RET(18)
// CHK
OPCODE(0x41BB)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
}
POST_IO
RET(20)
// CHK
OPCODE(0x41BC)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
- FETCH_WORD(src);
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ FETCH_SWORD(src);
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
}
POST_IO
RET(14)
// CHK
OPCODE(0x419F)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = AREG(7);
AREG(7) += 2;
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
}
POST_IO
RET(14)
// CHK
OPCODE(0x41A7)
{
- u32 adr, res;
- u32 src, dst;
+ s32 src, res;
+ u32 adr;
adr = AREG(7) - 2;
AREG(7) = adr;
PRE_IO
- READ_WORD_F(adr, src)
- res = DREGu16((Opcode >> 9) & 7);
- if (((s32)res < 0) || (res > src))
+ READSX_WORD_F(adr, src)
+ res = DREGs16((Opcode >> 9) & 7);
+ if ((res < 0) || (res > src))
{
flag_N = res >> 8;
- SET_PC(execute_exception(M68K_CHK_EX, GET_PC, GET_SR));
+ SET_PC(execute_exception(ctx, M68K_CHK_EX, GET_PC, GET_SR));
}
POST_IO
RET(16)
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;
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
res = adr;
AREG((Opcode >> 9) & 7) = res;
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
res = DREGu16((Opcode >> 0) & 7);
res--;
DREGu16((Opcode >> 0) & 7) = res;
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if ((!flag_NotZ) || (flag_C & 0x100))
{
res = DREGu16((Opcode >> 0) & 7);
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (flag_NotZ && (!(flag_C & 0x100)))
{
res = DREGu16((Opcode >> 0) & 7);
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (flag_C & 0x100)
{
res = DREGu16((Opcode >> 0) & 7);
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (!(flag_C & 0x100))
{
res = DREGu16((Opcode >> 0) & 7);
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (!flag_NotZ)
{
res = DREGu16((Opcode >> 0) & 7);
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (flag_NotZ)
{
res = DREGu16((Opcode >> 0) & 7);
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (flag_V & 0x80)
{
res = DREGu16((Opcode >> 0) & 7);
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (!(flag_V & 0x80))
{
res = DREGu16((Opcode >> 0) & 7);
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (flag_N & 0x80)
{
res = DREGu16((Opcode >> 0) & 7);
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (!(flag_N & 0x80))
{
res = DREGu16((Opcode >> 0) & 7);
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if ((flag_N ^ flag_V) & 0x80)
{
res = DREGu16((Opcode >> 0) & 7);
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (!((flag_N ^ flag_V) & 0x80))
{
res = DREGu16((Opcode >> 0) & 7);
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if ((!flag_NotZ) || ((flag_N ^ flag_V) & 0x80))
{
res = DREGu16((Opcode >> 0) & 7);
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
u32 adr, res;
u32 src, dst;
+ NOT_POLLING
+
if (flag_NotZ && (!((flag_N ^ flag_V) & 0x80)))
{
res = DREGu16((Opcode >> 0) & 7);
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
if (flag_NotZ && (!(flag_C & 0x100)))
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if ((!flag_NotZ) || (flag_C & 0x100))
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if (!(flag_C & 0x100))
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if (flag_C & 0x100)
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if (flag_NotZ)
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if (!flag_NotZ)
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if (!(flag_V & 0x80))
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if (flag_V & 0x80)
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if (!(flag_N & 0x80))
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if (flag_N & 0x80)
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if (!((flag_N ^ flag_V) & 0x80))
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
if ((flag_N ^ flag_V) & 0x80)
{
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter -= 2;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
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)
}
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)
}
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
OPCODE(0x6001)
{
#ifdef FAMEC_CHECK_BRANCHES
- u32 newPC = (u32)(PC) - BasePC;
+ u32 newPC = GET_PC;
s8 offs=Opcode;
newPC += offs;
SET_PC(newPC);
{
u32 newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
newPC += GET_SWORD;
SET_PC(newPC);
CHECK_BRANCH_EXCEPTION(newPC)
PRE_IO
- oldPC = (u32)(PC) - BasePC;
+ oldPC = GET_PC;
PUSH_32_F(oldPC)
#ifdef FAMEC_CHECK_BRANCHES
offs = Opcode;
{
u32 oldPC, newPC;
- newPC = (u32)(PC) - BasePC;
+ newPC = GET_PC;
oldPC = newPC + 2;
PUSH_32_F(oldPC)
newPC += GET_SWORD;
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_BYTE_F(adr, src)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_WORD_F(adr, src)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_LONG_F(adr, src)
{
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)
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG((Opcode >> 0) & 7) - 1;
AREG((Opcode >> 0) & 7) = adr;
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
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG(7) - 2;
AREG(7) = adr;
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
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG((Opcode >> 0) & 7) - 1;
AREG((Opcode >> 0) & 7) = adr;
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
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG(7) - 2;
AREG(7) = adr;
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
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
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
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
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
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
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
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
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(162)
+RET(152)
#else
RET(22)
#endif
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-RET(162)
+RET(152)
#else
RET(82)
#endif
DREGu32((Opcode >> 9) & 7) = res;
}
#ifdef USE_CYCLONE_TIMING_DIV
-RET(162)
+RET(152)
#else
RET(102)
#endif
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)
{
- 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
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)
{
- 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(160)
+RET(150)
#else
RET(20)
#endif
{
flag_V = M68K_SR_V;
#ifdef USE_CYCLONE_TIMING_DIV
-RET(160)
+RET(150)
#else
RET(80)
#endif
DREGu32((Opcode >> 9) & 7) = res;
}
#ifdef USE_CYCLONE_TIMING_DIV
-RET(160)
+RET(150)
#else
RET(100)
#endif
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
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
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
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
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)
}
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
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)
}
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
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)
}
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
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)
}
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
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)
}
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
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)
}
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
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)
}
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
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)
}
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)
{
- 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
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)
}
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)
{
- 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
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)
}
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
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)
}
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
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)
}
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
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)
}
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);
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_BYTE_F(adr, src)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_WORD_F(adr, src)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_LONG_F(adr, src)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READSX_WORD_F(adr, src)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READSX_LONG_F(adr, src)
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);
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_BYTE_F(adr, src)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_WORD_F(adr, src)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_LONG_F(adr, src)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READSX_WORD_F(adr, src)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READSX_LONG_F(adr, src)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_BYTE_F(adr, src)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_WORD_F(adr, src)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_LONG_F(adr, src)
{
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;
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG((Opcode >> 0) & 7) - 1;
AREG((Opcode >> 0) & 7) = adr;
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)
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG(7) - 2;
AREG(7) = adr;
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)
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG((Opcode >> 0) & 7) - 1;
AREG((Opcode >> 0) & 7) = adr;
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)
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG(7) - 2;
AREG(7) = adr;
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)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_WORD_F(adr, src)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READSX_WORD_F(adr, src)
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);
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_BYTE_F(adr, src)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_WORD_F(adr, src)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READ_LONG_F(adr, src)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READSX_WORD_F(adr, src)
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)
u32 adr, res;
u32 src, dst;
- adr = (u32)(PC) - BasePC;
+ adr = GET_PC;
DECODE_EXT_WORD
PRE_IO
READSX_LONG_F(adr, src)
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);
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);
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);
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);
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);
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);
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));
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));
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)));
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);
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);
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);
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)
{
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;
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;
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);
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);
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);
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));
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));
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));
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);
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);
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);
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;
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;
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;
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;
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;
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;
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;
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;
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;
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));
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
src = DREGu32((Opcode >> 0) & 7);
if (sft)
{
- m68kcontext.io_cycle_counter -= sft * 2;
+ ctx->io_cycle_counter -= sft * 2;
sft %= 33;
if (sft != 0)
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;
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;
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;
}
#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;
+ u32 newPC = GET_PC;
s8 offs=Opcode;
newPC += offs;
SET_PC(newPC);
#else
PC += ((s8)(Opcode & 0xFE)) >> 1;
#endif
- {
- extern int idle_hit_counter;
- idle_hit_counter++;
- }
- m68kcontext.io_cycle_counter = 10;
-RET(10)
+ UPDATE_IDLE_COUNT
+RET0()
}
// BCC
{
if (flag_NotZ)
{
- extern int idle_hit_counter;
- idle_hit_counter++;
+ UPDATE_IDLE_COUNT
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter = 8;
+ //if (idle_hit)
+ RET0()
}
RET(8)
}
{
if (!flag_NotZ)
{
- extern int idle_hit_counter;
- idle_hit_counter++;
+ UPDATE_IDLE_COUNT
PC += ((s8)(Opcode & 0xFE)) >> 1;
- m68kcontext.io_cycle_counter = 8;
+ //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);
+extern int SekRegisterIdlePatch(unsigned int pc, int oldop, int newop, void *ctx);
OPCODE(idle_detector_bcc8)
{
- extern int idledet_start_frame;
- extern char Pico[];
int frame_count, cond_true, bytes, ret, newop;
u16 *dest_pc;
dest_pc = PC + (((s8)(Opcode & 0xFE)) >> 1);
- frame_count = *(int *)(Pico+0x22208+0x1c); // Pico.m.frame_count
- if (frame_count < idledet_start_frame)
+ if (!SekIsIdleReady())
goto end;
bytes = 0 - (s8)(Opcode & 0xFE) - 2;
ret = SekIsIdleCode(dest_pc, bytes);
newop = (Opcode & 0xfe) | 0x7100;
if (!ret) newop |= 0x200;
- if (Opcode & 0x0100) newop |= 0x400; // beq
+ if ( Opcode & 0x0100) newop |= 0x400; // beq
+ if (!(Opcode & 0x0f00)) newop |= 0xc00; // bra
- ret = SekRegisterIdlePatch(GET_PC - 2, Opcode, newop);
+ ret = SekRegisterIdlePatch(GET_PC - 2, Opcode, newop, ctx);
switch (ret)
{
case 0: PC[-1] = newop; break;
case 1: break;
- case 2: JumpTable[Opcode] = (Opcode & 0x0100) ? CAST_OP(0x6701) : CAST_OP(0x6601); break;
+ case 2: JumpTable[Opcode] = (Opcode & 0x0f00) ?
+ ((Opcode & 0x0100) ? CAST_OP(0x6701) : CAST_OP(0x6601)) :
+ CAST_OP(0x6001); break;
}
end:
- cond_true = (Opcode & 0x0100) ? !flag_NotZ : flag_NotZ; // beq?
+ 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;
+ ctx->io_cycle_counter -= 2;
}
RET(8)
}
-OPCODE(idle_detector_dead)
-{
- // patch without further questions
- int newop = 0x7d00 | (Opcode & 0xff);
- PC[-1] = newop;
- SekRegisterIdlePatch(GET_PC - 2, Opcode, newop);
-
- PC += ((s8)(Opcode & 0xFE)) >> 1;
-RET(10)
-}
#endif // PICODRIVE_HACK