From: hackbard Date: Tue, 1 Apr 2003 14:10:43 +0000 (+0000) Subject: - X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=9cf539e8c623ad62dd894a0a3442a4c1b620a0b8;p=physik%2Fmorpheus.git - --- diff --git a/defines.h b/defines.h index 17e83cf..7e9b07d 100644 --- a/defines.h +++ b/defines.h @@ -18,8 +18,9 @@ #define DEFAULT_SLOPE_NEL 1 #define DEFAULT_START_NEL 0 -#define DEFAULT_A_P_RANGE 0.2 +#define DEFAULT_A_P_RANGE 3 #define DEFAULT_A_P_FAKTOR 0.2 +#define DEFAULT_A_P_P0 0.2 #define DEFAULT_STEPS 5000 diff --git a/display.c b/display.c index 809b556..6b97057 100644 --- a/display.c +++ b/display.c @@ -8,7 +8,7 @@ #include "defines.h" -int display_init(int x,int y,int z,display *display,void *cell,int *argc,char **argv) +int display_init(u32 x,u32 y,u32 z,display *display,void *cell,int *argc,char **argv) { #ifdef USE_DFB_API DFBSurfaceDescription surface_dsc; @@ -177,11 +177,11 @@ int display_scan_event(display *display,u32 *x,u32 *y,u32 *z,int *quit) if(keyboard_event.type==DIET_KEYPRESS) { if(keyboard_event.key_id==DIKI_LEFT && *x!=0) *x-=1; - if(keyboard_event.key_id==DIKI_RIGHT && *x!=(display->max_x)-1) *x+=1; + if(keyboard_event.key_id==DIKI_RIGHT && *x!=display->max_x-1) *x+=1; if(keyboard_event.key_id==DIKI_DOWN && *y!=0) *y-=1; - if(keyboard_event.key_id==DIKI_UP && *y!=(display->max_y)-1) *y+=1; + if(keyboard_event.key_id==DIKI_UP && *y!=display->max_y-1) *y+=1; if(keyboard_event.key_id==DIKI_PAGE_UP && *z!=0) *z-=1; - if(keyboard_event.key_id==DIKI_PAGE_DOWN && *z!=(display->max_z)-1) *z+=1; + if(keyboard_event.key_id==DIKI_PAGE_DOWN && *z!=display->max_z-1) *z+=1; if(keyboard_event.key_id==DIKI_Q) *quit=1; } return 23; diff --git a/main.c b/main.c index 9438a32..7159a7b 100644 --- a/main.c +++ b/main.c @@ -27,26 +27,25 @@ /* global variables */ u32 sum_z_cells; -u32 sum_range_rate; int random_fd; /* /dev/urandom file descriptor */ int usage() { puts("usage:"); puts("-h: help"); - puts("-a \t slope of nuclear energy loss (default 1)"); - puts("-c \t nuclear enery loss at depths 0 (default 0)"); - puts("-x \t # x cells (default 50)"); - puts("-y \t # y cells (default 50)"); - puts("-z \t # z cells (default 100)"); - puts("-s \t # steps to calculate (default 5000)"); + printf("-a \t slope of nuclear energy loss (default %d)\n",DEFAULT_SLOPE_NEL); + printf("-c \t nuclear enery loss at depths 0 (default %d)\n",DEFAULT_START_NEL); + printf("-x \t # x cells (default %d)\n",DEFAULT_X_SEG); + printf("-y \t # y cells (default %d)\n",DEFAULT_Y_SEG); + printf("-z \t # z cells (default %d)\n",DEFAULT_Z_SEG); + printf("-s \t # steps to calculate (default %d)\n",DEFAULT_STEPS); puts("-X \t display area intercept point x (default # x celss / 2)"); puts("-Y \t display area intercept point y (default # y cells / 2)"); puts("-Z \t display area intercept point z (default # z cells / 2)"); - puts("-d \t refresh every loops (default 100)"); - puts("-r \t pressure range from amorphous SiCx (default 2)"); - puts("-f \t faktor for pressure from amorphous SiCx (default 0.2)"); - puts("-p \t p0 for probability of cell getting amorph (default 0.2)"); + printf("-d \t refresh every loops (default %d)\n",DEFAULT_DISPLAY_REF_RATE); + printf("-r \t pressure range from amorphous SiCx (default %d)\n",DEFAULT_A_P_RANGE); + printf("-f \t faktor for pressure from amorphous SiCx (default %f)\n",DEFAULT_A_P_FAKTOR); + printf("-p \t p0 for probability of cell getting amorph (default %f)\n",DEFAULT_A_P_P0); return -23; } @@ -63,14 +62,13 @@ int make_cryst(u32 *cell) } /* look at cell ... */ -int process_cell(void *cell_p,u32 x,u32 y,u32 z,u32 x_max,u32 y_max,u32 z_max,int range,int faktor,int p0) +int process_cell(void *cell_p,u32 x,u32 y,u32 z,u32 x_max,u32 y_max,u32 z_max,int range,double faktor,double p0) { u32 *cell; - int i,j,k,count; + int i,j,k; double pressure; - // float count; cell=(u32 *)(cell_p+x+y*(x_max-1)+z*(x_max-1)*(y_max-1)); - count=p0; + pressure=p0*URAND_2BYTE_MAX; for(i=-range;i<=range;i++) { for(j=-range;j<=range;j++) @@ -80,19 +78,17 @@ int process_cell(void *cell_p,u32 x,u32 y,u32 z,u32 x_max,u32 y_max,u32 z_max,in if(!(i==0 && j==0 && k==0)) { if(*(u32 *)(cell_p+((x+x_max+i)%x_max)+((y+j+y_max)%y_max)*(x_max-1)+((z+k+z_max)%z_max)*(x_max-1)*(y_max-1))&AMORPH) pressure+=faktor*URAND_2BYTE_MAX/(i*i+j*j+k*k); - // count+=(3*range*range-i*i-j*j-k*k); } } } } - // count+=faktor*1.0/(i*i+j*j+k*k); if(*cell&AMORPH) { /* wrong probability! just test by now ...*/ - if(rand_get(sum_range_rate)>count) make_cryst(cell); + if(rand_get(URAND_2BYTE_MAX)>pressure) make_cryst(cell); } else { - if(rand_get(sum_range_rate)<=count) make_amorph(cell); + if(rand_get(URAND_2BYTE_MAX)<=pressure) make_amorph(cell); } return 23; } @@ -120,7 +116,7 @@ int main(int argc,char **argv) start_nel=DEFAULT_START_NEL; a_p_range=DEFAULT_A_P_RANGE; a_p_faktor=DEFAULT_A_P_FAKTOR; - a_p_p0=NOT_SPECIFIED; + a_p_p0=DEFAULT_A_P_P0; steps=DEFAULT_STEPS; display_x=x_cell/2; display_y=y_cell/2; @@ -191,27 +187,10 @@ int main(int argc,char **argv) return -23; } - /* calculate sum_z_cells, sum_range_rate one time! */ + /* calculate sum_z_cells one time! */ sum_z_cells=0; for(i=1;i<=z_cell;i++) sum_z_cells+=(start_nel+i*slope_nel); printfd("debug: sum z cells -> %u\n",sum_z_cells); - // sum_range_rate=0; - // for(i=-a_p_range;i<=a_p_range;i++) - // { - // for(j=-a_p_range;j<=a_p_range;j++) - // { - // for(k=-a_p_range;k<=a_p_range;k++) - // { - // if(!(i==0 && j==0 && k==0)) - // sum_range_rate+=((3*a_p_range*a_p_range)-i*i-j*j-k*k); - // } - // } - // } - // printfd("debug: sum range rate -> %u\n",sum_range_rate); - // /* add a_p_p0 ... */ - // if(a_p_p0==NOT_SPECIFIED) a_p_p0=sum_range_rate/4; - // sum_range_rate+=a_p_p0; - /* testing ... */ @@ -249,6 +228,13 @@ int main(int argc,char **argv) display_draw(&display,display_x,display_y,display_z); display_event_init(&display); + /* debug ... */ + for(i=0;i 0x%x\n",i,*(u32 *)(cell_p+i)); + } + while(!quit) { display_scan_event(&display,&display_x,&display_y,&display_z,&quit);