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