X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cpu%2Ffame%2Ffamec.c;h=db4eae692c919ee3590e2ee4ce90a26ae56128ae;hb=c041308933a54fce3b1e98b0228e19f96475ae40;hp=6891526014c5e14e8edb8c34269ea15643856a40;hpb=9a1f192a146e9b9752ec1a760745b1261fe9bdec;p=picodrive.git diff --git a/cpu/fame/famec.c b/cpu/fame/famec.c index 6891526..db4eae6 100644 --- a/cpu/fame/famec.c +++ b/cpu/fame/famec.c @@ -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 @@ -647,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."); @@ -666,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) @@ -732,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 @@ -753,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 @@ -794,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; @@ -814,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 @@ -908,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 @@ -925,9 +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; + //if (m68kcontext.io_cycle_counter <= 0) goto famec_End; line=interrupt_chk__(); if (line>0) { @@ -962,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: {