delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/29/14:46:56

Message-ID: <33663D9A.1C1B@swipnet.se>
Date: Tue, 29 Apr 1997 20:27:38 +0200
From: Deltaman <deltaman AT swipnet DOT se>
Reply-To: deltaman AT swipnet DOT se
MIME-Version: 1.0
To: BDC Client Team <cs19 AT cityscape DOT co DOT uk>
CC: djgpp AT delorie DOT com
Subject: Re: Help detecting processor and speed
References: <862316098 DOT 18214 DOT 0 AT itsb DOT demon DOT co DOT uk>

BDC Client Team wrote:
>
> I have nearly finished a game using djgpp and allegro 2.2 - I wish to make
> this game run the same regardless of the processor and speed of the machine
> that it is running on.
> 
> What I think I need to do is setup a pause in the middle of the main loop
> with the length of pause determined by the speed and type of processor
> e.g. pause 0 milliseconds if a 486 33mhz, pause 10 milliseconds if a 486 66mhz
> , pause 100 if Pentium 75mhz, and so on.
> 
> Can anyone tell me a way that I can write a function that returns processor
> type and speed?
> 
I think a better solution would be to use the built in timer functions
in allegro, since the processor isn't the only thing that decides speed.
This way will not work on too slow machines, but AFAIK it'll work on all
with higher speed. This way could (maybe) be too slow (depends on how
much you update).

Example code:

...           // Your include stuff
int update;   // An int to check if it's time to update yet (Don't
forget to declare extern if needed)
...           // All functions goes here

void timerFunction() {
if (update == TRUE) update = FALSE;
}
END_OF_FUNCTION(TimerFunction);

... // Your init stuff goes here

update = FALSE;
LOCK_VARIABLE(update);
LOCK_FUNCTION(timerFunction);

install_int(timerFunction, [Here (in MilliSeconds) you write how often
the screen should update]);

... // begin loop

if (update = FALSE) { 
update = TRUE;
... // Here you do your updating
}
... // end loop

Hope this helps, I've never tried this myself so I'm not sure it will
work. 
________________________________________________________________________
                        |
  deltaman AT swipnet DOT se   |   http://www.geocities.com/TimesSquare/8240
________________________|_______________________________________________
______  _______        _______ _______ _______ _______ __   _
 |     \ |______ |         |    |_____| |  |  | |_____| | \  |
 |_____/ |______ |_____    |    |     | |  |  | |     | |  \_|

- Raw text -


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