+void BlitScreen(int skip)
+{
+}
+
+/* throttle */
+extern uint8 PAL;
+extern int FSkip;
+static struct timeval tv_expect;
+static int skip_count = 0;
+static int us_interval, us_interval1024;
+#define MAX_LAG_FRAMES 3
+
+void RefreshThrottleFPS(void)
+{
+ skip_count = 0;
+ us_interval = PAL ? 20000 : 16667;
+ us_interval1024 = PAL ? 20000*1024 : 17066667;
+
+ vout_fbdev_wait_vsync(layer_fb);
+ gettimeofday(&tv_expect, 0);
+ tv_expect.tv_usec *= 1024;
+}
+
+void SpeedThrottle(void)
+{
+ struct timeval now;
+ int diff;
+
+ gettimeofday(&now, 0);
+
+ // usec*1024 units to prevent drifting
+ tv_expect.tv_usec += us_interval1024;
+ if (tv_expect.tv_usec > 1000000 * 1024) {
+ tv_expect.tv_usec -= 1000000 * 1024;
+ tv_expect.tv_sec++;
+ }
+
+ diff = (tv_expect.tv_sec - now.tv_sec) * 1000000 +
+ (tv_expect.tv_usec >> 10) - now.tv_usec;
+
+ if (Settings.frameskip >= 0)
+ {
+ if (skip_count >= Settings.frameskip)
+ skip_count = 0;
+ else {
+ skip_count++;
+ FSkip = 1;
+ }
+ }
+ else
+ {
+ FSkip = diff < -us_interval;
+ }
+
+ if (diff > MAX_LAG_FRAMES * us_interval
+ || diff < -MAX_LAG_FRAMES * us_interval)
+ {
+ //printf("reset %d\n", diff);
+ RefreshThrottleFPS();
+ return;
+ }
+ else if (diff > us_interval)
+ {
+ usleep(diff - us_interval);
+ }
+}
+
+/* called just before emulation */