From: hackbard Date: Tue, 8 Apr 2003 17:19:10 +0000 (+0000) Subject: - X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2fc464b1e03445cd60e9305dc9b75471ebdb04af;p=physik%2Fmorpheus.git - --- diff --git a/defines.h b/defines.h index b11396e..17e680f 100644 --- a/defines.h +++ b/defines.h @@ -35,6 +35,8 @@ #define URAND_MAX 0xffffffff #define URAND_2BYTE_MAX 0xffff +#define MAX_CHARS_RANDOM_FILE 64 + typedef unsigned int u32; typedef long long unsigned int u64; @@ -53,6 +55,7 @@ typedef struct __cell { /* display stuff */ typedef struct __display { + int step; /* display step */ u32 max_x,max_y,max_z; /* dimensions */ cell *cell_p; /* pointer to cell data */ #ifdef USE_DFB_API diff --git a/display.c b/display.c index 9509276..733ae23 100644 --- a/display.c +++ b/display.c @@ -140,6 +140,7 @@ int display_draw(display *display,u32 x,u32 y,u32 z) display->primary_surface->FillRectangle(display->primary_surface,menu_x,menu_y,menu_w,menu_h); display->primary_surface->SetColor(display->primary_surface,r,g,b,a); display->primary_surface->DrawRectangle(display->primary_surface,menu_x,menu_y,menu_w,menu_h); + display->primary_surface->DrawLine(display->primary_surface,menu_x+display_faktor_x*display->max_x/2,menu_y+display_faktor_y,menu_x+display_faktor_x*display->max_x/2,menu_y+display_faktor_y*display->max_y-display_faktor_y); font_dsc.flags=DFDESC_HEIGHT; font_dsc.height=menu_h/10; display->dfb->CreateFont(display->dfb,DISPLAY_FONT,&font_dsc,&(display->font)); @@ -155,6 +156,8 @@ int display_draw(display *display,u32 x,u32 y,u32 z) display->primary_surface->DrawString(display->primary_surface,text,-1,menu_x+display_faktor_x,menu_y+display_faktor_y*5+menu_h/10*5,DSTF_LEFT); sprintf(text,"c conc.: %u",(display->cell_p+x+y*display->max_x+z*display->max_x*display->max_y)->conc); display->primary_surface->DrawString(display->primary_surface,text,-1,menu_x+display_faktor_x,menu_y+display_faktor_y*6+menu_h/10*6,DSTF_LEFT); + sprintf(text,"step: %d",display->step); + display->primary_surface->DrawString(display->primary_surface,text,-1,menu_x+display_faktor_x*display->max_x/2+display_faktor_x,menu_y+display_faktor_y+menu_h/10,DSTF_LEFT); /* flip all to surface */ display->primary_surface->Flip(display->primary_surface,NULL,0); #endif diff --git a/main.c b/main.c index c019f0a..2ac8d6a 100644 --- a/main.c +++ b/main.c @@ -27,6 +27,7 @@ /* global variables */ u32 *rand_buf,*rand_current; +char random_file[MAX_CHARS_RANDOM_FILE]; u32 gr; int random_fd; /* /dev/urandom file descriptor */ @@ -49,6 +50,7 @@ int usage() printf("-p \t p0 for probability of cell getting amorph (default %f)\n",DEFAULT_A_P_P0); printf("-C \t C start concentration (default %d)\n",DEFAULT_C_DIST_START_CONC); printf("-S \t slope of linear C distribution (default %d)\n",DEFAULT_C_DIST_SLOPE); + puts("-R \t read random datat from file (default not used)"); return -23; } @@ -199,6 +201,7 @@ int main(int argc,char **argv) display_y=y_cell/2; display_z=z_cell/2; display_refresh_rate=DEFAULT_DISPLAY_REF_RATE; + strcpy(random_file,""); /* parse command args */ for(i=1;i #include #include +#include +#include #include "defines.h" @@ -13,6 +15,7 @@ extern u32 gr; extern int random_fd; extern u32 *rand_buf,*rand_current; +extern char random_file[MAX_CHARS_RANDOM_FILE]; /* return random integer between 0 - max-1 */ u32 rand_get(u32 max) @@ -22,9 +25,17 @@ u32 rand_get(u32 max) printfd("debug: reading new random bytes\n"); if(read(random_fd,rand_buf,RAND_BUF_SIZE)!=RAND_BUF_SIZE) { - puts("failed reading 1 mega bytes of random data"); - return -23; + if(!strcmp(random_file,"")) + { + puts("random file end, starting over ..."); + lseek(random_fd,0,SEEK_SET); + } else + { + puts("failed reading 1 mega bytes of random data"); + return -23; + } } + printfd("debug: finished reading random bytes\n"); rand_current=rand_buf; } /* cells numbered 0...max-1 */