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 > Divide? Floating point?

#46691 - LOst? - Wed Jun 29, 2005 4:20 am

Just want to know if you can use divide faster on the DS than the GBA, or if it is the same slow divide?

Also, how do you manage 3D coordinates? With floating point? Or fixed point?

What is consolePrintf? Who made it?

Who made libnds?

#46692 - rize - Wed Jun 29, 2005 4:42 am

it's all fixed point, but there is a hardware divide and square root unit

you load the parameter registers, set the control register, check the "done" bit and retrieve the result when its finished. there are ndslib functions that use the hardware for divide and sqrt and you can look them up in nds/arm9/math.h to see how they work

#46694 - gladius - Wed Jun 29, 2005 4:42 am

There is a hardware divide unit built into the DS, so they are much faster than on the DS.

And you should use fixed point for your 3d engine. Floating point is just too slow without a hardware unit to work with it.

#46697 - tepples - Wed Jun 29, 2005 5:59 am

gladius wrote:
There is a hardware divide unit built into the DS, so they are much faster than on the DS.

But does the runtime library (e.g. __divsi3()) use the divide HW automatically for those combinations of data types where it makes sense?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#46702 - LOst? - Wed Jun 29, 2005 6:19 am

Thank you for your kind replies!

I have finally got my DevkitPro environment up, and i can now run my DS demos on the real hardware for the first time. I am very satisfied!

#46710 - rize - Wed Jun 29, 2005 7:31 am

be advised that ( last I checked) dualis doesn't produce accurate results for f32 hardware divide and sqrt. If you get weird results the emulator may be to blame.

#46751 - crossraleigh - Thu Jun 30, 2005 3:56 am

tepples wrote:
But does the runtime library (e.g. __divsi3()) use the divide HW automatically for those combinations of data types where it makes sense?

As of a couple weeks ago, both libnds and libgba use SWI calls for division. I thought that libnds would be changed to use hardware, but glancing at the current CVS it doesn't look like it has.

In response to the OP:

Like gladius said, the DS doesn't have an FPU; use fixed point. Specifically, divf32() and sqrtf32() give access to the hardware's 20:12 fixed point functions that rize described.

Joat and dovoto made and maintain ndslib, so I imagine that one of them made consolePrintf. WinterMute integrates their changes into libnds since apparently Joat won't agree to move ndslib to the devkitPro repository.
_________________
My world is black and white, but if I blink fast enough, I see it in grayscale.