*
*/
+#ifdef USE_DFB_API
+#include <directfb.h>
+#endif
+
#define DEFAULT_X_SEG 50
#define DEFAULT_Y_SEG 50
#define DEFAULT_Z_SEG 100
/* program defines, dont touch ;) */
-#ifdef DEBUG
- #define DEBUG 1
-#else
- #define DEBUG 0
-#endif
-
#define URAND_MAX 0xffffffff
typedef unsigned int u32;
typedef long long unsigned int u64;
-#define printfd(fmt,args...) if(DEBUG) printf(fmt,##args);
+#ifdef DEBUG
+ #define DEBUG_IT 1
+#else
+ #define DEBUG_IT 0
+#endif
+
+#define printfd(fmt,args...) if(DEBUG_IT) printf(fmt,##args);
-/* segment struct
- *
- * not used by now
- */
-struct __segment
-{
- u32 status; /* C concentration */
-}
+/* display stuff */
+typedef struct __display {
+ u32 max_x,max_y,max_z; /* dimensions */
+ u32 *cell_p; /* pointer to cell data */
+#ifdef USE_DFB_API
+ IDirectFB *dfb; /* pointer to dfb main construct */
+ IDirectFBSurface *primary_surface; /* pointer to dfb primary surface */
+#endif
+ int screen_height,screen_width; /* screen dimensions */
+} display;
+
+#define DEFAULT_DISPLAY_X 25
+#define DEFAULT_DISPLAY_Y 25
+#define DEFAULT_DISPLAY_Z 50
+#define DEFAULT_DISPLAY_REF_RATE 100
-/* masks for u32 segments */
+
+/* masks for u32 cell */
#define AMORPH 0x00000001
#define CRYSTAL 0x00000000
#define C_CONC_MASK 0xfffffffe
--- /dev/null
+/*
+ * display.c - visualization api
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "defines.h"
+
+#ifdef USE_DFB_API
+static IDirectFB *dfb=NULL;
+static IDirectFBSurface *primary_surface=NULL;
+static int screen_width=0;
+static int screen_height=0;
+#endif
+
+int display_init(int x,int y,int z,display *display,u32 *cell,int *argc,char **argv)
+{
+#ifdef USE_DFB_API
+ DFBSurfaceDescription surface_dsc;
+ // DFBFontDescription font_dsc;
+#endif
+
+ /* store dimensions */
+ display->max_x=x;
+ display->max_y=y;
+ display->max_z=z;
+ /* store pointer to cells */
+ display->cell_p=cell;
+
+ /* the api(s) */
+#ifdef USE_DFB_API
+ DirectFBInit(argc,&argv);
+ DirectFBCreate(&dfb);
+ dfb->SetCooperativeLevel(dfb,DFSCL_FULLSCREEN);
+ surface_dsc.flags=DSDESC_CAPS;
+ surface_dsc.caps=DSCAPS_PRIMARY|DSCAPS_FLIPPING;
+ dfb->CreateSurface(dfb,&surface_dsc,&primary_surface);
+ primary_surface->GetSize(primary_surface,&screen_width,&screen_height);
+ display->dfb=dfb;
+ display->primary_surface=primary_surface;
+ display->screen_width=screen_width;
+ display->screen_height=screen_height;
+#endif
+ return 23;
+}
+
+int display_draw(u32 *cell,int x,int y,int z)
+{
+#ifdef USE_DFB_API
+
+#endif
+ return 23;
+}
#include "defines.h"
/* global variables */
-u32 sum_z_segments;
+u32 sum_z_cells;
int random_fd; /* /dev/urandom file descriptor */
int usage()
puts("-h: help");
puts("-a <value> \t slope of nuclear energy loss (default 1)");
puts("-c <value> \t nuclear enery loss at depths 0 (default 0)");
- puts("-x <value> \t # x segments (default 50)");
- puts("-y <value> \t # y segments (default 50)");
- puts("-z <value> \t # z segments (default 100)");
- puts("-s <value> \t # steps to calculate (default 5000");
+ puts("-x <value> \t # x cells (default 50)");
+ puts("-y <value> \t # y cells (default 50)");
+ puts("-z <value> \t # z cells (default 100)");
+ puts("-s <value> \t # steps to calculate (default 5000)");
+ puts("-X <value> \t display area intercept point x (default 25)");
+ puts("-Y <value> \t display area intercept point y (default 25)");
+ puts("-Z <value> \t display area intercept point z (default 50)");
+ puts("-d <value> \t refresh every <value> loops (default 100)");
return -23;
}
-int make_amorph(u32 *segment)
+int make_amorph(u32 *cell)
{
- *segment=*segment|AMORPH
+ *cell=*cell|AMORPH;
return 23;
}
-/* look at segment ... */
-int process_segment(u32 *segment)
+int make_cryst(u32 *cell)
+{
+ *cell=*cell&(~AMORPH);
+ return 23;
+}
+
+/* look at cell ... */
+int process_cell(u32 *cell)
{
/* tag it ... testing! */
- make_amorph(segment);
+ make_amorph(cell);
return 23;
}
int main(int argc,char **argv)
{
- u32 x_seg,y_seg,z_seg; /* amount of segments */
- u32 x,y,z; /* segments */
+ u32 x_cell,y_cell,z_cell; /* amount of segments */
+ u32 x,y,z; /* cells */
int i; /* for counting */
int slope_nel,start_nel; /* nuclear energy loss: slope, constant */
int steps; /* # steps */
- void *segments_p;
+ 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 */
/* default values */
- x_seg=DEFAULT_X_SEG;
- y_seg=DEFAULT_Y_SEG;
- z_seg=DEFAULT_Z_SEG;
+ x_cell=DEFAULT_X_SEG;
+ y_cell=DEFAULT_Y_SEG;
+ z_cell=DEFAULT_Z_SEG;
slope_nel=DEFAULT_SLOPE_NEL;
start_nel=DEFAULT_START_NEL;
steps=DEFAULT_STEPS;
+ display_x=DEFAULT_DISPLAY_X-1;
+ display_y=DEFAULT_DISPLAY_Y-1;
+ display_z=DEFAULT_DISPLAY_Z-1;
+ display_refresh_rate=DEFAULT_DISPLAY_REF_RATE;
/* parse command args */
for(i=1;i<argc;i++)
start_nel=atoi(argv[++i]);
break;
case 'x':
- x_seg=atoi(argv[++i]);
+ x_cell=atoi(argv[++i]);
break;
case 'y':
- y_seg=atoi(argv[++i]);
+ y_cell=atoi(argv[++i]);
break;
case 'z':
- z_seg=atoi(argv[++i]);
+ z_cell=atoi(argv[++i]);
break;
- case 's':
+ case 's':
steps=atoi(argv[++i]);
break;
+ case 'X':
+ display_x=atoi(argv[++i]);
+ break;
+ case 'Y':
+ display_y=atoi(argv[++i]);
+ break;
+ case 'Z':
+ display_z=atoi(argv[++i]);
+ break;
+ case 'd':
+ display_refresh_rate=atoi(argv[++i]);
+ break;
default:
usage();
return -23;
return -23;
}
- /* calculate sum_z_segments one time! */
- sum_z_segments=0;
- for(i=1;i<=z_seg;i++) sum_z_segments+=(start_nel+i*slope_nel);
- printfd("debug: sum z segments -> %d\n",sum_z_segments);
+ /* 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 -> %d\n",sum_z_cells);
/* testing ... */
- /* allocate segments */
- if((segments_p=malloc(x_seg*y_seg*z_seg*sizeof(u32)))==NULL)
+ /* allocate cells */
+ if((cell_p=malloc(x_cell*y_cell*z_cell*sizeof(u32)))==NULL)
{
- puts("failed allocating memory for segments\n");
+ puts("failed allocating memory for cells\n");
return -23;
}
- memset(segments_p,0,x_seg*y_seg*z_seg*sizeof(u32));
+ memset(cell_p,0,x_cell*y_cell*z_cell*sizeof(u32));
+
+ /* init display */
+ display_init(x_cell,y_cell,z_cell,&display,cell_p,&argc,argv);
/* main routine */
for(i=0;i<steps;i++)
{
- x=rand_get(x_seg);
- y=rand_get(y_seg);
+ x=rand_get(x_cell);
+ y=rand_get(y_cell);
z=rand_get_lgp(slope_nel,start_nel);
/* todo */
- distrib_c_conc(segments_p);
- process_segment((u32)(segments_p+x+y*(x_seg-1)+z*(x_seg-1)*(y_seg-1)));
- display(segments_p);
- /* */
+ // distrib_c_conc(cell_p);
+ process_cell((u32 *)(cell_p+x+y*(x_cell-1)+z*(x_cell-1)*(y_cell-1)));
+ /* display stuff */
+ if((i%display_refresh_rate)==0)
+ {
+ puts("refreshing diplay ...");
+ // display_draw(&display,display_x,display_y,display_z);
+ }
+ /* */
}
+
+ /* display again and quit when button hit */
+ puts("hit button to quit ...");
+ getchar();
+
return 23;
}