www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/02/07:48:41

From: siowtalker AT aol DOT com (SIowTalker)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Simple timer question...
Lines: 21
NNTP-Posting-Host: ladder07.news.aol.com
X-Admin: news AT aol DOT com
Date: 1 May 1999 18:41:06 GMT
Organization: AOL http://www.aol.com
References: <eQKZuWASpyK3Ew2w AT zaynar DOT demon DOT co DOT uk>
Message-ID: <19990501144106.24950.00001763@ng-fi1.aol.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

make a function like this

#include <go32.h>
unsigned long QueryTimer(void)
{
  unsigned long clock = _farpeekl(_dos_ds, 0x0046C);
  return(clock);
}

then so each game loop takes at least 100 milliseconds, you save the time
setting in the beggining of the game loop. Then at the end you get the time
again and test if the difference between the two times is less than 100, if it
is...it waits. Here's an example:

start_time = TimerQuery()
// do game processing
while((start_time-TimerQuery())<100) { }

Hope that helps...
-Chad

- Raw text -


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