Homebrew [DEV] Limit/control FPS

  • Thread starter Thread starter Urbanshadow
  • Start date Start date
  • Views Views 1,372
  • Replies Replies 2

Urbanshadow

Well-Known Member
Member
Joined
Oct 16, 2015
Messages
1,591
Solutions
1
Reaction score
716
Trophies
1
Age
35
XP
1,808
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,
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
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