projects
/
physik
/
nlsop.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
479365d
)
added LIBC_RAND functionality & x-z view in real TEM mode now
author
hackbard
<hackbard>
Thu, 27 Jan 2005 15:31:24 +0000
(15:31 +0000)
committer
hackbard
<hackbard>
Thu, 27 Jan 2005 15:31:24 +0000
(15:31 +0000)
dfbapi.c
patch
|
blob
|
history
random.c
patch
|
blob
|
history
diff --git
a/dfbapi.c
b/dfbapi.c
index
da7b5f3
..
b922cc4
100644
(file)
--- a/
dfbapi.c
+++ b/
dfbapi.c
@@
-188,7
+188,7
@@
int d2_lattice_draw(d2_lattice *d2_l,int x,int y,int arg_c,char **arg_v,unsigned
int d3_lattice_draw(d3_lattice *d3_l,int x,int y,int z,int arg_c,char **arg_v,unsigned char mode,int max_extra,u32 *p1,u32 max1,u32 *p2,u32 max2)
{
int x_c,y_c,z_c;
int d3_lattice_draw(d3_lattice *d3_l,int x,int y,int z,int arg_c,char **arg_v,unsigned char mode,int max_extra,u32 *p1,u32 max1,u32 *p2,u32 max2)
{
int x_c,y_c,z_c;
- int i;
+ int i
,sum
;
unsigned char foobar;
unsigned char r,g,b,a;
unsigned char foobar;
unsigned char r,g,b,a;
@@
-199,7
+199,14
@@
int d3_lattice_draw(d3_lattice *d3_l,int x,int y,int z,int arg_c,char **arg_v,un
{
for(z_c=0;z_c<d3_l->max_z;z_c++)
{
{
for(z_c=0;z_c<d3_l->max_z;z_c++)
{
- if((!mode)||mode==3) dx_lattice_get_color((*d3_l).status+x_c+y_c*d3_l->max_x+z_c*d3_l->max_x*d3_l->max_y,&r,&g,&b,mode);
+ if((!mode)||mode==3)
+ {
+ sum=0;
+ for(i=-2;i<=2;i++)
+ if(*(d3_l->status+x_c+((y_c+i+d3_l->max_y)%d3_l->max_y)*d3_l->max_x+z_c*d3_l->max_x*d3_l->max_y)&RED) sum+=0xff;
+ g=0; b=0;
+ r=(unsigned char)(sum/5);
+ }
if(mode==3)
{
if(d3_l->max_x*p1[z_c]/max1==x_c)
if(mode==3)
{
if(d3_l->max_x*p1[z_c]/max1==x_c)
diff --git
a/random.c
b/random.c
index
468a3a5
..
a664fa7
100644
(file)
--- a/
random.c
+++ b/
random.c
@@
-12,6
+12,10
@@
#include <stdlib.h>
#include <math.h>
#include <stdlib.h>
#include <math.h>
+#ifdef USE_LIBC_RAND
+#include <time.h>
+#endif
+
#include "random.h"
static int rand_fd;
#include "random.h"
static int rand_fd;
@@
-21,11
+25,13
@@
int rand_init(char *rf)
{
if(rf==NULL)
{
{
if(rf==NULL)
{
+#ifndef USE_LIBC_RAND
if((rand_fd=open("/dev/urandom",O_RDONLY))<0)
{
puts("cannot open /dev/urandom");
return -1;
}
if((rand_fd=open("/dev/urandom",O_RDONLY))<0)
{
puts("cannot open /dev/urandom");
return -1;
}
+#endif
} else
{
if((rand_fd=open(rf,O_RDONLY))<0)
} else
{
if((rand_fd=open(rf,O_RDONLY))<0)
@@
-46,7
+52,9
@@
int rand_init(char *rf)
int rand_close(void)
{
int rand_close(void)
{
+#ifndef USE_LIBC_RAND
close(rand_fd);
close(rand_fd);
+#endif
return 1;
}
return 1;
}
@@
-58,6
+66,12
@@
u32 get_rand(u32 max)
#ifdef MORE_PRINTF
printf("getting another %d bytes of random data ...\n",BUFSIZE);
#endif
#ifdef MORE_PRINTF
printf("getting another %d bytes of random data ...\n",BUFSIZE);
#endif
+#ifdef USE_LIBC_RAND
+ c_ptr=b_ptr;
+ srand((int)time(NULL));
+ while(c_ptr<b_ptr+BUFSIZE) *(c_ptr++)=(u32)rand();
+ c_ptr=b_ptr;
+#else
if(read(rand_fd,b_ptr,BUFSIZE*sizeof(u32))<BUFSIZE*sizeof(u32))
{
/* -> assume random file, end reached */
if(read(rand_fd,b_ptr,BUFSIZE*sizeof(u32))<BUFSIZE*sizeof(u32))
{
/* -> assume random file, end reached */
@@
-66,12
+80,17
@@
u32 get_rand(u32 max)
read(rand_fd,b_ptr,BUFSIZE*sizeof(u32));
}
c_ptr=b_ptr;
read(rand_fd,b_ptr,BUFSIZE*sizeof(u32));
}
c_ptr=b_ptr;
+#endif
#ifdef MORE_PRINTF
printf("got it!\n");
#endif
}
#ifdef MORE_PRINTF
printf("got it!\n");
#endif
}
+#ifdef USE_LIBC_RAND
+ return((u32)(*(c_ptr++)*(max*1.0/((long long unsigned int)RAND_MAX+1))));
+#else
return((u32)(*(c_ptr++)*(max*1.0/((long long unsigned int)URAND_MAX+1))));
return((u32)(*(c_ptr++)*(max*1.0/((long long unsigned int)URAND_MAX+1))));
+#endif
}
u32 get_rand_lgp(u32 max,double a,double b)
}
u32 get_rand_lgp(u32 max,double a,double b)