d3_l->p_surface->SetColor(d3_l->p_surface,0x80,0x80,0xff,0xff);
for(i=1;i<=arg_c;i++)
{
- if(i<8)
+ if(i<13)
{
d3_l->p_surface->DrawString(d3_l->p_surface,arg_v[i],-1,
d3_l->info_x+d3_l->fakt_x,
- d3_l->info_y+d3_l->fakt_y+d3_l->font_h+(i-1)*2*d3_l->font_h,
+ d3_l->info_y+2*d3_l->fakt_y+d3_l->font_h+(i-1)*d3_l->font_h,
DSTF_LEFT);
} else
{
d3_l->p_surface->DrawString(d3_l->p_surface,arg_v[i],-1,
d3_l->info_x+d3_l->info_w/2+d3_l->fakt_x,
- d3_l->info_y+d3_l->fakt_y+d3_l->font_h+(i%8-1)*2*d3_l->font_h,
+ d3_l->info_y+2*d3_l->fakt_y+d3_l->font_h+(i%13-1)*d3_l->font_h,
DSTF_LEFT);
}
}
{
DFBInputEvent ke;
+ d3_l->k_buffer->WaitForEvent(d3_l->k_buffer);
d3_l->k_buffer->GetEvent(d3_l->k_buffer,DFB_EVENT(&ke));
if(ke.type==DIET_KEYPRESS)
{
if(ke.key_id==DIKI_LEFT && *x!=0) *x-=1;
if(ke.key_id==DIKI_RIGHT && *x!=d3_l->max_x-1) *x+=1;
- if(ke.key_id==DIKI_DOWN && *y!=0) *y-=1;
- if(ke.key_id==DIKI_UP && *y!=d3_l->max_y-1) *y+=1;
- if(ke.key_id==DIKI_PAGE_DOWN && *z!=0) *z-=1;
- if(ke.key_id==DIKI_PAGE_UP && *z!=d3_l->max_z-1) *z+=1;
+ if(ke.key_id==DIKI_UP && *y!=0) *y-=1;
+ if(ke.key_id==DIKI_DOWN && *y!=d3_l->max_y-1) *y+=1;
+ if(ke.key_id==DIKI_PAGE_UP && *z!=0) *z-=1;
+ if(ke.key_id==DIKI_PAGE_DOWN && *z!=d3_l->max_z-1) *z+=1;
if(ke.key_id==DIKI_Q) *q=1;
if(ke.key_id==DIKI_ESCAPE) *esc=1;
}
}
}
}
- // p*=*conc;
- // printf("debug: p * conc = %f\n",p);
if(!(*thiz&AMORPH))
{
if(get_rand(URAND_MAX)<=p)
{
MAKE_AMORPH(thiz);
- printf("debug: c->a %d - %d\n",*t_c,*conc);
*t_c=*t_c+1-*conc;
} else *t_c+=1;
} else
if(get_rand(URAND_MAX)>p)
{
MAKE_CRYST(thiz);
- printf("debug: a->c %d - %d\n",*t_c,*conc);
*t_c=*t_c+1+*conc;
} else *t_c+=1;
}
}
}
temp=(int)((i+1)*a+b)*t_c/(sum*area_h[i]);
- // if(temp)
- // {
- for(j=0;j<area;j++)
+ for(j=0;j<area;j++)
+ {
+ if(!(*(d3_l->status+(i*area)+j)&AMORPH))
{
- if(!(*(d3_l->status+(i*area)+j)&AMORPH))
- {
- *(d3_l->extra+(i*area)+j)=temp;
- total+=temp;
- }
+ *(d3_l->extra+(i*area)+j)=temp;
+ total+=temp;
}
- // }
+ }
left=(int)(((i+1)*a+b)*t_c/sum)%area_h[i];
while(left)
{
return 1;
}
-int save_to_file(char *sf,d3_lattice *d3_l)
+int save_to_file(char *sf,d3_lattice *d3_l,info *my_inf)
{
int sf_fd,c;
puts("failed saving d3 lattice struct");
return -1;
}
+ if(write(sf_fd,my_inf,sizeof(info))<sizeof(info))
+ {
+ puts("failed saving info struct");
+ return-1;
+ }
c=d3_l->max_x*d3_l->max_y*d3_l->max_z;
if(write(sf_fd,d3_l->status,c*sizeof(unsigned char))<c*sizeof(unsigned char))
{
return 1;
}
-int load_from_file(char *lf,d3_lattice *d3_l)
+int load_from_file(char *lf,d3_lattice *d3_l,info *my_inf)
{
int lf_fd,c;
puts("failed reading d3 lattice struct");
return -1;
}
+ if(read(lf_fd,my_inf,sizeof(info))<sizeof(info))
+ {
+ puts("failed reading info struct");
+ return-1;
+ }
c=d3_l->max_x*d3_l->max_y*d3_l->max_z;
if((d3_l->status=(unsigned char*)malloc(c*sizeof(unsigned char)))==NULL)
{
{
u32 max_x,max_y,max_z,x,y,z,x_c,y_c,z_c;
int i,quit,escape,nowait;
- double a_el,b_el,a_cd,b_cd,a_ap,b_ap;
- int cc,steps,range,refresh;
+ int refresh;
char s_file[MAX_CHARS];
char l_file[MAX_CHARS];
char r_file[MAX_CHARS];
char conc_txt[MAX_TXT];
char steps_txt[MAX_TXT];
char cc_txt[MAX_TXT];
+ char a_txt[MAX_TXT];
+ char s_txt[MAX_TXT];
+ char ap_txt[MAX_TXT];
+ char el_txt[MAX_TXT];
+ char cd_txt[MAX_TXT];
+ char r_txt[MAX_TXT];
+ char ap2_txt[MAX_TXT];
+ char cd2_txt[MAX_TXT];
+ char el2_txt[MAX_TXT];
char *arg_v[MAX_ARGV];
d3_lattice d3_l;
+ info my_info;
max_x=X;
max_y=Y;
max_z=Z;
- steps=STEPS;
- range=RANGE;
+ my_info.steps=STEPS;
+ my_info.range=RANGE;
refresh=REFRESH;
- a_el=A_EL;
- b_el=B_EL;
- a_cd=A_CD;
- b_cd=B_CD;
- a_ap=A_AP;
- b_ap=B_AP;
- cc=CC;
+ my_info.a_el=A_EL;
+ my_info.b_el=B_EL;
+ my_info.a_cd=A_CD;
+ my_info.b_cd=B_CD;
+ my_info.a_ap=A_AP;
+ my_info.b_ap=B_AP;
+ my_info.cc=CC;
nowait=0;
quit=0;
escape=0;
nowait=1;
break;
case 'a':
- a_el=atof(argv[++i]);
+ my_info.a_el=atof(argv[++i]);
break;
case 'b':
- b_el=atof(argv[++i]);
+ my_info.b_el=atof(argv[++i]);
break;
case 'x':
max_x=atoi(argv[++i]);
break;
*/
case 's':
- steps=atoi(argv[++i]);
+ my_info.steps=atoi(argv[++i]);
break;
case 'd':
refresh=atoi(argv[++i]);
break;
case 'r':
- range=atoi(argv[++i]);
+ my_info.range=atoi(argv[++i]);
break;
case 'f':
- a_ap=atof(argv[++i]);
+ my_info.a_ap=atof(argv[++i]);
break;
case 'p':
- b_ap=atof(argv[++i]);
+ my_info.b_ap=atof(argv[++i]);
break;
case 'A':
- a_cd=atof(argv[++i]);
+ my_info.a_cd=atof(argv[++i]);
break;
case 'B':
- b_cd=atof(argv[++i]);
+ my_info.b_cd=atof(argv[++i]);
break;
case 'C':
- cc=atoi(argv[++i]);
+ my_info.cc=atoi(argv[++i]);
break;
case 'L':
strcpy(l_file,argv[++i]);
y=max_y/2-1;
z=max_z/2-1;
+
+
if(!strcmp(r_file,"")) rand_init(NULL);
else rand_init(r_file);
memset(d3_l.extra,0,i*sizeof(int));
} else
{
- load_from_file(l_file,&d3_l);
+ load_from_file(l_file,&d3_l,&my_info);
d3_lattice_init(&argc,argv,&d3_l,d3_l.max_x,d3_l.max_y,d3_l.max_z);
}
d3_event_init(&d3_l);
+ strcpy(a_txt,"args:");
+ sprintf(s_txt,"steps: %d",my_info.steps);
+ sprintf(r_txt,"pressure range: %d",my_info.range);
+ sprintf(ap_txt,"p faktor: %.2f",my_info.a_ap);
+ sprintf(ap2_txt,"p offset: %.2f",my_info.b_ap);
+ sprintf(el_txt,"e loss slope: %.2f",my_info.a_el);
+ sprintf(el2_txt,"e loss offset: %.2f",my_info.b_el);
+ sprintf(cd_txt,"c distrib slope: %.2f",my_info.a_cd);
+ sprintf(cd2_txt,"c distrib offset: %.2f",my_info.b_cd);
+ 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]=NULL;
+ arg_v[10]=steps_txt;;
+ arg_v[11]=cc_txt;
+ arg_v[12]=NULL;
+ arg_v[13]=NULL;
+ arg_v[14]=a_txt;
+ arg_v[15]=NULL;
+ arg_v[16]=s_txt;
+ arg_v[17]=r_txt;
+ arg_v[18]=ap_txt;
+ arg_v[19]=ap2_txt;
+ arg_v[20]=el_txt;
+ arg_v[21]=el2_txt;
+ arg_v[22]=cd_txt;
+ arg_v[23]=cd2_txt;
+
if(!strcmp(l_file,""))
{
i=0;
- while((i<steps) && (quit==0) && (escape==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,a_el,b_el);
- distrib_c(&d3_l,cc,a_cd,b_cd);
- process_cell(&d3_l,x_c,y_c,z_c,range,a_ap,b_ap,&cc);
+ z_c=get_rand_lgp(d3_l.max_z,my_info.a_el,my_info.b_el);
+ distrib_c(&d3_l,my_info.cc,my_info.a_cd,my_info.b_cd);
+ process_cell(&d3_l,x_c,y_c,z_c,my_info.range,my_info.a_ap,my_info.b_ap,&(my_info.cc));
if(i%refresh==0)
{
sprintf(x_txt,"x: %d",x+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",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);
+ sprintf(cc_txt,"total c: %d",my_info.cc);
+ d3_lattice_draw(&d3_l,x,y,z,23,arg_v);
// scan_event(&d3_l,&x,&y,&z,&quit,&escape);
}
i++;
}
}
- if(strcmp(s_file,"")) save_to_file(s_file,&d3_l);
+ if(strcmp(s_file,"")) save_to_file(s_file,&d3_l,&my_info);
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(x_txt,"x: %d",x+1);
+ sprintf(y_txt,"y: %d",y+1);
+ sprintf(z_txt,"z: %d",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));
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);
+ sprintf(cc_txt,"total c: %d",my_info.cc);
+ d3_lattice_draw(&d3_l,x,y,z,23,arg_v);
scan_event(&d3_l,&x,&y,&z,&quit,&escape);
}