PDA

View Full Version : Timer


IFeelYourPain
01-17-2009, 10:43 PM
I'm looking for some way so that I can run a function every half second.

ralph l mayo
01-19-2009, 12:47 AM
Language? Platform?

IFeelYourPain
01-19-2009, 01:27 AM
Language? Platform?

C programming for PSP.

ralph l mayo
01-19-2009, 02:03 AM
It is platform-dependent and I don't know anything about PSP development, but assuming microsleep() or millisleep() don't show up in the SDK you'll need to find a way to query the hardware clock that returns the time with enough granularity to grab it, loop until it's half a second later, and then return.

This is all complicated by threading, which is also platform-dependent... you probably don't want your sleep function to just burn the CPU for that half-second loop so you'll have to figure out how to yield between testing times.

edit: int sceKernelDelayThread ( SceUInt delay ) (http://psp.jim.sh/pspsdk-doc/group__ThreadMan.html#g76893a433dee550c0b7be52d807e62a8) if you're using this library

IFeelYourPain
01-19-2009, 07:33 AM
It is platform-dependent and I don't know anything about PSP development, but assuming microsleep() or millisleep() don't show up in the SDK you'll need to find a way to query the hardware clock that returns the time with enough granularity to grab it, loop until it's half a second later, and then return.

This is all complicated by threading, which is also platform-dependent... you probably don't want your sleep function to just burn the CPU for that half-second loop so you'll have to figure out how to yield between testing times.

edit: int sceKernelDelayThread ( SceUInt delay ) (http://psp.jim.sh/pspsdk-doc/group__ThreadMan.html#g76893a433dee550c0b7be52d807e62a8) if you're using this library
That would be the correct library.