www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/23/15:18:16

Message-Id: <335E5BA8.7CC1@canvaslink.com>
Date: Wed, 23 Apr 1997 14:57:44 -0400
From: Tom Grandgent <tgrand AT canvaslink DOT com>
Reply-To: tgrand AT canvaslink DOT com
Organization: Canvas Link, Inc.
Mime-Version: 1.0
To: Christoph Kukulies <kuku AT gilberto DOT physik DOT rwth-aachen DOT de>
Cc: djgpp AT delorie DOT com
Subject: Re: timer interrupt - sample code anyone?
References: <199704231733 DOT TAA18274 AT gilberto DOT physik DOT rwth-aachen DOT de>

Christoph Kukulies wrote:
> 
> [ - ]
> >
> > Wow..  I was just experimenting with that last night.  I needed
> > to measure the number of milliseconds per frame of my game, so
> > I made a 1KHz timer.  It wasn't quite enough, so I tried making a
> > 10KHz timer.  (Both of these incremented a global 32 bit value.)
> > The 1KHz timer had no apparent effect on the game, but the 10KHz
> > timer knocked the framerate down from around 72Hz to about 68-69Hz.
> 
> Just curious: How did you know it *was* 72Hz? :-)

Ok, I have a system of measuring the frame rate in my game that I
think is pretty foolproof.  I have a variable called frame_count that
is incremented at the end of every frame.  I then have an ISR which
is called once per second.  In this ISR, I copy frame_count into
a variable called fps, then I set frame_count back to 0.

So, the frame_count is always counting up until a second has passed,
then it gets reset and the measured fps variable is updated.  I
think this system seems completely accurate..  It is literally
counting the frames that were drawn during each second. :)

The only disadvantage to this is that the known frame rate is only
updated once a second, but that is no longer a problem for me.

	Tom Grandgent
	tgrand AT canvaslink DOT com
	Canvas Link, Inc.

- Raw text -


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