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
static void rotate_on(void)
{
    if (driver->rotate_palette != NULL && (driver->flags & PALETTE_ROTATION)) {
	rotate = 1;
	rotatetimer = tl_create_timer();
	rotate_update();
	tl_set_multihandler(rotatetimer, rotatehandler);
	if (driver->flags & ASYNC_PALETTE) {
	    tl_add_timer(asyncgroup, rotatetimer);
	}
	else
	    tl_add_timer(syncgroup, rotatetimer);
    }
    else {
	driver->print(0, 0, "Rotating of palette not supported by this configuration");
    }
}