+ cell->status&=~AMORPH;
+ return 23;
+}
+
+int distrib_c_conc(cell *cell_p,int c_c0,int c_slope,u32 c_conc,u32 x_max,u32 y_max,u32 z_max)
+{
+ int i,j;
+ u32 area,c_area,total,count;
+ u32 x,y,z,sum_c_z;
+
+ total=0;
+ area=x_max*y_max;
+ sum_c_z=c_c0*z_max+c_slope*gr;
+
+ for(i=0;i<z_max;i++)
+ {
+ count=0;
+ c_area=(c_conc*(c_c0+(i+1)*c_slope))/sum_c_z;
+ for(j=0;j<area;j++)
+ {
+ if(!(cell_p+j+i*area)->status&AMORPH) count++;
+ }
+ for(j=0;j<area;j++)
+ {
+ if(!(cell_p+j+i*area)->status&AMORPH)
+ {
+ (cell_p+j+i*area)->conc=c_area/count;
+ total+=c_area/count;
+ }
+ }
+ j=0;
+ while(j<c_area%count)
+ {
+ x=rand_get(x_max);
+ y=rand_get(y_max);
+ if(!(cell_p+x+y*x_max+i*area)->status&AMORPH)
+ {
+ (cell_p+x+y*x_max+i*area)->conc+=1;
+ total++;
+ j++;
+ }
+ }
+ }
+ i=0;
+ while(i<c_conc-total)
+ {
+ x=rand_get(x_max);
+ y=rand_get(y_max);
+ z=rand_get_lgp(c_slope,c_c0,z_max);
+ if(!(cell_p+x+y*x_max+z*area)->status&AMORPH)
+ {
+ (cell_p+x+y*x_max+z*area)->conc+=1;
+ i++;
+ }
+ }
+ return 23;
+}
+
+/* look at cell ... */
+int process_cell(cell *cell_p,u32 x,u32 y,u32 z,u32 x_max,u32 y_max,u32 z_max,int range,double faktor,double p0,u32 *c_conc)
+{
+ cell *this_cell;
+ int i,j,k;
+ double pressure;
+
+ this_cell=cell_p+x+y*x_max+z*x_max*y_max;
+ pressure=p0*URAND_2BYTE_MAX;
+
+ for(i=-range;i<=range;i++)
+ {
+ for(j=-range;j<=range;j++)
+ {
+ for(k=-range;k<=range;k++)
+ {
+ if(!(i==0 && j==0 && k==0))
+ {
+ // if((cell_p+((x+x_max+i)%x_max)+((y+j+y_max)%y_max)*x_max+((z+k+z_max)%z_max)*x_max*y_max)->status&AMORPH) pressure+=(cell_p+((x+x_max+i)%x_max)+((y+j+y_max)%y_max)*x_max+((z+k+z_max)%z_max)*x_max*y_max)->conc*faktor*URAND_2BYTE_MAX/(i*i+j*j+k*k);
+ if((cell_p+((x+x_max+i)%x_max)+((y+j+y_max)%y_max)*x_max+((z+k+z_max)%z_max)*x_max*y_max)->status&AMORPH) pressure+=faktor*URAND_2BYTE_MAX/(i*i+j*j+k*k);
+ }
+ }
+ }
+ }
+ pressure*=this_cell->conc;
+ if(this_cell->status&AMORPH)
+ {
+ /* wrong probability! just test by now ...*/
+ if(rand_get(URAND_2BYTE_MAX)>pressure)
+ {
+ make_cryst(this_cell);
+ *c_conc=*c_conc+1+this_cell->conc;
+ } else *c_conc+=1;
+ } else
+ {
+ if(rand_get(URAND_2BYTE_MAX)<=pressure)
+ {
+ make_amorph(this_cell);
+ *c_conc=*c_conc+1-this_cell->conc;
+ } else *c_conc+=1;
+ }