--- Frodo4/Src/C64_x.h 2004/01/10 15:07:14 1.5 +++ Frodo4/Src/C64_x.h 2005/06/27 19:55:48 1.8 @@ -1,7 +1,7 @@ /* * C64_x.h - Put the pieces together, X specific stuff * - * Frodo (C) 1994-1997,2002-2003 Christian Bauer + * Frodo (C) 1994-1997,2002-2005 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -95,6 +95,27 @@ int usleep(unsigned long int microSecond } #endif +#ifdef __linux__ +// select() timing is much more accurate under Linux +static void Delay_usec(unsigned long usec) +{ + int was_error; + struct timeval tv; + + tv.tv_sec = 0; + tv.tv_usec = usec; + do { + errno = 0; + was_error = select(0, NULL, NULL, NULL, &tv); + } while (was_error && (errno == EINTR)); +} +#else +static void Delay_usec(unsigned long usec) +{ + usleep(usec); +} +#endif + /* * Constructor, system-dependent things @@ -247,7 +268,7 @@ void C64::VBlank(bool draw_frame) // Limit speed to 100% if desired if ((speed_index > 100) && ThePrefs.LimitSpeed) { - usleep((unsigned long)(ThePrefs.SkipFrames * 20000 - elapsed_time)); + Delay_usec((unsigned long)(ThePrefs.SkipFrames * 20000 - elapsed_time)); speed_index = 100; }