From: notaz Date: Sat, 14 Oct 2017 22:15:00 +0000 (+0300) Subject: famec: eliminate global context ptr X-Git-Tag: v1.93~37 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7669591e0876778fc4f3977b145c012f2e3a12e9;p=picodrive.git famec: eliminate global context ptr saves like 25-35K of .text current compile resource usage on i5-6600K: cpu mem gcc 5.4.0: 17.0 1.1g clang 3.8: 1686 2.3g FAMEC_NO_GOTOS: gcc 5.4.0: 8.4 0.4g clang 3.8: 20.0 0.15g vs2008/O2: ~1800 ? vs2008/O1: ~720 ? --- diff --git a/cpu/fame/fame.h b/cpu/fame/fame.h index 93172c87..0baabf26 100644 --- a/cpu/fame/fame.h +++ b/cpu/fame/fame.h @@ -143,8 +143,6 @@ typedef struct unsigned long Fetch[M68K_FETCHBANK1]; } M68K_CONTEXT; -extern M68K_CONTEXT *g_m68kcontext; - typedef enum { fm68k_reason_emulate = 0, @@ -163,7 +161,7 @@ int fm68k_reset(M68K_CONTEXT *ctx); int fm68k_emulate(M68K_CONTEXT *ctx, int n, fm68k_call_reason reason); int fm68k_would_interrupt(M68K_CONTEXT *ctx); // to be called from fm68k_emulate() -unsigned fm68k_get_pc(M68K_CONTEXT *ctx); +unsigned int fm68k_get_pc(const M68K_CONTEXT *ctx); // PICODRIVE_HACK int fm68k_idle_install(void); diff --git a/cpu/fame/famec.c b/cpu/fame/famec.c index 508a12f7..41620944 100644 --- a/cpu/fame/famec.c +++ b/cpu/fame/famec.c @@ -228,21 +228,21 @@ typedef signed int s32; // internals core macros ///////////////////////// -#define DREG(X) (m68kcontext.dreg[(X)].D) -#define DREGu32(X) (m68kcontext.dreg[(X)].D) -#define DREGs32(X) (m68kcontext.dreg[(X)].SD) -#define DREGu16(X) (m68kcontext.dreg[(X)].W) -#define DREGs16(X) (m68kcontext.dreg[(X)].SW) -#define DREGu8(X) (m68kcontext.dreg[(X)].B) -#define DREGs8(X) (m68kcontext.dreg[(X)].SB) - -#define AREG(X) (m68kcontext.areg[(X)].D) -#define AREGu32(X) (m68kcontext.areg[(X)].D) -#define AREGs32(X) (m68kcontext.areg[(X)].SD) -#define AREGu16(X) (m68kcontext.areg[(X)].W) -#define AREGs16(X) (m68kcontext.areg[(X)].SW) - -#define ASP (m68kcontext.asp) +#define DREG(X) (ctx->dreg[(X)].D) +#define DREGu32(X) (ctx->dreg[(X)].D) +#define DREGs32(X) (ctx->dreg[(X)].SD) +#define DREGu16(X) (ctx->dreg[(X)].W) +#define DREGs16(X) (ctx->dreg[(X)].SW) +#define DREGu8(X) (ctx->dreg[(X)].B) +#define DREGs8(X) (ctx->dreg[(X)].SB) + +#define AREG(X) (ctx->areg[(X)].D) +#define AREGu32(X) (ctx->areg[(X)].D) +#define AREGs32(X) (ctx->areg[(X)].SD) +#define AREGu16(X) (ctx->areg[(X)].W) +#define AREGs16(X) (ctx->areg[(X)].SW) + +#define ASP (ctx->asp) #define LSL(A, C) ((A) << (C)) #define LSR(A, C) ((A) >> (C)) @@ -271,39 +271,39 @@ typedef signed int s32; #ifdef FAMEC_ROLL_INLINE #define RET(A) \ - m68kcontext.io_cycle_counter -= (A); \ - if (m68kcontext.io_cycle_counter <= 0) goto famec_Exec_End; \ + ctx->io_cycle_counter -= (A); \ + if (ctx->io_cycle_counter <= 0) goto famec_Exec_End; \ NEXT #else #define RET(A) \ - m68kcontext.io_cycle_counter -= (A); \ - if (m68kcontext.io_cycle_counter <= 0) goto famec_Exec_End; \ + ctx->io_cycle_counter -= (A); \ + if (ctx->io_cycle_counter <= 0) goto famec_Exec_End; \ goto famec_Exec; #endif #define RET0() \ - m68kcontext.io_cycle_counter = -6; \ + ctx->io_cycle_counter = -6; \ goto famec_End; #else #define NEXT \ - do{ \ - FETCH_WORD(Opcode); \ - JumpTable[Opcode](); \ - }while(m68kcontext.io_cycle_counter>0); + do { \ + FETCH_WORD(Opcode); \ + JumpTable[Opcode](ctx); \ + } while (ctx->io_cycle_counter > 0); #define RET(A) \ - m68kcontext.io_cycle_counter -= (A); \ + ctx->io_cycle_counter -= (A); \ return; #define RET0() \ - m68kcontext.io_cycle_counter = -6; \ + ctx->io_cycle_counter = -6; \ return; #endif -#define M68K_PPL (m68kcontext.sr >> 8) & 7 +#define M68K_PPL (ctx->sr >> 8) & 7 #define GET_PC \ (u32)((uptr)PC - BasePC) @@ -321,7 +321,7 @@ typedef signed int s32; { \ u32 pc = A; \ FORCE_ALIGNMENT(pc); \ - BasePC = m68kcontext.Fetch[(pc >> M68K_FETCHSFT) & M68K_FETCHMASK]; \ + BasePC = ctx->Fetch[(pc >> M68K_FETCHSFT) & M68K_FETCHMASK]; \ PC = (u16*)((pc & M68K_ADR_MASK) + BasePC); \ } @@ -331,7 +331,7 @@ typedef signed int s32; { \ u32 pc = A; \ FORCE_ALIGNMENT(pc); \ - BasePC = m68kcontext.Fetch[(pc >> M68K_FETCHSFT) & M68K_FETCHMASK]; \ + BasePC = ctx->Fetch[(pc >> M68K_FETCHSFT) & M68K_FETCHMASK]; \ BasePC -= pc & 0xFF000000; \ PC = (u16*)(pc + BasePC); \ } @@ -346,29 +346,29 @@ typedef signed int s32; // CCnt = io_cycle_counter; #define READ_BYTE_F(A, D) \ - D = m68kcontext.read_byte(A) & 0xFF; + D = ctx->read_byte(A) & 0xFF; #define READ_WORD_F(A, D) \ - D = m68kcontext.read_word(A) & 0xFFFF; + D = ctx->read_word(A) & 0xFFFF; #define READ_LONG_F(A, D) \ - D = m68kcontext.read_long(A); + D = ctx->read_long(A); #define READSX_LONG_F READ_LONG_F #define WRITE_LONG_F(A, D) \ - m68kcontext.write_long(A, D); + ctx->write_long(A, D); #define WRITE_LONG_DEC_F(A, D) \ - m68kcontext.write_word((A) + 2, (D) & 0xFFFF); \ - m68kcontext.write_word((A), (D) >> 16); + ctx->write_word((A) + 2, (D) & 0xFFFF); \ + ctx->write_word((A), (D) >> 16); #define PUSH_32_F(D) \ AREG(7) -= 4; \ - m68kcontext.write_long(AREG(7), D); + ctx->write_long(AREG(7), D); #define POP_32_F(D) \ - D = m68kcontext.read_long(AREG(7)); \ + D = ctx->read_long(AREG(7)); \ AREG(7) += 4; #ifndef FAME_BIG_ENDIAN @@ -440,23 +440,23 @@ typedef signed int s32; #endif #define READSX_BYTE_F(A, D) \ - D = (s8)m68kcontext.read_byte(A); + D = (s8)ctx->read_byte(A); #define READSX_WORD_F(A, D) \ - D = (s16)m68kcontext.read_word(A); + D = (s16)ctx->read_word(A); #define WRITE_BYTE_F(A, D) \ - m68kcontext.write_byte(A, D); + ctx->write_byte(A, D); #define WRITE_WORD_F(A, D) \ - m68kcontext.write_word(A, D); + ctx->write_word(A, D); #define PUSH_16_F(D) \ - m68kcontext.write_word(AREG(7) -= 2, D); \ + ctx->write_word(AREG(7) -= 2, D); \ #define POP_16_F(D) \ - D = (u16)m68kcontext.read_word(AREG(7)); \ + D = (u16)ctx->read_word(AREG(7)); \ AREG(7) += 2; #define GET_CCR \ @@ -501,17 +501,17 @@ typedef signed int s32; #endif #define CHECK_INT_TO_JUMP(CLK) \ - if (interrupt_chk__()) \ + if (interrupt_chk__(ctx)) \ { \ - cycles_needed=m68kcontext.io_cycle_counter-(CLK); \ - m68kcontext.io_cycle_counter=(CLK); \ + cycles_needed=ctx->io_cycle_counter-(CLK); \ + ctx->io_cycle_counter=(CLK); \ } #ifdef FAMEC_CHECK_BRANCHES #ifdef FAMEC_NO_GOTOS -#define CHECK_BRANCH_EXCEPTION_GOTO_END m68kcontext.io_cycle_counter=0; return; +#define CHECK_BRANCH_EXCEPTION_GOTO_END ctx->io_cycle_counter=0; return; #else #define CHECK_BRANCH_EXCEPTION_GOTO_END goto famec_Exec_End; #endif @@ -520,8 +520,8 @@ typedef signed int s32; if ((_PC_)&1) \ { \ u32 new_PC, pr_PC=GET_PC; \ - m68kcontext.execinfo |= FM68K_EMULATE_GROUP_0; \ - new_PC = execute_exception_group_0(M68K_ADDRESS_ERROR_EX, 0, pr_PC, 0x12 ); \ + ctx->execinfo |= FM68K_EMULATE_GROUP_0; \ + new_PC = execute_exception_group_0(ctx, M68K_ADDRESS_ERROR_EX, 0, pr_PC, 0x12 ); \ SET_PC(new_PC); \ CHECK_BRANCH_EXCEPTION_GOTO_END \ } @@ -529,29 +529,24 @@ typedef signed int s32; #define CHECK_BRANCH_EXCEPTION(_PC_) #endif - -// global variable -/////////////////// - -/* Current CPU context */ -M68K_CONTEXT *g_m68kcontext; -#define m68kcontext (*g_m68kcontext) - #ifdef FAMEC_NO_GOTOS -#define Opcode m68kcontext.Opcode -#define cycles_needed m68kcontext.cycles_needed -#define PC m68kcontext.PC -#define BasePC m68kcontext.BasePC -#define flag_C m68kcontext.flag_C -#define flag_V m68kcontext.flag_V -#define flag_NotZ m68kcontext.flag_NotZ -#define flag_N m68kcontext.flag_N -#define flag_X m68kcontext.flag_X +#define Opcode ctx->Opcode +#define cycles_needed ctx->cycles_needed +#define PC ctx->PC +#define BasePC ctx->BasePC +#define flag_C ctx->flag_C +#define flag_V ctx->flag_V +#define flag_NotZ ctx->flag_NotZ +#define flag_N ctx->flag_N +#define flag_X ctx->flag_X #endif -#define flag_T m68kcontext.flag_T -#define flag_S m68kcontext.flag_S -#define flag_I m68kcontext.flag_I +#define flag_T ctx->flag_T +#define flag_S ctx->flag_S +#define flag_I ctx->flag_I + +// global variable +/////////////////// static u32 initialised = 0; @@ -560,7 +555,7 @@ extern M68K_CONTEXT PicoCpuFS68k; #endif /* Custom function handler */ -typedef void (*opcode_func)(void); +typedef void (*opcode_func)(M68K_CONTEXT *ctx); static opcode_func JumpTable[0x10000]; @@ -679,30 +674,28 @@ int fm68k_reset(M68K_CONTEXT *ctx) if (!initialised) init_jump_table(); - g_m68kcontext = ctx; - // Si la CPU esta en ejecucion, salir con M68K_RUNNING - if (m68kcontext.execinfo & M68K_RUNNING) + if (ctx->execinfo & M68K_RUNNING) return M68K_RUNNING; // Resetear registros - //memset(&m68kcontext.dreg[0], 0, 16*4); + //memset(&ctx->dreg[0], 0, 16*4); // Resetear interrupts, execinfo y ASP - m68kcontext.interrupts[0] = 0; - m68kcontext.execinfo = 0; + ctx->interrupts[0] = 0; + ctx->execinfo = 0; ASP = 0; // Fijar registro de estado - m68kcontext.sr = (m68kcontext.sr & 0xff) | 0x2700; + ctx->sr = (ctx->sr & 0xff) | 0x2700; // Obtener puntero de pila inicial y PC - AREG(7) = m68kcontext.read_long(0); - m68kcontext.pc = m68kcontext.read_long(4); + AREG(7) = ctx->read_long(0); + ctx->pc = ctx->read_long(4); #ifdef FAMEC_DEBUG puts("Reset 68k done!\n"); - printf("PC = 0x%08X\n",m68kcontext.pc); + printf("PC = 0x%08X\n",ctx->pc); #endif return M68K_OK; @@ -714,39 +707,39 @@ int fm68k_reset(M68K_CONTEXT *ctx) /* No recibe parametros */ /* Retorna 68k PC */ /****************************************************************************/ -u32 fm68k_get_pc(M68K_CONTEXT *context) +u32 fm68k_get_pc(const M68K_CONTEXT *ctx) { #ifdef FAMEC_NO_GOTOS - return (context->execinfo & M68K_RUNNING)?(uptr)PC-BasePC:context->pc; + return (ctx->execinfo & M68K_RUNNING)?(uptr)PC-BasePC:ctx->pc; #else - return context->pc; // approximate PC in this mode + return ctx->pc; // approximate PC in this mode #endif } ////////////////////////// // Chequea las interrupciones y las inicia -static FAMEC_EXTRA_INLINE s32 interrupt_chk__(void) +static FAMEC_EXTRA_INLINE s32 interrupt_chk__(M68K_CONTEXT *ctx) { - if (m68kcontext.interrupts[0] > flag_I) - return m68kcontext.interrupts[0]; + if (ctx->interrupts[0] > flag_I) + return ctx->interrupts[0]; return 0; } int fm68k_would_interrupt(M68K_CONTEXT *ctx) { - return interrupt_chk__(); + return interrupt_chk__(ctx); } -static FAMEC_EXTRA_INLINE u32 execute_exception(s32 vect, u32 oldPC, u32 oldSR) +static FAMEC_EXTRA_INLINE u32 execute_exception(M68K_CONTEXT *ctx, s32 vect, u32 oldPC, u32 oldSR) { u32 newPC; //u32 oldSR = GET_SR; - m68kcontext.io_cycle_counter -= exception_cycle_table[vect]; + ctx->io_cycle_counter -= exception_cycle_table[vect]; #ifdef FAMEC_EMULATE_TRACE - m68kcontext.execinfo &= ~FM68K_EMULATE_TRACE; + ctx->execinfo &= ~FM68K_EMULATE_TRACE; #endif PRE_IO @@ -785,12 +778,12 @@ static FAMEC_EXTRA_INLINE u32 execute_exception(s32 vect, u32 oldPC, u32 oldSR) return newPC; } -static FAMEC_EXTRA_INLINE u32 execute_exception_group_0(s32 vect, s32 addr, u16 spec_info, u32 oldSR) +static FAMEC_EXTRA_INLINE u32 execute_exception_group_0(M68K_CONTEXT *ctx, s32 vect, s32 addr, u16 spec_info, u32 oldSR) { u32 newPC; u16 inst_reg = 0; - newPC = execute_exception(vect, addr, oldSR); - //if (!(m68kcontext.icust_handler && m68kcontext.icust_handler[vect])) + newPC = execute_exception(ctx, vect, addr, oldSR); + //if (!(ctx->icust_handler && ctx->icust_handler[vect])) { PUSH_16_F(inst_reg); PUSH_32_F(addr); @@ -802,7 +795,7 @@ static FAMEC_EXTRA_INLINE u32 execute_exception_group_0(s32 vect, s32 addr, u16 #ifdef FAMEC_NO_GOTOS -#define OPCODE(N_OP) static void OP_##N_OP(void) +#define OPCODE(N_OP) static void OP_##N_OP(M68K_CONTEXT *ctx) #define CAST_OP(N_OP) (opcode_func)&OP_##N_OP #include "famec_opcodes.h" #endif @@ -839,21 +832,19 @@ int fm68k_emulate(M68K_CONTEXT *ctx, s32 cycles, fm68k_call_reason reason) } #endif // FAMEC_NO_GOTOS - g_m68kcontext = ctx; - // won't emulate double fault - // if (m68kcontext.execinfo & M68K_FAULTED) return -1; + // if (ctx->execinfo & M68K_FAULTED) return -1; // Cache PPL flag_I = M68K_PPL; - if (m68kcontext.execinfo & FM68K_HALTED) + if (ctx->execinfo & FM68K_HALTED) { - if (interrupt_chk__() <= 0) + if (interrupt_chk__(ctx) <= 0) { return cycles; } - m68kcontext.execinfo &= ~FM68K_HALTED; + ctx->execinfo &= ~FM68K_HALTED; } #ifdef FAMEC_DEBUG @@ -861,13 +852,13 @@ int fm68k_emulate(M68K_CONTEXT *ctx, s32 cycles, fm68k_call_reason reason) #endif /* Poner la CPU en estado de ejecucion */ - m68kcontext.execinfo |= M68K_RUNNING; + ctx->execinfo |= M68K_RUNNING; // Cache SR - SET_SR(m68kcontext.sr) + SET_SR(ctx->sr) // Fijar PC - SET_PC(m68kcontext.pc) + SET_PC(ctx->pc) #ifdef FAMEC_DEBUG printf("PC: %p\n",PC); @@ -875,33 +866,33 @@ int fm68k_emulate(M68K_CONTEXT *ctx, s32 cycles, fm68k_call_reason reason) #endif /* guardar ciclos de ejecucion solicitados */ - m68kcontext.io_cycle_counter = cycles; + ctx->io_cycle_counter = cycles; cycles_needed = 0; #ifdef FAMEC_EMULATE_TRACE - if (!(m68kcontext.execinfo & FM68K_EMULATE_TRACE)) + if (!(ctx->execinfo & FM68K_EMULATE_TRACE)) #endif { - s32 line=interrupt_chk__(); + s32 line=interrupt_chk__(ctx); if (line>0) { /* comprobar si hay rutina de acknowledge */ - if (m68kcontext.iack_handler != NULL) - m68kcontext.iack_handler(line); + if (ctx->iack_handler != NULL) + ctx->iack_handler(line); else - m68kcontext.interrupts[0] = 0; + ctx->interrupts[0] = 0; - SET_PC(execute_exception(line + 0x18, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, line + 0x18, GET_PC, GET_SR)); flag_I = (u32)line; - if (m68kcontext.io_cycle_counter <= 0) goto famec_End; + if (ctx->io_cycle_counter <= 0) goto famec_End; } #ifdef FAMEC_EMULATE_TRACE else if (flag_T) { - m68kcontext.execinfo |= FM68K_EMULATE_TRACE; - cycles_needed = m68kcontext.io_cycle_counter; - m68kcontext.io_cycle_counter=0; + ctx->execinfo |= FM68K_EMULATE_TRACE; + cycles_needed = ctx->io_cycle_counter; + ctx->io_cycle_counter=0; } #endif } @@ -927,14 +918,14 @@ famec_Exec: #endif #ifdef FAMEC_EMULATE_TRACE - if (m68kcontext.execinfo & FM68K_EMULATE_TRACE) + if (ctx->execinfo & FM68K_EMULATE_TRACE) { - m68kcontext.io_cycle_counter += cycles_needed; + ctx->io_cycle_counter += cycles_needed; cycles_needed = 0; - m68kcontext.execinfo &= ~FM68K_EMULATE_TRACE; - m68kcontext.execinfo |= FM68K_DO_TRACE; - SET_PC(execute_exception(M68K_TRACE_EX, GET_PC, GET_SR)); - if (m68kcontext.io_cycle_counter > 0) + ctx->execinfo &= ~FM68K_EMULATE_TRACE; + ctx->execinfo |= FM68K_DO_TRACE; + SET_PC(execute_exception(ctx, M68K_TRACE_EX, GET_PC, GET_SR)); + if (ctx->io_cycle_counter > 0) { //NEXT goto famec_Exec; @@ -945,24 +936,24 @@ famec_Exec: if (cycles_needed != 0) { u32 line; - m68kcontext.io_cycle_counter += cycles_needed; + ctx->io_cycle_counter += cycles_needed; cycles_needed = 0; - //if (m68kcontext.io_cycle_counter <= 0) goto famec_End; - line=interrupt_chk__(); + //if (ctx->io_cycle_counter <= 0) goto famec_End; + line=interrupt_chk__(ctx); if (line>0) { - if (m68kcontext.iack_handler != NULL) - m68kcontext.iack_handler(line); + if (ctx->iack_handler != NULL) + ctx->iack_handler(line); else - m68kcontext.interrupts[0] = 0; + ctx->interrupts[0] = 0; - SET_PC(execute_exception(line + 0x18, GET_PC, GET_SR)); + SET_PC(execute_exception(ctx, line + 0x18, GET_PC, GET_SR)); flag_I = (u32)line; } #ifdef FAMEC_EMULATE_TRACE if (!(flag_T)) #endif - if (m68kcontext.io_cycle_counter > 0) + if (ctx->io_cycle_counter > 0) { //NEXT goto famec_Exec; @@ -970,19 +961,19 @@ famec_Exec: } famec_End: - m68kcontext.sr = GET_SR; - m68kcontext.pc = GET_PC; + ctx->sr = GET_SR; + ctx->pc = GET_PC; - m68kcontext.execinfo &= ~M68K_RUNNING; + ctx->execinfo &= ~M68K_RUNNING; #ifdef FAMEC_DEBUG printf("En really end...\n"); printf("PC: %p\n",PC); printf("BasePC: 0x%08x\n",BasePC); - printf("pc: 0x%08x\n",m68kcontext.pc); + printf("pc: 0x%08x\n",ctx->pc); #endif - return cycles - m68kcontext.io_cycle_counter; + return cycles - ctx->io_cycle_counter; #ifndef FAMEC_NO_GOTOS init_jump_table: diff --git a/cpu/fame/famec_opcodes.h b/cpu/fame/famec_opcodes.h index 2df6d78a..e069e9ea 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) @@ -17337,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 @@ -17369,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) } @@ -17397,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 @@ -17429,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 @@ -17460,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 @@ -17491,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 @@ -17523,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) } @@ -17550,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 @@ -17582,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) } @@ -17610,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 @@ -17642,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 @@ -17673,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 @@ -17704,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 @@ -17736,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) } @@ -18319,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); } @@ -18349,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); } @@ -18379,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); } @@ -18409,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); } @@ -18439,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); } @@ -18468,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); } @@ -18497,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); } @@ -18527,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); } @@ -18557,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); } @@ -18578,21 +18578,21 @@ OPCODE(0x4AFC) extern void SekFinishIdleDet(void); SekFinishIdleDet(); #endif - SET_PC(execute_exception(M68K_ILLEGAL_INSTRUCTION_EX, GET_PC-2, GET_SR)); + 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 } @@ -18619,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 @@ -18651,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) } @@ -18679,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 @@ -18711,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 @@ -18742,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 @@ -18773,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 @@ -18805,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 @@ -18837,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 @@ -18869,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) } @@ -18896,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 @@ -18928,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) } @@ -18956,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 @@ -18988,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 @@ -19019,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 @@ -19050,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 @@ -19082,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 @@ -19114,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 @@ -19146,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) } @@ -19224,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); @@ -19240,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; @@ -19256,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) @@ -19280,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); @@ -19292,7 +19292,7 @@ OPCODE(0x4E72) AREG(7) = ASP; ASP = res; } - m68kcontext.execinfo |= FM68K_HALTED; + ctx->execinfo |= FM68K_HALTED; RET0() } @@ -19304,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 @@ -19319,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) } @@ -19342,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) } @@ -19604,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) } @@ -19622,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) @@ -19642,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) @@ -19662,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) @@ -19682,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) @@ -19702,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) @@ -19721,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) @@ -19740,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) @@ -19760,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) @@ -19780,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) @@ -19797,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) @@ -19817,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) @@ -19837,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) @@ -25051,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) } @@ -25065,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) } @@ -25079,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) } @@ -25093,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) } @@ -25107,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) } @@ -25121,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) } @@ -25135,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) } @@ -25149,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) } @@ -25163,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) } @@ -25177,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) } @@ -25191,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) } @@ -25205,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) } @@ -25219,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) } @@ -25233,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) } @@ -27100,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 @@ -27148,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 @@ -27197,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 @@ -27246,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 @@ -27295,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 @@ -27344,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 @@ -27392,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 @@ -27440,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 @@ -27489,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 @@ -27538,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 @@ -27584,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 @@ -27633,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 @@ -27682,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 @@ -27728,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 @@ -27768,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) } @@ -27784,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 @@ -27824,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) } @@ -27841,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 @@ -27881,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) } @@ -27898,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 @@ -27938,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) } @@ -27955,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 @@ -27995,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) } @@ -28012,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 @@ -28052,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) } @@ -28068,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 @@ -28108,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) } @@ -28124,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 @@ -28164,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) } @@ -28181,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 @@ -28221,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) } @@ -28238,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 @@ -28278,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) } @@ -28292,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 @@ -28332,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) } @@ -28349,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 @@ -28389,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) } @@ -28406,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 @@ -28446,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) } @@ -28475,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); @@ -30649,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); @@ -34966,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); @@ -37126,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); @@ -37146,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); @@ -37166,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); @@ -37186,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); @@ -37205,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); @@ -37224,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); @@ -37243,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)); @@ -37264,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)); @@ -37285,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))); @@ -37307,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); @@ -37327,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); @@ -37347,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); @@ -37367,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) { @@ -37406,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; @@ -37431,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; @@ -37456,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); @@ -37476,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); @@ -37496,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); @@ -37516,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)); @@ -37537,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)); @@ -37558,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)); @@ -37580,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); @@ -37600,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); @@ -37620,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); @@ -37643,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; @@ -37696,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; @@ -37754,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; @@ -37808,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; @@ -37847,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; @@ -37891,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; @@ -37933,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; @@ -37965,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; @@ -38002,7 +38002,7 @@ 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) @@ -38040,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)); @@ -38071,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; @@ -38107,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; @@ -38139,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; @@ -38187,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; @@ -38240,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; @@ -38289,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; @@ -38329,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; @@ -38374,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; @@ -38417,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; @@ -38449,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; @@ -38486,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) @@ -38524,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; @@ -38562,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; @@ -38605,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; @@ -40112,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; @@ -40128,7 +40128,7 @@ end: if (cond_true) { PC = dest_pc; - m68kcontext.io_cycle_counter -= 2; + ctx->io_cycle_counter -= 2; } RET(8) } diff --git a/pico/cd/mcd.c b/pico/cd/mcd.c index 929b57f3..72488343 100644 --- a/pico/cd/mcd.c +++ b/pico/cd/mcd.c @@ -139,7 +139,6 @@ static void SekRunS68k(unsigned int to) m68k_set_context(&PicoCpuMM68k); #elif defined(EMU_F68K) SekCycleCntS68k += fm68k_emulate(&PicoCpuFS68k, cyc_do, 0) - cyc_do; - g_m68kcontext = &PicoCpuFM68k; #endif } diff --git a/pico/cd/sek.c b/pico/cd/sek.c index 6f54801b..baf0d9e5 100644 --- a/pico/cd/sek.c +++ b/pico/cd/sek.c @@ -117,15 +117,10 @@ PICO_INTERNAL void SekInitS68k(void) } #endif #ifdef EMU_F68K - { - void *oldcontext = g_m68kcontext; - g_m68kcontext = &PicoCpuFS68k; - memset(&PicoCpuFS68k, 0, sizeof(PicoCpuFS68k)); - fm68k_init(); - PicoCpuFS68k.iack_handler = SekIntAckFS68k; - PicoCpuFS68k.sr = 0x2704; // Z flag - g_m68kcontext = oldcontext; - } + memset(&PicoCpuFS68k, 0, sizeof(PicoCpuFS68k)); + fm68k_init(); + PicoCpuFS68k.iack_handler = SekIntAckFS68k; + PicoCpuFS68k.sr = 0x2704; // Z flag #endif } @@ -149,11 +144,7 @@ PICO_INTERNAL int SekResetS68k(void) } #endif #ifdef EMU_F68K - { - void *oldcontext = g_m68kcontext; - fm68k_reset(&PicoCpuFS68k); - g_m68kcontext = oldcontext; - } + fm68k_reset(&PicoCpuFS68k); #endif return 0; diff --git a/pico/debugCPU.c b/pico/debugCPU.c index 36e71a7c..128f4144 100644 --- a/pico/debugCPU.c +++ b/pico/debugCPU.c @@ -30,6 +30,7 @@ static struct Cyclone *currentC68k = NULL; #define other_is_stopped() (currentC68k->state_flags&1) #define other_is_tracing() ((currentC68k->state_flags&2)?1:0) #elif defined(EMU_F68K) +static struct M68K_CONTEXT *g_m68kcontext; #define other_set_sub(s) g_m68kcontext=(s)?&PicoCpuFS68k:&PicoCpuFM68k; #define other_get_sr() g_m68kcontext->sr #define other_dar(i) ((unsigned int*)g_m68kcontext->dreg)[i] diff --git a/pico/sek.c b/pico/sek.c index c76a3e8e..a40e3081 100644 --- a/pico/sek.c +++ b/pico/sek.c @@ -128,15 +128,10 @@ PICO_INTERNAL void SekInit(void) } #endif #ifdef EMU_F68K - { - void *oldcontext = g_m68kcontext; - g_m68kcontext = &PicoCpuFM68k; - memset(&PicoCpuFM68k, 0, sizeof(PicoCpuFM68k)); - fm68k_init(); - PicoCpuFM68k.iack_handler = SekIntAckF68K; - PicoCpuFM68k.sr = 0x2704; // Z flag - g_m68kcontext = oldcontext; - } + memset(&PicoCpuFM68k, 0, sizeof(PicoCpuFM68k)); + fm68k_init(); + PicoCpuFM68k.iack_handler = SekIntAckF68K; + PicoCpuFM68k.sr = 0x2704; // Z flag #endif }