From: hackbard Date: Tue, 10 Jun 2003 00:08:11 +0000 (+0000) Subject: added NODFB mode X-Git-Tag: fpb~42 X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd74c3d7003b61f0680a3272a6657a1a7913f42d;p=physik%2Fnlsop.git added NODFB mode --- diff --git a/configure b/configure index 31ed2e9..6155704 100755 --- a/configure +++ b/configure @@ -6,6 +6,7 @@ name="nlsop" prefix=/usr dfblib="" dfbinc="" +nodfb=0 echo $run_cmd @@ -24,6 +25,7 @@ while [ "$1" ]; do --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 @@ -41,8 +43,8 @@ else 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 @@ -57,20 +59,41 @@ else 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) diff --git a/dfbapi.c b/dfbapi.c index eb74fa3..3b0c895 100644 --- a/dfbapi.c +++ b/dfbapi.c @@ -11,14 +11,11 @@ /* 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); @@ -48,15 +45,11 @@ int d2_lattice_init(int *argc,char **argv,d2_lattice *d2_l,int x,int y) } 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); diff --git a/dfbapi.h b/dfbapi.h index 985d983..a2a37a9 100644 --- a/dfbapi.h +++ b/dfbapi.h @@ -27,11 +27,15 @@ typedef struct __d2_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 } d2_lattice; typedef struct __d3_lattice @@ -45,18 +49,22 @@ 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); diff --git a/nlsop.c b/nlsop.c index 81f408d..f2acfb4 100644 --- a/nlsop.c +++ b/nlsop.c @@ -369,7 +369,7 @@ int convert_file(char *cf,d3_lattice *d3_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]; @@ -399,9 +399,9 @@ int main(int argc,char **argv) 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; @@ -442,13 +442,13 @@ int main(int argc,char **argv) 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': @@ -514,19 +514,26 @@ int main(int argc,char **argv) } 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"); @@ -549,10 +556,15 @@ int main(int argc,char **argv) 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); @@ -608,7 +620,9 @@ int main(int argc,char **argv) 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) @@ -631,11 +645,15 @@ int main(int argc,char **argv) 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; }