How To Wait/Pause?

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
jgrimm
Posts: 27
Joined: Sun Nov 29, 2009 2:00 am

How To Wait/Pause?

Post by jgrimm »

how do you pause program execution for an amount of time? what i need to do is like the BASIC sleep command, so pause 5 miliseconds is SLEEP 5. how do i do this in ps2sdk? thx
cheriff
Regular
Posts: 258
Joined: Wed Jun 23, 2004 5:35 pm
Location: Sydney.au

Post by cheriff »

ps2sdk contains a basic libc. The parts it implements, should be very similar to any other libc:

Code: Select all

NAME
     sleep -- suspend thread execution for an interval measured in seconds

LIBRARY
     Standard C Library (libc, -lc)

SYNOPSIS
     #include <unistd.h>

     unsigned int
     sleep&#40;unsigned int seconds&#41;;
and, lo and behold:

Code: Select all

[email protected]&#58;~/code/$ grep -R sleep ps2sdk/ee/libc/
ps2sdk/ee/libc/include/unistd.h&#58;unsigned int sleep&#40;unsigned int seconds&#41;;
Damn, I need a decent signature!
ragnarok2040
Posts: 202
Joined: Wed Aug 09, 2006 1:00 am

Post by ragnarok2040 »

There currently isn't anything in ps2sdk that's millisecond accurate except for clock(). You can just use CLOCKS_PER_SEC/1000 to calculate the amount of ticks per millisecond, or just define it as 576 using a macro, and compare to clock() until the period of time has passed.
jgrimm
Posts: 27
Joined: Sun Nov 29, 2009 2:00 am

Post by jgrimm »

ok thx guys it doesnt need to be to be perfect i just need somthing that counts time :)
Post Reply