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 > Compiling Box2D

#171660 - headspin - Wed Dec 09, 2009 11:32 am

I'm trying to compile Box2D against the latest libnds and I have most of it working apart from code that needs changing from using SIN_bin, COS_bin and TAN_bin to sinLerp, cosLerp and tanLerp.

I'm not entirely sure what format the binary LUT's were in comparison to what the "Lerp" functions return. Can I simply replace XXX_bin[idx] << 4 with xxxLerp(idx) << 4?

Code:
inline Fixed Fixed::cosf() {
   int idx = (((long long)g*(long long)G_1_DIV_PI)>>24)%512;
   if(idx < 0)
      idx += 512;
   return Fixed(RAW, COS_bin[idx] << 4);
}
inline Fixed Fixed::sinf() {
   int idx = (((long long)g*(long long)G_1_DIV_PI)>>24)%512;
   if(idx < 0)
         idx += 512;
   return Fixed(RAW, SIN_bin[idx] << 4);
}
inline Fixed Fixed::tanf() {
   int idx = (((long long)g*(long long)G_1_DIV_PI)>>24)%512;
   if(idx < 0)
            idx += 512;
   return Fixed(RAW, TAN_bin[idx] << 4);
}

_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game

#171664 - Morukutsu - Wed Dec 09, 2009 8:07 pm

Quote:
Can I simply replace XXX_bin[idx] << 4 with xxxLerp(idx) << 4?

Yes :)