Search
lxdream.org :: lxdream/src/gtkui/gtkui.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gtkui/gtkui.c
changeset 678:35eb00945316
prev669:ab344e42bca9
next681:1755a126b109
author nkeynes
date Thu May 29 11:00:26 2008 +0000 (13 years ago)
permissions -rw-r--r--
last change Split gdrom.h into public and private gddriver.h
Reorganize gdrom mount to use a disc change hook
file annotate diff log raw
1.1 --- a/src/gtkui/gtkui.c Mon May 12 10:00:13 2008 +0000
1.2 +++ b/src/gtkui/gtkui.c Thu May 29 11:00:26 2008 +0000
1.3 @@ -16,20 +16,19 @@
1.4 * GNU General Public License for more details.
1.5 */
1.6
1.7 -#include "lxdream.h"
1.8 +#include <time.h>
1.9 +#include <stdlib.h>
1.10 +#include <unistd.h>
1.11 #include <sys/time.h>
1.12 -#include <time.h>
1.13 -#include <unistd.h>
1.14 #include <glib/gi18n.h>
1.15 #include <gtk/gtkversion.h>
1.16 +#include "lxdream.h"
1.17 #include "dreamcast.h"
1.18 +#include "dream.h"
1.19 #include "display.h"
1.20 #include "gdrom/gdrom.h"
1.21 #include "gtkui/gtkui.h"
1.22
1.23 -/* Base GUI clock is 10ms */
1.24 -#define GUI_TICK_PERIOD 10000000
1.25 -
1.26 void gtk_gui_start( void );
1.27 void gtk_gui_stop( void );
1.28 void gtk_gui_alloc_resources ( void );
1.29 @@ -370,36 +369,36 @@
1.30 {
1.31 gtk_gui_nanos += nanosecs;
1.32 if( gtk_gui_nanos > GUI_TICK_PERIOD ) { /* 10 ms */
1.33 - gtk_gui_nanos -= GUI_TICK_PERIOD;
1.34 - gtk_gui_ticks ++;
1.35 - uint32_t current_period = gtk_gui_ticks * GUI_TICK_PERIOD;
1.36 + gtk_gui_nanos -= GUI_TICK_PERIOD;
1.37 + gtk_gui_ticks ++;
1.38 + uint32_t current_period = gtk_gui_ticks * GUI_TICK_PERIOD;
1.39
1.40 - // Run the event loop
1.41 - while( gtk_events_pending() )
1.42 - gtk_main_iteration();
1.43 + // Run the event loop
1.44 + while( gtk_events_pending() )
1.45 + gtk_main_iteration();
1.46
1.47 - struct timeval tv;
1.48 - gettimeofday(&tv,NULL);
1.49 - uint32_t ns = ((tv.tv_sec - gtk_gui_lasttv.tv_sec) * 1000000000) +
1.50 - (tv.tv_usec - gtk_gui_lasttv.tv_usec)*1000;
1.51 - if( (ns * 1.05) < current_period ) {
1.52 - // We've gotten ahead - sleep for a little bit
1.53 - struct timespec tv;
1.54 - tv.tv_sec = 0;
1.55 - tv.tv_nsec = current_period - ns;
1.56 - nanosleep(&tv, &tv);
1.57 - }
1.58 + struct timeval tv;
1.59 + gettimeofday(&tv,NULL);
1.60 + uint32_t ns = ((tv.tv_sec - gtk_gui_lasttv.tv_sec) * 1000000000) +
1.61 + (tv.tv_usec - gtk_gui_lasttv.tv_usec)*1000;
1.62 + if( (ns * 1.05) < current_period ) {
1.63 + // We've gotten ahead - sleep for a little bit
1.64 + struct timespec tv;
1.65 + tv.tv_sec = 0;
1.66 + tv.tv_nsec = current_period - ns;
1.67 + nanosleep(&tv, &tv);
1.68 + }
1.69
1.70 - /* Update the display every 10 ticks (ie 10 times a second) and
1.71 - * save the current tv value */
1.72 - if( gtk_gui_ticks > 10 ) {
1.73 - gtk_gui_ticks -= 10;
1.74 -
1.75 - double speed = (float)( (double)current_period * 100.0 / ns );
1.76 - gtk_gui_lasttv.tv_sec = tv.tv_sec;
1.77 - gtk_gui_lasttv.tv_usec = tv.tv_usec;
1.78 - main_window_set_speed( main_win, speed );
1.79 - }
1.80 + /* Update the display every 10 ticks (ie 10 times a second) and
1.81 + * save the current tv value */
1.82 + if( gtk_gui_ticks > 10 ) {
1.83 + gtk_gui_ticks -= 10;
1.84 +
1.85 + double speed = (float)( (double)current_period * 100.0 / ns );
1.86 + gtk_gui_lasttv.tv_sec = tv.tv_sec;
1.87 + gtk_gui_lasttv.tv_usec = tv.tv_usec;
1.88 + main_window_set_speed( main_win, speed );
1.89 + }
1.90 }
1.91 return nanosecs;
1.92 }
.