Message-Id: <35C5F9FD.2CE@cableol.co.uk> Date: Mon, 03 Aug 1998 18:57:17 +0100 From: Allens Mime-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: Same speed on every machine References: <35C396B2 DOT C31C29EA AT aditfree DOT com> <35d43129 DOT 140559707 AT news DOT ican DOT net> <35C4420A DOT 500482B8 AT aditfree DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk C.Rothwell wrote: > > cam and or nenette remove trailing 666 wrote: > > > On Sat, 01 Aug 1998 23:29:06 +0100, "C.Rothwell" > > added to the entropy with: > > >Is there a fool proof way of getting somethng to run at the same speed > > >on any PC without it slowing down the older machines? > > > > yeah - run it on the slowest machine you want it to run on, and then > > use that as the standard for how fast the program is allowed to run on > > faster machines. > > Well, my problem is that It works fin on a 386 and up to a P150 then it > starts to get faster (more so on cyrix machines) and I suspect that on a > P400 it would be unplayable. > > Although I don't have access to anything more than a P200. > I could put a screen update on an interupt but it might cause problems on > the slower machines with slow graphics cards. I have been used to using the > Amiga and this is the first time I have had to deal with such variance in > speed of CPU's.Try finding the speed of the machine by finding how much it can count up to in a certain time, then delay it with a loop by that a proportional amount of for the faster machines. Sample untested code, which you will have to change '#define time_for_386 1000' to the amount delaytime gets up to on a 386: #include #include #define time_for_386 1000 int speed(); void delay(); int delaytime; int main(){ speed(); /* Game goes here..*/ delay(); /*With the call to delay in it*/ } int speed(){ struct tm value; int start,start2; do{ start2=start; start=time(NULL); }while (start2==start); do{ delaytime++; printf ("%d %d\n",start,time(NULL)); }while (start==time(NULL)); } void delay(){ int n; for (n=0 ;n < delaytime - time_for_386;n++ ){ } }