| View previous topic :: View next topic |
| Author |
Message |
Kojima
Joined: 26 Jun 2006 Posts: 275
|
Posted: Thu Jul 13, 2006 3:34 am Post subject: GetTickCount equilivent? |
|
|
Hi,
Is there a psp sdk version of getTickcount or similar function that I can use to build my timer class? |
|
| Back to top |
|
 |
zilt
Joined: 21 Feb 2006 Posts: 45 Location: Ontario, Canada
|
Posted: Thu Jul 13, 2006 3:43 am Post subject: |
|
|
Are you unable to do even the most basic searching of the psp include files? Try grepping for 'tick' in the psp include files directory. You might even find a function you're looking for. _________________ "We are dreamers, shapers, singers, and makers. We study the mysteries of laser and circuit, crystal and scanner, holographic demons and invocations of equations. These are the tools we employ and we know... many things." -- Elric, B5 |
|
| Back to top |
|
 |
siberianstar
Joined: 22 Jun 2006 Posts: 70
|
Posted: Thu Jul 13, 2006 3:44 am Post subject: |
|
|
| Code: | int gettick() {
static timeval tv;
gettimeofday(&tv, 0);
return (int)(tv.tv_sec * 1000) + (tv.tv_usec / 1000);
} |
include sys/time.h |
|
| Back to top |
|
 |
Kojima
Joined: 26 Jun 2006 Posts: 275
|
Posted: Thu Jul 13, 2006 4:00 am Post subject: |
|
|
Thanks Sib.
Zlit, in the words of a great man. "I dunno" |
|
| Back to top |
|
 |
sg57
Joined: 14 Oct 2005 Posts: 154
|
Posted: Thu Jul 13, 2006 5:49 am Post subject: |
|
|
I just made my own little GetTickCount function for when i was porting a Quake II MD2 Model loader to PSPGL instead of OpenGL.
I had something like:
| Code: |
int GetTickCount() {
return time()/1000;
}
|
Since the 'time' function returns the current second from that clock at GNU or where ever it said, i divided it by 1000 to get it into miliseconds as the key frame required it.
Oh and im just wondering if that would work. I was too lazy to go searching. |
|
| Back to top |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Thu Jul 13, 2006 6:12 am Post subject: |
|
|
Nope, not even close. Taking a second based timer and dividing it by 1000 gives you kiloseconds not milliseconds :)
Seeing as you obviously dont know how to use grep :P
#include <psprtc.h>
u64 tick;
u64 millis;
sceRtcGetCurrentTick(&tick)
millis = tick / ((u64) sceRtcGetTickResolution() / 1000); |
|
| Back to top |
|
 |
Edorul
Joined: 27 May 2006 Posts: 7 Location: France
|
Posted: Thu Jul 13, 2006 6:17 am Post subject: |
|
|
If you want you can use this function: int sceRtcGetCurrentTick(u64 *tick);
defined in "psprtc.h". It returns a time in microseconds.
Here is a sample how to use it:
| Code: |
#include <psprtc.h>
//return time in milliseconds
u64 GetTick()
{
u64 temp;
sceRtcGetCurrentTick(&temp);
return temp/1000;
}
void main()
{
u64 tick;
tick = GetTick();
}
|
edit : "bis repetita placent"... TyRaNiD and I have posted nearly the same post at the same moment! :D |
|
| Back to top |
|
 |
Kojima
Joined: 26 Jun 2006 Posts: 275
|
Posted: Thu Jul 13, 2006 6:47 am Post subject: |
|
|
| Lol thanks guys. As for grep, I thought that was a kind of grape until two days ago so don't blame me. :) |
|
| Back to top |
|
 |
|