コード例 #1
0
ファイル: timers.c プロジェクト: fourks/bb.js
static void update_async()
{
    int time = tl_process_group(asyncgroup);
    if (time != -1) {
	struct itimerval t;
	t.it_interval.tv_sec = 0;
	t.it_interval.tv_usec = 0;
	t.it_value.tv_sec = time / 1000000;
	t.it_value.tv_usec = time % 1000000;
	if (!reghandler) {
#ifdef __DJGPP__
            _go32_dpmi_seginfo pmint;
            pmint.pm_selector=_my_cs();
	    pmint.pm_offset=&alarmhandler;
	    _go32_dpmi_chain_protected_mode_interrupt_vector(0x1c,&pmint);
#endif
	    signal(SIGALRM, alarmhandler), reghandler = 1;
	}
	setitimer(ITIMER_REAL, &t, &t);
	registered = 1;
    }
    else if (registered) {
	struct itimerval t;
	t.it_interval.tv_sec = 0;
	t.it_interval.tv_usec = 0;
	t.it_value.tv_sec = 0;
	t.it_value.tv_usec = 0;
	setitimer(ITIMER_REAL, &t, &t);
	registered = 0;
    }
}
コード例 #2
0
ファイル: timers.c プロジェクト: Jheengut/gmerlin
static void
update_async (void)
{
  int time = tl_process_group (asyncgroup, NULL);
  if (time != -1)
    {
      struct itimerval t;
      t.it_interval.tv_sec = 0;
      t.it_interval.tv_usec = 0;
      t.it_value.tv_sec = time / 1000000;
      t.it_value.tv_usec = time % 1000000;
      if (!reghandler)
	{
	  signal (SIGALRM, alarmhandler), reghandler = 1;
	}
      setitimer (ITIMER_REAL, &t, &t);
      registered = 1;
    }
  else if (registered)
    {
      struct itimerval t;
      t.it_interval.tv_sec = 0;
      t.it_interval.tv_usec = 0;
      t.it_value.tv_sec = 0;
      t.it_value.tv_usec = 0;
      setitimer (ITIMER_REAL, &t, &t);
      registered = 0;
    }
}
コード例 #3
0
ファイル: scene7.c プロジェクト: artyfarty/bb-osx
static void updatestatus(void)
{
    double times = (zcontext->currentformula->v.mc - zcontext->currentformula->v.nc) / (zcontext->s.mc - zcontext->s.nc);
    ui_display();
    sprintf(zoomed, "%.2f", times);

    tl_process_group(syncgroup, NULL);
    bbupdate();
    drawingtime = tl_lookup_timer(maintimer);
    tl_reset_timer(maintimer);
    if (drawingtime > 200000)
	drawingtime = 200000;
    mul = (double) drawingtime / FRAMETIME;
    incalculation = 0;
}
コード例 #4
0
ファイル: scene7.c プロジェクト: artyfarty/bb-osx
static void ui_waitfunc(void)
{
    int l;
    bbupdate();
    tl_process_group(syncgroup, NULL);
    l = tl_lookup_timer(maintimer);
    if (interruptiblemode) {
	if (zcontext->incalculation && !starttime1)
	    starttime1 = l;
	else if (starttime1 && !zcontext->incalculation && !endtime1)
	    endtime1 = l;
	if (maxtime && l > maxtime && zcontext->readyforinterrupt)
	    zcontext->interrupt = 1, endtime1 = l;
    }
}
コード例 #5
0
ファイル: bb.c プロジェクト: 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);
}
コード例 #6
0
ファイル: bb.c プロジェクト: julioh/Cursoaslccs
int bbupdate()
{
    int ch;
    tl_update_time();
    TIME = tl_lookup_timer(scenetimer);
    tl_process_group (syncgroup, NULL);
    ch = aa_getkey(context, 0);
    switch (ch) {
    case 's':
    case 'S':
    case AA_BACKSPACE:
	finish_stuff = 1;
	break;
    case AA_ESC:
    case 'q':
	finish_stuff = 1, quitnow = 1;
    }
    return (ch);
}
コード例 #7
0
ファイル: bb.c プロジェクト: julioh/Cursoaslccs
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;
}
コード例 #8
0
ファイル: scene7.c プロジェクト: artyfarty/bb-osx
void scene6(void)
{
    int width, height, scanline;
    int i, formula = 0;
    char *buffer1, *buffer2;
    displayed = 0;
    incalculation = 0;
    fastmode = 2;
    interruptiblemode = 0;
    autopilot = 0;
    maxstep = MAXSTEP;
    speedup = STEP;
    step = 0;
    tbreak = 0;
    maintimer = tl_create_timer();
    signal(SIGFPE, SIG_IGN);
    width = aa_imgwidth(context);
    height = aa_imgheight(context);
    scanline = width;
    buffer1 = context->imagebuffer;
    buffer2 = malloc(width * height);
    endtime = starttime + ETIME1;
    params->bright = -255;

    zcontext = make_context(width, height, scanline, 0, 1, flip_buffers, ui_waitfunc, buffer1, buffer2, get_pixelwidth(width), get_pixelheight(height));
    if (!zcontext) {
	exit(-1);
    }
    set_formula(zcontext, formula);
    for (i = 0; i < 255; i++) {
	/*zcontext->colors[i] = (i * 15) % 255 + 1; */
	zcontext->colors[i] = (i * 8) % 255 + 1;
    }
    zcontext->colors[0] = 0;
    zcontext->num_colors = 255;
    tbreak = 2;
    zcontext->maxiter = 150;
    fastmode--;
    zcontext->range = 8;
    zcontext->incoloringmode = 0;
    zcontext->coloringmode = 0;
    zcontext->plane = 0;
    ui_do_fractal(NEW_IMAGE);
    ui_autopilot();
    speedup = 1 * STEP;
    maxstep *= 5;
    step = -maxstep;
    tl_process_group(syncgroup, NULL);
    bbupdate();
    tl_reset_timer(maintimer);
    main_loop();
    starttime = endtime;
    context->imagebuffer = buffer1;
    free(buffer2);
    tl_free_timer(maintimer);
    params->bright = 0;
    params->randomval = 0;
    initlepic();
    drawptr = mydraw1;
    timestuff(-60, ctrllepic, draw, 2000000);
    drawptr = mydraw;
    /*timestuff(60, NULL, draw, 4 * 1000000); */
    /*timestuff(20, blur, draw, 4 * 1000000); */
    timestuff(60, NULL, draw, 3 * 1000000);

}