-----!!!!
authorhackbard <hackbard>
Wed, 14 May 2003 17:32:50 +0000 (17:32 +0000)
committerhackbard <hackbard>
Wed, 14 May 2003 17:32:50 +0000 (17:32 +0000)
dfbapi.h
nlsop.c
nlsop.h
random.h

index 54ab56b..985d983 100644 (file)
--- a/dfbapi.h
+++ b/dfbapi.h
@@ -5,6 +5,9 @@
  *
  */
 
+#ifndef DFBAPI_H
+#define DFBAPI_H
+
 #include <directfb.h>
 
 /* two dimensional lattice */
@@ -56,5 +59,9 @@ 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_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 d3_event_init(d3_lattice *d3_l);
+int scan_event(d3_lattice *d3_l,int *x,int *y,int *z,int *q,int *esc);
 int dx_lattice_get_color(unsigned char *status,unsigned char *r,unsigned char *g,unsigned char *b);
 
+#endif /* DFBAPI_H */
diff --git a/nlsop.c b/nlsop.c
index 030db9f..041fac0 100644 (file)
--- a/nlsop.c
+++ b/nlsop.c
@@ -79,7 +79,7 @@ int process_cell(d3_lattice *d3_l,u32 x,u32 y,u32 z,int r,double a,double b,int
  p*=*conc;
  if(!(*thiz&AMORPH))
  {
-  if(rand_get(URAND_MAX)<=p)
+  if(get_rand(URAND_MAX)<=p)
   {
    MAKE_AMORPH(thiz);
    *t_c=*t_c+1-*conc;
@@ -87,7 +87,7 @@ int process_cell(d3_lattice *d3_l,u32 x,u32 y,u32 z,int r,double a,double b,int
  } else
  {
   /* assume 1-p probability */
-  if(rand_get(URAND_MAX)>p)
+  if(get_rand(URAND_MAX)>p)
   {
    MAKE_CRYST(thiz);
    *t_c=*t_c+1+*conc;
@@ -138,13 +138,14 @@ int distrib_c(d3_lattice *d3_l,int t_c,double a,double b)
   left=(int)(((i+1)*a+b)*t_c/sum)%area_h[i];
   while(left)
   {
-  x=get_rand(d3_l->max_x);
-  y=get_rand(d3_l->max_y);
-  if(!(*(d3_l->status+(i*area)+x+y*d3_l->max_x)&AMORPH))
-  {
-   *(d3_l->extra+(i*area)+x+y*d3_l->max_x)+=1;
-   total+=1;
-   left-=1;
+   x=get_rand(d3_l->max_x);
+   y=get_rand(d3_l->max_y);
+   if(!(*(d3_l->status+(i*area)+x+y*d3_l->max_x)&AMORPH))
+   {
+    *(d3_l->extra+(i*area)+x+y*d3_l->max_x)+=1;
+    total+=1;
+    left-=1;
+   }
   }
  }
  left=t_c-total;
@@ -381,9 +382,9 @@ int main(int argc,char **argv)
  {
   while((i<steps) && (quit==0) && (escape==0))
   {
-   x_c=rand_get(d3_l.max_x);
-   y_c=rand_get(d3_l.max_y);
-   z_c=rand_get_lgp(d3_l.max_z,a_el,b_el);
+   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);
    if(i%refresh==0)
@@ -408,10 +409,12 @@ int main(int argc,char **argv)
     d3_lattice_draw(&d3_l,x,y,z,10,arg_v);
     scan_event(&d3_l,&x,&y,&z,&quit,&escape);
    }
-   ++i;
+   i++;
   }
  }
 
+ if(strcmp(s_file,"")) save_to_file(s_file,&d3_l);
+
  while((quit==0) && (escape==0) && (nowait==0))
  {
   sprintf(x_txt,"x: %d",x);
diff --git a/nlsop.h b/nlsop.h
index 4700010..54c3bbf 100644 (file)
--- a/nlsop.h
+++ b/nlsop.h
@@ -5,12 +5,15 @@
  *
  */
 
+#ifndef NLSOP_H
+#define NLSOP_H
+
 typedef unsigned int u32;
 
 #define AMORPH 1
 
-#define A_EL 1
-#define B_EL 0
+#define A_EL 1.
+#define B_EL .0
 
 #define X 50
 #define Y 50
@@ -20,8 +23,8 @@ typedef unsigned int u32;
 #define RANGE 3
 #define REFRESH 20
 
-#define A_CD 1
-#define B_CD 0
+#define A_CD 1.
+#define B_CD .0
 
 #define CC 0
 
@@ -30,3 +33,5 @@ typedef unsigned int u32;
 
 #define MAX_CHARS 64
 #define MAX_TXT 32
+
+#endif /* NLSOP_H */
index 54d0f78..e443f81 100644 (file)
--- a/random.h
+++ b/random.h
@@ -5,6 +5,9 @@
  *
  */
 
+#ifndef RANDOM_H
+#define RANDOM_H
+
 #include "nlsop.h"
 #include <math.h>
 #include <stdio.h>
@@ -18,3 +21,4 @@ u32 get_rand_lgp(u32 max,double a,double b);
 #define BUFSIZE (16*1048576) /* 64 MByte */
 #define URAND_MAX 0xffffffff
 
+#endif /* RANDOM_H */