gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > does extern void swiDelay(uint32 duration); work?

#43781 - ErUs - Thu May 26, 2005 7:03 pm

syntax:
swiDelay( 500 ); // would pause for half a second?

is it not implemented yet?

ndslib btw

#43852 - ErUs - Fri May 27, 2005 9:30 am

hehehe 63 views and no reply :o

nvr mind

#43903 - crossraleigh - Fri May 27, 2005 8:43 pm

It's just an SWI call, so there isn't really anything to implement. I don't know if duration is in milliseconds, but whatever the unit, the function should work.

#44231 - Joat - Tue May 31, 2005 4:54 am

It works fine, but units are in terms of iterations of a loop like so:

loop:
sub counter, #1
bne loop

in BIOS ROM.

No idea what the width / wait states are for the two bios ROMs are however.

500 iterations is not more than a few thousand cycles however, even on the really high side, let's say 10k cycles, on the ARM9, so you're talking
around 0.1 ms. It's a relativey easy thing to test / calibrate tho (why I haven't done it yet, dunno...), just run a timer loop for 3 or 4 different delay counts, and repeat a number of times, with cache disabled.

If you want to delay for large times (say a frame or more), using swiDelay is *not* a good way. The CPU is running at full tilt in a busy-wait. It's really only good for short delays while keeping one of the two CPU's out of main RAM to prevent slowing down the other one. Putting the CPU to sleep until the next v-blank is a much better way, and for e.g. half a second delay, do 30 frames that way.
_________________
Joat
http://www.bottledlight.com

#44331 - tepples - Tue May 31, 2005 9:30 pm

Joat wrote:
If you want to delay for large times (say a frame or more), using swiDelay is *not* a good way. The CPU is running at full tilt in a busy-wait. It's really only good for short delays while keeping one of the two CPU's out of main RAM to prevent slowing down the other one.

Wouldn't setting the vcount trigger a few scanlines down and then waiting for a vcount irq be an even better way?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.