prefix=/usr
dfblib=""
dfbinc=""
+nodfb=0
echo $run_cmd
--help) usage; shift 1;;
--with-dfblib) dfblib=`echo $1 | awk -F= '{ print $2 }'`; shift;;
--with-dfbinc) dfbinc=`echo $1 | awk -F= '{ print $2 }'`; shift;;
+ --without-dfb) nodfb=1; shift ;;
esac
done
fi
fi
if [ "$dfb_inc_dir" = "0" ]; then
- echo "dfb includes missing ..."
- exit 1
+ echo "dfb includes not found ..."
+ nodfb=1
fi
dfb_lib_dir="0"
if [ -z "$dfblib" ]; then
fi
fi
if [ "$dfb_lib_dir" = "0" ]; then
- echo "dfb libs missing ..."
- exit 1
+ echo "dfb libs not found ..."
+ nodfb=1
fi
-echo "directfb installation looks good :)"
+
+[ "$nodfb" = "0" ] && echo "directfb installation looks good :)"
echo "creating Makefile"
+
cat > Makefile << EOF
# $name Makefile, created `date`
INCLUDEDIR = /usr/include
+EOF
+
+if [ "$nodfb" = "0" ]; then
+
+cat >> Makefile << EOF
CFLAGS = -DDEBUG -DUSE_DFB_API -DFONT=\"$prefix/share/$name/decker.ttf\" -O3 -Wall -I$dfb_inc_dir
LIBS = -L$dfb_lib_dir -ldirectfb
OBJS = random.o dfbapi.o
+EOF
+
+else
+
+cat >> Makefile << EOF
+CFLAGS = -DDEBUG -DNODFB -O3 -Wall
+LIBS =
+
+OBJS = random.o
+EOF
+
+fi
+
+cat >> Makefile << EOF
OBJS2 = $name
$name: \$(OBJS)
/* two dimensional lattice */
-int d2_lattice_init(int *argc,char **argv,d2_lattice *d2_l,int x,int y)
+int d2_lattice_init(int *argc,char **argv,d2_lattice *d2_l)
{
DFBSurfaceDescription surface_dsc;
DFBFontDescription font_dsc;
- d2_l->max_x=x;
- d2_l->max_y=y;
-
DirectFBInit(argc,&argv);
DirectFBCreate(&(d2_l->dfb));
d2_l->dfb->SetCooperativeLevel(d2_l->dfb,DFSCL_FULLSCREEN);
} else return 1;
}
-int d3_lattice_init(int *argc,char **argv,d3_lattice *d3_l,int x,int y,int z)
+int d3_lattice_init(int *argc,char **argv,d3_lattice *d3_l)
{
DFBSurfaceDescription surface_dsc;
DFBFontDescription font_dsc;
- d3_l->max_x=x;
- d3_l->max_y=y;
- d3_l->max_z=z;
-
DirectFBInit(argc,&argv);
DirectFBCreate(&(d3_l->dfb));
d3_l->dfb->SetCooperativeLevel(d3_l->dfb,DFSCL_FULLSCREEN);
unsigned char *status; /* status&1 -> red, else blue */
int *extra; /* store extra values */
void *v_ptr; /* void ptr, for any use */
+#ifdef USE_DFB_API
IDirectFB *dfb;
IDirectFBSurface *p_surface;
IDirectFBFont *font;
IDirectFBInputDevice *keyboard;
IDirectFBEventBuffer *k_buffer;
+#else
+ char *foo1,*foo2,foo3,foo4;
+#endif
} d2_lattice;
typedef struct __d3_lattice
unsigned char *status; /* status&1 -> red, else blue */
int *extra; /* store extra values */
void *v_ptr; /* void ptr, for any use */
+#ifdef USE_DFB_API
IDirectFB *dfb;
IDirectFBSurface *p_surface;
IDirectFBFont *font;
IDirectFBInputDevice *keyboard;
IDirectFBEventBuffer *k_buffer;
+#else
+ char *foo1,*foo2,foo3,foo4;
+#endif
} d3_lattice;
/* function prototypes */
-int d2_lattice_init(int *argc,char **argv,d2_lattice *d2_l,int x,int y);
+int d2_lattice_init(int *argc,char **argv,d2_lattice *d2_l);
int d2_lattice_release(d2_lattice *d2_l);
int d2_lattice_draw(d2_lattice *d2_l,int x,int y,int arg_c,char **arg_v);
-int d3_lattice_init(int *argc,char **argv,d3_lattice *d3_l,int x,int y,int z);
+int d3_lattice_init(int *argc,char **argv,d3_lattice *d3_l);
int d3_lattice_release(d3_lattice *d3_l);
int d3_lattice_draw(d3_lattice *d3_l,int x,int y,int z,int arg_c,char **arg_v);
int d2_event_init(d2_lattice *d2_l);
int main(int argc,char **argv)
{
- u32 max_x,max_y,max_z,x,y,z,x_c,y_c,z_c;
+ u32 x,y,z,x_c,y_c,z_c;
int i,quit,escape,nowait;
int refresh,resave;
char s_file[MAX_CHARS];
d3_lattice d3_l;
info my_info;
- max_x=X;
- max_y=Y;
- max_z=Z;
+ d3_l.max_x=X;
+ d3_l.max_y=Y;
+ d3_l.max_z=Z;
my_info.steps=STEPS;
my_info.range=RANGE;
refresh=REFRESH;
my_info.b_el=atof(argv[++i]);
break;
case 'x':
- max_x=atoi(argv[++i]);
+ d3_l.max_x=atoi(argv[++i]);
break;
case 'y':
- max_y=atoi(argv[++i]);
+ d3_l.max_y=atoi(argv[++i]);
break;
case 'z':
- max_z=atoi(argv[++i]);
+ d3_l.max_z=atoi(argv[++i]);
break;
/*
case 'X':
} else usage();
}
- x=max_x/2-1;
- y=max_y/2-1;
- z=max_z/2-1;
-
+ x=d3_l.max_x/2-1;
+ y=d3_l.max_y/2-1;
+ z=d3_l.max_z/2-1;
+#ifdef NODFB
+ if(!strcmp(s_file,"")
+ {
+ puts("NODFB defined, run with -S option");
+ return -1;
+ }
if(!strcmp(r_file,"")) rand_init(NULL);
else rand_init(r_file);
if(!strcmp(l_file,""))
{
- i=max_x*max_y*max_z;
- d3_lattice_init(&argc,argv,&d3_l,max_x,max_y,max_z);
+ i=d3_l.max_x*d3_l.max_y*d3_l.max_z;
+#ifdef USE_DFB_API
+ d3_lattice_init(&argc,argv,&d3_l);
+#endif
if((d3_l.status=(unsigned char *)malloc(i*sizeof(unsigned char)))==NULL)
{
puts("failed allocating status buffer");
convert_file(c_file,&d3_l);
puts("done");
return 1;
- } else d3_lattice_init(&argc,argv,&d3_l,d3_l.max_x,d3_l.max_y,d3_l.max_z);
+ }
+#ifdef USE_DFB_API
+ else d3_lattice_init(&argc,argv,&d3_l);
+#endif
}
-
+
+#ifedef USE_DFB_API
d3_event_init(&d3_l);
+#endif
strcpy(a_txt,"args:");
sprintf(s_txt,"steps: %d",my_info.steps);
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",my_info.cc);
+#ifdef USE_DFB_API
d3_lattice_draw(&d3_l,x,y,z,24,arg_v);
+#endif
// scan_event(&d3_l,&x,&y,&z,&quit,&escape);
}
if(i%resave==0 && strcmp(s_file,"") && resave!=0)
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",my_info.cc);
+#ifdef USE_DFB_API
d3_lattice_draw(&d3_l,x,y,z,24,arg_v);
scan_event(&d3_l,&x,&y,&z,&quit,&escape);
+#endif
}
+#ifdef USE_DFB_API
d3_lattice_release(&d3_l);
+#endif
return 1;
}