home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Amiga / Jeux / demos / crystalPPC.lha / def.h < prev    next >
C/C++ Source or Header  |  1998-01-15  |  5KB  |  185 lines

  1. #ifndef DEF_H
  2. #define DEF_H
  3.  
  4. //---------------------------------------------------------------
  5. // Test if the makefile correctly defines all the operating
  6. // system (one of the OS_ flags), the compiler (one of the
  7. // COMP_ flags) and the processor (one of the PROC_ flags).
  8. //---------------------------------------------------------------
  9.  
  10. #if !defined(OS_SOLARIS) && !defined(OS_LINUX) && !defined(OS_DOS) && !defined(OS_UNIX) && !defined(OS_MACOS) && !defined(OS_AMIGAOS)
  11. #  error "Please specify the operating system in the makefile! (one of OS_...)"
  12. #endif
  13.  
  14. #if !defined(COMP_GCC) && !defined(COMP_DJGPP) && !defined(COMP_WCC) && !defined(COMP_UNKNOWN) && !defined(COMP_MWERKS)
  15. #  error "Please specify the compiler in the makefile! (one of COMP_...)"
  16. #endif
  17.  
  18. #if !defined(PROC_INTEL) && !defined(PROC_SPARC) && !defined(PROC_UNKNOWN) && !defined(PROC_POWERPC) && !defined(PROC_M68K)
  19. #  error "Please specify the processor in the makefile! (one of PROC_...)"
  20. #endif
  21.  
  22. #if defined(OS_SOLARIS) && !defined(DO_X11)
  23. #  error "You need X Windows support on a Solaris machine!"
  24. #endif
  25.  
  26. #if defined(OS_LINUX) && !defined(DO_X11)
  27. #  error "Currently you need X Windows support on a Linux machine!"
  28. #endif
  29.  
  30. #if defined(OS_UNIX) && !defined(DO_X11)
  31. #  error "Currently you need X Windows support on a Unix machine!"
  32. #endif
  33.  
  34. #if defined(OS_AMIGAOS) && !defined(DO_AMIGAOS)
  35. #  error "Currently you need AmigaOS support on an Amiga machine!"
  36. #endif
  37.  
  38. #if defined(DO_SHM) && !defined(DO_X11)
  39. #  error "The shared memory extension only works in X Windows!"
  40. #endif
  41.  
  42. #if defined(DO_SVGALIB)
  43. #  error "Support for SVGALIB is currently not implemented!"
  44. #endif
  45.  
  46. //---------------------------------------------------------------
  47.  
  48. #include <stdio.h>
  49. #include <stdlib.h>
  50. #include <math.h>
  51. #include <time.h>
  52. #include <signal.h>
  53. #include <errno.h>
  54. #include <string.h>
  55.  
  56. #ifndef TRUE
  57. #define TRUE 1
  58. #endif
  59.  
  60. #ifndef FALSE
  61. #define FALSE 0
  62. #endif
  63.  
  64. #ifndef MIN
  65. #define MIN(a,b) ((a)<(b)?(a):(b))
  66. #endif
  67.  
  68. #ifndef MAX
  69. #define MAX(a,b) ((a)>(b)?(a):(b))
  70. #endif
  71.  
  72. #ifndef ABS
  73. #define ABS(x) ((x)<0?-(x):(x))
  74. #endif
  75.  
  76. #if !defined(SIGN) && !defined(DO_AMIGAOS)
  77. #define SIGN(x) ((x)<0?-1:((x)>0?1:0))
  78. #endif
  79.  
  80. #define EPSILON 0.001           /* Small value */
  81. #define SMALL_EPSILON 0.000001  /* Very small value */
  82. #define INFINITE 999999000      /* Very large number */
  83. #ifndef PI
  84. #define PI 3.14159265358979323  /* You know this number, don't you? */
  85. #endif
  86. #ifndef M_PI
  87. #define M_PI PI
  88. #endif
  89.  
  90. #define DEBUG 0
  91. //vonmir
  92. //#define VERBOSE 1
  93. #define VERBOSE 0
  94. //
  95. #if DEBUG
  96. #define PRINTF(x) dprintf##x
  97. #else
  98. #define PRINTF(x)
  99. #endif
  100.  
  101.  
  102. #if VERBOSE
  103. #define MSG(x) dprintf##x
  104. #else
  105. #define MSG(x)
  106. #endif
  107.  
  108. #ifdef PROC_INTEL
  109. /*
  110. //#pragma aux RoundToInt=\
  111. //        "fistp DWORD [eax]"\
  112. //        parm nomemory [eax] [8087]\
  113. //        modify exact [8087];
  114. */
  115.  
  116. // This is 'stolen' from someone (I don't remember who anymore). It
  117. // is a nice and fast way to convert a floating point number to int
  118. // (only works on a i386 type processor).
  119. // It is equivalent to 'i=(int)(f+.5)'. 
  120. #define FIST_MAGIC ((((65536.0 * 65536.0 * 16)+(65536.0 * 0.5))* 65536.0))
  121. inline long QuickRound (float inval)
  122. {
  123.   double dtemp = FIST_MAGIC + inval;
  124.   return ((*(long *)&dtemp) - 0x80000000);
  125. }
  126.  
  127. inline long QuickInt (float inval)
  128. {
  129.   double dtemp = FIST_MAGIC + (inval-.4999);
  130.   return ((*(long *)&dtemp) - 0x80000000);
  131. }
  132.  
  133. // This is my own invention derived from the previous one. This converts
  134. // a floating point number to a 16.16 fixed point integer. It is
  135. // equivalent to 'i=(int)(f*65536.)'.
  136. #define FIST_MAGIC2 ((((65536.0 * 16)+(0.5))* 65536.0))
  137. inline long QuickInt16 (float inval)
  138. {
  139.   double dtemp = FIST_MAGIC2 + inval;
  140.   return ((*(long *)&dtemp) - 0x80000000);
  141. }
  142. #endif
  143.  
  144. #ifdef PROC_M68K
  145.  
  146. #define FIST_MAGIC ((((65536.0 * 65536.0 * 16)+(65536.0 * 0.5))* 65536.0))
  147. inline long QuickRound (float inval)
  148. {
  149.   double dtemp = FIST_MAGIC + inval;
  150.   return (*(((long *)&dtemp) + 1)) - 0x80000000;
  151. }
  152.     
  153. inline long QuickInt (float inval)
  154. {
  155.   double dtemp = FIST_MAGIC + (inval-.4999);
  156.   return (*(((long *)&dtemp) + 1)) - 0x80000000;
  157. }
  158.         
  159. #define FIST_MAGIC2 ((((65536.0 * 16)+(0.5))* 65536.0))
  160. inline long QuickInt16 (float inval)
  161. {
  162.   double dtemp = FIST_MAGIC2 + inval;
  163.   return (*(((long *)&dtemp) + 1)) - 0x80000000;
  164. }
  165. #endif
  166.             
  167. #if defined(PROC_INTEL) || defined(PROC_M68K)
  168. #  define QRound(x) QuickRound(x)
  169. #  define QInt(x) QuickInt(x)
  170. #  define QInt16(x) QuickInt16(x)
  171. #else
  172. #  define QRound(x) ((int)((x)+.5))
  173. #  define QInt(x) ((int)(x))
  174. #  define QInt16(x) ((int)((x)*65536.))
  175. #endif
  176.  
  177. #define ASPECT FRAME_HEIGHT
  178.  
  179. //#define SMALL_Z .01
  180. #define SMALL_Z .1
  181.  
  182. #define USE_OCCLUSION 0 // Experimental feature, will not work in this version.
  183.  
  184. #endif /*DEF_H*/
  185.