home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / ste / wave_20 / fixed.h < prev    next >
Text File  |  1992-11-25  |  1KB  |  37 lines

  1. /*
  2.   These definitions are the implementation of
  3.   a fixed point math system. This system has the
  4.   accurracy to support ALL ST and TT resolutions.
  5.  
  6.   This system allows three times as many floating point
  7.   operations using Mark Williams C on an ST.
  8.  
  9.   Because of improvements in the integer math capabilities of
  10.   the 68010, 020, 030, and 040, these functions will still 
  11.   provide an improvement over the 68882 co-processor on the TT,
  12.   providing the compiler used takes advantage of these improvements.
  13.  
  14.   This system uses the low eight bits as the fraction, the
  15.   middle sixteen bits as the whole number, and the eight upper
  16.   most bits are scratch bits used during multiplies and
  17.   divides.
  18. */
  19.  
  20. /*
  21.   Define the type
  22. */
  23. typedef long Fixed ;
  24.  
  25. /*
  26.   Define the multiplicative dyadic operators
  27. */
  28. #define fmult(a, b) ((a * b) >> 8)
  29. #define fdiv(a, b)  ((a << 8) / b)
  30.  
  31. /*
  32.   convert between floating and fixed point
  33. */
  34. #define fl_fp(a)      ((long)(a * 256.0))
  35. #define fp_fl(a)      (((float)a) / 256.0)
  36. #define fp_long(a)    (a >> 8)
  37.