// File : fp.h // Coded by : Scotte // History : Created 19/12/99 14:59:01 // // Modified 12/03/00 Added casts to convert to hword and word types // // Description : Fixed point number stuff // Notes : None #ifndef _FP_H_ #define _FP_H_ #include "gtypes.h" // Function : mSETFP12_4() // Coded by : Scotte // History : Created 19/12/99 15:02:21 // // Description : Set a 16 bit fixed point number (12.4) // // Parameters : n - number to convert to fixed point // // Returns : Fixed point version of n // // Notes : None #define mSETFP12_4(n)\ ((hword)((n)*16)) // Function : mSETFP12_4S() // Coded by : Scotte // History : Created 19/12/99 15:02:21 // // Description : Set a 16 bit fixed point number (12.4) // // Parameters : n - number to convert to fixed point // // Returns : Fixed point version of n // // Notes : Uses a shift instead of multipilcation #define mSETFP12_4S(n)\ ((hword)((n)<<4)) // Function : mGETFP12_4() // Coded by : Scotte // History : Created 19/12/99 15:02:21 // // Description : Get a number from 16 bit fixed point number (12.4) // // Parameters : n - fixed point number to convert // // Returns : Whole part of fixed point number // // Notes : None #define mGETFP12_4(n)\ ((hword)((n)/16)) // Function : mGETFP12_4S() // Coded by : Scotte // History : Created 19/12/99 15:02:21 // // Description : Get a number from 16 bit fixed point number (12.4) // // Parameters : n - number to convert to fixed point // // Returns : Whole part of fixed point number // // Notes : Uses shift instead of division #define mGETFP12_4S(n)\ ((hword)((n)>>4)) // Macro : mSETFP24_8() // Coded by : Scotte // History : Created 12/03/00 11:04:04 // // Description : Set a 32 bit fixed point number (24.8) // // Parameters : n - number to convert to fixed point // // Returns : Fixed point version of n // // Notes : None #define mSETFP24_8(n)\ ((word)((n)*256)) // Macro : mSETFP24_8S() // Coded by : Scotte // History : Created 12/03/00 11:04:04 // // Description : Set a 32 bit fixed point number (24.8) // // Parameters : n - number to convert to fixed point // // Returns : Fixed point version of n // // Notes : Uses a shift instead of multiplication #define mSETFP24_8S(n)\ ((word)((n)<<8)) // Function : mGETFP24_8() // Coded by : Scotte // History : Created 12/03/00 11:05:28 // // Description : Get a number from 16 bit fixed point number (12.4) // // Parameters : n - number to convert to fixed point // // Returns : Whole part of fixed point number // // Notes : None #define mGETFP24_8(n)\ ((word)((n)/256)) // Function : mGETFP24_8S() // Coded by : Scotte // History : Created 12/03/00 11:05:28 // // Description : Get a number from 16 bit fixed point number (12.4) // // Parameters : n - number to convert to fixed point // // Returns : Whole part of fixed point number // // Notes : Uses shift instead of division #define mGETFP24_8S(n)\ ((word)((n)>>8)) #endif