| View previous topic :: View next topic |
| Author |
Message |
JJPeerless
Joined: 20 Jun 2005 Posts: 82
|
Posted: Fri Jul 08, 2005 9:08 am Post subject: pause function |
|
|
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? |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Fri Jul 08, 2005 9:14 am Post subject: |
|
|
| Code: | | int sceKernelDelayThread(unsigned int usecs); |
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. |
|
| Back to top |
|
 |
JJPeerless
Joined: 20 Jun 2005 Posts: 82
|
Posted: Fri Jul 08, 2005 9:17 am Post subject: |
|
|
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.. |
|
| Back to top |
|
 |
beatwho
Joined: 15 Dec 2004 Posts: 28
|
Posted: Fri Jul 08, 2005 9:34 am Post subject: |
|
|
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!
} |
|
| Back to top |
|
 |
JJPeerless
Joined: 20 Jun 2005 Posts: 82
|
Posted: Fri Jul 08, 2005 9:41 am Post subject: |
|
|
hmm yea..it is working..its just my dosomethingcool() i guess isnt..
let me look over my code..and ill repost =) |
|
| Back to top |
|
 |
|