void speed_test (fractal_context * c, struct image *img) { //unsigned int sum; tl_timer *t; int time; unsigned int i; set_fractalc (c, img); t = tl_create_timer (); cfractalc.maxiter = 100; #ifdef SLOWFUNCPTR i = calculateswitch (0.0, 0.0, 0.0, 0.0, 0); #else (void) cfractalc.currentformula->calculate (0.0, 0.0, 0.0, 0.0); if (cfractalc.currentformula->calculate_periodicity != NULL) (void) cfractalc.currentformula->calculate_periodicity (0.0, 0.0, 0.0, 0.0); if (cfractalc.currentformula->smooth_calculate != NULL) (void) cfractalc.currentformula->smooth_calculate (0.0, 0.0, 0.0, 0.0); if (cfractalc.currentformula->smooth_calculate_periodicity != NULL) (void) cfractalc.currentformula->smooth_calculate_periodicity (0.0, 0.0, 0.0, 0.0); #endif cfractalc.maxiter = 20000000; tl_update_time (); tl_reset_timer (t); /*sum = rdtsc (); */ #ifdef SLOWFUNCPTR i = calculateswitch (0.0, 0.0, 0.0, 0.0, 0); #else i = cfractalc.currentformula->calculate (0.0, 0.0, 0.0, 0.0); #endif /*sum -= rdtsc (); printf ("%f\n", (double) (-sum) / cfractalc.maxiter); */ tl_update_time (); time = tl_lookup_timer (t); x_message ("Result:%i Formulaname:%s Time:%i Mloops per sec:%.2f", (int) i, cfractalc.currentformula->name[0], time, cfractalc.maxiter / (double) time); #ifndef SLOWFUNCPTR if (cfractalc.currentformula->smooth_calculate != NULL) { tl_update_time (); tl_reset_timer (t); i = cfractalc.currentformula->smooth_calculate (0.0, 0.0, 0.0, 0.0); tl_update_time (); time = tl_lookup_timer (t); x_message ("Result:%i Formulaname:%s Time:%i Mloops per sec:%.2f", (int) i, cfractalc.currentformula->name[0], time, cfractalc.maxiter / (double) time); } #endif tl_free_timer (t); }
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"); } }
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); }
static int uih_message1 (uih_context * c, CONST char *message, int type) { static int pid; int i; for (i = 0; i < NMESSAGES && c->messg.message[i] != NULL; i++); if (i == NMESSAGES) uih_scrollup (c), i--; c->messg.message[i] = mystrdup (message); c->messg.messagetype[i] = type; c->messg.messagetimer[i] = tl_create_timer (); tl_reset_timer (c->messg.messagetimer[i]); tl_set_interval (c->messg.messagetimer[i], 1);; tl_slowdown_timer (c->messg.messagetimer[i], EXPIRETIME);; tl_set_handler (c->messg.messagetimer[i], (void (*)(void *)) uih_scrollup, c); tl_add_timer (syncgroup, c->messg.messagetimer[i]); /*tl_remove_timer (c->messg.messagetimer[i]); */ c->messg.pid[i] = ++pid; c->display = 1; return (pid); }
int bb(void) { aa_gotoxy(context, 0, 0); introscreen(); params = aa_getrenderparams(); aa_render(context, params, 0, 0, 1, 1); font = uncompressfont( /*context->params.font */ &aa_font16); scenetimer = tl_create_timer(); srand(time(NULL)); if (stage != 1) finish_stuff = 1; do switch (stage) { default: case 1: load_song("bb.s3m"); bbupdate(); starttime = endtime = TIME; scene1(); scene3(); if (quitnow) goto quit; vezen(&fk1, &fk2, &fk3, &fk4); messager("FILIP KUPSA known as FK, Tingle Notions, Dawn Music\n" "birth: June 22 1979, Tabor, Czech Republic, sex: male\n" "\n" "1992 - Changed his piano for 386/mp.com/pc-speaker music\n" "1993 - Got his first Sound Blaster\n" "1995 - Changed his SB for a new GUS technology\n" "1996 - Composed his first great hits\n" "1996 - FAT recomposition made by Windows 95\n" "1997 - Released his musac in BB\n" "\n" "1998 - Got retired\n" "\n" "Contact address: via KT"); devezen2(); scene4(); scene2(); if (quitnow) goto quit; vezen(&ms1, &ms2, &ms3, &ms4); messager("MOJMIR SVOBODA known as MS, TiTania, MSS, Bill\n" "birth: ??, Tabor, Czech Republic, sex: ? male ?\n" "\n" "1993 - Installed Linux on his 386sx/25 + 40MB HDD\n" "1994 - Removed Linux to make space for Doom\n" "1995 - Reinstalled Linux on his 486Dx4/120 + 850MB\n" "1996 - Removed Linux to make space for Windows 95\n" "\n" "1997 - Removed Windows 95 to make space for aalib\n" "\n" "Contact address: [email protected]"); devezen3(); scene8(); scene6(); case 2: if (quitnow) goto quit; vezen(&kt1, &kt2, &kt3, &kt4); messager("KAMIL TOMAN known as KT, Kato, Whale, Bart\n" "birth: May 19 1979, Tabor, Czech Republic, sex: male\n" "\n" "1993 - Became a linux extremist\n" "1993 - Successful attempt to establish a secret organization\n" " Commandline Brotherhood\n" "1995 - Action 'koules' - a secret project to train brotherhood\n" " members - covered under a game design\n" "\n" "1998 - Heading a new wave of command line revolution\n" "\n" "Contact address: [email protected]"); bbupdate(); starttime = endtime = TIME; devezen1(); if (quitnow) goto quit; scene7(); if (quitnow) goto quit; scene5(); if (quitnow) goto quit; scene10(); vezen(&hh1, &hh2, &hh3, &hh4); messager("JAN HUBICKA known as HH, Jahusoft, HuJaSoft, JHS, UNIX, Honza\n" "birth: Apr 1 1978, Tabor, Czech Republic, sex: male\n" "\n" "1991 - Installed underground hackers OS Linux\n" "1995 - Headed Action 'koules'\n" "1996 - Famous troan XaoS to convert all windows instalations\n" " into Linux\n" "\n" "1998 - Secret plan to make `Text Windows` system to confuse users\n" "2001 - Planning an assassination of dictator Bill G.\n" "\n" "Contact address: [email protected]"); devezen4(); if (quitnow) goto quit; credits(); if (quitnow) goto quit; case 3: if (loopmode) break; credits2(); } while (loopmode); quit:; aa_close(context); return (0); }
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); }
int uih_save_enable(struct uih_context *uih, xio_file f, int mode) { struct uih_savedcontext *s; int i; last = 0; if (uih->save) { uih_error(uih, "Recording is already enabled"); return 0; } s = (struct uih_savedcontext *) calloc(1, sizeof(*s)); if (f == NULL || s == NULL) { uih_error(uih, "File could not be opended or out of memory"); return 0; } uih->savec = s; s->fcontext = make_fractalc(1, uih->image->pixelwidth * uih->image->width, uih->image->pixelheight * uih->image->height); if (s->fcontext == NULL) { uih_error(uih, "File could not be opended or out of memory"); return 0; } s->mode = mode; /*Invalidate context to force save everything first */ s->speedup = STEP; s->maxstep = MAXSTEP; s->xcenter = INT_MAX; s->fastmode = 2; s->juliamode = 0; s->cycling = 0; for (i = 0; i < uih_nfilters; i++) s->filter[i] = 0; s->pressed = 0; s->firsttime = 1; uih->palettechanged = 1; s->cyclingspeed = 30; s->fcontext->pre = s->fcontext->pim = 0; s->fcontext->bre = s->fcontext->bim = 0; s->fcontext->currentformula = NULL; s->fcontext->periodicity = 1; s->fcontext->maxiter = 170; s->fcontext->bailout = 4; s->fcontext->coloringmode = 0; s->fcontext->incoloringmode = 0; s->fcontext->outtcolor = 0; s->fcontext->intcolor = 0; s->fcontext->mandelbrot = 1; s->fcontext->plane = 0; s->fcontext->range = 3; s->fcontext->angle = 0; s->rotatepressed = 0; s->autorotate = 0; s->fastrotate = 0; s->rotationspeed = 10; s->clearscreen = 0; s->color = 0; s->xtextpos = 1; s->ytextpos = 1; s->file = f; s->timer = tl_create_timer(); s->synctimer = tl_create_timer(); uih->viewchanged = 1; uih->palettechanged = 1; uih->save = 1; uih_emulatetimers(uih); tl_reset_timer(s->timer); uih->moved = 0; #ifndef _plan9_ if (mode == UIH_SAVEANIMATION) myputs(";Animation file automatically generated by XaoS " XaoS_VERSION "\n" "; - a realtime interactive fractal zoomer\n" ";Use xaos -play <filename> to replay it\n"); else if (mode == UIH_SAVEPOS) myputs(";Position file automatically generated by XaoS " XaoS_VERSION "\n" "; - a realtime interactive fractal zoomer\n" ";Use xaos -load <filename> to display it\n"); #endif uih_saveframe(uih); uih_updatemenus(uih, "save"); xio_putc('\n', f); return 1; }