From: "DeHackEd" References: Subject: Re: Help with Timer function Date: Mon, 16 Feb 1998 16:21:04 -0500 Lines: 63 Message-ID: Newsgroups: comp.os.msdos.djgpp To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Do you have Allegro? I recommend it. It already has timer, keyboard, screen, sound and othter things (made for games, but completely free). Then in your code, have something like this (excuse my mess of comments, but I don't know how my newsgroup reader will allign messages and word wrap them): #include volatile int minutes; volatile int seconds; volatile char time_is_up = 0; void count_down_timer() { if (!doit) return; // code is not needed right now if (seconds == 0) // take away a minute { seconds = 59; if (minutes == 0) { time_is_up = 1; remove_int(count_down_timer); // disables on list } minutes--; } else seconds--; // just take 1 away from seconds } END_OF_FUNCTION(count_down_timer) // IMPORTANT! int main() { allegro_init(); install_timer(); LOCK_VARIABLE(minutes); LOCK_VARIABLE(seconds); LOCK_VARIABLE(doit); LOCK_FUNCTION(count_down_timer); // 1000 is the millisecond delay between executions /* your code here. when you want to start the clock, set the times in minutes and seconds and just put this in. */ install_timer_ex(count_down_timer, 1000); /* make sure you adjust time_is_up as necessary. The function automaticly takes itself off the timer list when it reaches 0 */ return 0; } /* You can get allegro at http://www.talula.demon.co.uk/allegro/ if you don't already have it. -- "DeHackEd" EMail address not given out due to low-life spammers. */