Page 1 of 1
usleep
Posted: Mon Oct 06, 2008 4:48 pm
by ambient_enigma
I need help getting usleep to work with devkitARM. I include unistd.h, but I get the error
"undefined reference to 'usleep'". Are there any other functions that perform a similar
function?
Re: usleep
Posted: Thu Oct 09, 2008 2:18 pm
by WinterMute
That really depends on what you want to use usleep for.
devkitARM is a bare metal toolchain with no threading so there are very few situations where usleep makes sense. Which platform are you writing code for and what do you need the delay for?
Re: usleep
Posted: Thu Oct 09, 2008 7:28 pm
by ambient_enigma
I am writing code for the NDS. I just need a simple function to slow down the update of my
sprite, otherwise it moves too fast. Currently I am using an extra swiWaitForVBlank before I
update my sprite to get the desired effect.
Re: usleep
Posted: Sat Oct 11, 2008 9:25 am
by Samson
On a Game Boy Colour game (years ago) I used fractional positions. The sprite structure then stored the speed in pixel-per-frame, and by using a value lower than one I could make it move slower.
Obviously I didn't have floating point, but I wrote everything with 16.8 bit fixed point. So when updating the sprites I just used the upper 16 bits, and when updating positions I handled the overflow from the 8 bit fraction to the 16 bit integer.