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 > c/c++ functions on DS

#51964 - lobster - Thu Aug 25, 2005 3:32 am

what c/c++ functions are available on DS? like if i include math.h will i be able to use sqrt, sin, cos, tan, asin, acos, and atan?

#51968 - LOst? - Thu Aug 25, 2005 4:06 am

lobster wrote:
what c/c++ functions are available on DS? like if i include math.h will i be able to use sqrt, sin, cos, tan, asin, acos, and atan?

For math, NDSlib has a few functions you can use. If you want to use sine, make a LUT on your computer first. Use fixed point math. NDS is built for use with 1.19.12 fixed point so most math functions require that format.
_________________
Exceptions are fun

#52087 - floatstarpx - Fri Aug 26, 2005 12:15 pm

LOst? wrote:
lobster wrote:
what c/c++ functions are available on DS? like if i include math.h will i be able to use sqrt, sin, cos, tan, asin, acos, and atan?

For math, NDSlib has a few functions you can use. If you want to use sine, make a LUT on your computer first. Use fixed point math. NDS is built for use with 1.19.12 fixed point so most math functions require that format.


doesn't NDSlib have sin & cos LUTs already? ranged 0-512 i think.

#52128 - lobster - Sat Aug 27, 2005 12:57 am

what is a LUT and how do i make/use it?

#52131 - tepples - Sat Aug 27, 2005 1:27 am

LUT == lookup table

Make a C program that 1. computes 4096*sin(2*Pi*(x/512)) for x=0 to 511 and then 2. outputs the C source code for an array of those values. Then include that array in your project, along with a function to look up sin() and cos() values in that table.

To see an example, look things related to 'hgrcos' in the source code of Tetanus On Drugs.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.