From: hackbard Date: Wed, 14 May 2003 15:56:03 +0000 (+0000) Subject: -!- :)) X-Git-Tag: fpb~58 X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=e28fcecc54036e7258172b96e97df4a8131f0d9a;p=physik%2Fnlsop.git -!- :)) --- diff --git a/dfbapi.c b/dfbapi.c index 2ff070e..aeb6cff 100644 --- a/dfbapi.c +++ b/dfbapi.c @@ -283,10 +283,10 @@ int 2d_event_init(2d_lattice *2d_l) return 1; } -int 3d_event_init(3d_lattice *3d_l) +int d3_event_init(d3_lattice *d3_l) { - 3d_l->dfb->GetInputDevice(3d_l->dfb,DIDID_KEYBOARD,&(3d_l->keyboard)); - 3d_l->keyboard->CreateEventBuffer(3d_l->keyboard,&(3d_l->k_buffer)); + d3_l->dfb->GetInputDevice(d3_l->dfb,DIDID_KEYBOARD,&(3d_l->keyboard)); + d3_l->keyboard->CreateEventBuffer(d3_l->keyboard,&(d3_l->k_buffer)); return 1; } diff --git a/nlsop.c b/nlsop.c index d646cdf..9e4c3bf 100644 --- a/nlsop.c +++ b/nlsop.c @@ -243,6 +243,14 @@ int main(int argc,char **argv) char s_file[MAX_CHARS]; char l_file[MAX_CHARS]; char r_file[MAX_CHARS]; + x_txt[MAX_TXT]; + y_txt[MAX_TXT]; + z_txt[MAX_TXT]; + status_txt[MAX_TXT]; + conc_txt[MAX_TXT]; + steps_txt[MAX_TXT]; + cc_txt[MAX_TXT]; + **arg_v; d3_lattice d3_l; max_x=X; @@ -342,8 +350,90 @@ int main(int argc,char **argv) } else usage(); } + if(!strcmp(r_file,"")) rand_init(NULL); + else rand_init(r_file); + if(!strcmp(l_file,"")) + { + i=max_x*max_y*max_z; + d3_lattice_init(&argc,argv,&d3_l,max_x,max_y,max_z); + if((d3_l->status=(unsigned char *)malloc(i*sizeof(unsigned char)))==NULL) + { + puts("failed allocating status buffer"); + return -1; + } + memset(d3_l->status,0,i*sizeof(unsigned char)); + if((d3_l->extra=(int *)malloc(i*sizeof(int)))==NULL) + { + puts("failed allocating concentration buffer"); + return -1; + } + memset(d3_l->extra,0,i*sizeof(int)); + } else + { + load_from_file(l_file,&d3_l); + d3_lattice_init(&argc,argv,&d3_l,d3_l->max_x,d3_l->max_y,d3_l->max_z); + } + + d3_event_init(&d3_l); + if(!strcmp(l_file,"")) + { + while((imax_x); + y_c=rand_get(d3_l->max_y); + z_c=rand_get_lgp(d3_l->max_z,a_el,b_el); + distrib_c(&3d_l,cc,a_cd,b_cd); + process_cell(&3d_l,x_c,y_c,z_c,range,a_ap,b_ap,&cc); + if(i%refresh==0) + { + sprintf(x_txt,"x: %d",x); + sprintf(y_txt,"y: %d",y); + sprintf(z_txt,"z: %d",z); + sprintf(status_txt,"status: %c",(*(d3_l->status+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)&AMORPH)?'a':'c'); + sprintf(conc_txt,"conc: %d",*(d3_l->extra+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)); + sprintf(steps_txt,"step: %d",i); + sprintf(cc_txt,"total c: %d",cc); + arg_v[1]=x_txt; + arg_v[2]=y_txt; + arg_v[3]=z_txt; + arg_v[4]=NULL; + arg_v[5]=status_txt; + arg_v[6]=conc_txt; + arg_v[7]=NULL; + arg_v[8]=NULL; + arg_v[9]=steps_txt; + arg_v[10]=cc_txt; + d3_lattice_draw(&d3_l,x,y,z,10,arg_v); + scan_event(&d3_l,&x,&y,&z,&quit,&escape); + } + ++i; + } + } + + while((quit==0) && (escape==0) && (nowait==0)) + { + sprintf(x_txt,"x: %d",x); + sprintf(y_txt,"y: %d",y); + sprintf(z_txt,"z: %d",z); + sprintf(status_txt,"status: %c",(*(d3_l->status+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)&AMORPH)?'a':'c'); + sprintf(conc_txt,"conc: %d",*(d3_l->extra+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)); + strcpy(steps_txt,"step: end!"); + sprintf(cc_txt,"total c: %d",cc); + arg_v[1]=x_txt; + arg_v[2]=y_txt; + arg_v[3]=z_txt; + arg_v[4]=NULL; + arg_v[5]=status_txt; + arg_v[6]=conc_txt; + arg_v[7]=NULL; + arg_v[8]=NULL; + arg_v[9]=steps_txt; + arg_v[10]=cc_txt; + d3_lattice_draw(&d3_l,x,y,z,10,arg_v); + scan_event(&d3_l,&x,&y,&z,&quit,&escape); + } return 1; }