[DEV] Limit/control FPS

Discussion in '3DS - Homebrew Development and Emulators' started by Urbanshadow, Jul 3, 2016.

  1. Urbanshadow
    OP

    Urbanshadow GBAtemp Maniac

    Member
    1,293
    471
    Oct 16, 2015
    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, Jul 3, 2016
  2. elhobbs

    elhobbs GBAtemp Advanced Fan

    Member
    782
    292
    Jul 28, 2008
    United States
    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.
     
    Thelostrune likes this.
  3. Urbanshadow
    OP

    Urbanshadow GBAtemp Maniac

    Member
    1,293
    471
    Oct 16, 2015
    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! :)