usleep

support for the ARM toolchain
Post Reply
ambient_enigma
Posts: 7
Joined: Mon Oct 06, 2008 4:42 pm

usleep

Post by ambient_enigma » Mon Oct 06, 2008 4:48 pm

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?

WinterMute
Site Admin
Posts: 1988
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: usleep

Post by WinterMute » Thu Oct 09, 2008 2:18 pm

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?
Help keep devkitPro toolchains free, Donate today

Personal Blog

ambient_enigma
Posts: 7
Joined: Mon Oct 06, 2008 4:42 pm

Re: usleep

Post by ambient_enigma » Thu Oct 09, 2008 7:28 pm

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.

Samson
Posts: 35
Joined: Mon May 19, 2008 8:05 am

Re: usleep

Post by Samson » Sat Oct 11, 2008 9:25 am

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests