Example #1
0
File: bb.c Project: stroucki/bb
void timestuff(int rate, void (*control) (int), void (*draw) (void), int maxtime)
{
    int waitmode = 0, t;
    tl_timer *timer;
    bbupdate();
    /*starttime = TIME; */
    endtime = starttime + maxtime;
    timer = tl_create_timer();
    if (control == NULL) {
	rate = -40;
    }
    if (rate < 0) {
	waitmode = 1, rate = -rate;
	control1 = control;
	tl_set_multihandler(timer, mycontrol);
    }
    else
	tl_set_multihandler(timer, control);
    tl_set_interval(timer, 1000000 / rate);
    tl_add_timer(syncgroup, timer);
    tl_reset_timer(timer);
    if (control != NULL)
	control(1);
    while (!finish_stuff && TIME < endtime) {
	called = 0;
	t = tl_process_group(syncgroup);
	bbupdate();
	if (TIME > endtime)
	    break;
#ifdef __DJGPP__
	if (0)
#else
	if (!called && waitmode)
#endif
	    tl_sleep(t);
	else {
	    if (draw != NULL)
		draw();
	}
    }
    starttime = endtime;
    tl_free_timer(timer);
}
Example #2
0
File: bb.c Project: stroucki/bb
void bbwait(int maxtime)
{
    int wait;
    if (finish_stuff)
	return;
    bbupdate();
    endtime = starttime + maxtime;
#ifdef __DJGPP__
    while (TIME < endtime)
	bbupdate();
#else
    wait = maxtime + starttime - TIME;

    if (wait > 0) {
	tl_sleep(maxtime + starttime - TIME);
    }
#endif
    starttime = endtime;
}
Example #3
0
void
bbwait (int maxtime)
{
  int wait;
  if (finish_stuff)
    return;
  bbupdate ();
  endtime = starttime + maxtime;

  wait = endtime - TIME;
  while (wait > 0)
    {
      int t;
      bbupdate ();
      t = tl_process_group (syncgroup, NULL);
      wait = endtime - TIME;
      if (wait < t)
	t = wait;
      tl_sleep (t);
    }
  starttime = endtime;
}