From: "DeHackEd" References: <6be66a$e7i$1 AT herald DOT Mines DOT EDU> Subject: Re: Keeping speed with slow CPUs Date: Fri, 6 Feb 1998 19:13:42 -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 If you are using Allegro, considder installing a timer interupt to do the following: void my_timer(/* insert a ... here for C++ */) { timer = 1; } And install it with the approprite time. Read the Allegro Docs... -- "DeHackEd" EMail address not given out due to low-life spammers. Jean-Luc Romano wrote in message <6be66a$e7i$1 AT herald DOT Mines DOT EDU>... > > >Hi, again. > > About a week ago I posted a message about the problem of having >fast computers run my game too fast. I wanted faster CPUs to >run my program at a normal speed while slower CPUs run my program >slower, since I do not want my game to not run at all. I proposed >the following code for regulating my event loop: > > while (!quitflag) /* event loop */ > { > /* Event loop stuff */ > > prepare_buffer(); > regulate(); > blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); > } > >And my regulate function is: > >void regulate() /* uses the timer to make sure a min amount > of time is spent each event loop */ >{ > while (timer < 100_milliseconds) /* has .1 secs passed yet? */ > { > /* Do nothing -- just wait out the timer */ > } > timer = 0; /* once done waiting, reset the timer */ >} > > George Foot told me this was a working way to prevent faster >machines from running my game too fast, but slower computers >would run it too slow (and George, if you are reading this, you may >want to answer). He briefly mentioned that there was another way >to regulate the event loop, one that would not be slower for slower >computers. > > Would anyone know how I would go about accomplishing this? > > George, you have any suggestions? > > Thanks. > > Jean-Luc Romano > >