X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fmisc.c;h=61683e6c9564c14ef8fa0fce45133b9cc4ffceac;hp=a17b1da5f12834dd4406b13bf268eb70a4ba4009;hb=a5a03e15b395ba1942c180d1cd0d3a4f43b87f56;hpb=c3d03cdffce070695ba0520d00667b42b8460087 diff --git a/src/misc.c b/src/misc.c index a17b1da5..61683e6c 100644 --- a/src/misc.c +++ b/src/misc.c @@ -41,31 +41,31 @@ long mainCounter(int mode) long counter_ms; gettimeofday(¤t_time,NULL); - if (mode==0 || current_time.tv_sec*counter_var+delay || actual_counter<*counter_var) + if (actual_counter >= *counter_var+delay || actual_counter < *counter_var) { *counter_var = actual_counter; return(TRUE); @@ -102,6 +102,20 @@ BOOL DelayReached(long *counter_var, int delay) return(FALSE); } +BOOL FrameReached(long *frame_counter_var, int frame_delay) +{ + long actual_frame_counter = FrameCounter; + + if (actual_frame_counter >= *frame_counter_var+frame_delay + || actual_frame_counter < *frame_counter_var) + { + *frame_counter_var = actual_frame_counter; + return(TRUE); + } + else + return(FALSE); +} + unsigned long be2long(unsigned long *be) /* big-endian -> longword */ { unsigned char *ptr = (unsigned char *)be; @@ -117,6 +131,16 @@ char *int2str(int ct, int nr) return(&str[strlen(str)-nr]); } +unsigned int SimpleRND(unsigned int max) +{ + static unsigned long root = 654321; + struct timeval current_time; + + gettimeofday(¤t_time,NULL); + root = root * 4253261 + current_time.tv_sec + current_time.tv_usec; + return(root % max); +} + unsigned int RND(unsigned int max) { return(rand() % max); @@ -171,22 +195,57 @@ void HandleAnimation(int mode) static BOOL anim_restart = TRUE; static BOOL reset_delay = TRUE; static int toon_nr = 0; + int draw_mode; +/* if (!toons_on || game_status==PLAYING) return; +*/ + +/* + if (!toons_on || tape.playing || tape.recording) + return; +*/ + + if (!toons_on) + return; switch(mode) { case ANIM_START: anim_restart = TRUE; reset_delay = TRUE; + + /* Fill empty backbuffer for animation functions */ + if (direct_draw_on && game_status==PLAYING) + { + int xx,yy; + + drawto_field = backbuffer; + + for(xx=0;xxposition==ANIMPOS_DOWN) pos_y = FULL_SYSIZE-anim->height; else if (anim->position==ANIMPOS_UPPER) - pos_y = RND((FULL_SYSIZE-anim->height)/2); + pos_y = SimpleRND((FULL_SYSIZE-anim->height)/2); else - pos_y = RND(FULL_SYSIZE-anim->height); + pos_y = SimpleRND(FULL_SYSIZE-anim->height); if (anim->direction==ANIMDIR_RIGHT) { @@ -319,7 +378,7 @@ BOOL AnimateToon(int toon_nr, BOOL restart) else if (anim->position==ANIMPOS_RIGHT) pos_x = FULL_SXSIZE-anim->width; else - pos_x = RND(FULL_SXSIZE-anim->width); + pos_x = SimpleRND(FULL_SXSIZE-anim->width); if (anim->direction==ANIMDIR_DOWN) {