home *** CD-ROM | disk | FTP | other *** search
/ Chestnut's Multimedia Mania / MM_MANIA.ISO / graphics / povsrc20 / ibmconf.h < prev    next >
C/C++ Source or Header  |  1993-09-28  |  11KB  |  347 lines

  1. /****************************************************************************
  2. *                   ibmconf.h
  3. *
  4. *  This file contains the IBM-PC specific defines. Rename to config.h when 
  5. *  compiling for IBM-PC.
  6. *
  7. *
  8. *  from Persistence of Vision Raytracer
  9. *  Copyright 1993 Persistence of Vision Team
  10. *---------------------------------------------------------------------------
  11. *  NOTICE: This source code file is provided so that users may experiment
  12. *  with enhancements to POV-Ray and to port the software to platforms other 
  13. *  than those supported by the POV-Ray Team.  There are strict rules under
  14. *  which you are permitted to use this file.  The rules are in the file
  15. *  named POVLEGAL.DOC which should be distributed with this file. If 
  16. *  POVLEGAL.DOC is not available or for more info please contact the POV-Ray
  17. *  Team Coordinator by leaving a message in CompuServe's Graphics Developer's
  18. *  Forum.  The latest version of POV-Ray may be found there as well.
  19. *
  20. * This program is based on the popular DKB raytracer version 2.12.
  21. * DKBTrace was originally written by David K. Buck.
  22. * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
  23. *
  24. *****************************************************************************/
  25.  
  26. /* Below are several defines needed by the generic parts of POV.  You
  27. *   may redefine them as needed in this config.h file.
  28. *
  29. *   The following constants are needed by various POV modules.  Each has
  30. *   a default (shown below) which is will be defined in frame.h if you don't 
  31. *   define them here.
  32. *
  33. *   #define EPSILON 1.0e-10               - a small value used for POLY
  34. *   #define FILE_NAME_LENGTH 150          - default file name length
  35. *   #define HUGE_VAL 1.0e+17              - a really big number
  36. *   #define DBL_FORMAT_STRING "%lf"       - the string to use for scanfs of doubles
  37. *   #define DEFAULT_OUTPUT_FORMAT  'd'    - the default +f format
  38. *   #define RED_RAW_FILE_EXTENSION ".red" - for +fr, this is the extension for the
  39. *                                           red file
  40. *   #define GREEN_RAW_FILE_EXTENSION ".grn"  - ditto for the green file
  41. *   #define BLUE_RAW_FILE_EXTENSION ".blu"   - ditto again for the blue file
  42. *   #define FILENAME_SEPARATOR "/"        - the character that separates names
  43. *                                           in a path.
  44. *   #define CASE_SENSITIVE_DEFAULT 2     - controls case sensitivity in DAT files
  45. *   #define READ_FILE_STRING "rb"        - special binary (raw, uncooked) 
  46. *   #define WRITE_FILE_STRING "wb"         modes of fopen()
  47. *   #define APPEND_FILE_STRING "ab"
  48. *   #define NORMAL '0'                   - machine-specific PaletteOption settings 
  49. *   #define GREY   'G'
  50. *
  51. *   These routines are required by POV to compute trace times.  The defaults 
  52. *   shown below are defined in most versions of C.  You may redefine them if
  53. *   your compiler doesn't support these.  If time is completely unsupported 
  54. *   define them as 0.
  55. *
  56. *   #define START_TIME time(&tstart);     
  57. *   #define STOP_TIME  time(&tstop);
  58. *   #define TIME_ELAPSED difftime (tstop, tstart);
  59. *
  60. *   Note difftime can be replaced with: #define TIME_ELAPSED (tstop - tstart); 
  61. *   in some cases. 
  62. *
  63. *   These are optional routines that POV calls.  You may define them
  64. *   or if undefined they will be defined as empty in frame.h.
  65. *
  66. *   #define STARTUP_POVRAY             - first executable statement of main
  67. *                                           (useful for initialization)
  68. *   #define PRINT_OTHER_CREDITS           - used for people who extend the machine specific modules
  69. *                                           (put your own printf's here)
  70. *   #define TEST_ABORT                    - code to test for ^C or abort
  71. *                                           (called on each pixel)
  72. *   #define FINISH_POVRAY              - last statement before exiting normally
  73. *   #define COOPERATE                    - called for multi-tasking
  74. *  
  75. *   These items are standard on some C compilers.  If they are not defined
  76. *   on your compiler or are called something different you may define your 
  77. *   own or use the defaults supplied in frame.h as shown below.
  78. *
  79. *   #define DBL double                    - floating point precision
  80. *   #define ACOS acos                     - arc cosine of DBL
  81. *   #define SQRT sqrt                     - square root of DBL
  82. *   #define POW pow                       - x to the y power - x, y DBL
  83. *   #define COS cos                       - cosine of DBL
  84. *   #define SIN sin                       - sine of DBL
  85. *   #define labs(x) (long) ((x<0)?-x:x)   - Returns the absolute value of long integer x
  86. *   #define max (x,y) ((x<y)?y:x)         - greater of x and y
  87. *
  88. *   On some systems "sprintf" returns the string rather than the length
  89. *   of the string.  If the string is returned, define the following:
  90. *   #define STRLN(x) strlen(x)
  91. *
  92. *   #define setvbuf(w,x,y,z)              - some systems don't understand setvbuf.
  93. *                                           If not, just define it away - it's
  94. *                                           not critical to the raytracer.  It
  95. *                                           just buffers disk accesses.
  96. *   This macro controls prototyping and is required by POV.  Choose one
  97. *   of the two options below or if left undefined it will default to ANSI 
  98. *   in frame.h
  99. *
  100. *   #define PARAMS (x) x                  - do ANSI prototyping
  101. *   #define PARAMS (x) ()                 - do K&R non-ANSI prototyping
  102. *
  103. *   These allow command line vs non-command line versions and alternate
  104. *   main routines.  Normally they should be undefined.  Define them 1 if needed.
  105. *   #define ALTMAIN 1
  106. *   #define NOCMDLINE 1
  107. ****************************************************/
  108. #ifdef _INTELC32_
  109. #include <i32.h>
  110. #include <float.h>
  111. #endif
  112.  
  113. #ifdef __WATCOMC__            /* Perhaps we should always include */
  114. #include <float.h>            /* FLOAT.H? What does ANSI say?--CWM */
  115. #endif
  116.  
  117. #ifndef GCCDOS
  118. #include <conio.h>
  119. #else
  120. #include <pc.h>
  121. #endif
  122.  
  123. #include <stdarg.h>
  124. #include <stdlib.h>
  125.  
  126. #ifdef MATH_CO
  127. #define DBL long double
  128. #else
  129. #define DBL double
  130. #endif
  131.  
  132. #ifdef MATH_CO
  133. #define DBL_FORMAT_STRING "%Lf"
  134. #else
  135. #define DBL_FORMAT_STRING "%lf"
  136. #endif
  137.  
  138. #define RED_RAW_FILE_EXTENSION   ".r8"  /* PICLAB's "RAW" file format */
  139. #define GREEN_RAW_FILE_EXTENSION ".g8"  /* PICLAB's "RAW" file format */
  140. #define BLUE_RAW_FILE_EXTENSION  ".b8"  /* PICLAB's "RAW" file format */
  141.  
  142. #define FILENAME_SEPARATOR "\\"         /* weird 'ol IBM's like backslashes */
  143.  
  144. #if defined(MATH_CO) && !defined(__TURBOC__)
  145. #define ACOS acosl
  146. #define SQRT sqrtl
  147. #define POW powl
  148. #define COS cosl
  149. #define SIN sinl
  150. #define EPSILON 1.0e-15
  151. #else
  152. #define EPSILON 1.0e-5
  153. #endif
  154.  
  155. #define DEFAULT_OUTPUT_FORMAT   't'
  156.  
  157. #define TEST_ABORT if (Options & EXITENABLE) if (kbhit()) { Stop_Flag = TRUE; getch(); }
  158.  
  159. /* defines for machine-specific PaletteOption settings */
  160. #define NORMAL  '0'
  161. #define GREY    'G'
  162. #define HSV     '0'
  163. #define P_332   '3'
  164. #define HICOLOR 'H'             /* 16 bits/pixel "high" color */
  165. #define FULLCOLOR 'T'           /* 24 bits/pixel "true" color */
  166.  
  167. #ifndef READ_ENV_VAR_BEFORE 
  168. #define READ_ENV_VAR_BEFORE if ((Option_String_Ptr = getenv("POVRAYOPT")) != NULL) read_options(Option_String_Ptr);
  169. #endif
  170. #ifndef READ_ENV_VAR_AFTER
  171. #define READ_ENV_VAR_AFTER     
  172. #endif
  173.  
  174. /**********************************
  175. *    The defines below have nothing to do with the generic part of POV.
  176. *    They are entirely machine specific.  In general do not include them 
  177. *    when porting to other platforms.
  178. ***********************************/
  179.  
  180. #ifdef _INTELC32_
  181.  #define COMPILER_VER ".ibmicb"
  182.  #define CONFIG_MATH _control87(MCW_EM, MCW_EM);
  183.  #define FINISH_POVRAY exit(0);
  184.  #define CDECL _cdecl
  185. #endif
  186.  
  187. #ifdef __ZTC__
  188.  #ifndef __386__
  189.   #define COMPILER_VER ".ibmztc"
  190.  #endif
  191.  #ifdef __386__
  192.   #define COMPILER_VER ".ibmztc386"
  193.  #endif
  194. #endif
  195.  
  196.  
  197. #ifdef GCCDOS
  198. void main(int, char **);
  199. #ifdef MK_FP
  200. #undef MK_FP
  201. #endif
  202. #define MK_FP(seg, ofs) ((void *)(0xE0000000 + ((seg)<<4) + ofs))
  203. #ifdef FP_OFF
  204. #undef FP_OFF
  205. #endif
  206. #define FP_OFF(ptr) (unsigned short)(ptr)
  207. #ifdef FP_SEG                   /* note: this produces a warning at >= /W3 */
  208. #undef FP_SEG
  209. #endif
  210. #define FP_SEG(ptr) (unsigned short)(((unsigned long)ptr >> 16) & 0x0FFF)
  211. #ifndef min
  212. #define min(x,y) ((x)<(y)?(x):(y))
  213. #endif
  214. #ifndef max
  215. #define max(x,y) ((x)>(y)?(x):(y))
  216. #endif
  217.  
  218. #undef  outpw( portid,v )
  219. #undef  outp( portid,v )
  220. #undef  inp( portid )
  221.  
  222. #define outpw( portid,v )  outportw( portid,v )
  223. #define outp( portid,v )  outportb( portid,v )
  224. #define inp( portid ) inportb( portid )
  225.  
  226. #define getch() getkey()
  227. #define _enable()
  228. #define _disable()
  229. #else
  230. #ifdef _INTELC32_
  231. #ifdef MK_FP
  232. #undef MK_FP
  233. #endif
  234. #define MK_FP(seg, ofs) ((void _far *)(((seg)<<4) + ofs))
  235. #ifndef far
  236. #define far _far
  237. #endif
  238. #else
  239.  
  240.  
  241. #ifdef __BORLANDC__
  242.  #define COMPILER_VER ".ibmbc"
  243.  #define IFF_SWITCH_CAST (long)
  244. #endif
  245.  
  246. #ifdef __TURBOC__
  247.  #define CDECL _cdecl
  248. #ifndef __BORLANDC__
  249.  #define COMPILER_VER ".ibmbtc"
  250. #endif
  251. #endif
  252.  
  253. #ifdef __WATCOMC__
  254.  #ifndef __386__
  255.   #define COMPILER_VER ".ibmwat"
  256.  #endif
  257.  #ifdef __386__
  258.   #define COMPILER_VER ".ibmwat386"
  259.  #endif
  260. #endif
  261.  
  262.  
  263. #ifndef __ZTC__
  264. #ifndef __TURBOC__
  265. #ifdef __WATCOMC__
  266.  
  267. #ifdef __386__
  268. #ifdef MK_FP
  269. #undef MK_FP
  270. #endif
  271. #define MK_FP(seg,ofs)  ((void *)(((unsigned long)(seg) << 4) | (unsigned)(ofs)))
  272. #ifdef FP_OFF
  273. #undef FP_OFF
  274. #endif
  275. #define FP_OFF(ptr) (((unsigned short)ptr) & 0x0F)
  276. #ifdef FP_SEG
  277. #undef FP_SEG
  278. #endif
  279. #define FP_SEG(ptr) (unsigned int)((unsigned long)ptr >> 4)
  280. #endif
  281.  
  282. #else
  283.  
  284. void _cdecl main(int, char **); /* so MSC can use FASTCALL's... */
  285. #define main (_cdecl main)
  286. #ifndef MK_FP
  287. #define MK_FP(seg,ofs)  ((void far *)(((unsigned long)(seg) << 16) | (unsigned)(ofs)))
  288. #endif
  289. #ifdef FP_OFF
  290. #undef FP_OFF
  291. #endif
  292. #define FP_OFF(ptr) (unsigned int)(ptr) /* MSC's version doesn't work!?!? */
  293. #ifdef FP_SEG                   /* note: this produces a warning at >= /W3 */
  294. #undef FP_SEG
  295. #endif
  296. #define FP_SEG(ptr) (unsigned int)((unsigned long)ptr >> 16)
  297. #endif
  298.  
  299. #else
  300.  
  301. #define _cdecl  cdecl   /* Turbo-C equivalent function names/keywords */
  302. #define _enable enable
  303. #define _disable disable
  304.  
  305. #undef  outpw( portid,v )
  306. #undef  outp( portid,v )
  307. #undef  inp( portid )
  308.  
  309. #define outpw( portid,v )  outport( portid,v )
  310. #define outp( portid,v )  outportb( portid,v )
  311. #define inp( portid ) inportb( portid )
  312. #endif
  313. #endif
  314. #endif
  315. #endif
  316.  
  317. #ifdef __WATCOMC__
  318. #ifndef COMPILER_VER
  319. #define COMPILER_VER ".ibmwat"
  320. #endif
  321. double sqrt(double x);
  322. #pragma aux sqrt = 0xD9 0xFA parm [8087] value [8087];
  323. double sin(double x);
  324. #pragma aux sin = 0xD9 0xFE parm [8087] value [8087];
  325. double cos(double x);
  326. #pragma aux cos = 0xD9 0xFF parm [8087] value [8087];
  327. double fabs(double x);
  328. #pragma aux fabs = 0xD9 0xE1 parm [8087] value [8087];
  329. #endif
  330.  
  331. #ifdef GCCDOS
  332. double fmod(double, double);
  333. #define COMPILER_VER ".ibmgcc"
  334. #endif
  335.  
  336. #ifndef COMPILER_VER    /* if we haven't figured this out yet... */
  337. #define COMPILER_VER ".ibmmsc"
  338. #endif
  339.  
  340. #define PRINT_CREDITS print_ibm_credits();
  341. #define PRINT_STATS print_ibm_stats();
  342. #define WAIT_FOR_KEYPRESS getch();
  343.  
  344.  
  345. void print_ibm_credits (void);
  346. void print_ibm_stats(void);
  347.