+ if((!strcmp(l_file,""))||(c_step))
+ {
+ if(get_c_ratio(&c_ratio,p_file,&my_info,&d3_l)!=1)
+ {
+ puts("failed calculating ratio");
+ return -1;
+ }
+ i=(c_step?c_step:0);
+ while((i<my_info.steps) && (quit==0) && (escape==0))
+ {
+ x_c=get_rand(d3_l.max_x);
+ y_c=get_rand(d3_l.max_y);
+ z_c=get_rand_lgp(d3_l.max_z,my_info.a_el,my_info.b_el);
+ distrib_c(&d3_l,&my_info,i,c_ratio);
+ process_cell(&d3_l,x_c,y_c,z_c,&my_info);
+#ifdef USE_DFB_API
+ if(i%refresh==0)
+ {
+ sprintf(xyz_txt,"x: %d y: %d z: %d",x+1,y+1,z+1);
+ 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 a_count: %d",i,amorph_count);
+ sprintf(cc_txt,"total c: %d c_count: %d",my_info.cc,cryst_count);
+ d3_lattice_draw(&d3_l,x,y,z,25,arg_v,mode,0);
+ }
+#endif
+ if(i%resave==0 && strcmp(s_file,"") && resave!=0 && i!=0)
+ {
+ sprintf(s_file_tmp,"%s_%d_of_%d",s_file,i,my_info.steps);
+ save_to_file(s_file_tmp,&d3_l,&my_info);
+#ifdef NODFB
+ printf("saved %s\n",s_file_tmp);
+#endif
+ }
+ i++;
+ }
+ }
+
+ if(strcmp(s_file,""))
+ {
+ printf("saved %s\n",s_file);
+ save_to_file(s_file,&d3_l,&my_info);
+ }
+
+#ifdef USE_DFB_API
+ /* allocating buffer for pressure values */
+ if((d3_l.v_ptr=malloc(d3_l.max_x*d3_l.max_y*d3_l.max_z*sizeof(unsigned char)))==NULL)
+ {
+ puts("cannot allocate buffer for pressure values");
+ return -1;
+ }
+ /* calc values */
+ calc_pressure(&d3_l,my_info.range);
+ max_extra=calc_max_extra(&d3_l);
+
+ while((quit==0) && (escape==0) && (nowait==0))
+ {
+ /* bahh! */
+ if(switchmode==0) mode=0;
+ if(switchmode==1) mode=1;
+ if(switchmode==2) mode=2;
+ /* end of bahh! */
+ sprintf(xyz_txt,"x: %d y: %d z: %d",x+1,y+1,z+1);
+ 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: end");
+ sprintf(cc_txt,"total c: %d",my_info.cc);
+ if(switchmode==0) strcpy(mode_txt,"view: a/c mode");
+ if(switchmode==1) strcpy(mode_txt,"view: c conc mode");
+ if(switchmode==2) strcpy(mode_txt,"view: a pressure mode");
+ d3_lattice_draw(&d3_l,x,y,z,25,arg_v,mode,max_extra);
+ bmp=0;
+ scan_event(&d3_l,&x,&y,&z,&quit,&escape,&switchmode,&bmp);
+ if(bmp) write_bmp(&d3_l,bmp,x,y,z);
+
+ }