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 

pause function

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



Joined: 20 Jun 2005
Posts: 82

PostPosted: Fri Jul 08, 2005 9:08 am    Post subject: pause function Reply with quote

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
View user's profile Send private message
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Fri Jul 08, 2005 9:14 am    Post subject: Reply with quote

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
View user's profile Send private message
JJPeerless



Joined: 20 Jun 2005
Posts: 82

PostPosted: Fri Jul 08, 2005 9:17 am    Post subject: Reply with quote

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
View user's profile Send private message
beatwho



Joined: 15 Dec 2004
Posts: 28

PostPosted: Fri Jul 08, 2005 9:34 am    Post subject: Reply with quote

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
View user's profile Send private message
JJPeerless



Joined: 20 Jun 2005
Posts: 82

PostPosted: Fri Jul 08, 2005 9:41 am    Post subject: Reply with quote

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

let me look over my code..and ill repost =)
Back to top
View user's profile Send private message
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