X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cpu%2Ffame%2Ffamec.c;h=db4eae692c919ee3590e2ee4ce90a26ae56128ae;hb=c041308933a54fce3b1e98b0228e19f96475ae40;hp=616027c2a58031972308c015ae58b19b41296e29;hpb=be26eb239bd06fd83ab740dca5582841eac652dd;p=picodrive.git diff --git a/cpu/fame/famec.c b/cpu/fame/famec.c index 616027c..db4eae6 100644 --- a/cpu/fame/famec.c +++ b/cpu/fame/famec.c @@ -24,7 +24,7 @@ #define FAMEC_CHECK_BRANCHES #define FAMEC_EXTRA_INLINE // #define FAMEC_DEBUG -#define FAMEC_NO_GOTOS +// #define FAMEC_NO_GOTOS #define FAMEC_ADR_BITS 24 // #define FAMEC_FETCHBITS 8 #define FAMEC_DATABITS 8 @@ -35,7 +35,17 @@ #define PICODRIVE_HACK // Options // - +#ifndef FAMEC_NO_GOTOS +// computed gotos is a GNU extension +#ifndef __GNUC__ +#define FAMEC_NO_GOTOS +#endif +// as of 3.3, clang takes over 3h to compile this in computed goto mode.. +#ifdef __clang__ +#define FAMEC_NO_GOTOS +#endif +#endif + #undef INLINE #ifdef _MSC_VER #define INLINE @@ -528,22 +538,20 @@ M68K_CONTEXT *g_m68kcontext; #define m68kcontext (*g_m68kcontext) #ifdef FAMEC_NO_GOTOS -static u32 Opcode; -static s32 cycles_needed; -static u16 *PC; -static uptr BasePC; -static u32 flag_C; -static u32 flag_V; -static u32 flag_NotZ; -static u32 flag_N; -static u32 flag_X; +#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 #endif -#ifdef FAMEC_EMULATE_TRACE -static u32 flag_T; -#endif -static u32 flag_S; -static u32 flag_I; +#define flag_T m68kcontext.flag_T +#define flag_S m68kcontext.flag_S +#define flag_I m68kcontext.flag_I static u32 initialised = 0; @@ -649,7 +657,7 @@ void fm68k_init(void) #endif if (!initialised) - fm68k_emulate(0, 0, 0); + fm68k_emulate(0, 0); #ifdef FAMEC_DEBUG puts("FAME initialized."); @@ -668,7 +676,7 @@ void fm68k_init(void) int fm68k_reset(void) { if (!initialised) - fm68k_emulate(0, 0, 0); + fm68k_emulate(0, 0); // Si la CPU esta en ejecucion, salir con M68K_RUNNING if (m68kcontext.execinfo & M68K_RUNNING) @@ -734,6 +742,9 @@ static FAMEC_EXTRA_INLINE u32 execute_exception(s32 vect, u32 oldPC, u32 oldSR) //u32 oldSR = GET_SR; m68kcontext.io_cycle_counter -= exception_cycle_table[vect]; +#ifdef FAMEC_EMULATE_TRACE + m68kcontext.execinfo &= ~FM68K_EMULATE_TRACE; +#endif PRE_IO @@ -755,6 +766,7 @@ static FAMEC_EXTRA_INLINE u32 execute_exception(s32 vect, u32 oldPC, u32 oldSR) /* adjust SR */ flag_S = M68K_SR_S; + flag_T = 0; #ifndef FAMEC_32BIT_PC newPC&=M68K_ADR_MASK @@ -796,7 +808,7 @@ static FAMEC_EXTRA_INLINE u32 execute_exception_group_0(s32 vect, s32 addr, u16 // main exec function ////////////////////// -int fm68k_emulate(s32 cycles, int dualcore, int idle_mode) +int fm68k_emulate(s32 cycles, int idle_mode) { #ifndef FAMEC_NO_GOTOS u32 Opcode; @@ -816,10 +828,8 @@ int fm68k_emulate(s32 cycles, int dualcore, int idle_mode) } #ifdef PICODRIVE_HACK - if (dualcore) goto dualcore_mode; if (idle_mode == 1) goto idle_install; else if (idle_mode == 2) goto idle_remove; -famec_restart: #endif // won't emulate double fault @@ -910,12 +920,11 @@ famec_Exec: #ifdef FAMEC_EMULATE_TRACE if (m68kcontext.execinfo & FM68K_EMULATE_TRACE) { - m68kcontext.io_cycle_counter = cycles_needed; + m68kcontext.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)); - flag_T=0; if (m68kcontext.io_cycle_counter > 0) { //NEXT @@ -927,8 +936,9 @@ famec_Exec: if (cycles_needed != 0) { u32 line; - m68kcontext.io_cycle_counter = cycles_needed; + m68kcontext.io_cycle_counter += cycles_needed; cycles_needed = 0; + //if (m68kcontext.io_cycle_counter <= 0) goto famec_End; line=interrupt_chk__(); if (line>0) { @@ -963,58 +973,7 @@ famec_End: printf("pc: 0x%08x\n",m68kcontext.pc); #endif -#ifdef PICODRIVE_HACK - if (!dualcore) -#endif - return cycles - m68kcontext.io_cycle_counter; - -#ifdef PICODRIVE_HACK -dualcore_mode: - - while (1) - { - extern int SekCycleAim, SekCycleCnt, SekCycleAimS68k, SekCycleCntS68k; - #define PS_STEP_M68K ((488<<16)/20) // ~24 - if (dualcore == 1) - { - dualcore = (488<<16); // ~ cycn in Pico.c - // adjust for first iteration - g_m68kcontext = &PicoCpuFS68k; - cycles = m68kcontext.io_cycle_counter = 0; - } - if (g_m68kcontext == &PicoCpuFS68k) - { - SekCycleCntS68k += cycles - m68kcontext.io_cycle_counter; - // end? - dualcore -= PS_STEP_M68K; - if (dualcore < 0) return 0; - // become main 68k - g_m68kcontext = &PicoCpuFM68k; - if ((cycles = SekCycleAim-SekCycleCnt-(dualcore>>16)) > 0) - { - if ((m68kcontext.execinfo & FM68K_HALTED) && m68kcontext.interrupts[0] <= (M68K_PPL)) - SekCycleCnt += cycles; // halted - else goto famec_restart; - //else { printf("go main %i\n", cycles); goto famec_restart; } - } - cycles = m68kcontext.io_cycle_counter = 0; - } - if (g_m68kcontext == &PicoCpuFM68k) - { - int cycn_s68k = (dualcore + dualcore/2 + dualcore/8) >> 16; - SekCycleCnt += cycles - m68kcontext.io_cycle_counter; - // become sub 68k - g_m68kcontext = &PicoCpuFS68k; - if ((cycles = SekCycleAimS68k-SekCycleCntS68k-cycn_s68k) > 0) - { - if ((m68kcontext.execinfo & FM68K_HALTED) && m68kcontext.interrupts[0] <= (M68K_PPL)) - SekCycleCntS68k += cycles; // halted - else goto famec_restart; - } - cycles = m68kcontext.io_cycle_counter = 0; - } - } -#endif + return cycles - m68kcontext.io_cycle_counter; init_jump_table: {