forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

psprtc.h

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
RCON



Joined: 03 Aug 2005
Posts: 16

PostPosted: Thu Sep 15, 2005 2:50 pm    Post subject: psprtc.h Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
RustyFunkNut



Joined: 26 Sep 2005
Posts: 17
Location: London, UK

PostPosted: Mon Sep 26, 2005 5:21 am    Post subject: Reply with quote

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

Code:

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!
Back to top
View user's profile Send private message MSN Messenger
RCON



Joined: 03 Aug 2005
Posts: 16

PostPosted: Mon Sep 26, 2005 5:29 am    Post subject: Reply with quote

thanks, that does help
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group