void allegrosetup(int scrwid,int scrhei,int cd) { #ifdef ALLEGRO // - Gets allegro up and working at specified screen size if (allegrostarted!=scrwid*scrhei*cd && ( (scrwid==320 && scrhei==200) || (scrwid==640 && scrhei==480) || (scrwid==800 && scrhei==600) || (scrwid==1024 && scrhei==768) ) ) { allegrostarted=scrwid*scrhei*cd; set_color_depth(cd); allegro_init (); install_keyboard (); install_timer (); #ifdef NOGRAPHICS printf("Not starting Allegro graphics.\n"); #else set_gfx_mode (GFX_AUTODETECT, scrwid, scrhei, 0, 0); set_pallete (desktop_palette); #endif } #ifndef NOGRAPHICS clear(screen); #endif #endif }
Player *load_player() { Player *p = (Player *)malloc( sizeof(Player) ); DATAFILE *data; BITMAP *t; memset( p, 0, sizeof(Player) ); data = load_datafile( "dat/sprites.dat" ); if (!data) fatal("Error reading datafile 'dat/sprites.dat'\n"); p->still_image = copy_bitmap( (BITMAP *)data[0].dat ); p->moving_images = V_new(); V_register_del_func( p->moving_images, (VectorFunc)destroy_bitmap ); t = copy_bitmap( (BITMAP *)data[0].dat ); V_add( p->moving_images, t ); t = copy_bitmap( (BITMAP *)data[1].dat ); V_add( p->moving_images, t ); t = copy_bitmap( (BITMAP *)data[2].dat ); V_add( p->moving_images, t ); t = copy_bitmap( (BITMAP *)data[1].dat ); V_add( p->moving_images, t ); p->ducking_image = copy_bitmap( (BITMAP *)data[a05_marioduck].dat ); p->jumping_image = copy_bitmap( (BITMAP *)data[a03_mariobat].dat ); p->attack_image = copy_bitmap( (BITMAP *)data[a04_mariobat].dat ); set_pallete( *((PALLETE *)data[Zpallete].dat) ); unload_datafile( data ); p->cur_image = p->still_image; p->width = p->cur_image->w; p->height = p->cur_image->h; p->invul = 0; p->life = MAX_LIFE; p->max_jump = MAX_JUMP; p->inventory = V_new(); p->quantity = IA_new(); p->inv_selection = 0; p->item_in_use = 0; p->cur_item_frame = 0; p->item_animation = V_new(); V_register_del_func( p->item_animation, (VectorFunc)destroy_bitmap ); p->weapon = 1; p->weapon_length = 20; p->weapon_timer = 0; p->weapon_speed = 15; p->weapon_delay = 10; return p; }
int main(int argc, char **argv) { int i,stillhappy; int events; allegro_init (); install_keyboard (); install_timer (); set_gfx_mode (GFX_AUTODETECT, scrwid, scrhei, 0, 0); set_pallete (desktop_palette); buffer = create_bitmap (scrwid, scrhei); clear (buffer); p.x=-0.9; p.y=0; q.x=0.9; q.y=0; srand(874984); frame=0; for (i=0; i<numps; i++) { randpart(&particle[i]); } while(!key[KEY_ESC]) { plotparts(); // blit (buffer, screen, 0, 0, 0, 0, scrwid, scrhei); moveparts(); // if (mymod(frame,32)==0) // plotfield(); frame=frame+speed; } }
void main() { allegro_init(); install_keyboard(); install_timer(); set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0); explosion = load_bmp("explosion.bmp",pal); starShip = load_bmp("rymdskepp.bmp",pal); theWorld = load_bmp("theWorld.bmp",pal); screenBuffer = create_bitmap(SCREEN_W, SCREEN_H); set_pallete(pal); int X = 0, initX = retrace_count + 1100; int textX, initTextX = retrace_count + 40; char *text; while (X < 500 && !key[KEY_ESC]) { X = (retrace_count-initX)/3; textX = 640-(retrace_count-initTextX); blit(theWorld, screenBuffer, 0, 0, 0, 0, 640, 480); if (X > 300) { blit(explosion, screen, 0, 0, 0, 0, 640, 480); } else { draw_sprite(screenBuffer, starShip, X, 220); } sprintf(text,"StarshipX: %d TextX: %d", X, textX ); textout(screenBuffer, font, text, 5, 5, 13); textout(screenBuffer, font, "The year is 2569, the date is 12 of february! The time 12:34 local!.. This happends............................Bzzz Were going too chrash. Bzzz....Watchout.................... Bzzzzzz.....Bzzzzz............NOOOOOOOOOOOOOOOOOOOOOOOOO" , textX, 60, 200); blit(screenBuffer, screen, 0, 0, 0, 0, 640, 480); } textout(screen, font, "Scary isnt it......" , 120, 40, 200); textout(screen, font, "Press [A Key] to exit.." , 100, 180, 200); readkey(); destroy_bitmap(screenBuffer); destroy_bitmap(theWorld); destroy_bitmap(explosion); destroy_bitmap(starShip); }
/* handles double-clicking on a FLIC object in the grabber */ static int view_fli(DATAFILE *dat) { show_mouse(NULL); clear_to_color(screen, gui_mg_color); play_memory_fli(dat->dat, screen, TRUE, fli_stopper); do { } while (mouse_b); clear_keybuf(); set_pallete(datedit_current_palette); show_mouse(screen); return D_REDRAW; }
void GameInit(void) { allegro_init(); install_keyboard(); install_timer(); install_mouse(); clear_keybuf(); set_gfx_mode(GFX_AUTODETECT, 320, 240, 0, 0); set_pallete(desktop_pallete); return; }
int main() { BITMAP *buffer; PALETTE pal; int c; allegro_init(); install_keyboard(); if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) { allegro_exit(); printf("Error setting graphics mode\n%s\n\n", allegro_error); return 1; } /* tile 1 colour */ for (c = 1; c != 128; c++) { pal[c].r = c * 49/127; pal[c].g = 0; pal[c].b = c * 63/127; } /* tile 2 colour */ for (c = 0; c != 127; c++) { pal[c + 128].r = 0; pal[c + 128].g = 0; pal[c + 128].b = c * 63/127; } pal[0].r = pal[0].g = pal[0].b = 0; pal[255].r = pal[255].g = pal[255].b = 63; set_pallete(pal); buffer = create_bitmap(SCREEN_W, SCREEN_H); while (!key[KEY_ESC]) { render(buffer); vsync(); blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); process_input(); } destroy_bitmap(buffer); return 0; }
int main() { allegro_init(); install_keyboard(); install_mouse(); install_timer(); if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) { allegro_exit(); printf("Error setting graphics mode\n%s\n\n", allegro_error); return 1; } set_pallete(desktop_pallete); clear(screen); do_dialog(the_dlg, -1); return 0; }
void main(void) { int i,j,k,c,x,y; RGB rgb; srand((int)time(NULL)); for (x=0;x<scrwid;x++) { for (y=0;y<scrhei;y++) { rx=(float)x/scrwid*2-1; ry=(float)(y-scrhei/2)/scrwid*2; px=(qx+1)/2*scrwid; py=scrhei/2+(qy)/2*scrwid; ix=(int)px; iy=(int)py; amount[x][y][0][0]=((float)ix+1-(float)px)*((float)(iy+1)-(float)py); amount[x][y][1][0]=((float)px-(float)ix)*((float)(iy+1)-(float)py); amount[x][y][0][1]=((float)ix+1-(float)px)*((float)py-(float)iy); amount[x][y][1][1]=((float)px-(float)ix)*((float)py-(float)iy); pix[x][y]=ix; piy[x][y]=iy; } } allegro_init (); install_keyboard (); install_timer (); set_gfx_mode (GFX_AUTODETECT, scrwid, scrhei, 0, 0); set_pallete (desktop_palette); _farsetsel(screen->seg); for (c=0;c<=255;c++) { if (c<128) { rgb.r=c*63/127; rgb.g=0; rgb.b=0; } else { rgb.r=127; rgb.g=(c-128)*63/127; rgb.b=rgb.g; } set_color(c,&rgb); } while(!key[KEY_ESC]) { for (y=0; y<scrhei; y++) { movedata(screen->seg, bmp_read_line(screen,y), _my_ds(), map[y], scrwid); } for (x=0; x<scrwid; x++) { for (y=0; y<scrhei; y++) { c=0; for (i=0;i<=1;i++) { for (j=0;j<=1;j++) { c=c+amount[x][y][i][j]*map[piy[x][y]+j][pix[x][y]+i]; } } c--; map2[y][x]=c; } } for (y=0; y<scrhei; y++) { movedata(_my_ds(), map2[y], screen->seg, bmp_write_line(screen,y), scrwid); } for (i=1;i<=10;i++) { circlefill(screen,myrnd()*scrwid,myrnd()*scrhei,8,myrnd()*255); } } }
void main(void) { int xy,i,j,c,x,y,front,back,n,minc,maxc; int ix,iy,k,address,jx,jy,kx,ky; float dzdx,dzdy,a,b,dot,norm; float rx,ry,sx,sy,px,py; long p,q; RGB rgb; for (x=0;x<scrwid;x++) { for (y=0;y<scrhei;y++) { rx=(float)x/scrwid*2-1; ry=(float)y/scrhei*2-1; sx=rx*.8; sy=ry*.8; px=(sx+1)/2*scrwid; py=(sy+1)/2*scrhei; ix=(int)px; iy=(int)py; amount[x][y][0][0]=((float)ix+1-(float)px)*((float)(iy+1)-(float)py); amount[x][y][1][0]=((float)px-(float)ix)*((float)(iy+1)-(float)py); amount[x][y][0][1]=((float)ix+1-(float)px)*((float)py-(float)iy); amount[x][y][1][1]=((float)px-(float)ix)*((float)py-(float)iy); pix[x][y]=ix; piy[x][y]=iy; // printf("%f",amount[x][y][0][0]+amount[x][y][1][0]+amount[x][y][0][1]+amount[x][y][1][1]); if (mysquare(amount[x][y][0][0]+amount[x][y][1][0]+amount[x][y][0][1]+amount[x][y][1][1]-1)>0.00001) { printf("%d %d %f %f ",ix,iy,px,py); printf("%f+%f(%f*%f)+%f+%f=%f? \n",amount[x][y][0][0],amount[x][y][1][0],(float)px-(float)ix,(float)(iy+1)-(float)py,amount[x][y][0][1],amount[x][y][1][1],amount[x][y][0][0]+amount[x][y][1][0]+amount[x][y][0][1]+amount[x][y][1][1]); } } } // srand(456789); srand((int)time(NULL)); //printf("%d\n",(int)time(NULL)); allegro_init (); install_keyboard (); install_timer (); set_gfx_mode (GFX_AUTODETECT, scrwid, scrhei, 0, 0); set_pallete (desktop_palette); buffer = create_bitmap (scrwid, scrhei); clear (buffer); // textout_centre (buffer, font, "Press SPACE!", 60, 220, 4); // Set up grayscale colours for (c=0;c<=255;c++) { i=0; rgb.r=c*63/255; rgb.g=0; rgb.b=0; set_color(c,&rgb); // colors[c]=GrAllocColor(c,i,i); } for (x=0; x<scrwid; x++) { for (y=0; y<scrhei; y++) { putpixel(buffer,x,y,128); } } blit (buffer, screen, 0, 0, 0, 0, scrwid, scrhei); _farsetsel(screen->seg); while(!key[KEY_ESC]) { for (y=0; y<scrhei; y++) { movedata(screen->seg, bmp_read_line(screen,y), _my_ds(), tmp[y], scrwid); } for (x=0; x<scrwid; x++) { for (y=0; y<scrhei; y++) { c=0; kx=x-scrwid/2; ky=y-scrhei/2; jx=kx*cos(ang)+ky*sin(ang); jy=-kx*sin(ang)+ky*cos(ang); ix=scrwid/2+0.9*jx; iy=scrhei/2+0.9*jy; k=0; i=0;j=0; // for (i=-1;i<=1;i++) { // for (j=-1;j<=1;j++) { // c=c+getpixel(screen, ix+i, iy+j); // address = bmp_read_line(screen, iy)+ix; c=c+tmp[iy][ix]; k++; // } // } c=c/k; c--; // address = bmp_write_line(buffer, y)+x; // _farnspokeb(address, c); tmp2[y][x]=c; // putpixel(buffer, x, y, c); } } for (y=0; y<scrhei; y++) { movedata(_my_ds(), tmp2[y], screen->seg, bmp_write_line(screen,y), scrwid); } for (i=1;i<=10;i++) circlefill(screen,myrnd()*scrwid,myrnd()*scrhei,8,myrnd()*255); // putpixel(buffer,scrwid/2,scrhei/2,255); // blit (buffer, screen, 0, 0, 0, 0, scrwid, scrhei); } destroy_bitmap(buffer); exit(0); getch(); // GrSetMode(GR_default_text); printf("max col %d\n",maxc); printf("min col %d\n",minc); }
int save_options_proc(int msg, DIALOG *d, int c) { int ret; int old_baud_rate; BITMAP *bmp; FILE *file; ret = d_button_proc(msg, d, c); if (ret == D_CLOSE) { old_baud_rate = comport.baud_rate; broadcast_dialog_message(MSG_SAVE_OPTIONS, 0); if (comport.baud_rate != old_baud_rate) { if (alert("WARNING!", "This operation may cause scan tool to stop responding.", "Are you sure you want to change the baud rate?", "Yes", "No", 0, 0) != 1) { comport.baud_rate = old_baud_rate; broadcast_dialog_message(MSG_REFRESH, 0); return D_O_K; } } close_comport(); // close current comport open_comport(); // try reinitializing comport (comport.status will be set) if ((!(display_mode & WINDOWED_MODE) && (display_mode & WINDOWED_MODE_SET)) || ((display_mode & WINDOWED_MODE) && !(display_mode & WINDOWED_MODE_SET))) { bmp = create_bitmap(SCREEN_W, SCREEN_H); if (bmp) { scare_mouse(); blit(screen, bmp, 0, 0, 0, 0, SCREEN_W, SCREEN_H); unscare_mouse(); if (display_mode & WINDOWED_MODE) { if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) == 0) display_mode |= WINDOWED_MODE_SET; else display_mode &= ~WINDOWED_MODE_SUPPORTED; } else { if (set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 640, 480, 0, 0) == 0) display_mode &= ~WINDOWED_MODE_SET; else display_mode &= ~FULLSCREEN_MODE_SUPPORTED; } set_pallete(datafile[MAIN_PALETTE].dat); gui_fg_color = C_BLACK; // set the foreground color gui_bg_color = C_WHITE; // set the background color gui_mg_color = C_GRAY; // set the disabled color set_mouse_sprite(NULL); // make mouse use current palette blit(bmp, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); show_mouse(screen); destroy_bitmap(bmp); } else alert("Error switching display modes.", "Not enough memory to save screen.", NULL, "OK", NULL, 0, 0); } file = fopen(options_file_name, "a"); if (file == NULL) alert("Options could not be saved, because file", options_file_name, "could not be open for writing", "OK", NULL, 0, 0); else { fclose(file); save_program_options(); } } return ret; }
int main() { int mickeyx = 0; int mickeyy = 0; BITMAP *custom_cursor; char msg[80]; int c = 0; allegro_init(); install_keyboard(); install_mouse(); install_timer(); set_gfx_mode(GFX_VGA, 320, 200, 0, 0); set_pallete(desktop_pallete); do { /* the mouse position is stored in the variables mouse_x and mouse_y */ sprintf(msg, "mouse_x = %-5d", mouse_x); textout(screen, font, msg, 16, 16, 255); sprintf(msg, "mouse_y = %-5d", mouse_y); textout(screen, font, msg, 16, 32, 255); /* or you can use this function to measure the speed of movement. * Note that we only call it every fourth time round the loop: * there's no need for that other than to slow the numbers down * a bit so that you will have time to read them... */ c++; if ((c & 3) == 0) get_mouse_mickeys(&mickeyx, &mickeyy); sprintf(msg, "mickey_x = %-7d", mickeyx); textout(screen, font, msg, 16, 64, 255); sprintf(msg, "mickey_y = %-7d", mickeyy); textout(screen, font, msg, 16, 80, 255); /* the mouse button state is stored in the variable mouse_b */ if (mouse_b & 1) textout(screen, font, "left button is pressed ", 16, 112, 255); else textout(screen, font, "left button not pressed", 16, 112, 255); if (mouse_b & 2) textout(screen, font, "right button is pressed ", 16, 128, 255); else textout(screen, font, "right button not pressed", 16, 128, 255); if (mouse_b & 4) textout(screen, font, "middle button is pressed ", 16, 144, 255); else textout(screen, font, "middle button not pressed", 16, 144, 255); vsync(); } while (!keypressed()); clear_keybuf(); /* To display a mouse pointer, call show_mouse(). There are several * things you should be aware of before you do this, though. For one, * it won't work unless you call install_timer() first. For another, * you must never draw anything onto the screen while the mouse * pointer is visible. So before you draw anything, be sure to turn * the mouse off with show_mouse(NULL), and turn it back on again when * you are done. */ clear(screen); textout_centre(screen, font, "Press a key to change cursor", SCREEN_W/2, SCREEN_H/2, 255); show_mouse(screen); readkey(); show_mouse(NULL); /* create a custom mouse cursor bitmap... */ custom_cursor = create_bitmap(32, 32); clear(custom_cursor); for (c=0; c<8; c++) circle(custom_cursor, 16, 16, c*2, c); /* select the custom cursor and set the focus point to the middle of it */ set_mouse_sprite(custom_cursor); set_mouse_sprite_focus(16, 16); clear(screen); textout_centre(screen, font, "Press a key to quit", SCREEN_W/2, SCREEN_H/2, 255); show_mouse(screen); readkey(); show_mouse(NULL); destroy_bitmap(custom_cursor); return 0; }
static void init() { char temp_buf[256]; is_not_genuine_scan_tool = FALSE; /* initialize some varaibles with default values */ strcpy(options_file_name, "scantool.cfg"); strcpy(data_file_name, "scantool.dat"); strcpy(code_defs_file_name, "codes.dat"); datafile = NULL; comport.status = NOT_OPEN; display_mode = 0; set_uformat(U_ASCII); /* initialize hardware */ write_log("\nInitializing Allegro... "); allegro_init(); write_log("OK"); set_window_title(WINDOW_TITLE); write_log("\nInstalling Timers... "); if (install_timer() != 0) { write_log("Error!"); fatal_error("Error installing timers"); } write_log("OK"); write_log("\nInstalling Keyboard... "); install_keyboard(); write_log("OK"); write_log("\nInstalling Mouse... "); install_mouse(); write_log("OK"); /* load options from file, the defaults will be automatically substituted if file does not exist */ write_log("\nLoading Preferences... "); set_config_file(options_file_name); /* if config file doesn't exist or is of an incorrect version */ if (strcmp(get_config_string(NULL, "version", ""), SCANTOOL_VERSION_STR) != 0) { /* update config file */ remove(options_file_name); set_config_file(options_file_name); set_config_string(NULL, "version", SCANTOOL_VERSION_STR); load_program_options(); // Load defaults save_program_options(); } else load_program_options(); write_log("OK"); display_mode |= FULLSCREEN_MODE_SUPPORTED; write_log("\nTrying Windowed Graphics Mode... "); if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) == 0) { display_mode |= WINDOWED_MODE_SUPPORTED; write_log("OK"); } else { display_mode &= ~(WINDOWED_MODE_SUPPORTED | WINDOWED_MODE_SET); write_log(allegro_error); } if (!(display_mode & WINDOWED_MODE_SET)) { write_log("\nTrying Full Screen Graphics Mode... "); if (set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 640, 480, 0, 0) == 0) { display_mode |= FULLSCREEN_MODE_SUPPORTED; write_log("OK"); } else { display_mode &= ~FULLSCREEN_MODE_SUPPORTED; write_log(allegro_error); } } if (!(display_mode & (FULLSCREEN_MODE_SUPPORTED | WINDOWED_MODE_SUPPORTED))) fatal_error(allegro_error); else if ((display_mode & WINDOWED_MODE_SUPPORTED) && !(display_mode & FULLSCREEN_MODE_SUPPORTED)) { set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0); display_mode &= WINDOWED_MODE_SET; } write_log("\nLoading Data File... "); packfile_password(PASSWORD); datafile = load_datafile(data_file_name); packfile_password(NULL); if (datafile == NULL) { sprintf(temp_buf, "Error loading %s!", data_file_name); write_log(temp_buf); fatal_error(temp_buf); } write_log("OK"); set_pallete(datafile[MAIN_PALETTE].dat); font = datafile[ARIAL12_FONT].dat; gui_fg_color = C_BLACK; // set the foreground color gui_bg_color = C_WHITE; // set the background color gui_mg_color = C_GRAY; // set the disabled color set_mouse_sprite(NULL); // make mouse use current palette write_log("\nInitializing Serial Module... "); serial_module_init(); write_log("OK"); sprintf(temp_buf, "\nOpening COM%i... ", comport.number + 1); write_log(temp_buf); /* try opening comport (comport.status will be set) */ open_comport(); switch (comport.status) { case READY: write_log("OK"); break; case NOT_OPEN: write_log("Error!"); break; default: write_log("Unknown Status"); break; } }
int main(void) { int f,i,j,k,c,x,y,ix,iy,displayloop; int usingmap,makingmap,mmx,mmy,tmpmap,maploop; float rx,ry,nrx,nry,px,py; RGB rgb; FILE *fp; img=(uchar **)calloc(scrhei,sizeof(uchar *)); for (y=0; y<scrhei; y++) { img[y]=(uchar *)calloc(scrwid,sizeof(uchar)); for (x=0; x<scrwid; x++) { img[y][x]=myrnd()*255; } } img2=(uchar **)calloc(scrhei,sizeof(uchar *)); for (y=0; y<scrhei; y++) { img2[y]=(uchar *)calloc(scrwid,sizeof(uchar)); for (x=0; x<scrwid; x++) { img2[y][x]=myrnd()*255; } } srand((int)time(NULL)); usingmap=0; makingmap=1; mmx=0; mmy=0; /* Originals from QB op[0] = 1; damp[0] = .999; force[0] = .005; op[1] = 1.02; damp[1] = .999; force[1] = .002; op[2] = 0; damp[2] = .999; force[2] = .002; op[3] = 1; damp[3] = .999; force[3] = .005; op[4] = 1; damp[4] = .999; force[4] = .005; op[5] = 0; damp[5] = .999; force[5] = .002; */ // 0 Accelerate op[0] = 1; damp[0] = .999; force[0] = .005; // 1 Velocity op[1] = 1.02; damp[1] = .999; force[1] = .01; // 2 Rotation op[2] = 0; damp[2] = .999; force[2] = .05; // 3 Drip op[3] = 1; damp[3] = .999; force[3] = .03; // 4 Dribble op[4] = 1; damp[4] = .999; force[4] = .01; // 5 Slide op[5] = 0; damp[5] = .999; force[5] = .01; for (f=0; f<fs; f++) { var[f] = op[f]; fon[f]=1; } allegro_init (); install_keyboard (); install_timer (); set_gfx_mode (GFX_AUTODETECT, scrwid, scrhei, 0, 0); set_pallete (desktop_palette); _farsetsel(screen->seg); for (c=0; c<=255; c++) { rgb.r=saw(0,c); rgb.g=saw(256/3,c); rgb.b=saw(2*256/3,c); set_color(c,&rgb); } while(!key[KEY_ESC]) { // Generate some more of the map for (maploop=1; maploop<scrwid*scrhei/15; maploop++) { rx=(float)mmx/scrwid*2-1; ry=(float)(mmy-scrhei/2)/scrwid*2; if (fon[1]) { rx = rx / var[1]; ry = ry / var[1]; } if (fon[0]) { rx = mysgn(rx)/var[1]*mypow(myabs(rx),1/var[6]); ry = mysgn(ry)/var[1]*mypow(myabs(ry),1/var[6]); } if (fon[2]) { nrx = rx * cos(var[2]) + ry * sin(var[2]); nry = -rx * sin(var[2]) + ry * cos(var[2]); rx = nrx; ry=nry; } if (fon[3]) { ry = ry / var[3]; } if (fon[4]) { ry = ((myabs(ry) - 1) / var[4] + 1) * mysgn(ry); } if (fon[5]) { rx = rx + var[5] * mysgn(rx); } px=(rx+1)/2*scrwid; py=scrhei/2+(ry)/2*scrwid; ix=(int)px; iy=(int)py; amount[mmx][mmy][0][0][makingmap]=((float)ix+1-(float)px)*((float)(iy+1)-(float)py); amount[mmx][mmy][1][0][makingmap]=((float)px-(float)ix)*((float)(iy+1)-(float)py); amount[mmx][mmy][0][1][makingmap]=((float)ix+1-(float)px)*((float)py-(float)iy); amount[mmx][mmy][1][1][makingmap]=((float)px-(float)ix)*((float)py-(float)iy); pix[mmx][mmy][makingmap]=ix; piy[mmx][mmy][makingmap]=iy; if (ix<0 || ix>=scrwid-1 || iy<0 || iy>=scrhei-1) { pix[mmx][mmy][makingmap]=scrwid/2; piy[mmx][mmy][makingmap]=scrhei/2; for (i=0; i<=1; i++) { for (j=0; j<=1; j++) { amount[mmx][mmy][i][j][makingmap]=0; } } } mmx++; if (mmx>=scrwid) { mmx=0; mmy++; if (mmy>=scrhei) { mmy=0; tmpmap=usingmap; usingmap=makingmap; makingmap=tmpmap; for (f=0; f<fs; f++) { perturb(f); } for (i=0; i<4; i++) { f = myrnd() * fs; if (myrnd()<.8) { if (myrnd()<.5) fon[f] = 1; else fon[f]=0; } } } } } // Animate for (x=0; x<scrwid; x++) { for (y=0; y<scrhei; y++) { c=0; for (i=0; i<=1; i++) { for (j=0; j<=1; j++) { c=c+amount[x][y][i][j][usingmap]*img[piy[x][y][usingmap]+j][pix[x][y][usingmap]+i]; } } c--; img2[y][x]=c; } } /* for (y=0;y<scrhei;y++) { for (x=0;x<scrwid;x++) { _farpokeb(screen->seg, (unsigned long)screen->line[y]+x, img2[y][x]); } }*/ for (y=0; y<scrhei; y++) { movedata(_my_ds(), img2[y], screen->seg, bmp_write_line(screen,y), scrwid); } for (f=0; f<fs; f++) { if (fon[f]) { hline(screen, scrwid/2, f*2, scrwid/2+(var[f] - op[f]) * scrwid * 4, 0); } } imgtmp=img; img=img2; img2=imgtmp; for (i=1; i<=5; i++) { mycircle(myrnd()*scrwid,myrnd()*scrhei,2+myrnd()*8,myrnd()*255); } } }
void main(void) { int xy,i,j,c,x,y,front,back,n,minc,maxc; int ix,iy,k,address,jx,jy,kx,ky; float dzdx,dzdy,a,b,dot,norm; float rx,ry,sx,sy,px,py; long p,q; RGB rgb; for (x=0;x<scrwid;x++) { for (y=0;y<scrhei;y++) { kx=x-scrwid/2; ky=y-scrhei/2; jx=kx*cos(ang)+ky*sin(ang); jy=-kx*sin(ang)+ky*cos(ang); ix=scrwid/2+(1-0.2*jx/scrwid)*jx; iy=scrhei/2+(1-0.2*jy/scrwid)*jy; dx[x][y]=ix; dy[x][y]=iy; } } // srand(456789); srand((int)time(NULL)); //printf("%d\n",(int)time(NULL)); allegro_init (); install_keyboard (); install_timer (); set_gfx_mode (GFX_AUTODETECT, scrwid, scrhei, 0, 0); set_pallete (desktop_palette); buffer = create_bitmap (scrwid, scrhei); clear (buffer); // textout_centre (buffer, font, "Press SPACE!", 60, 220, 4); // Set up grayscale colours for (c=0;c<=255;c++) { i=0; rgb.r=c*63/255; rgb.g=0; rgb.b=0; set_color(c,&rgb); // colors[c]=GrAllocColor(c,i,i); } for (x=0; x<scrwid; x++) { for (y=0; y<scrhei; y++) { putpixel(buffer,x,y,128); } } blit (buffer, screen, 0, 0, 0, 0, scrwid, scrhei); _farsetsel(screen->seg); while(!key[KEY_ESC]) { for (y=0; y<scrhei; y++) { movedata(screen->seg, bmp_read_line(screen,y), _my_ds(), tmp[y], scrwid); } for (x=0; x<scrwid; x++) { for (y=0; y<scrhei; y++) { c=tmp[dy[x][y]][dx[x][y]]; c--; tmp2[y][x]=c; } } for (y=0; y<scrhei; y++) { movedata(_my_ds(), tmp2[y], screen->seg, bmp_write_line(screen,y), scrwid); } for (i=1;i<=10;i++) circlefill(screen,myrnd()*scrwid,myrnd()*scrhei,8,myrnd()*255); // putpixel(buffer,scrwid/2,scrhei/2,255); // blit (buffer, screen, 0, 0, 0, 0, scrwid, scrhei); } destroy_bitmap(buffer); exit(0); getch(); // GrSetMode(GR_default_text); printf("max col %d\n",maxc); printf("min col %d\n",minc); }
void main(void) { int xy,i,c,x,y,front,back,n,minc,maxc; float dzdx,dzdy,a,b,dot,norm,tmp; long p,q; RGB rgb; long starttime; int numframes; // srand(456789); srand((int)time(NULL)); // printf("%d\n",(int)time(NULL)); mytime=10; maxc=0; minc=255; // Set up ripples numripples=3; for (i=0; i<numripples; i++) { newripple(i); } Map2d<int> dzdxmap=Map2d<int>(scrwid,scrhei); Map2d<int> dzdymap=Map2d<int>(scrwid,scrhei); allegro_init (); install_keyboard (); install_timer (); set_gfx_mode (GFX_AUTODETECT, scrwid, scrhei, 0, 0); set_pallete (desktop_palette); buffer = create_bitmap (scrwid, scrhei); clear (buffer); // Set up grayscale colours for (c=0;c<=255;c++) { i=0; rgb.r=c*63/255; rgb.g=0; rgb.b=0; set_color(c,&rgb); // colors[c]=GrAllocColor(c,i,i); } PALLETE my_pallete; BITMAP *scr_buffer; scr_buffer = load_bitmap("paulcld.pcx",my_pallete); set_pallete (my_pallete); blit (scr_buffer, screen, 0,0,0,0,320,200); // circlefill (buffer, x, y, 3, 255); textout_centre (buffer, font, "Press SPACE!", 60, 220, 4); blit (buffer, screen, 0, 0, 0, 0, scrwid, scrhei); starttime=uclock(); numframes=0; while(!key[KEY_ESC]) { for (x=0; x<scrwid; x=x+jump) { for (y=0; y<scrhei; y=y+jump) { dzdx=0; dzdy=0; for (i=0;i<numripples;i++) { ripples[i].front=ripples[i].v*(mytime-ripples[i].st); ripples[i].back=ripples[i].v*(mytime-ripples[i].st)-ripples[i].w; if (ripples[i].back>scrwid) newripple(i); } for (i=0;i<numripples;i++) { xy=(sqrt((x-ripples[i].x)*(x-ripples[i].x)+(y-ripples[i].y)*(y-ripples[i].y))); // printf("xy%i",xy); // printf("x%i",x); // printf("y%i",y); // printf("rx%i",ripples[i].x); // printf("ry%i",ripples[i].y); // printf("f%i\n",front); // printf("b%i\n",back); if ((xy>2)&&(xy<ripples[i].front)&&(xy>ripples[i].back)) { // printf("*********"); a=pi/ripples[i].w*sin(2*pi*ripples[i].n/ripples[i].w*(xy-ripples[i].v*(mytime-ripples[i].st))); // printf("a%f",a); b=(float)10.0/mysquare(xy+1); // printf("b%f",b); // norm=1500/(mysquare(xy))*(exp(3*(xy-(ripples[i].v)*((mytime-ripples[i].st)))/ripples[i].w)); norm=2.0*(xy-ripples[i].back)/(ripples[i].front-ripples[i].back); // printf("n%f",norm); dzdx=dzdx+a*b*(x-ripples[i].x)*ripples[i].w*norm; dzdy=dzdy+a*b*(y-ripples[i].y)*ripples[i].w*norm; } } // dot=dzdx*lx+dzdy*ly; // dot=dot*(dzdx*0.8+dzdy*0.6); // dot=dzdx*0.8+dzdy*0.6; // dot=dzdx * 1 * 0.8 + dzdy * 1 * 0.6; // float f=mymod(0.5+dot*0.5*scale); dzdxmap.pos[x][y]=refract*dzdx; dzdymap.pos[x][y]=refract*dzdy; if (x>0 && y>0) { int nwdx=dzdxmap.pos[x-jump][y-jump]; int nedx=dzdxmap.pos[x][y-jump]; int swdx=dzdxmap.pos[x-jump][y]; int sedx=dzdxmap.pos[x][y]; int nwdy=dzdymap.pos[x-jump][y-jump]; int nedy=dzdymap.pos[x][y-jump]; int swdy=dzdymap.pos[x-jump][y]; int sedy=dzdymap.pos[x][y]; for (int i=0;i<jump;i++) for (int j=0;j<jump;j++) { float a=(float)i/(float)jump; float d=(float)j/(float)jump; int idzdx=(1.0-a)*(1.0-d)*nwdx+(a)*(1.0-d)*nedx+(1.0-a)*(d)*swdx+(a)*(d)*sedx; int idzdy=(1.0-a)*(1.0-d)*nwdy+(a)*(1.0-d)*nedy+(1.0-a)*(d)*swdy+(a)*(d)*sedy; int rx=x-jump+i+idzdx; int ry=y-jump+j+idzdy; if (rx>=0 && ry>=0 && rx<scrwid && ry<scrhei) c=getpixel(scr_buffer,rx,ry); else c=0; // c=ucharchop(8*sqrt(idzdx*idzdx+idzdy*idzdy)); putpixel(buffer,x-jump+i,y-jump+j,c); } } // GrFilledBox(x,y,x+jump-1,y+jump-1,colors[c]); } } /* for (i=0;i<numripples;i++) { mycircle(ripples[i].x,ripples[i].y,ripples[i].front,colors[0]); mycircle(ripples[i].x,ripples[i].y,ripples[i].back,colors[0]); }*/ blit (buffer, screen, 0, 0, 0, 0, scrwid, scrhei); mytime=mytime+2; numframes++; // save_bitmap(getnextfilename("bmp"),buffer,my_pallete); } destroy_bitmap(buffer); allegro_exit(); printf("%d frames per second.\n",UCLOCKS_PER_SEC*numframes/(uclock()-starttime)); printf("max col %d\n",maxc); printf("min col %d\n",minc); }
void main(void) { int xy,i,j,c,x,y,front,back,n,minc,maxc; int ix,iy; float dzdx,dzdy,a,b,dot,norm,tmp; float rx,ry,sx,sy,px,py; long p,q; RGB rgb; for (x=0;x<scrwid;x++) { for (y=0;y<scrhei;y++) { rx=(float)x/scrwid*2-1; ry=(float)y/scrhei*2-1; sx=rx*.99; sy=ry*.99; px=(sx+1)/2*scrwid; py=(sy+1)/2*scrhei; ix=(int)px; iy=(int)py; amount[x][y][0][0]=((float)ix+1-px)*((float)iy+1-py); amount[x][y][1][0]=(px-(float)ix)*((float)iy+1-py); amount[x][y][0][1]=((float)ix+1-px)*(py-(float)iy); amount[x][y][1][1]=(px-(float)ix)*(py-(float)iy); pix[x][y]=ix; piy[x][y]=iy; printf("%d %d %f %f ",x,y,px,py); printf("%f=1? \n",amount[x][y][0][0]+amount[x][y][1][0]+amount[x][y][0][1]+amount[x][y][1][1]); } } // srand(456789); srand((int)time(NULL)); //printf("%d\n",(int)time(NULL)); allegro_init (); install_keyboard (); install_timer (); set_gfx_mode (GFX_AUTODETECT, scrwid, scrhei, 0, 0); set_pallete (desktop_palette); buffer = create_bitmap (scrwid, scrhei); clear (buffer); // textout_centre (buffer, font, "Press SPACE!", 60, 220, 4); blit (buffer, screen, 0, 0, 0, 0, scrwid, scrhei); // Set up grayscale colours for (c=0;c<=255;c++) { i=0; rgb.r=c*63/255; rgb.g=0; rgb.b=0; set_color(c,&rgb); // colors[c]=GrAllocColor(c,i,i); } while(!key[KEY_ESC]) { for (x=0; x<scrwid; x=x+res) { for (y=0; y<scrhei; y=y+res) { c=0; for (i=0;i<1;i++) { for (j=0;j<1;j++) { c=c+getpixel(buffer, pix[x][y]+i, piy[x][y]+j)*amount[x][y][i][j]; } } putpixel(buffer, x, y, c); } } putpixel(buffer,myrnd()*scrwid,myrnd()*scrhei,myrnd()*255); blit (buffer, screen, 0, 0, 0, 0, scrwid, scrhei); } destroy_bitmap(buffer); exit(0); getch(); // GrSetMode(GR_default_text); printf("max col %d\n",maxc); printf("min col %d\n",minc); }
void main(void) { int xy,i,c,x,y,front,back,n,minc,maxc; float dzdx,dzdy,a,b,dot,norm,tmp; long p,q; RGB rgb; // srand(456789); srand((int)time(NULL)); //printf("%d\n",(int)time(NULL)); mytime=10; maxc=0; minc=255; // Set up ripples numripples=5; for (i=0; i<numripples; i++) { newripple(i); } allegro_init (); install_keyboard (); install_timer (); set_gfx_mode (GFX_AUTODETECT, scrwid, scrhei, 0, 0); set_pallete (desktop_palette); buffer = create_bitmap (scrwid, scrhei); clear (buffer); // Set up grayscale colours for (c=0;c<=255;c++) { i=0; rgb.r=c*63/255; rgb.g=0; rgb.b=0; set_color(c,&rgb); // colors[c]=GrAllocColor(c,i,i); } // circlefill (buffer, x, y, 3, 255); textout_centre (buffer, font, "Press SPACE!", 60, 220, 4); blit (buffer, screen, 0, 0, 0, 0, 320, 240); while(!key[KEY_ESC]) { for (x=0; x<scrwid; x=x+res) { for (y=0; y<scrhei; y=y+res) { dzdx=0; dzdy=0; for (i=0;i<numripples;i++) { ripples[i].front=ripples[i].v*(mytime-ripples[i].st); ripples[i].back=ripples[i].v*(mytime-ripples[i].st)-ripples[i].w; if (ripples[i].back>scrwid) newripple(i); } for (i=0;i<numripples;i++) { xy=(sqrt((x-ripples[i].x)*(x-ripples[i].x)+(y-ripples[i].y)*(y-ripples[i].y))); //printf("xy%i",xy); //printf("x%i",x); //printf("y%i",y); //printf("rx%i",ripples[i].x); //printf("ry%i",ripples[i].y); //printf("f%i\n",front); //printf("b%i\n",back); if ((xy>2)&&(xy<ripples[i].front)&&(xy>ripples[i].back)) { //printf("*********"); a=pi/ripples[i].w*sin(2*pi*ripples[i].n/ripples[i].w*(xy-ripples[i].v*(mytime-ripples[i].st))); //printf("a%f",a); b=(float)1/xy; //printf("b%f",b); norm=1500/(mysquare(xy))*(exp(3*(xy-(ripples[i].v)*((mytime-ripples[i].st)))/ripples[i].w)); //printf("n%f",norm); dzdx=dzdx+a*b*(x-ripples[i].x)*ripples[i].w*norm; dzdy=dzdy+a*b*(y-ripples[i].y)*ripples[i].w*norm; } } //dot=dzdx*lx+dzdy*ly; //dot=dot*(dzdx*0.8+dzdy*0.6); //dot=dzdx*0.8+dzdy*0.6; dot=dzdx * 1 * 0.8 + dzdy * 1 * 0.6; c=128+dot*128*scale; if (c<minc) minc=c; if (c>maxc) maxc=c; if (c<0) c=0; if (c>255) c=255; /*GrPlot(x,y,colors[c]); GrPlot(x+1,y,colors[c]); GrPlot(x,y+1,colors[c]); GrPlot(x+1,y+1,colors[c]);*/ rectfill(buffer, x, y, x+res-1, y+res-1, c); // GrFilledBox(x,y,x+res-1,y+res-1,colors[c]); } } /*for (i=0;i<numripples;i++) { mycircle(ripples[i].x,ripples[i].y,ripples[i].front,colors[0]); mycircle(ripples[i].x,ripples[i].y,ripples[i].back,colors[0]); }*/ blit (buffer, screen, 0, 0, 0, 0, 320, 240); mytime=mytime+2; } destroy_bitmap(buffer); exit(0); getch(); // GrSetMode(GR_default_text); printf("max col %d\n",maxc); printf("min col %d\n",minc); }