fork/training-mode-ce
git clone https://git.julia.blue/fork/training-mode-ce
4578fd4
techchase-camera
1#ifndef MEX_H_INLINE 2#define MEX_H_INLINE 3 4#include "structs.h" 5#include "fighter.h" 6#include "obj.h" 7#include "mex.h" 8#include "datatypes.h" 9#include "gx.h" 10#include "hsd.h" 11#include "math.h" 12#include "useful.h" 13#include "scene.h" 14#include "preload.h" 15 16/*** Macros ***/ 17#define countof (A ) (sizeof(A)/sizeof(*(A))) 18 19/*** Functions ***/ 20 21static inline int min (int a ,int b ) { 22return a < b ?a :b ; 23} 24 25static inline int max (int a ,int b ) { 26return a > b ?a :b ; 27} 28 29static inline float lerp (float start ,float end ,float t ) 30{ 31// clamp 32if (t < 0 ) 33t = 0 ; 34else if (t > 1 ) 35t = 1 ; 36 37return start + t * (end - start ); 38} 39 40static inline int abs (int x ) 41{ 42if (x < 0 ) 43return - x ; 44else 45return x ; 46} 47 48static float ceil (float x ) 49{ 50if (x != x )return x ;// NaN 51if (x >=2147483647.0f || x <=-2147483648.0f )return x ;// Too large for int 52 53int trunc = (int )x ; 54 55if (x == (float )trunc ) 56return x ; 57if (x > 0 ) 58return (float )(trunc + 1 ); 59return (float )trunc ; 60} 61 62static void PRIM_DRAW (float x ,float y ,float z ,u32 color ) 63{ 64gx_pipe -> d .F32 = x ; 65gx_pipe -> d .F32 = y ; 66gx_pipe -> d .F32 = z ; 67gx_pipe -> d .U32 = color ; 68} 69 70static HSD_Pad * PadGetMaster (int player_index ) 71{ 72return & stc_master_pads -> pad [player_index ]; 73} 74static HSD_Pad * PadGetEngine (int player_index ) 75{ 76return & stc_engine_pads -> pad [player_index ]; 77} 78static PADStatus * PadGetRaw (int player_index ) 79{ 80PadLibData * p = stc_padlibdata ; 81u8 index = (p -> qread + p -> qnum - 1 ) %p -> qnum ; 82return & p -> queue [index ].stat [player_index ]; 83} 84 85static float Math_Vec2Distance (Vec2 * a ,Vec2 * b ) 86{ 87return sqrtf (squaref (a -> X - b -> X )+ squaref (a -> Y - b -> Y )); 88} 89 90static float Math_Vec3Distance (Vec3 * a ,Vec3 * b ) 91{ 92return sqrtf (squaref (a -> X - b -> X )+ squaref (a -> Y - b -> Y )+ squaref (a -> Z - b -> Z )); 93} 94 95static inline float fmin (float a ,float b ) 96{ 97return (((a )< (b )) ? (a ) : (b )); 98} 99 100static inline float fmax (float a ,float b ) 101{ 102return (((a )> (b )) ? (a ) : (b )); 103} 104 105static inline float fclamp (float n ,float min ,float max ) { 106return fmin (max ,fmax (min ,n )); 107} 108 109static inline float smooth_lerp (float time ,float start ,float end ) { 110float delta = time * time * (3.0f - 2.0f * time ); 111return delta * (end - start )+ start ; 112} 113 114#endif