// // Created by Wouter Groeneveld on 08/07/20. // #ifndef GBA_BITMAP_ENGINE_PROJECT_MATH_H #define GBA_BITMAP_ENGINE_PROJECT_MATH_H #include #ifdef CODE_COMPILED_AS_PART_OF_TEST #include #else #include #endif #include #include // fixed point math things that were missing from TONC extern FIXED HALF; extern FIXED ONE; extern FIXED TWO; #define SIN_LUT_MAX ((512 << 6) * 2) // 65536, FFFFh range #define FIX12_SHIFT 12 #define FIX12_SCALE ( 1<> 4; } INLINE FIXED fxsin(FIXED fxrad) { if(fxrad == 0) return 0; FIXED theta = fxrad2lut(fxrad); FIXED sin = lu_sin(theta); return fx12Tofx8(sin); } INLINE FIXED fxcos(FIXED fxrad) { if(fxrad == 0) return ONE; FIXED theta = fxrad2lut(fxrad); FIXED cos = lu_cos(theta); return fx12Tofx8(cos); } INLINE FIXED fxtan(FIXED fxrad) { if(fxrad == 0) return 0; FIXED theta = fxrad2lut(fxrad); FIXED sin = lu_sin(theta); FIXED cos = lu_cos(theta); return fx12Tofx8(fx12div(sin, cos)); } #endif //GBA_BITMAP_ENGINE_PROJECT_MATH_H