psprtc.h

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
RCON
Posts: 16
Joined: Wed Aug 03, 2005 1:02 am
Contact:

psprtc.h

Post by RCON »

Has anyone figured out how to use the psprtc.h include? I am trying to overcome some timing issues I am having with the clock() function in time.h. The sceRtcGetCurrentTick(u64 *tick) function looks promising but I don't know exactly how to use it.

-Louie
RustyFunkNut
Posts: 17
Joined: Mon Sep 26, 2005 5:10 am
Location: London, UK

Post by RustyFunkNut »

Here's what I'm using (assumes C++, but easy to convert to C):

Code: Select all

static u64	gLastTick = 0;
static float	gFreqInv;

void RenderFrame()
{
    u64 current_tick;

    float elapsed_time( 0.0f );
    if(sceRtcGetCurrentTick( &current_tick ) == 0)
    {
        if(gLastTick == 0)
        {
            u32 ticks_per_second( sceRtcGetTickResolution() );
		
            gFreqInv = 1.0f / float( ticks_per_second );
            gLastTick = current_tick;
        }

        u64 elapsed_ticks( current_tick - gLastTick );
		
        elapsed_time = float(elapsed_ticks) * gFreqInv;
        gLastTick = current_tick;
    }

     // Elapsed time in seconds is in elapsed_time (or 0.0f if the call failed)
}
It should be fairly clear what's going on. The main thing is that sceRtcGetCurrentTick() returns 0 on success.

I'm not sure what the resolution of the timer is, but it should be accurate to at least 1 millisecond.

Hope that helps!
RCON
Posts: 16
Joined: Wed Aug 03, 2005 1:02 am
Contact:

Post by RCON »

thanks, that does help
Post Reply