#define DEFAULT_SLOPE_NEL 1
#define DEFAULT_START_NEL 0
-#define DEFAULT_A_P_RANGE 2
-#define DEFAULT_A_P_FAKTOR 1
+#define DEFAULT_A_P_RANGE 0.2
+#define DEFAULT_A_P_FAKTOR 0.2
#define DEFAULT_STEPS 5000
IDirectFB *dfb; /* pointer to dfb main construct */
IDirectFBSurface *primary_surface; /* pointer to dfb primary surface */
IDirectFBFont *font; /* the font */
+ IDirectFBInputDevice *keyboard; /* for keyboard input */
+ IDirectFBEventBuffer *keyboard_buffer; /* event buffer */
#endif
int screen_height,screen_width; /* screen dimensions */
} display;
int display_release(display *display)
{
#ifdef USE_DFB_API
+ display->font->Release(display->font);
display->primary_surface->Release(display->primary_surface);
display->dfb->Release(display->dfb);
#endif
}
#endif
-int display_draw(display *display,int x,int y,int z)
+int display_draw(display *display,u32 x,u32 y,u32 z)
{
#ifdef USE_DFB_API
int menu_x,menu_y,menu_w,menu_h; /* for the yellow box */
- int x_c,y_c,z_c;
+ DFBFontDescription font_dsc;
+ char text[MAX_TXT];
+ u32 x_c,y_c,z_c;
unsigned char r,g,b,a;
int display_faktor_x,display_faktor_y;
a=0xff; /* no alpha blending */
display->primary_surface->FillRectangle(display->primary_surface,menu_x,menu_y,menu_w,menu_h);
display->primary_surface->SetColor(display->primary_surface,r,g,b,a);
display->primary_surface->DrawRectangle(display->primary_surface,menu_x,menu_y,menu_w,menu_h);
+ font_dsc.flags=DFDESC_HEIGHT;
+ font_dsc.height=menu_h/10;
+ display->dfb->CreateFont(display->dfb,DISPLAY_FONT,&font_dsc,&(display->font));
+ display->primary_surface->SetFont(display->primary_surface,display->font);
+ display->primary_surface->SetColor(display->primary_surface,0x80,0x80,0xff,0xff);
+ sprintf(text,"x: %u",x);
+ display->primary_surface->DrawString(display->primary_surface,text,-1,menu_x+display_faktor_x,menu_y+display_faktor_y+menu_h/10,DSTF_LEFT);
+ sprintf(text,"y: %u",y);
+ display->primary_surface->DrawString(display->primary_surface,text,-1,menu_x+display_faktor_x,menu_y+display_faktor_y*2+menu_h/10*2,DSTF_LEFT);
+ sprintf(text,"z: %u",z);
+ display->primary_surface->DrawString(display->primary_surface,text,-1,menu_x+display_faktor_x,menu_y+display_faktor_y*3+menu_h/10*3,DSTF_LEFT);
+ sprintf(text,"status: %c",*(u32 *)(display->cell_p+x+y*(display->max_x-1)+z*(display->max_x-1)*(display->max_y-1))&AMORPH?'a':'c');
+ display->primary_surface->DrawString(display->primary_surface,text,-1,menu_x+display_faktor_x,menu_y+display_faktor_y*5+menu_h/10*5,DSTF_LEFT);
+ sprintf(text,"C conc.: %u",(*(u32 *)(display->cell_p+x+y*(display->max_x-1)+z*(display->max_x-1)*(display->max_y-1))&C_CONC_MASK)>>1);
+ display->primary_surface->DrawString(display->primary_surface,text,-1,menu_x+display_faktor_x,menu_y+display_faktor_y*6+menu_h/10*6,DSTF_LEFT);
/* flip all to surface */
display->primary_surface->Flip(display->primary_surface,NULL,0);
#endif
return 23;
}
+
+int display_event_init(display *display)
+{
+#ifdef USE_DFB_API
+ display->dfb->GetInputDevice(display->dfb,DIDID_KEYBOARD,&(display->keyboard));
+ display->keyboard->CreateEventBuffer(display->keyboard,&(display->keyboard_buffer));
+#endif
+ return 23;
+}
+
+int display_scan_event(display *display,u32 *x,u32 *y,u32 *z,int *quit)
+{
+ DFBInputEvent keyboard_event;
+ display->keyboard_buffer->GetEvent(display->keyboard_buffer,DFB_EVENT(&keyboard_event));
+ 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_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_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_Q) *quit=1;
+ }
+ return 23;
+}
int dfb_choose_color(u32 *cell_p,unsigned char *r,unsigned char *g,unsigned char
*b);
int display_draw(display *display,int x,int y,int z);
+int display_event_init(display *display);
+int display_scan_event(display *display,u32 *x,u32 *y,u32 *z,int *quit);
puts("-Z <value> \t display area intercept point z (default # z cells / 2)");
puts("-d <value> \t refresh every <value> loops (default 100)");
puts("-r <value> \t pressure range from amorphous SiCx (default 2)");
- puts("-f <value> \t (unused) faktor for pressure from amorphous SiCx (default 1)");
- puts("-p <value> \t p0 for probability of cell getting amorph (default sum_range_rate / 4)");
+ puts("-f <value> \t faktor for pressure from amorphous SiCx (default 0.2)");
+ puts("-p <value> \t p0 for probability of cell getting amorph (default 0.2)");
return -23;
}
{
u32 *cell;
int i,j,k,count;
+ double pressure;
// float count;
cell=(u32 *)(cell_p+x+y*(x_max-1)+z*(x_max-1)*(y_max-1));
count=p0;
{
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) count+=(3*range*range-i*i-j*j-k*k);
+ 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);
}
}
}
{
u32 x_cell,y_cell,z_cell; /* amount of segments */
u32 x,y,z; /* cells */
- int i,j,k; /* for counting */
+ int i; /* for counting */
int slope_nel,start_nel; /* nuclear energy loss: slope, constant */
- int a_p_range,a_p_faktor,a_p_p0; /* p. range, p0 and faktor of amorphous sic */
+ int a_p_range; /* p. range of amorphous sic */
+ double a_p_faktor,a_p_p0; /* p0 and faktor of amorphous sic */
int steps; /* # steps */
void *cell_p;
struct __display display;
u32 display_x,display_y,display_z; /* intercept point of diplayed areas */
u32 display_refresh_rate; /* refresh rate for display */
+ int quit=0; /* continue/quit status */
/* default values */
x_cell=DEFAULT_X_SEG;
a_p_range=atoi(argv[++i]);
break;
case 'f':
- a_p_faktor=atoi(argv[++i]);
+ a_p_faktor=atof(argv[++i]);
break;
case 'p':
- a_p_p0=atoi(argv[++i]);
+ a_p_p0=atof(argv[++i]);
break;
default:
usage();
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;
+ // 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 ... */
process_cell(cell_p,x,y,z,x_cell,y_cell,z_cell,a_p_range,a_p_faktor,a_p_p0);
/* display stuff */
- if((i%display_refresh_rate)==0)
+ if((i%display_refresh_rate)==0)
display_draw(&display,display_x,display_y,display_z);
}
- /* display again and quit when button hit */
+ /* display again and listen for events */
display_draw(&display,display_x,display_y,display_z);
- puts("hit button to quit ...");
- getchar();
+ display_event_init(&display);
+
+ while(!quit)
+ {
+ display_scan_event(&display,&display_x,&display_y,&display_z,&quit);
+ display_draw(&display,display_x,display_y,display_z);
+ }
display_release(&display);