Welcome! Log In Create A New Profile

Advanced

How would I do a basic Timer for regulating frame rate?

Posted by DaveB1980 
How would I do a basic Timer for regulating frame rate?
December 22, 2014 10:46PM
Hey all, first time poster and Wii Homebrew newbie here. Hopefully my first question isn't too stupid...

Would anyone be able to provide some insight on how I could code a basic timer for regulating frame updates on the Wii? I've tinkered with other libraries in the past on other platforms that had built-in/pre-made Timers I could use to get the number of "ticks" since the last iteration of my game loop. Is there something similar in DevKitPro, LibOGC or any of the other OOTB libraries in the toolchain I could utilize?

Any help would be greatly appreciated!
Re: How would I do a basic Timer for regulating frame rate?
December 24, 2014 03:02AM
I think the framerate is locked at 60 but you can use this function to check the time that has passed each frame.


#include    // Needed for gettime and ticks_to_millisecs

float temp=ticks_to_millisecs(gettime());
Re: How would I do a basic Timer for regulating frame rate?
December 24, 2014 04:13AM
Quote
owen
I think the framerate is locked at 60 but you can use this function to check the time that has passed each frame.


#include    // Needed for gettime and ticks_to_millisecs

float temp=ticks_to_millisecs(gettime());
Ah, great! I wasn't aware that it is/was already regulating the frame rate, but 60 was my ideal target so bonus! :)
Re: How would I do a basic Timer for regulating frame rate?
December 24, 2014 04:23AM
Max 60 fps but if you do too much work it will slow down to zero, lol, so try no to take too long to draw.
Re: How would I do a basic Timer for regulating frame rate?
December 24, 2014 09:26AM
You can also use gettick() instead of gettime() which gives the 4 less significant bytes of CPU clock instaed of 8 bytes but it is more quick to give the result.

In ogc/lwp_watchdog.h there are the descriptions of the time functions.

The screen framerate depends on the video mode:

480i: 29.97 FPS
480p: 59.94 FPS
576i: 25 FPS



Edited 1 time(s). Last edit at 12/24/2014 09:26AM by oibaf.
Re: How would I do a basic Timer for regulating frame rate?
December 24, 2014 01:00PM
Load each texture before draw or use a big texture atlas. See which method gives best results.
Re: How would I do a basic Timer for regulating frame rate?
December 24, 2014 02:03PM
Quote
oibaf
The screen framerate depends on the video mode:

480i: 29.97 FPS
480p: 59.94 FPS
576i: 25 FPS

You're wrong with the rates, the framerate is always 60 FPS (59.94 is the exact rate) in NTSC and PAL-M (also known as PAL 60) modes (480i and 480p) or 50 FPS in PAL modes (576i and 576p).



Edited 2 time(s). Last edit at 12/24/2014 02:05PM by TheCodingBrony.
Re: How would I do a basic Timer for regulating frame rate?
December 24, 2014 07:51PM
I am not wrong.

In the interlaced modes the frame rate is the half of the frequency refresh rate since at each vsync a semi frame (filed) is displayed and 2 fields are necessary for a whole frame.

Instead in the progressive mode at each vsync a whole frame is displayed.

[documentation.apple.com]
Re: How would I do a basic Timer for regulating frame rate?
December 25, 2014 03:39AM
I'm referring to the framerate that Wii games run on which is the most important to consider (60FPS in NTSC & MPAL, 50FPS in PAL whether it is progressive or interlaced)... Please don't make things too complicated as it might confuse beginners.
Sorry, only registered users may post in this forum.

Click here to login