delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/03/16:07:21

Message-Id: <35C5F9FD.2CE@cableol.co.uk>
Date: Mon, 03 Aug 1998 18:57:17 +0100
From: Allens <allen DOT asjp AT cableol DOT co DOT uk>
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>

C.Rothwell wrote:
> 
> cam and or nenette remove trailing 666 wrote:
> 
> > On Sat, 01 Aug 1998 23:29:06 +0100, "C.Rothwell"
> > <enquiries AT aditfree DOT com> 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 <time.h>
#include <stdio.h>
#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++ ){
	}
}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019