Homebrew [DEV] Limit/control FPS

Urbanshadow

Well-Known Member
OP
Member
Joined
Oct 16, 2015
Messages
1,578
Trophies
0
Age
33
XP
1,723
Country
Hi all!

I was wondering if there was a way for a userland homebrew to have a fps limiter or controller with millisecond precision or more. I have found svcSleepThread(nanoseconds), but I think this needs arm9 and I still need a way to tic/toc (check the amount of time a code block has taken) at least in milliseconds. time.h has time(null) which gives you unixtime but unfortunately this is down to second precision. The main goal is to have the system idling (sleeping) if the system can run accross a homebrew's logic and rendering cycle in less time than necessary or be able to actively do things it the system can't keep up with a desired framerate (ie 30).

Any clues for me?
 
Last edited by Urbanshadow,

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,030
Country
United States
Hi all!

I was wondering if there was a way for a userland homebrew to have a fps limiter or controller with millisecond precision or more. I have found svcSleepThread(nanoseconds), but I think this needs arm9 and I still need a way to tic/toc (check the amount of time a code block has taken) at least in milliseconds. time.h has time(null) which gives you unixtime but unfortunately this is down to second precision. The main goal is to have the system idling (sleeping) if the system can run accross a homebrew's logic and rendering cycle in less time than necessary or be able to actively do things it the system can't keep up with a desired framerate (ie 30).

Any clues for me?
osGetTime will get you milliseconds. There is also svcGetSystemTick which is a much higher precision timer - there are 268123480 ticks per second. svcSleepThread does not require arm9 it is usable in normal user code. You can also wait for vblank to idle the cpu as needed - gspWaitForVBlank. There are a few gspWait variants too.
 
  • Like
Reactions: Thelostrune

Urbanshadow

Well-Known Member
OP
Member
Joined
Oct 16, 2015
Messages
1,578
Trophies
0
Age
33
XP
1,723
Country
osGetTime will get you milliseconds. There is also svcGetSystemTick which is a much higher precision timer - there are 268123480 ticks per second. svcSleepThread does not require arm9 it is usable in normal user code. You can also wait for vblank to idle the cpu as needed - gspWaitForVBlank. There are a few gspWait variants too.

Yeah I was trying to get more info on the VBlank as it really looks like it does pretty much everything I want to implement. Looks like svcGetSystemTick and svcSleepThread are the way to go for manual control. Thanks! :)
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Black_Manta_8bit @ Black_Manta_8bit: hey