pause function

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

Moderators: cheriff, TyRaNiD

Post Reply
JJPeerless
Posts: 82
Joined: Mon Jun 20, 2005 3:32 am

pause function

Post by JJPeerless »

hey..im writing my own pause function..this is what i wrote..seems like it should work to me at least..

void pgPause(unsigned long p)
{
struct timeval curT;
unsigned long startTime, endTime,curTime;
sceKernelLibcGettimeofday(curT,0);
startTime = (curT.tv_sec*1000000) + curT.tv_usec;
endTime=startTime+p;

while(curTime<endTime)
{
sceKernelLibcGettimeofday(curT,0);
curTime=(curT.tv_sec*1000000)+curT.tv_usec;
}

}

however, the psp freezes up..? help?
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Code: Select all

int sceKernelDelayThread&#40;unsigned int usecs&#41;;
This will delay the current thread for at least the amount specified in the usecs argument (microseconds, of course).

The PSP's kernel uses a cooperative scheduler, so you have to deliberately yield your thread in order for other threads to execute. Your method blocks the CPU.
JJPeerless
Posts: 82
Joined: Mon Jun 20, 2005 3:32 am

Post by JJPeerless »

well, im trying to "pause" a while loop..

like i have something like this

while(condition)
{

dosomethingcool();
wait(100 milliseconds);
}

i wanted it to so i can pause between each "step" in a while loop

if i sleep the thread..the while loop still goes, but the psp fucntions just stop..so only some of the "dosomethingcool" get put to the screen..
beatwho
Posts: 28
Joined: Wed Dec 15, 2004 4:58 pm

Post by beatwho »

if you sleep the thread, then the whole thread should sleep (crazy huh), not just the "psp functions".

it should work just like you said:

while(condition)
{
dosomethingstrange();
sleep(100 milliseconds); // the loop stops here for 100 milliseconds!
}
JJPeerless
Posts: 82
Joined: Mon Jun 20, 2005 3:32 am

Post by JJPeerless »

hmm yea..it is working..its just my dosomethingcool() i guess isnt..

let me look over my code..and ill repost =)
Post Reply