Path: chuka.playstation.co.uk!chuka.playstation.co.uk!news From: James Russell Newsgroups: scee.yaroze.programming.libraries Subject: Re: Timers Date: Tue, 23 Sep 1997 02:55:23 +1200 Organization: Peace Computers NZ Ltd Lines: 47 Message-ID: <342686DB.1F1A@peace.co.nz> References: <605k25$5325@emeka.playstation.co.uk> NNTP-Posting-Host: 202.37.70.35 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.0Gold (X11; I; IRIX 6.2 IP22) Lewis_Evans@PLAYSTATION.SONY.COM wrote: > > All you need is a method for translating frameCounter times in your program > to seconds in the real world. > (assuming you have a frameCounter variable that's updated every pass > through the main loop). > > Firstly detect PAL or NTSC; now you know 50 or 60 frames per second. > > Secondly calculate the program's own frame rate from its hsync count. (Get > hsync by VSync(1); But that won't work if the frame rate is variable. > 240 scan lines for one frame of NTSC and 270 for PAL (roughly)). This tells > you the frame rate divider > (integer, typically 1 to 4). Now you know how long one frame takes. > > Eg in a PAL program with hsync count 340, frame rate divider is 2, ie > running at 25 fps. > > Hence you can detect when N.M seconds have passed. > Whoa, didn't get that at all. One solution I could use would be to use Bresenhams (!) algorithm. If in PAL, run the program as normal (50 times a second) but if in NTSC you've got to run the interrupt on MOST (but not all) Vsync interrupts. To figure out which ones, draw an imaginary line from (0,0) to (width 60 (or X*60),50 (or X*50)). Every frame, advance 1 pixel to the right and if you go 'up' a pixel, call the interrupt, otherwise don't. This effectively calls the interrupt 5/6 of the time on an NTSC system, i.e. 50 times a second. Because Bresenhams handles the error nicely, you don't get the slight speedup/slowdown caused by an inaccurate fraction representation of 5/6. I would LIKE to use the root counters, and the User Guide *briefly* mentions something about the root counter and interrupts, but ends there. No luck then. Cheers, James