inline unsigned int dyna_run(PowerPC_func* func, unsigned int (*code)(void)){ PowerPC_instr* return_addr; register void* r3 __asm__("r3"); register void* r29 __asm__("r29") = rdram; register void* r30 __asm__("r30") = func; register void* r31 __asm__("r31") = NULL; end_section(TRAMP_SECTION); __asm__ volatile( "mtctr %4 \n" "bl 1f \n" "mflr %3 \n" "lwz %2, 12(1) \n" "addi 1, 1, 8 \n" "b 2f \n" "1: \n" "stwu 1, -8(1) \n" "mflr 0 \n" "stw 0, 12(1) \n" "bctr \n" "2: \n" : "=r" (r3), "=r" (r30), "=r" (return_addr), "=r" (link_branch) : "r" (code), "r" (r29), "r" (r30), "r" (r31) : "r0", "r2", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "fr0", "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", "fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "lr", "ctr", "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", "ca"); last_func = r30; link_branch = link_branch == return_addr ? NULL : link_branch - 1; return r3; }
void new_vi(void) { DWORD Dif; DWORD CurrentFPSTime; static DWORD LastFPSTime = 0; static DWORD CounterTime = 0; static DWORD CalculatedTime; static int VI_Counter = 0; static int VI_WaitCounter = 0; long time; start_section(IDLE_SECTION); // if ( (!Config.showVIS) && (!Config.limitFps) ) return; VI_Counter++; CurrentFPSTime = ticks_to_microsecs(gettick()); Dif = CurrentFPSTime - LastFPSTime; if (Timers.limitVIs) { if (Timers.limitVIs == 2 && Timers.frameDrawn == 0) VI_WaitCounter++; else { if (Dif < (double) VILimitMicroseconds * (VI_WaitCounter + 1) ) { CalculatedTime = CounterTime + (double)VILimitMicroseconds * (double)VI_Counter; time = (int)(CalculatedTime - CurrentFPSTime); if (time>0&&time<1000000) { usleep(time); } CurrentFPSTime = CurrentFPSTime + time; } Timers.frameDrawn = 0; VI_WaitCounter = 0; } } // DWORD diff_millisecs = ticks_to_millisecs(diff_ticks(CounterTime,CurrentFPSTime)); if (CounterTime > CurrentFPSTime) { CounterTime = ticks_to_microsecs(gettick()); VI_Counter = 0 ; } else if (CurrentFPSTime - CounterTime >= 500000.0 ) { Timers.vis = (float) (VI_Counter * 1000000.0 / (CurrentFPSTime - CounterTime)); // sprintf(txtbuffer,"Timer.VIs: Current = %dus; Last = %dus; diff_ms = %d; FPS_count = %d", CurrentFPSTime, CounterTime, diff_millisecs, VI_Counter); // DEBUG_print(txtbuffer,0); CounterTime = ticks_to_microsecs(gettick()); VI_Counter = 0 ; } LastFPSTime = CurrentFPSTime ; Timers.lastViTime = CurrentFPSTime; end_section(IDLE_SECTION); }
void new_vi(void) { int Dif; unsigned int CurrentFPSTime; static unsigned int LastFPSTime = 0; static unsigned int CounterTime = 0; static unsigned int CalculatedTime ; static int VI_Counter = 0; double AdjustedLimit = VILimitMilliseconds * 100.0 / l_SpeedFactor; // adjust for selected emulator speed int time; start_section(IDLE_SECTION); VI_Counter++; #ifdef DBG if(g_DebuggerActive) DebuggerCallback(DEBUG_UI_VI, 0); #endif if(LastFPSTime == 0) { LastFPSTime = gettimeofday_msec(); CounterTime = gettimeofday_msec(); return; } CurrentFPSTime = gettimeofday_msec(); Dif = CurrentFPSTime - LastFPSTime; if (Dif < AdjustedLimit) { CalculatedTime = CounterTime + AdjustedLimit * VI_Counter; time = (int)(CalculatedTime - CurrentFPSTime); if (time > 0) { #ifdef WIN32 Sleep(time); #else usleep(time * 1000); #endif } CurrentFPSTime = CurrentFPSTime + time; } if (CurrentFPSTime - CounterTime >= 1000.0 ) { CounterTime = gettimeofday_msec(); VI_Counter = 0 ; } LastFPSTime = CurrentFPSTime ; end_section(IDLE_SECTION); }
static void new_page(void) { /* * * Check the page or byte limit before starting a new page. * */ if ( ++pages > page_break || bytes > byte_break ) { pages = 1; bytes = 500; /* to cover section initialization */ end_section(); new_section(); } /* End if */ } /* End of new_page */