Esempio n. 1
0
void pcnt_gte_end(int op)
{
	pcnt_end(PCNT_GTE);
}
Esempio n. 2
0
/* called on every vsync */
void pl_frame_limit(void)
{
	static struct timeval tv_old, tv_expect;
	static int vsync_cnt_prev;
	struct timeval now;
	int diff, usadj;

	vsync_cnt++;

	/* doing input here because the pad is polled
	 * thousands of times per frame for some reason */
	update_input();

	pcnt_end(PCNT_ALL);
	gettimeofday(&now, 0);

	if (now.tv_sec != tv_old.tv_sec) {
		diff = tvdiff(now, tv_old);
		vsps_cur = 0.0f;
		if (0 < diff && diff < 2000000)
			vsps_cur = 1000000.0f * (vsync_cnt - vsync_cnt_prev) / diff;
		vsync_cnt_prev = vsync_cnt;
		flips_per_sec = flip_cnt;
		flip_cnt = 0;
		tv_old = now;
		if (g_opts & OPT_SHOWCPU)
			tick_per_sec = get_cpu_ticks();

		if (hud_new_msg > 0) {
			hud_new_msg--;
			if (hud_new_msg == 0)
				hud_msg[0] = 0;
		}
	}
#ifdef PCNT
	static int ya_vsync_count;
	if (++ya_vsync_count == PCNT_FRAMES) {
		pcnt_print(vsps_cur);
		ya_vsync_count = 0;
	}
#endif

	tvadd(tv_expect, pl_frame_interval);
	diff = tvdiff(tv_expect, now);
	if (diff > MAX_LAG_FRAMES * pl_frame_interval || diff < -MAX_LAG_FRAMES * pl_frame_interval) {
		//printf("pl_frame_limit reset, diff=%d, iv %d\n", diff, pl_frame_interval);
		tv_expect = now;
		diff = 0;
		// try to align with vsync
		usadj = vsync_usec_time;
		while (usadj < tv_expect.tv_usec - pl_frame_interval)
			usadj += pl_frame_interval;
		tv_expect.tv_usec = usadj;
	}

	if (!(g_opts & OPT_NO_FRAMELIM) && diff > pl_frame_interval) {
		// yay for working usleep on pandora!
		//printf("usleep %d\n", diff - pl_frame_interval / 2);
		usleep(diff - pl_frame_interval / 2);
	}

	if (UseFrameSkip) {
		if (diff < -pl_frame_interval) {
			// P.E.Op.S. makes skip decision based on this
			fps_skip = 1.0f;
			plugin_skip_advice = 1;
		}
		else if (diff >= 0) {
			fps_skip = 100.0f;
			plugin_skip_advice = 0;
		}
	}

	pcnt_start(PCNT_ALL);
}