home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1995 November / PCWK1195.iso / inne / dos / fraktale / frasr192.exe / FRACTINT.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-08  |  25.5 KB  |  895 lines

  1. /* FRACTINT.H - common structures and values for the FRACTINT routines */
  2.  
  3. #ifndef FRACTINT_H
  4. #define FRACTINT_H
  5.  
  6. #include <math.h>
  7. #ifndef PORT_H
  8. #include "port.h"
  9. #endif
  10. #ifndef BIGNUM_DEFINED
  11. #include "bignum.h"
  12. #include "bigflt.h"
  13. #endif
  14.  
  15. typedef BYTE BOOLEAN;
  16.  
  17. #ifndef C6
  18. #define _fastcall    /* _fastcall is a Microsoft C6.00 extension */
  19. #endif
  20.  
  21. #ifndef XFRACT
  22. typedef int SEGTYPE;
  23. typedef unsigned USEGTYPE;
  24. #ifdef __TURBOC__
  25. #   define _bios_printer(a,b,c)   biosprint((a),(c),(b))
  26. #   define _bios_serialcom(a,b,c) bioscom((a),(c),(b))
  27. #else
  28. #ifndef __WATCOMC__
  29. #ifndef MK_FP
  30. #   define MK_FP(seg,off) (VOIDFARPTR )( (((long)(seg))<<16) | \
  31.                                           ((unsigned)(off)) )
  32. #endif
  33. #endif
  34. #endif
  35. #else
  36. typedef char * SEGTYPE;
  37. typedef char * USEGTYPE;
  38. #   define MK_FP(seg,off) (VOIDFARPTR )(seg+off)
  39. #include <sys/types.h> /* need size_t */
  40. #endif
  41.  
  42.  
  43. #ifndef XFRACT
  44. #define clock_ticks() clock()
  45. #endif
  46.  
  47. #ifdef XFRACT
  48. #define _fstrcpy(to,from) strcpy(to,from)
  49. #define _fmemmove(a,b,c) (bn_t)memmove(a,b,c)
  50. #define _fmemset(a,b,c) (bn_t)memset(a,b,c)
  51. #define _fmemcpy(a,b,c) (bn_t)memcpy(a,b,c)
  52. #define difftime(now,then) ((now)-(then))
  53. #endif
  54.  
  55. /* for gotos in former FRACTINT.C pieces */
  56. #define RESTART           1
  57. #define IMAGESTART        2
  58. #define RESTORESTART      3
  59. #define CONTINUE          4
  60.  
  61. /* these are used to declare arrays for file names */
  62. #define FILE_MAX_PATH  80       /* max length of path+filename  */
  63. #define FILE_MAX_DIR   80       /* max length of directory name */
  64. #define FILE_MAX_DRIVE  3       /* max length of drive letter   */
  65. #define FILE_MAX_FNAME  9       /* max length of filename       */
  66. #define FILE_MAX_EXT    5       /* max length of extension      */
  67.  
  68. #define MAXPARAMS 10        /* maximum number of parameters */
  69. #define MAXPIXELS 2048        /* Maximum pixel count across/down the screen */
  70. #define DEFAULTASPECT ((float)0.75)/* Assumed overall screen dimensions, y/x  */
  71. #define DEFAULTASPECTDRIFT ((float)0.02) /* drift of < 2% is forced to 0% */
  72.  
  73. struct videoinfo {        /* All we need to know about a Video Adapter */
  74.     char    name[26];    /* Adapter name (IBM EGA, etc)        */
  75.     char    comment[26];    /* Comments (UNTESTED, etc)        */
  76.     int    keynum;     /* key number used to invoked this mode */
  77.                 /* 2-10 = F2-10, 11-40 = S,C,A{F1-F10}    */
  78.     int    videomodeax;    /* begin with INT 10H, AX=(this)    */
  79.     int    videomodebx;    /*        ...and BX=(this)    */
  80.     int    videomodecx;    /*        ...and CX=(this)    */
  81.     int    videomodedx;    /*        ...and DX=(this)    */
  82.                 /* NOTE:  IF AX==BX==CX==0, SEE BELOW    */
  83.     int    dotmode;    /* video access method used by asm code */
  84.                 /*    1 == BIOS 10H, AH=12,13 (SLOW)    */
  85.                 /*    2 == access like EGA/VGA    */
  86.                 /*    3 == access like MCGA        */
  87.                 /*    4 == Tseng-like  SuperVGA*256    */
  88.                 /*    5 == P'dise-like SuperVGA*256   */
  89.                 /*    6 == Vega-like     SuperVGA*256    */
  90.                 /*    7 == "Tweaked" IBM-VGA ...*256  */
  91.                 /*    8 == "Tweaked" SuperVGA ...*256 */
  92.                 /*    9 == Targa Format        */
  93.                 /*    10 = Hercules            */
  94.                 /*    11 = "disk video" (no screen)   */
  95.                 /*    12 = 8514/A            */
  96.                 /*    13 = CGA 320x200x4, 640x200x2    */
  97.                 /*    14 = Tandy 1000         */
  98.                 /*    15 = TRIDENT  SuperVGA*256    */
  99.                 /*    16 = Chips&Tech SuperVGA*256    */
  100.     int    xdots;        /* number of dots across the screen    */
  101.     int    ydots;        /* number of dots down the screen    */
  102.     int    colors;     /* number of colors available        */
  103.     };
  104.  
  105. typedef struct videoinfo far        VIDEOINFO;
  106. #define INFO_ID     "Fractal"
  107. typedef    struct fractal_info FRACTAL_INFO;
  108.  
  109. /*
  110.  * Note: because non-MSDOS machines store structures differently, we have
  111.  * to do special processing of the fractal_info structure in loadfile.c.
  112.  * Make sure changes to the structure here get reflected there.
  113.  */
  114. #ifndef XFRACT
  115. #define FRACTAL_INFO_SIZE sizeof(FRACTAL_INFO)
  116. #else
  117. /* This value should be the MSDOS size, not the Unix size. */
  118. #define FRACTAL_INFO_SIZE 502
  119. #endif
  120.  
  121. struct fractal_info        /*  for saving data in GIF file     */
  122. {
  123.     char  info_id[8];        /* Unique identifier for info block */
  124.     short iterationsold;    /* Pre version 18.24 */
  125.     short fractal_type;        /* 0=Mandelbrot 1=Julia 2= ... */
  126.     double xmin;
  127.     double xmax;
  128.     double ymin;
  129.     double ymax;
  130.     double creal;
  131.     double cimag;
  132.     short videomodeax;
  133.     short videomodebx;
  134.     short videomodecx;
  135.     short videomodedx;
  136.     short dotmode;
  137.     short xdots;
  138.     short ydots;
  139.     short colors;
  140.     short version;        /* used to be 'future[0]' */
  141.     float parm3;
  142.     float parm4;
  143.     float potential[3];
  144.     short rseed;
  145.     short rflag;
  146.     short biomorph;
  147.     short inside;
  148.     short logmap;
  149.     float invert[3];
  150.     short decomp[2];
  151.     short symmetry;
  152.             /* version 2 stuff */
  153.     short init3d[16];
  154.     short previewfactor;
  155.     short xtrans;
  156.     short ytrans;
  157.     short red_crop_left;
  158.     short red_crop_right;
  159.     short blue_crop_left;
  160.     short blue_crop_right;
  161.     short red_bright;
  162.     short blue_bright;
  163.     short xadjust;
  164.     short eyeseparation;
  165.     short glassestype;
  166.             /* version 3 stuff, release 13 */
  167.     short outside;
  168.             /* version 4 stuff, release 14 */
  169.     double x3rd;      /* 3rd corner */
  170.     double y3rd;
  171.     char stdcalcmode;      /* 1/2/g/b */
  172.     char useinitorbit;      /* init Mandelbrot orbit flag */
  173.     short calc_status;      /* resumable, finished, etc */
  174.     long tot_extend_len;  /* total length of extension blocks in .gif file */
  175.     short distest;
  176.     short floatflag;
  177.     short bailoutold;
  178.     long calctime;
  179.     BYTE trigndx[4];      /* which trig functions selected */
  180.     short finattract;
  181.     double initorbit[2];  /* init Mandelbrot orbit values */
  182.     short periodicity;      /* periodicity checking */
  183.             /* version 5 stuff, release 15 */
  184.     short pot16bit;      /* save 16 bit continuous potential info */
  185.     float faspectratio;   /* finalaspectratio, y/x */
  186.     short system;       /* 0 for dos, 1 for windows */
  187.     short release;      /* release number, with 2 decimals implied */
  188.     short flag3d;       /* stored only for now, for future use */
  189.     short transparent[2];
  190.     short ambient;
  191.     short haze;
  192.     short randomize;
  193.             /* version 6 stuff, release 15.x */
  194.     short rotate_lo;
  195.     short rotate_hi;
  196.     short distestwidth;
  197.             /* version 7 stuff, release 16 */
  198.     double dparm3;
  199.     double dparm4;
  200.             /* version 8 stuff, release 17 */
  201.     short fillcolor;
  202.             /* version 9 stuff, release 18 */
  203.     double mxmaxfp;
  204.     double mxminfp;
  205.     double mymaxfp;
  206.     double myminfp;
  207.     short zdots;
  208.     float originfp;
  209.     float depthfp;
  210.     float heightfp;
  211.     float widthfp;
  212.     float distfp;
  213.     float eyesfp;
  214.     short orbittype;
  215.     short juli3Dmode;
  216.     short maxfn;
  217.     short inversejulia;
  218.     double dparm5;
  219.     double dparm6;
  220.     double dparm7;
  221.     double dparm8;
  222.     double dparm9;
  223.     double dparm10;
  224.             /* version 10 stuff, release 19 */
  225.     long bailout;
  226.     short bailoutest;
  227.     long iterations;
  228.     short bf_math;
  229.     short bflength;
  230.     short yadjust;        /* yikes! we left this out ages ago! */
  231.     short old_demm_colors;
  232.     short future[42];      /* for stuff we haven't thought of yet */
  233. };
  234.  
  235. #define ITEMNAMELEN 18     /* max length of names in .frm/.l/.ifs/.fc */
  236. struct history_info    
  237. {
  238.     short fractal_type;
  239.     double xmin;
  240.     double xmax;
  241.     double ymin;
  242.     double ymax;
  243.     double creal;
  244.     double cimag;
  245.     double potential[3];
  246.     short rseed;
  247.     short rflag;
  248.     short biomorph;
  249.     short inside;
  250.     short logmap;
  251.     double invert[3];
  252.     short decomp;
  253.     short symmetry;
  254.     short init3d[16];
  255.     short previewfactor;
  256.     short xtrans;
  257.     short ytrans;
  258.     short red_crop_left;
  259.     short red_crop_right;
  260.     short blue_crop_left;
  261.     short blue_crop_right;
  262.     short red_bright;
  263.     short blue_bright;
  264.     short xadjust;
  265.     short eyeseparation;
  266.     short glassestype;
  267.     short outside;
  268.     double x3rd;      
  269.     double y3rd;
  270.     char stdcalcmode;
  271.     char three_pass;
  272.     char useinitorbit;      
  273.     short distest;
  274.     short bailoutold;
  275.     BYTE trigndx[4];      
  276.     short finattract;
  277.     double initorbit[2];  
  278.     short periodicity;      
  279.     short pot16bit;      
  280.     short release;
  281.     short save_release;
  282.     short flag3d; 
  283.     short transparent[2];
  284.     short ambient;
  285.     short haze;
  286.     short randomize;
  287.     short rotate_lo;
  288.     short rotate_hi;
  289.     short distestwidth;
  290.     double dparm3;
  291.     double dparm4;
  292.     short fillcolor;
  293.     double mxmaxfp;
  294.     double mxminfp;
  295.     double mymaxfp;
  296.     double myminfp;
  297.     short zdots;
  298.     float originfp;
  299.     float depthfp;
  300.     float heightfp;
  301.     float widthfp;
  302.     float distfp;
  303.     float eyesfp;
  304.     short orbittype;
  305.     short juli3Dmode;
  306.     char  maxfn;
  307.     short major_method;
  308.     short minor_method;
  309.     double dparm5;
  310.     double dparm6;
  311.     double dparm7;
  312.     double dparm8;
  313.     double dparm9;
  314.     double dparm10;
  315.     long bailout;
  316.     short bailoutest;
  317.     long iterations;
  318.     short bf_math;
  319.     short bflength;
  320.     short yadjust;
  321.     short old_demm_colors;
  322.     char filename[80];
  323.     char itemname[ITEMNAMELEN+1];
  324.     unsigned char dac[256][3];
  325. };
  326.  
  327. typedef struct history_info HISTORY;
  328.  
  329. #define MAXVIDEOMODES 300    /* maximum entries in fractint.cfg      */
  330. #ifndef XFRACT
  331. #define MAXVIDEOTABLE 40        /* size of the resident video modes table */
  332. #else
  333. #define MAXVIDEOTABLE 2         /* size of the resident video modes table */
  334. #endif
  335.  
  336. #define AUTOINVERT -123456.789
  337. #define ENDVID 22400   /* video table uses extra seg up to here */
  338.  
  339. #define N_ATTR 8            /* max number of attractors    */
  340.  
  341. extern    long     l_at_rad;    /* finite attractor radius  */
  342. extern    double     f_at_rad;    /* finite attractor radius  */
  343.  
  344. #define NUMIFS      64     /* number of ifs functions in ifs array */
  345. #define IFSPARM    7     /* number of ifs parameters */
  346. #define IFS3DPARM 13     /* number of ifs 3D parameters */
  347.  
  348. struct moreparams
  349. {
  350.    int      type;                        /* index in fractalname of the fractal */
  351.    char     *param[MAXPARAMS-4];    /* name of the parameters */
  352.    double   paramvalue[MAXPARAMS-4];     /* default parameter values */
  353. };
  354.  
  355. typedef struct moreparams far       MOREPARAMS;
  356.  
  357. struct fractalspecificstuff
  358. {
  359.    char  *name;             /* name of the fractal */
  360.                     /* (leading "*" supresses name display) */ 
  361.    char  *param[4];            /* name of the parameters */
  362.    double paramvalue[4];         /* default parameter values */
  363.    int     helptext;            /* helpdefs.h HT_xxxx, -1 for none */
  364.    int     helpformula;            /* helpdefs.h HF_xxxx, -1 for none */
  365.    unsigned flags;             /* constraints, bits defined below */
  366.    float xmin;                /* default XMIN corner */
  367.    float xmax;                /* default XMAX corner */
  368.    float ymin;                /* default YMIN corner */
  369.    float ymax;                /* default YMAX corner */
  370.    int     isinteger;            /* 1 if integerfractal, 0 otherwise */
  371.    int     tojulia;            /* mandel-to-julia switch */
  372.    int     tomandel;            /* julia-to-mandel switch */
  373.    int     tofloat;            /* integer-to-floating switch */
  374.    int     symmetry;            /* applicable symmetry logic
  375.                        0 = no symmetry
  376.                       -1 = y-axis symmetry (If No Params)
  377.                        1 = y-axis symmetry
  378.                       -2 = x-axis symmetry (No Parms)
  379.                        2 = x-axis symmetry
  380.                       -3 = y-axis AND x-axis (No Parms)
  381.                        3 = y-axis AND x-axis symmetry
  382.                       -4 = polar symmetry (No Parms)
  383.                        4 = polar symmetry
  384.                        5 = PI (sin/cos) symmetry
  385.                        6 = NEWTON (power) symmetry
  386.                                 */
  387. #ifdef XFRACT
  388.    int (*orbitcalc)();    /* function that calculates one orbit */
  389. #else
  390.    int (*orbitcalc)(void);    /* function that calculates one orbit */
  391. #endif
  392.    int (*per_pixel)(void);    /* once-per-pixel init */
  393.    int (*per_image)(void);    /* once-per-image setup */
  394.    int (*calctype)(void);    /* name of main fractal function */
  395.    int orbit_bailout;        /* usual bailout value for orbit calc */
  396. };
  397.  
  398. struct alternatemathstuff
  399. {
  400.    int type;            /* index in fractalname of the fractal */
  401.    int math;             /* kind of math used */
  402. #ifdef XFRACT
  403.    int (*orbitcalc)();    /* function that calculates one orbit */
  404. #else
  405.    int (*orbitcalc)(void);    /* function that calculates one orbit */
  406. #endif
  407.    int (*per_pixel)(void);    /* once-per-pixel init */
  408.    int (*per_image)(void);    /* once-per-image setup */
  409. };
  410.  
  411. typedef struct alternatemathstuff ALTERNATE;
  412.  
  413. /* defines for symmetry */
  414. #define  NOSYM        0
  415. #define  XAXIS_NOPARM  -1
  416. #define  XAXIS        1
  417. #define  YAXIS_NOPARM  -2
  418. #define  YAXIS        2
  419. #define  XYAXIS_NOPARM -3
  420. #define  XYAXIS     3
  421. #define  ORIGIN_NOPARM -4
  422. #define  ORIGIN     4
  423. #define  PI_SYM_NOPARM -5
  424. #define  PI_SYM     5
  425. #define  XAXIS_NOIMAG  -6
  426. #define  XAXIS_NOREAL    6
  427. #define  NOPLOT        99
  428. #define  SETUP_SYM    100
  429.  
  430. /* defines for inside/outside */
  431. #define ITER        -1
  432. #define REAL        -2
  433. #define IMAG        -3
  434. #define MULT        -4
  435. #define SUM         -5
  436. #define ATAN        -6
  437. #define ZMAG       -59
  438. #define BOF60      -60
  439. #define BOF61      -61
  440. #define EPSCROSS  -100
  441. #define STARTRAIL -101
  442. #define PERIOD    -102
  443.  
  444. /* defines for bailoutest */
  445. enum bailouts { Mod, Real, Imag, Or, And };
  446. enum Major  {breadth_first, depth_first, random_walk, random_run};
  447. enum Minor  {left_first, right_first};
  448.  
  449. /* bitmask defines for fractalspecific flags */
  450. #define  NOZOOM     1    /* zoombox not allowed at all          */
  451. #define  NOGUESS    2    /* solid guessing not allowed          */
  452. #define  NOTRACE    4    /* boundary tracing not allowed        */
  453. #define  NOROTATE    8    /* zoombox rotate/stretch not allowed  */
  454. #define  NORESUME      16    /* can't interrupt and resume          */
  455. #define  INFCALC       32    /* this type calculates forever        */
  456. #define  TRIG1           64    /* number of trig functions in formula */
  457. #define  TRIG2          128
  458. #define  TRIG3          192
  459. #define  TRIG4          256
  460. #define  WINFRAC      512    /* supported in WinFrac                */
  461. #define  PARMS3D     1024    /* uses 3d parameters                  */
  462. #define  OKJB        2048    /* works with Julibrot                 */
  463. #define  MORE        4096    /* more than 4 parms                   */
  464. #define  BAILTEST    8192    /* can use different bailout tests     */
  465. #define  BF_MATH    16384    /* supports arbitrary precision        */
  466. #define  LD_MATH    32768    /* supports long double                */
  467.  
  468. extern struct fractalspecificstuff far fractalspecific[];
  469. extern struct fractalspecificstuff far *curfractalspecific;
  470.  
  471. #define DEFAULTFRACTALTYPE    ".gif"
  472. #define ALTERNATEFRACTALTYPE    ".fra"
  473.  
  474. #ifndef _CMPLX_DEFINED
  475. #include "cmplx.h"
  476. #endif
  477.  
  478. #ifndef sqr
  479. #define sqr(x) ((x)*(x))
  480. #endif
  481.  
  482. #ifndef lsqr
  483. #define lsqr(x) (multiply((x),(x),bitshift))
  484. #endif
  485.  
  486. #define CMPLXmod(z)      (sqr((z).x)+sqr((z).y))
  487. #define CMPLXconj(z)    ((z).y =  -((z).y))
  488. #define LCMPLXmod(z)       (lsqr((z).x)+lsqr((z).y))
  489. #define LCMPLXconj(z)    ((z).y =  -((z).y))
  490.  
  491. typedef  _LCMPLX LCMPLX;
  492.  
  493. /* 3D stuff - formerly in 3d.h */
  494. #ifndef dot_product
  495. #define dot_product(v1,v2)  ((v1)[0]*(v2)[0]+(v1)[1]*(v2)[1]+(v1)[2]*(v2)[2])  /* TW 7-09-89 */
  496. #endif
  497.  
  498. #define    CMAX    4   /* maximum column (4 x 4 matrix) */
  499. #define    RMAX    4   /* maximum row     (4 x 4 matrix) */
  500. #define    DIM       3   /* number of dimensions */
  501.  
  502. typedef double MATRIX [RMAX] [CMAX];  /* matrix of doubles */
  503. typedef int   IMATRIX [RMAX] [CMAX];  /* matrix of ints    */
  504. typedef long  LMATRIX [RMAX] [CMAX];  /* matrix of longs   */
  505.  
  506. /* A MATRIX is used to describe a transformation from one coordinate
  507. system to another.  Multiple transformations may be concatenated by
  508. multiplying their transformation matrices. */
  509.  
  510. typedef double VECTOR [DIM];  /* vector of doubles */
  511. typedef int   IVECTOR [DIM];  /* vector of ints    */
  512. typedef long  LVECTOR [DIM];  /* vector of longs   */
  513.  
  514. /* A VECTOR is an array of three coordinates [x,y,z] representing magnitude
  515. and direction. A fourth dimension is assumed to always have the value 1, but
  516. is not in the data structure */
  517.  
  518.  
  519. #define PI 3.14159265358979323846
  520.  
  521. #define SPHERE      init3d[0]        /* sphere? 1 = yes, 0 = no  */
  522. #define ILLUMINE  (FILLTYPE>4)    /* illumination model        */
  523.  
  524. /* regular 3D */
  525. #define XROT      init3d[1]    /* rotate x-axis 60 degrees */
  526. #define YROT      init3d[2]    /* rotate y-axis 90 degrees */
  527. #define ZROT      init3d[3]    /* rotate x-axis  0 degrees */
  528. #define XSCALE      init3d[4]    /* scale x-axis, 90 percent */
  529. #define YSCALE      init3d[5]    /* scale y-axis, 90 percent */
  530.  
  531. /* sphere 3D */
  532. #define PHI1      init3d[1]    /* longitude start, 180     */
  533. #define PHI2      init3d[2]    /* longitude end ,   0        */
  534. #define THETA1      init3d[3]        /* latitude start,-90 degrees */
  535. #define THETA2      init3d[4]        /* latitude stop,  90 degrees */
  536. #define RADIUS      init3d[5]    /* should be user input */
  537.  
  538. /* common parameters */
  539. #define ROUGH      init3d[6]    /* scale z-axis, 30 percent */
  540. #define WATERLINE init3d[7]    /* water level            */
  541. #define FILLTYPE  init3d[8]    /* fill type            */
  542. #define ZVIEWER   init3d[9]    /* perspective view point   */
  543. #define XSHIFT      init3d[10]    /* x shift */
  544. #define YSHIFT      init3d[11]    /* y shift */
  545. #define XLIGHT      init3d[12]    /* x light vector coordinate */
  546. #define YLIGHT      init3d[13]    /* y light vector coordinate */
  547. #define ZLIGHT      init3d[14]    /* z light vector coordinate */
  548. #define LIGHTAVG  init3d[15]    /* number of points to average */
  549.  
  550. #ifndef TRUE
  551. #define TRUE 1
  552. #define FALSE 0
  553. #endif
  554.  
  555. /* Math definitions (normally in float.h) that are missing on some systems. */
  556. #ifndef FLT_MIN
  557. #define FLT_MIN 1.17549435e-38
  558. #endif
  559. #ifndef FLT_MAX
  560. #define FLT_MAX 3.40282347e+38
  561. #endif
  562. #ifndef DBL_EPSILON
  563. #define DBL_EPSILON 2.2204460492503131e-16
  564. #endif
  565.  
  566. /* gcc doesn't like the real DBL_MAX for some reason */
  567. #ifdef XFRACT
  568. #ifdef DBL_MAX
  569. #undef DBL_MAX
  570. #define DBL_MAX 1.79769313486231e+308
  571. #endif
  572. #endif
  573.  
  574. #ifndef XFRACT
  575. #define UPARR "\x18"
  576. #define DNARR "\x19"
  577. #define RTARR "\x1A"
  578. #define LTARR "\x1B"
  579. #else
  580. #define UPARR "K"
  581. #define DNARR "J"
  582. #define RTARR "L"
  583. #define LTARR "H"
  584. #endif
  585.  
  586. #define JIIM  0
  587. #define ORBIT 1
  588.  
  589. struct workliststuff    /* work list entry for std escape time engines */
  590. {
  591.     int xxstart;    /* screen window for this entry */
  592.     int xxstop;
  593.     int yystart;
  594.     int yystop;
  595.     int yybegin;    /* start row within window, for 2pass/ssg resume */
  596.     int sym;    /* if symmetry in window, prevents bad combines */
  597.     int pass;    /* for 2pass and solid guessing */
  598. };
  599.  
  600. typedef struct workliststuff        WORKLIST;
  601.  
  602.  
  603. #define MAXCALCWORK 12
  604.  
  605. struct coords {
  606.     int x,y;
  607.     };
  608.  
  609. struct dblcoords {
  610.     double x,y;
  611.     };
  612.  
  613. extern BYTE trigndx[];
  614. extern void (*ltrig0)(void), (*ltrig1)(void), (*ltrig2)(void), (*ltrig3)(void);
  615. extern void (*dtrig0)(void), (*dtrig1)(void), (*dtrig2)(void), (*dtrig3)(void);
  616.  
  617. struct trig_funct_lst
  618. {
  619.     char *name;
  620.     void (*lfunct)(void);
  621.     void (*dfunct)(void);
  622.     void (*mfunct)(void);
  623. } ;
  624. extern struct trig_funct_lst trigfn[];
  625.  
  626. /* function prototypes */
  627.  
  628. extern    void   (_fastcall *plot)(int, int, int);
  629.  
  630. /* for overlay return stack */
  631.  
  632. #define BIG 100000.0
  633.  
  634. #define CTL(x) ((x)&0x1f)
  635.  
  636. /* nonalpha tests if we have a control character */
  637. #define nonalpha(c) ((c)<32 || (c)>127)
  638.  
  639. /* keys */
  640. #define   INSERT     1082
  641. #define   DELETE     1083
  642. #define   PAGE_UP     1073
  643. #define   PAGE_DOWN     1081
  644. #define   CTL_HOME     1119
  645. #define   CTL_END     1117
  646. #define   LEFT_ARROW     1075
  647. #define   RIGHT_ARROW     1077
  648. #define   UP_ARROW     1072
  649. #define   DOWN_ARROW     1080
  650. #define   LEFT_ARROW_2     1115
  651. #define   RIGHT_ARROW_2  1116
  652. #define   UP_ARROW_2     1141
  653. #define   DOWN_ARROW_2     1145
  654. #define   HOME         1071
  655. #define   END         1079
  656. #define   ENTER      13
  657. #define   ENTER_2     1013
  658. #define   CTL_ENTER      10
  659. #define   CTL_ENTER_2    1010
  660. #define   CTL_PAGE_UP    1132
  661. #define   CTL_PAGE_DOWN  1118
  662. #define   CTL_MINUS      1142
  663. #define   CTL_PLUS       1144
  664. #define   CTL_INSERT     1146
  665. #define   CTL_DEL        1147
  666. #define   CTL_BACKSLASH  28
  667. #define   F1         1059
  668. #define   F2         1060
  669. #define   F3         1061
  670. #define   F4         1062
  671. #define   F5         1063
  672. #define   F6         1064
  673. #define   F7         1065
  674. #define   F8         1066
  675. #define   F9         1067
  676. #define   F10         1068
  677. #define   BACKSPACE     8
  678. #define   TAB            9
  679. #define   CTL_TAB        1148
  680. #define   ALT_TAB        1165
  681. #define   BACK_TAB     1015  /* shift tab */
  682. #define   ESC            27
  683. #define   SPACE          32
  684. #define   SF1            1084
  685. #define   SF2            1085
  686. #define   SF3            1086
  687. #define   SF4            1087
  688. #define   SF5            1088
  689. #define   SF6            1089
  690. #define   SF7            1090
  691. #define   SF8            1091
  692. #define   SF9            1092
  693. #define   SF10           1093
  694. /* text colors */
  695. #define BLACK       0
  696. #define BLUE       1
  697. #define GREEN       2
  698. #define CYAN       3
  699. #define RED       4
  700. #define MAGENTA    5
  701. #define BROWN       6 /* dirty yellow on cga */
  702. #define WHITE       7
  703. /* use values below this for foreground only, they don't work background */
  704. #define GRAY       8 /* don't use this much - is black on cga */
  705. #define L_BLUE       9
  706. #define L_GREEN   10
  707. #define L_CYAN      11
  708. #define L_RED      12
  709. #define L_MAGENTA 13
  710. #define YELLOW      14
  711. #define L_WHITE   15
  712. #define INVERSE 0x8000 /* when 640x200x2 text or mode 7, inverse */
  713. #define BRIGHT    0x4000 /* when mode 7, bright */
  714. /* and their use: */
  715. extern BYTE txtcolor[];
  716. #define C_TITLE       txtcolor[0]+BRIGHT
  717. #define C_TITLE_DEV      txtcolor[1]
  718. #define C_HELP_HDG      txtcolor[2]+BRIGHT
  719. #define C_HELP_BODY      txtcolor[3]
  720. #define C_HELP_INSTR      txtcolor[4]
  721. #define C_HELP_LINK      txtcolor[5]+BRIGHT
  722. #define C_HELP_CURLINK      txtcolor[6]+INVERSE
  723. #define C_PROMPT_BKGRD      txtcolor[7]
  724. #define C_PROMPT_TEXT      txtcolor[8]
  725. #define C_PROMPT_LO      txtcolor[9]
  726. #define C_PROMPT_MED      txtcolor[10]
  727. #ifndef XFRACT
  728. #define C_PROMPT_HI      txtcolor[11]+BRIGHT
  729. #else
  730. #define C_PROMPT_HI      txtcolor[11]
  731. #endif
  732. #define C_PROMPT_INPUT      txtcolor[12]+INVERSE
  733. #define C_PROMPT_CHOOSE   txtcolor[13]+INVERSE
  734. #define C_CHOICE_CURRENT  txtcolor[14]+INVERSE
  735. #define C_CHOICE_SP_INSTR txtcolor[15]
  736. #define C_CHOICE_SP_KEYIN txtcolor[16]+BRIGHT
  737. #define C_GENERAL_HI      txtcolor[17]+BRIGHT
  738. #define C_GENERAL_MED      txtcolor[18]
  739. #define C_GENERAL_LO      txtcolor[19]
  740. #define C_GENERAL_INPUT   txtcolor[20]+INVERSE
  741. #define C_DVID_BKGRD      txtcolor[21]
  742. #define C_DVID_HI      txtcolor[22]+BRIGHT
  743. #define C_DVID_LO      txtcolor[23]
  744. #define C_STOP_ERR      txtcolor[24]+BRIGHT
  745. #define C_STOP_INFO      txtcolor[25]+BRIGHT
  746. #define C_TITLE_LOW      txtcolor[26]
  747. #define C_AUTHDIV1      txtcolor[27]+INVERSE
  748. #define C_AUTHDIV2      txtcolor[28]+INVERSE
  749. #define C_PRIMARY      txtcolor[29]
  750. #define C_CONTRIB      txtcolor[30]
  751.  
  752. /* structure for xmmmoveextended parameter */
  753. struct XMM_Move
  754.   {
  755.     unsigned long   Length;
  756.     unsigned int    SourceHandle;
  757.     unsigned long   SourceOffset;
  758.     unsigned int    DestHandle;
  759.     unsigned long   DestOffset;
  760.   };
  761.  
  762. /* structure passed to fullscreen_prompts */
  763. struct fullscreenvalues
  764. {
  765.    int type;   /* 'd' for double, 'f' for float, 's' for string,   */
  766.            /* 'D' for integer in double, '*' for comment */
  767.            /* 'i' for integer, 'y' for yes=1 no=0              */
  768.            /* 0x100+n for string of length n           */
  769.            /* 'l' for one of a list of strings                 */
  770.            /* 'L' for long */
  771.    union
  772.    {
  773.       double dval;    /* when type 'd' or 'f'  */
  774.       int    ival;    /* when type is 'i'      */
  775.       long   Lval;    /* when type is 'L'      */
  776.       char   sval[16];    /* when type is 's'      */
  777.       char  far *sbuf;    /* when type is 0x100+n  */
  778.       struct {        /* when type is 'l'      */
  779.      int  val;    /*   selected choice     */
  780.      int  vlen;    /*   char len per choice */
  781.      char **list;    /*   list of values     */
  782.      int  llen;    /*   number of values     */
  783.       } ch;
  784.    } uval;
  785. };
  786.  
  787. #define   FILEATTR     0x37       /* File attributes; select all but volume labels */
  788. #define   HIDDEN     2
  789. #define   SYSTEM     4
  790. #define   SUBDIR     16
  791.  
  792. struct DIR_SEARCH        /* Allocate DTA and define structure */
  793. {
  794.      char path[21];        /* DOS path and filespec */
  795.      char attribute;        /* File attributes wanted */
  796.      int  ftime;        /* File creation time */
  797.      int  fdate;        /* File creation date */
  798.      long size;         /* File size in bytes */
  799.      char filename[13];     /* Filename and extension */
  800. };
  801.  
  802. extern struct DIR_SEARCH DTA;   /* Disk Transfer Area */
  803.  
  804. typedef struct palett
  805. {
  806.    BYTE red;
  807.    BYTE green;
  808.    BYTE blue;
  809. }
  810. Palettetype;
  811.  
  812. struct ext_blk_2 {
  813.    char got_data;
  814.    int length;
  815.    char far *resume_data;
  816.    };
  817.  
  818. struct ext_blk_3 {
  819.    char got_data;
  820.    char form_name[40];
  821.    };
  822.  
  823. struct ext_blk_4 {
  824.    char got_data;
  825.    int length;
  826.    int far *range_data;
  827.    };
  828.  
  829. struct ext_blk_5 {
  830.    char got_data;
  831.    int length;
  832.    char far *apm_data;
  833.    };
  834.  
  835. struct affine
  836. {
  837.    /* weird order so a,b,e and c,d,f are vectors */
  838.    double a;
  839.    double b;
  840.    double e;
  841.    double c;
  842.    double d;
  843.    double f;
  844. };
  845.  
  846. #define sign(x) (((x) < 0) ? -1 : ((x) != 0)  ? 1 : 0)
  847.  
  848. #if (_MSC_VER >= 700)
  849. typedef char __based(__segname("_CODE")) FCODE;
  850. #else
  851. typedef char far FCODE;
  852. #endif
  853.  
  854. #if (_MSC_VER >= 700)
  855. typedef BYTE __based(__segname("_CODE")) BFCODE;
  856. #else
  857. typedef BYTE far BFCODE;
  858. #endif
  859.  
  860. #if (_MSC_VER >= 700)
  861. typedef int __based(__segname("_CODE")) IFCODE;
  862. #else
  863. typedef int far IFCODE;
  864. #endif
  865.  
  866. #if (_MSC_VER >= 700)
  867. typedef unsigned int __based(__segname("_CODE")) UIFCODE;
  868. #else
  869. typedef unsigned int far UIFCODE;
  870. #endif
  871.  
  872. #if (_MSC_VER >= 700)
  873. typedef long __based(__segname("_CODE")) LFCODE;
  874. #else
  875. typedef long far LFCODE;
  876. #endif
  877.  
  878. #if (_MSC_VER >= 700)
  879. typedef double __based(__segname("_CODE")) DFCODE;
  880. #else
  881. typedef double far DFCODE;
  882. #endif
  883. #endif
  884.  
  885. #if _MSC_VER == 800 
  886. #ifndef FIXTAN_DEFINED
  887. /* !!!!! stupid MSVC tan(x) bug fix !!!!!!!!            */
  888. /* tan(x) can return -tan(x) if -pi/2 < x < pi/2       */
  889. /* if tan(x) has been called before outside this range. */
  890. double fixtan( double x );
  891. #define tan fixtan
  892. #define FIXTAN_DEFINED
  893. #endif
  894. #endif
  895.