GetTickCount equilivent?

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

Moderators: cheriff, TyRaNiD

Post Reply
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

GetTickCount equilivent?

Post by Kojima »

Hi,

Is there a psp sdk version of getTickcount or similar function that I can use to build my timer class?
zilt
Posts: 45
Joined: Tue Feb 21, 2006 11:59 pm
Location: Ontario, Canada
Contact:

Post by zilt »

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
siberianstar
Posts: 70
Joined: Thu Jun 22, 2006 9:24 pm

Post by siberianstar »

Code: Select all

int gettick() {
	static timeval tv;
	gettimeofday(&tv, 0);
	return (int)(tv.tv_sec * 1000) + (tv.tv_usec / 1000);
}
include sys/time.h
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

Thanks Sib.

Zlit, in the words of a great man. "I dunno"
sg57
Posts: 144
Joined: Fri Oct 14, 2005 2:26 pm

Post by sg57 »

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: Select all

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.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

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);
Edorul
Posts: 7
Joined: Sat May 27, 2006 3:57 am
Location: France
Contact:

Post by Edorul »

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: Select all

#include <psprtc.h>

//return time in milliseconds
u64 GetTick&#40;&#41;
&#123;
     u64 temp;
     sceRtcGetCurrentTick&#40;&temp&#41;;
     return temp/1000;
&#125;

void main&#40;&#41;
&#123;
     u64 tick;
     tick = GetTick&#40;&#41;;
&#125;

edit : "bis repetita placent"... TyRaNiD and I have posted nearly the same post at the same moment! :D
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

Post by Kojima »

Lol thanks guys. As for grep, I thought that was a kind of grape until two days ago so don't blame me. :)
Post Reply