home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Utilities / DVIM72-Mac 1.9.6 / source / INITGLOB.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-14  |  3.3 KB  |  107 lines  |  [TEXT/R*ch]

  1. /* -*-C-*- initglob.h */
  2. /*-->initglob*/
  3. /**********************************************************************/
  4. /****************************** initglob ******************************/
  5. /**********************************************************************/
  6. #include "dvihead.h"
  7. #include "commands.h"
  8. #include "gendefs.h"
  9. #include "gblprocs.h"
  10. #include "egblvars.h"
  11. #include "m72.h"
  12. #include "math.h"
  13. #include "mac-specific.h"
  14.  
  15.  
  16. void
  17. initglob()            /* initialize global variables */
  18. {
  19.     register INT16 i;        /* loop index */
  20.     register char* tcp;        /* temporary character pointer */
  21.     float halfmag;            /* temp used to initialize mag_table */
  22.  
  23. /***********************************************************************
  24.     Set up masks such that rightones[k]  has 1-bits at the right end  of
  25.     the word from k ..     HOST_WORD_SIZE-1, where bits are numbered  from
  26.     left (high-order) to right (lower-order), 0 .. HOST_WORD_SIZE-1.
  27.  
  28.     img_mask[k] has  a 1-bit  in  position k,  bits numbered  as  above.
  29.     power[k] is  1  <<  k,  and gpower[k]  is  2**k-1  (i.e.  1-bits  in
  30.     low-order k positions).  These 3 require only 32 entries each  since
  31.     they deal with 32-bit words from the PK and GF font files.
  32.  
  33.     These are set  at run-time, rather  than compile time  to avoid  (a)
  34.     problems with C  preprocessors which sometimes  do not handle  large
  35.     constants correctly, and (b) host byte-order dependence.
  36. ***********************************************************************/
  37.  
  38.     rightones[HOST_WORD_SIZE-1] = 1;
  39.     for (i = HOST_WORD_SIZE-2; (i >= 0); --i)
  40.     rightones[i] = (rightones[i+1] << 1) | 1;
  41.  
  42.     img_mask[31] = 1;
  43.     for (i = 30; i >= 0; --i)
  44.     img_mask[i] = img_mask[i+1] << 1;
  45.  
  46.     power[0] = 1;
  47.     for (i = 1; i <= 31; ++i)
  48.     power[i] = power[i-1] << 1;
  49.  
  50.     gpower[0] = 0;        /* NB: we have gpower[0..32], not [0..31] */
  51.     for (i = 1; i <= 32; ++i)
  52.     gpower[i] = power[i-1] | gpower[i-1];
  53.  
  54.     debug_code = 0;
  55.  
  56.     basemag = g_dpi * 5;
  57.     runmag = basemag;
  58.  
  59.     npage = 0;
  60.     copies = 1;                /* number of copies of each page */
  61.     topmargin = 1.0;            /* DVI driver standard default */
  62.     leftmargin = 1.0;            /* DVI driver standard default */
  63.  
  64.     subfile[0] = '\0';
  65.  
  66. #if    VIRTUAL_FONTS
  67.     virt_font = FALSE;
  68. #endif
  69.  
  70.     /*
  71.     Copy default file fields into global  variables, then replace by any
  72.     runtime environment  variable definitions.  We need not  do this for
  73.     TOPS-20   and  VAX  VMS,  since   SUBPATH and  FONTPATH are  already
  74.     initialized to logical  names  which   the  operating  system   will
  75.     translate at file open time.
  76.     */
  77.  
  78.     (void)strcpy(helpcmd,DVIHELP);
  79.     (void)strcpy(subpath,SUBPATH);
  80.     (void)strcpy(subname,SUBNAME);
  81.     (void)strcpy(subext,SUBEXT);
  82.     (void)strcpy(fontpath,FONTPATH);
  83.     (void)strcpy(fontlist,FONTLIST);
  84.  
  85.     if ((tcp = GETENV("DVIHELP")) != (char *)NULL)
  86.     (void)strcpy(helpcmd,tcp);
  87.  
  88. #if    (OS_ATARI | OS_PCDOS | OS_UNIX | OS_THINKC)
  89.     if ((tcp = GETENV(TEXFONTS)) != (char *)NULL)
  90.     {
  91.         (void)strcpy(subpath,tcp);
  92.         (void)strcpy(fontpath,tcp);
  93.     }
  94. #endif
  95.  
  96.     if ((tcp = GETENV("FONTLIST")) != (char *)NULL)
  97.     (void)strcpy(fontlist,tcp);
  98.  
  99. /* Initialize mag_table */
  100.     mag_table[16] = 1.0;
  101.     halfmag = (float)sqrt(1.2);
  102.     for (i = 17; i < 33; i++)
  103.         mag_table[i] = halfmag * mag_table[i-1];
  104.     for (i = 15; i >= 0; i--)
  105.         mag_table[i] = mag_table[i+1] / halfmag;
  106. }
  107.