X-Git-Url: https://hackdaworld.org/gitweb/?p=physik%2Fmorpheus.git;a=blobdiff_plain;f=main.c;h=6916f226ecaad42df4cbba74ebf897a0c9a6a75d;hp=2e9cc0c46f0f06189e32fd4719a5de44af903a40;hb=6ee2d4c247b82dc4aea6e9e5e6aecd7d857aaafd;hpb=4dc55f36080bc8cc78c07efe25bf3f222c3d0a9a diff --git a/main.c b/main.c index 2e9cc0c..6916f22 100644 --- a/main.c +++ b/main.c @@ -26,6 +26,7 @@ #include "display.h" /* global variables */ +u32 *rand_buf,*rand_current; u32 gr; int random_fd; /* /dev/urandom file descriptor */ @@ -65,10 +66,8 @@ int make_cryst(cell *cell) 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) { - /* cryst. c to distribute */ - int i,j; - u32 area,c_area,total; + u32 area,c_area,total,count; u32 x,y,z,sum_c_z; total=0; @@ -77,17 +76,22 @@ int distrib_c_conc(cell *cell_p,int c_c0,int c_slope,u32 c_conc,u32 x_max,u32 y_ for(i=0;istatus&AMORPH) count++; + } + for(j=0;jstatus&AMORPH) { - (cell_p+j+i*area)->conc=c_area/area; - total+=c_area/area; + (cell_p+j+i*area)->conc=c_area/count; + total+=c_area/count; } } j=0; - while(jconc; if(this_cell->status&AMORPH) { /* wrong probability! just test by now ...*/ @@ -271,11 +278,20 @@ int main(int argc,char **argv) for(i=1;i<=z_cell;i++) gr+=i; printfd("debug: gr = %d\n",gr); + /* allocate random number buffer */ + printf("malloc will free %d bytes now ...\n",RAND_BUF_SIZE); + if((rand_buf=(u32 *)malloc(RAND_BUF_SIZE))==NULL) + { + puts("failed allocating memory for random numbers"); + return -23; + } + rand_current=rand_buf+RAND_BUF_SIZE; + /* allocate cells */ printf("malloc will free %d bytes now ...\n",x_cell*y_cell*z_cell*sizeof(cell)); if((cell_p=(cell *)malloc(x_cell*y_cell*z_cell*sizeof(cell)))==NULL) { - puts("failed allocating memory for cells\n"); + puts("failed allocating memory for cells"); return -23; } memset(cell_p,0,x_cell*y_cell*z_cell*sizeof(cell)); @@ -291,9 +307,10 @@ int main(int argc,char **argv) x=rand_get(x_cell); y=rand_get(y_cell); z=rand_get_lgp(slope_nel,start_nel,z_cell); + printfd("x = %u, y = %u, z = %u\n",x,y,z); /* todo */ - // distrib_c_conc(cell_p,c_dist_c0,c_dist_slope,c_conc,x_cell,y_cell,z_cell); + distrib_c_conc(cell_p,c_dist_c0,c_dist_slope,c_conc,x_cell,y_cell,z_cell); // process_cell(cell_p+x+y*x_cell+z*x_cell*y_cell); process_cell(cell_p,x,y,z,x_cell,y_cell,z_cell,a_p_range,a_p_faktor,a_p_p0,&c_conc);