home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 11 / 11.iso / m / m242 / 3.ddi / DEMOS1.ZIP / EG_DEMO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-11  |  73.4 KB  |  2,480 lines

  1. #include "eg_proto.h"
  2.  
  3.  
  4. /* keyboard defines */
  5.  
  6. #define RETURN      13
  7. #define ESCAPE      27
  8. #define HOME       -71
  9. #define CURUP      -72
  10. #define END        -79
  11. #define CURDN      -80
  12.  
  13. /* default colors */
  14. int color[16]     = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
  15.  
  16. int max_x,max_y,max_colors;    /* max colors and sizes */
  17. int dev,grafx_mode;                /* device and graphics mode */
  18. int forg,back;                          /* foreground and background colors */
  19. int mouse;                              /* store whether mouse available */
  20. char str[20][70],*s[20];        /* strings for windows */
  21. int cga_pal;                        /* CGA Palette */
  22.  
  23. #ifdef __TURBOC__        /* defined by Turbo C compiler */
  24.   int _stklen = 10000;   /* increase default stack size to 10000 */
  25. #endif
  26.  
  27. main()
  28. {
  29.     unsigned char banks;        /* banks for Video 7 Card */
  30.     int i,key,reconfig,x,y;    /* work variables */
  31.     int selection;                /* selection from EG_SMENU */
  32.     struct egstatus stat;    /* EG status structure */
  33.     int shadow,clear;            /* colors for menu shadow and clear screen */
  34.     int t_forg,t_back;        /* title foregraound and background for EG_SMENU */
  35.     char cardtype[23];        /* string for card type */
  36.     char font[20];                /* font for menus */
  37.     char selecs[15][80];        /* array of strings for menus */
  38.     char *sels[15];
  39.  
  40.     cga_pal = 0;
  41.  
  42.     dev = device_query();        /* check graphics card */
  43.     i = check_vid7(&banks);        /* check for Video-7 card */
  44.  
  45.     if (i){                        /* if Video 7 */
  46.          dev = 5;                /* use 1024x768x16 */
  47.          if (banks > 1){
  48.              dev = 6;
  49.              grafx_mode = 101;
  50.          }
  51.          else                    /* use 800x600x16 */
  52.              grafx_mode = 98;
  53.          strcpy(cardtype,"Video 7 Extended VGA");
  54.     }
  55.     else{            
  56.         if (dev & 16){         /* VGA adapter */
  57.              dev = 2;
  58.              grafx_mode = 18;
  59.              strcpy(cardtype,"VGA");
  60.         }
  61.         else{
  62.             if (dev & 4){            /* EGA adapter */
  63.                  dev = 1;
  64.                  i = ega_mem();      /* check amount of available memory */
  65.                  grafx_mode = 16;
  66.                  strcpy(cardtype,"EGA");
  67.             }
  68.             else{
  69.                 if (dev & 64){            /* Hercules adapter */
  70.                      dev = 3;
  71.                      grafx_mode = 20;
  72.                      strcpy(cardtype,"Hercules");
  73.                 }
  74.                 else{                        /* CGA Adpater */
  75.                      dev = 0;
  76.                      grafx_mode = 4;
  77.                      cga_pal  = 3;
  78.                      strcpy(cardtype,"CGA");
  79.                 }
  80.             }
  81.         }    
  82.     }
  83.  
  84.     /* set up defaults */
  85.  
  86.     forg = 1; back = 15; shadow = 3; clear = 11;
  87.     selection = 0;    t_forg = 15; t_back = 4; 
  88.  
  89.  
  90.     /* devices are as follows :
  91.         CGA        -    0
  92.         EGA        -    1
  93.         VGA        -    2
  94.         HERC        -    3
  95.         PARADISE    -    4
  96.         VIDEO 7    -    5    ( 800 x 600)    
  97.         VIDEO 7    -    6    (1024 x 768)    
  98.         IBM 8514    -    7    (1024 x 768)    
  99.     */
  100.  
  101.  
  102.     switch(dev){
  103.         case 0 :    setibm(); initgraf(grafx_mode,0,0); 
  104.                     for (i = 1; i < 16; i++)    /* set up colors */
  105.                           color[i] = 1;    
  106.                     strcpy(font,"micprint.sms");
  107.                     x = y = 50;    cga_pal = 2;
  108.                     forg = 3; back = 2;    shadow = -1;
  109.                     t_forg = 1; t_back = 2;
  110.                     clear  = 0;    color[4] = 0;    
  111.                     break;
  112.         case 1 :    setega(); initgraf(grafx_mode,0,0); 
  113.                     /* load up logo */
  114.                     strcpy(font,"sbo.sms");
  115.                     x = y = 140;
  116.                     break;
  117.         case 2 :    setvga(); initgraf(grafx_mode,0,0); 
  118.                     /* load up logo */
  119.                     strcpy(font,"sbo.sms");
  120.                     x = y = 140;
  121.                     break;
  122.         case 3 :    setherc(1); initgraf(grafx_mode,0,0); 
  123.                     /* load up logo */
  124.                     for (i = 1; i < 16; i++)
  125.                           color[i] = 1;    
  126.                     t_forg = 1; t_back = 1;
  127.                     strcpy(font,"sbo.sms");
  128.                     x = y = 130; forg = 0; back = 1;
  129.                     shadow = -1; grafx_mode = 20;
  130.                     clear  = 1;     color[4] = 0;
  131.                     break;
  132.         case 5 :    /* Use VGA logo here */
  133.         case 6 :    setvga(); initgraf(18,0,0); 
  134.                     /* load up logo */
  135.                     strcpy(font,"sbo.sms");
  136.                     x = y = 140;
  137.                     break;
  138.  
  139.     }
  140.  
  141.     eg_status(&stat);            /* get status */
  142.  
  143.     /* set up max colors and sizes */
  144.  
  145.     max_x = stat.x_res-1;    
  146.     max_y = stat.y_res-1;
  147.    max_colors = stat.avail_colors;
  148.  
  149.     /* init and load fonts */
  150.  
  151.     fontinit();
  152.     font_load(0,font);
  153.  
  154.     /* Use mouse if available */
  155.  
  156.     if (m_instal() == -1 && dev < 4){
  157.          mouse = 1;
  158.           m_curon();
  159.          m_curtyp(0);
  160.     }
  161.  
  162.      clearscr(clear);        /* clear the screen */
  163.     
  164.     /* set up strings for window  function */
  165.  
  166.      strcpy(str[0],"You appear to have a");
  167.      strcpy(str[1]," ");
  168.      strcpy(str[2],cardtype);
  169.      strcpy(str[3]," ");
  170.      strcpy(str[4],"card in your computer");
  171.      strcpy(str[5]," ");
  172.      strcpy(str[6],"Enter 1 to reconfigure or");
  173.      strcpy(str[7]," ");
  174.      strcpy(str[8],"0 to run the demo in this mode :");
  175.      for (i = 0; i < 9; i++)
  176.             s[i] = str[i];
  177.  
  178.      switch(dev){
  179.           case 0 :    eg_window(4,0,"ibmrom",200,75,9,s,1,0,1);
  180.                     break;
  181.         case 1 :    eg_window(4,0,"sbo.sms",200,75,9,s,4,15,1);
  182.                     break;
  183.         case 2 :    eg_window(4,0,"sbo.sms",200,75,9,s,4,15,1);
  184.                     break;
  185.         case 3 :    eg_window(4,0,"sbo.sms",200,75,9,s,1,0,1);
  186.                     break;
  187.         case 4 :    eg_window(4,0,"sbo.sms",200,75,9,s,4,15,1);
  188.                     break;
  189.         case 5 :
  190.         case 6 :    eg_window(4,0,"sbo.sms",200,75,9,s,4,15,1);
  191.                     break;
  192.     }
  193.     /* call our function to get a key without echo to screen */
  194.  
  195.     esgetkey(&reconfig);
  196.  
  197.     /* if key = '1', put a menu up to make a card selection */
  198.  
  199.     if (reconfig == 49){      
  200.           clearscr(clear);
  201.           strcpy(selecs[0],"IBM CGA CARD");
  202.           strcpy(selecs[1],"IBM EGA CARD");
  203.           strcpy(selecs[2],"IBM VGA CARD");
  204.           strcpy(selecs[3],"Hercules CARD");
  205.           strcpy(selecs[4],"Paradise Professional Card");
  206.           strcpy(selecs[5],"Video 7 Extended VGA Card");
  207.           strcpy(selecs[6],"IBM 8514");
  208.           for  (i = 0; i < 7; i++)
  209.                   sels[i] = selecs[i];
  210.           i = eg_smenu(0,7,sels,x,y,forg,back,shadow,4,1,"Select A Device",t_forg,t_back);
  211.           if (i != -1)
  212.                 dev = i;
  213.           switch(dev){
  214.                 case 0 :     grafx_mode = 4;  break;
  215.                 case 1 :     grafx_mode = 16; break;
  216.                 case 2 :     grafx_mode = 18; break;
  217.                 case 3 :     grafx_mode = 20; break;
  218.                 case 4 :     grafx_mode = 88; break;
  219.                 case 5 :     grafx_mode = 98; break;
  220.                 case 6 :     dev = 7; grafx_mode = 8514; break;
  221.                 case -1:  break;
  222.             }
  223.     }
  224.  
  225.             /* reset colors */
  226.     
  227.             for (i = 0; i < 16; i++)
  228.                   color[i] = i;    
  229.  
  230.             /* reset colors */
  231.             forg = 1; back = 15; shadow = 3; clear = 11;
  232.  
  233.             switch(dev){
  234.                 case 0 :    setibm(); 
  235.                             for (i = 1; i < 16; i++)
  236.                                   color[i] = 1;    
  237.                             strcpy(font,"micprint.sms");
  238.                             x = y = 2;    cga_pal = 2; forg = 3; back = 2;
  239.                             shadow = -1; clear  = 0; color[4] = 0;
  240.                             break;
  241.                 case 1 :    setega(); strcpy(font,"sbo.sms"); x = y = 40; break;
  242.                 case 2 :    setvga(); strcpy(font,"sbo.sms"); x = y = 40; break;
  243.                 case 3 :    setherc(1);
  244.                             for (i = 1; i < 16; i++)
  245.                                   color[i] = 1;    
  246.                             strcpy(font,"sbo.sms");
  247.                             x = y = 30;    forg = 0; back = 1; shadow = -1;
  248.                             grafx_mode = 20;    clear  = 1;    color[4] = 0; break;
  249.                 case 4 :    set_pvga();    strcpy(font,"sbo.sms");    x = y = 30;    mouse = 0; break;
  250.                 case 5 :    set_vid7();    strcpy(font,"sbo.sms");    x = y = 40;    mouse = 0; break;
  251.                 case 6 :    set_vid7();    strcpy(font,"roman3.sms");    x = y = 40;    mouse = 0; break;
  252.                 case 7 :    set8514();    strcpy(font,"roman3.sms");    x = y = 40;    mouse = 0; break;
  253.             }
  254.     fontquit();        /* unload fonts */
  255.  
  256. /* set up labels */
  257.  
  258.       hatch_init();
  259.  
  260.  /* set up menu choices */
  261.     
  262.   strcpy(selecs[0],"Lines");
  263.   strcpy(selecs[1],"Arcs and circles");
  264.   strcpy(selecs[2],"Rectangles");
  265.   strcpy(selecs[3],"Bit mapped fonts");
  266.   strcpy(selecs[4],"Vector fonts");
  267.   strcpy(selecs[5],"2-D graphs");
  268.   strcpy(selecs[6],"3-D bars");
  269.   strcpy(selecs[7],"3-D pies");
  270.   strcpy(selecs[8],"Animation");
  271.   strcpy(selecs[9],"EXIT");
  272.  
  273.     for  (i = 0; i < 10; i++)
  274.             sels[i] = selecs[i];
  275.             
  276.     initgraf(grafx_mode,cga_pal,0);
  277.     eg_status(&stat);
  278.  
  279.     max_x = stat.x_res-1;
  280.     max_y = stat.y_res-1;
  281.    max_colors = stat.avail_colors;
  282.  
  283.     selection = 0;
  284.     if (m_instal() == -1 && dev < 4)
  285.         mouse = 1;
  286.  
  287.     /* loop through till exit */
  288.  
  289.     while (selection != 10){
  290.              clearscr(clear);
  291.  
  292.         /* display menu directions */
  293.              strcpy(str[0],"Use the UP and DOWN arrow keys");
  294.              strcpy(str[1],"or the mouse cursor to highlight");
  295.              strcpy(str[2],"any selection in the menu.");
  296.              strcpy(str[3],"HOME and END keys will bring you");
  297.              strcpy(str[4],"to the top and bottom of the menu.");
  298.               strcpy(str[5]," ");
  299.              strcpy(str[6],"Hit RETURN or the left mouse button");
  300.              strcpy(str[7],"to make a selection.");
  301.              for (i = 0; i < 8; i++)
  302.                     s[i] = str[i];
  303.  
  304.             worldon(0);
  305.             switch(dev){
  306.                 case 0 : strcpy(str[0],"Use the up and");
  307.                             strcpy(str[1],"down arrow keys");
  308.                             strcpy(str[2],"or the mouse");
  309.                             strcpy(str[3],"to move the");
  310.                             strcpy(str[4],"cursor thru the");
  311.                             strcpy(str[5],"menu. Home and");
  312.                             strcpy(str[6],"end keys will");
  313.                             strcpy(str[7],"bring you to");
  314.                             strcpy(str[8],"the top and");
  315.                              strcpy(str[9],"bottom of the");
  316.                             strcpy(str[10],"menu.");
  317.                             strcpy(str[11]," ");
  318.                             strcpy(str[12],"Hit return or");
  319.                             strcpy(str[13],"the left mouse");
  320.                             strcpy(str[14],"button to make");
  321.                             strcpy(str[15],"a selection.");
  322.                             for (i = 0; i < 16; i++)
  323.                                   s[i] = str[i];
  324.                             eg_window(0,0,"ibmrom",190,35,16,s,3,1,0);    
  325.                             break;
  326.                 case 1 :    eg_window(4,0,"ega8x14",315,75,8,s,4,15,0);    
  327.                             if (font_load(0,"roman3.sms")){
  328.                                 initgraf(3,0,0);
  329.                                 printf("Fonts not In Current Directory!!!\n");
  330.                                 printf("Demo Cancelled!!!\n");
  331.                                 exit(1);
  332.                             }
  333.                             fhatsay(0,"Essential",1,400,250); 
  334.                             fhatsay(0," Graphics",1,400,280); 
  335.                             fhatsay(0,"   Demo",1,400,310); 
  336.                             font_unload(0);
  337.                             break;
  338.                 case 2 :    eg_window(4,0,"vga8x16",150,300,8,s,4,15,0);
  339.                             if (font_load(0,"roman3.sms")){
  340.                                 initgraf(3,0,0);
  341.                                 printf("Fonts not In Current Directory!!!\n");
  342.                                 printf("Demo Cancelled!!!\n");
  343.                                 exit(1);
  344.                             }
  345.                             fhatsay(0,"Essential",1,375,100); 
  346.                             fhatsay(0," Graphics",1,375,140); 
  347.                             fhatsay(0,"   Demo",1,375,180); 
  348.                             font_unload(0);
  349.                             break;
  350.                 case 3 :    eg_window(4,0,"ibmrom",350,75,8,s,1,0,0);    break;
  351.                 case 4 :    strcpy(str[0],"Use the UP and DOWN arrow keys");
  352.                             strcpy(str[1],"to highlight any selection");
  353.                             strcpy(str[2],"in the menu.");
  354.                             strcpy(str[3],"HOME and END keys will bring you");
  355.                             strcpy(str[4],"to the top and bottom of the menu.");
  356.                              strcpy(str[5]," ");
  357.                             strcpy(str[6],"Hit RETURN to make a selection.");
  358.                             for (i = 0; i < 7; i++)
  359.                                     s[i] = str[i];
  360.                             eg_window(4,0,"sbo.sms",210,450,7,s,4,15,0);    
  361.                             if (font_load(0,"roman3.sms")){
  362.                                 initgraf(3,0,0);
  363.                                 printf("Fonts not In Current Directory!!!\n");
  364.                                 printf("Demo Cancelled!!!\n");
  365.                                 exit(1);
  366.                             }
  367.                             fhatsay(0,"Essential",1,575,150); 
  368.                             fhatsay(0," Graphics",1,575,190); 
  369.                             fhatsay(0,"   Demo",1,575,230); 
  370.                             font_unload(0);
  371.                             break;
  372.                 case 5 :    strcpy(str[0],"Use the UP and DOWN arrow keys");
  373.                             strcpy(str[1],"to highlight any selection");
  374.                             strcpy(str[2],"in the menu.");
  375.                             strcpy(str[3],"HOME and END keys will bring you");
  376.                             strcpy(str[4],"to the top and bottom of the menu.");
  377.                              strcpy(str[5]," ");
  378.                             strcpy(str[6],"Hit RETURN to make a selection.");
  379.                             for (i = 0; i < 7; i++)
  380.                                     s[i] = str[i];
  381.                             eg_window(2,0,"sbo.sms",210,450,7,s,4,15,0);    
  382.                             if (font_load(0,"roman3.sms")){
  383.                                 initgraf(3,0,0);
  384.                                 printf("Fonts not In Current Directory!!!\n");
  385.                                 printf("Demo Cancelled!!!\n");
  386.                                 exit(1);
  387.                             }
  388.                             fhatsay(0,"Essential",1,575,150); 
  389.                             fhatsay(0," Graphics",1,575,190); 
  390.                             fhatsay(0,"   Demo",1,575,230); 
  391.                             font_unload(0);
  392.                             break;
  393.                 case 6 :
  394.                 case 7 :    
  395.                             strcpy(str[0],"Use the UP and DOWN arrow keys");
  396.                             strcpy(str[1],"to highlight any selection");
  397.                             strcpy(str[2],"in the menu.");
  398.                             strcpy(str[3],"HOME and END keys will bring you");
  399.                             strcpy(str[4],"to the top and bottom of the menu.");
  400.                              strcpy(str[5]," ");
  401.                             strcpy(str[6],"Hit RETURN to make a selection.");
  402.                             for (i = 0; i < 7; i++)
  403.                                     s[i] = str[i];
  404.                             eg_window(4,0,"roman3.sms",90,530,7,s,4,15,0);    
  405.                             if (font_load(0,"roman3.sms")){
  406.                                 initgraf(3,0,0);
  407.                                 printf("Fonts not In Current Directory!!!\n");
  408.                                 printf("Demo Cancelled!!!\n");
  409.                                 exit(1);
  410.                             }
  411.                             fhatsay(0,"Essential",1,775,150); 
  412.                             fhatsay(0," Graphics",1,775,190); 
  413.                             fhatsay(0,"   Demo",1,775,230); 
  414.                             font_unload(0);
  415.                             break;
  416.             }
  417.             fontinit();
  418.             font_load(0,font);
  419.             if (mouse){
  420.                 m_curon();
  421.                 m_curtyp(0);
  422.             }
  423.             selection = eg_smenu(0,10,sels,x,y,forg,back,shadow,4,0,"",0,0);
  424.             if (mouse)
  425.                 m_curoff();
  426.             fontquit();
  427.  
  428.         /* call the appropiate demo function */
  429.             switch(selection){
  430.              case -1 : initgraf(3,0,0);
  431.                            exit(0);
  432.              case 0  : dots_and_lines();        break;
  433.              case 1  : arcs_and_circles();    break;
  434.              case 2  : rectangles();             break;
  435.              case 3  : bit_mapped_fonts();    break;
  436.              case 4  : vector_fonts();          break;
  437.              case 5  : two_d_grafs();          break;
  438.              case 6  : three_d_bars();         break;
  439.              case 7  : three_d_pies();         break;
  440.              case 8  : animation();             break;
  441.              case 9  : initgraf(3,0,0);
  442.                            exit(0);
  443.             }   
  444.     }
  445. }
  446.  
  447. /* draw some dot and line patterns */
  448.  
  449. dots_and_lines(){
  450.  
  451.     int key;
  452.     int j,k,l,m,jump,max;
  453.     int x,y,color,inc;
  454.     int xinc,yinc,moveinc;
  455.     int xo,yo,i,startx,starty;
  456.  
  457.     /* set up the window */
  458.  
  459.     strcpy(str[0],"Essential Graphics' low level");
  460.     strcpy(str[1],"functions are the fastest around.");
  461.     strcpy(str[2],"So if speed is a prime factor in");
  462.     strcpy(str[3],"your graphics, check us out !!!");
  463.     strcpy(str[4]," ");
  464.     strcpy(str[5],"Hit any key to continue.");
  465.     for (i = 0; i < 6; i++)
  466.             s[i] = str[i];
  467.  
  468.     clearscr(0);
  469.  
  470.     switch(dev){
  471.         case 0 :    eg_window(4,1,"ibmrom",200,75,6,s,1,0,1);
  472.                     break;
  473.         case 1 :    eg_window(4,1,"sbo.sms",200,75,6,s,4,15,1);
  474.                     break;
  475.         case 2 :    eg_window(4,1,"sbo.sms",200,75,6,s,4,15,1);
  476.                     break;
  477.         case 3 :    eg_window(4,1,"sbo.sms",200,75,6,s,1,0,1);
  478.                     break;
  479.         case 4 :    eg_window(4,1,"sbo.sms",200,75,6,s,4,15,1);
  480.                     break;
  481.         case 5 :    eg_window(4,1,"sbo.sms",200,75,6,s,4,15,1);
  482.                     break;
  483.         case 6 :
  484.         case 7 :    eg_window(4,1,"roman3.sms",200,75,6,s,4,15,1);
  485.                     break;
  486.     }
  487.     clearscr(0);
  488.  
  489.     /* set up defaults */
  490.  
  491.    moveinc = 0;    inc = 5;    startx = max_x/4;    starty = max_y/5;
  492.     switch(dev){
  493.         case 0 :    xinc = 5; yinc = 3; break;
  494.         case 1 :    xinc = 7; yinc = 5; break;
  495.         case 2 :    xinc = 7; yinc = 7; break;
  496.         case 3 :    xinc = 7; yinc = 5; break;
  497.         case 4 :
  498.         case 5 :
  499.         case 6 :
  500.         case 7 :    xinc = 12; yinc = 9; break;
  501.     }
  502.  
  503.    for (color = 1; color < 16; color++,moveinc += inc){
  504.           if (inkey(&k) != -1) break;
  505.             if (moveinc > max_x || moveinc > max_y) moveinc = 0;
  506.         for (x = startx+moveinc; x < max_x-startx-moveinc; x += xinc){
  507.                 eg_line(max_x/2,max_y/2,x,starty+moveinc,color%max_colors);
  508.                 if (inkey(&k) != -1) break;
  509.           }    
  510.            for (y = starty+moveinc; y < max_y-starty-moveinc; y += yinc){
  511.                 eg_line(max_x/2,max_y/2,max_x-startx-moveinc,y,color%max_colors);
  512.                 if (inkey(&k) != -1) break;
  513.           }    
  514.         for (x = max_x-startx-moveinc; x > startx+moveinc; x -= xinc){
  515.                 eg_line(max_x/2,max_y/2,x,max_y-starty-moveinc,color%max_colors);
  516.                 if (inkey(&k) != -1) break;
  517.           }    
  518.         for (y = max_y-starty-moveinc; y > starty+moveinc; y -= yinc){
  519.                 eg_line(max_x/2,max_y/2,startx+moveinc,y,color%max_colors);
  520.                 if (inkey(&k) != -1) break;
  521.           }        
  522.       }
  523.  
  524.     /* set up defaults */
  525.   moveinc = 35;  inc = 0;  y = max_y-1; x = 0;
  526.   clearscr(0);
  527.   for (color = 1; color < 16; color++,moveinc += 20){
  528.          if (inkey(&k) != -1) break;
  529.          if (moveinc > max_x || moveinc > max_y) moveinc = 35;
  530.        for (x = 0; x < max_x; x += xinc){
  531.             eg_line(max_x/2,max_y/2,x,0+moveinc,color%max_colors);
  532.                 if (inkey(&k) != -1) break;
  533.        }
  534.        for (y = 0; y < max_y; y += yinc){
  535.             eg_line(max_x/2,max_y/2,max_x-1-moveinc,y,color%max_colors);
  536.                 if (inkey(&k) != -1) break;
  537.        }
  538.        for (x = max_x-1; x >= 0; x -= xinc){
  539.             eg_line(max_x/2,max_y/2,x,max_y-1-moveinc,color%max_colors);
  540.                 if (inkey(&k) != -1) break;
  541.        }
  542.        for (y = max_y-1; y >= 0; y -= yinc){
  543.             eg_line(max_x/2,max_y/2,0+moveinc,y,color%max_colors);
  544.                 if (inkey(&k) != -1) break;
  545.        }
  546.   }
  547.  
  548.     /* set up the window */
  549.  
  550.     strcpy(str[0],"Hit Return at any time");
  551.     strcpy(str[1],"to move to the next");
  552.     strcpy(str[2],"screen.");
  553.     for (i = 0; i < 3; i++)
  554.             s[i] = str[i];
  555.         
  556.     switch(dev){
  557.         case 0 :    eg_window(4,1,"ibmrom",200,75,3,s,3,2,1);
  558.                     break;
  559.         case 1 :    eg_window(4,1,"sbo.sms",200,75,3,s,4,15,1);
  560.                     break;
  561.         case 2 :    eg_window(4,1,"sbo.sms",200,75,3,s,4,15,1);
  562.                     break;
  563.         case 3 :    eg_window(4,1,"sbo.sms",200,75,3,s,1,0,1);
  564.                     break;
  565.         case 4 :    eg_window(4,1,"sbo.sms",200,75,3,s,4,15,1);
  566.                     break;
  567.         case 5 :    eg_window(4,1,"sbo.sms",200,75,3,s,4,15,1);
  568.                     break;
  569.         case 6 :
  570.         case 7 :    eg_window(4,1,"roman3.sms",200,75,3,s,4,15,1);
  571.                     break;
  572.     }
  573. }
  574.  
  575.  
  576. arcs_and_circles(){
  577.  
  578.     int key;
  579.     int radius;
  580.     int x,y,i;
  581.     
  582.       hatch_init();
  583.  
  584.     /* set up the window */
  585.  
  586.     strcpy(str[0],"Arcs and circles can be drawn in");
  587.     strcpy(str[1],"any color, size or angle.  Hatch");
  588.     strcpy(str[2],"styles or solids may be used");
  589.     strcpy(str[3],"to fill the arcs.");
  590.     strcpy(str[4]," ");
  591.     strcpy(str[5],"Hit any key to continue.");
  592.     strcpy(str[6],"or change screens.");
  593.     for (i = 0; i < 7; i++)
  594.             s[i] = str[i];
  595.  
  596.     clearscr(0);
  597.     switch(dev){
  598.         case 0 :    eg_window(4,1,"ibmrom",200,75,7,s,1,0,1);
  599.                     break;
  600.         case 1 :    eg_window(4,1,"sbo.sms",200,75,7,s,4,15,1);
  601.                     break;
  602.         case 2 :    eg_window(4,1,"sbo.sms",200,75,7,s,4,15,1);
  603.                     break;
  604.         case 3 :    eg_window(4,1,"sbo.sms",200,75,7,s,1,0,1);
  605.                     break;
  606.         case 4 :    eg_window(4,1,"sbo.sms",200,75,7,s,4,15,1);
  607.                     break;
  608.         case 5 :    eg_window(4,1,"sbo.sms",200,75,7,s,4,15,1);
  609.                     break;
  610.         case 6 :
  611.         case 7 :    eg_window(4,1,"roman3.sms",200,75,7,s,4,15,1);
  612.                     break;
  613.     }
  614.  
  615.     radius = max_y/20;    x = max_x - max_x/7;    y = max_y - max_y/7;
  616.  
  617.     clearscr(0);
  618.     while (inkey(&key) == -1){
  619.             eg_arc(rand()%x+(radius+10),rand()%y+(radius+10),1+rand()%radius,rand()%max_colors,rand()%180,180+(rand()%180),rand()%2,-1);
  620.             eg_circle(rand()%x+(radius+10),rand()%y+(radius+10),1+rand()%radius,rand()%max_colors,rand()%2);
  621.     }
  622.     clearscr(0);
  623.     while (inkey(&key) == -1)
  624.             eg_arc(rand()%x+(radius+10),rand()%y+(radius+10),1+rand()%radius,rand()%max_colors,rand()%180,180+(rand()%180),0,rand()%4);
  625. }
  626.  
  627.  
  628.  
  629. rectangles(){
  630.  
  631.     int x,y,i,key,c;
  632.     int xsize,ysize;
  633.  
  634.     xsize = max_x/5;    ysize = max_y/5;
  635.  
  636.       hatch_init();
  637.     /* set up the window */
  638.     strcpy(str[0],"Rectangles and boxes can be drawn");
  639.     strcpy(str[1],"in any color or size.");
  640.     strcpy(str[2],"Hatch styles or solids may");
  641.     strcpy(str[3],"be used for filling.");
  642.     strcpy(str[4]," ");
  643.     strcpy(str[5],"Hit any key to continue.");
  644.     strcpy(str[6],"or change screens.");
  645.     for (i = 0; i < 7; i++)
  646.             s[i] = str[i];
  647.  
  648.     clearscr(0);
  649.     switch(dev){
  650.         case 0 :    eg_window(4,1,"ibmrom",200,75,7,s,3,2,1);
  651.                     break;
  652.         case 1 :    eg_window(4,1,"sbo.sms",200,75,7,s,4,15,1);
  653.                     break;
  654.         case 2 :    eg_window(4,1,"sbo.sms",200,75,7,s,4,15,1);
  655.                     break;
  656.         case 3 :    eg_window(4,1,"sbo.sms",200,75,7,s,1,0,1);
  657.                     break;
  658.         case 4 :    eg_window(4,1,"sbo.sms",200,75,7,s,4,15,1);
  659.                     break;
  660.         case 5 :    eg_window(4,1,"sbo.sms",200,75,7,s,4,15,1);
  661.                     break;
  662.         case 6 :
  663.         case 7 :    eg_window(4,1,"roman3.sms",200,75,7,s,4,15,1);
  664.                     break;
  665.     }
  666.  
  667.     clearscr(0);
  668.     while(inkey(&key) == -1){
  669.          x = rand()%(max_x-xsize); 
  670.          y = rand()%(max_y-ysize); 
  671.          eg_rectangle(x,y,x+rand()%xsize,y+rand()%ysize,rand()%max_colors,0,-1);
  672.     }
  673.     clearscr(0);
  674.     while(inkey(&key) == -1){
  675.          x = rand()%(max_x-xsize); 
  676.          y = rand()%(max_y-ysize); 
  677.          eg_rectangle(x,y,x+rand()%xsize,y+rand()%ysize,rand()%max_colors,1,-1);
  678.     }
  679.     clearscr(0);
  680.     while(inkey(&key) == -1){
  681.          x = rand()%(max_x-xsize); 
  682.          y = rand()%(max_y-ysize); 
  683.          eg_rectangle(x,y,x+rand()%xsize,y+rand()%ysize,rand()%max_colors,rand()%2,rand()%4);
  684.     }
  685. }
  686.  
  687. bit_mapped_fonts()
  688. {
  689.     char chr,strgpt[10];
  690.     int x_loc,y_loc,font,x,y,key,pixels,i;
  691.     int c,h,ch,lf,vsize,hsize,baseline;
  692.  
  693.     fontinit();
  694.     /* load up all fonts */
  695.    if (font_load(0,"ibmrom")){
  696.          printf("Error loading fonts!!!\n");
  697.          exit(0);
  698.     }
  699.    if (font_load(1,"sbo.sms")){
  700.          printf("Error loading fonts!!!\n");
  701.          exit(0);
  702.     }
  703.     if (dev != 3){
  704.        if (font_load(2,"ega8x14")){
  705.              printf("Error loading fonts!!!\n");
  706.              exit(0);
  707.         }
  708.     }
  709.     else{
  710.        if (font_load(2,"mono.sms")){
  711.              printf("Error loading fonts!!!\n");
  712.              exit(0);
  713.         }
  714.     }
  715.    if (font_load(3,"roman3.sms")){
  716.          printf("Error loading fonts!!!\n");
  717.          exit(0);
  718.     }
  719.    if (font_load(4,"moon.sms")){
  720.          printf("Error loading fonts!!!\n");
  721.          exit(0);
  722.     }
  723.    if (font_load(5,"sboi.sms")){
  724.          printf("Error loading fonts!!!\n");
  725.          exit(0);
  726.     }
  727.    if (font_load(6,"script1.sms")){
  728.          printf("Error loading fonts!!!\n");
  729.          exit(0);
  730.     }
  731.  
  732.   clipsize(0,0,max_x,max_y+1);
  733.   clipon();
  734.  
  735.     /* set up the window */
  736.     strcpy(str[0],"Essential Graphic's comes complete");
  737.     strcpy(str[1],"with 10 bit mapped fonts.  Hundreds");
  738.     strcpy(str[2],"more are also available thru third");
  739.     strcpy(str[3],"party vendors.");
  740.     strcpy(str[4]," ");
  741.     strcpy(str[5],"Hit any key to change screens.");
  742.     strcpy(str[6]," ");
  743.     strcpy(str[7],"Let's look at some !");
  744.     for (i = 0; i < 8; i++)
  745.             s[i] = str[i];
  746.  
  747.     clearscr(color[0]);
  748.     switch(dev){
  749.         case 0 :    eg_window(3,1,"ibmrom",200,75,8,s,2,3,1);
  750.                     color[4] = 2; color[15] = 3;
  751.                     break;
  752.         case 1 :    eg_window(4,1,"sbo.sms",200,75,8,s,15,1,1);
  753.                     break;
  754.         case 2 :    eg_window(4,1,"sbo.sms",200,75,8,s,15,1,1);
  755.                     break;
  756.         case 3 :    eg_window(4,1,"sbo.sms",200,75,8,s,1,0,1);
  757.                     break;
  758.         case 4 :    eg_window(4,1,"sbo.sms",200,75,8,s,15,1,1);
  759.                     break;
  760.         case 5 :    eg_window(4,1,"sbo.sms",200,75,8,s,15,1,1);
  761.                     break;
  762.         case 6 :
  763.         case 7 :    eg_window(4,1,"roman3.sms",200,75,8,s,4,15,1);
  764.                     break;
  765.     }
  766.  
  767.   clearscr(color[4]);
  768. /* display random font strings */
  769.   while (inkey(&key) == -1){
  770.      x_loc =  rand()%max_x;
  771.      y_loc =  rand()%max_y;
  772.      font  =  rand()%7;
  773.      if (font != 4)
  774.          pixels = fontpixn(font,"A graphics text string.",0,23);
  775.      else
  776.          pixels = fontpixn(font,"Large text string.",0,18);
  777.  
  778.      font_info(font,&c,&h,&ch,&lf,&vsize,&hsize,&baseline);
  779.  
  780.      if (pixels+x_loc >= max_x) x_loc = max_x - pixels;
  781.      if (vsize+y_loc >= max_y) y_loc = max_y - vsize;
  782.      if (y_loc -vsize <= 0) y_loc = 0 + vsize;
  783.     
  784.      if (font != 4){
  785.          fhatsay(font,"A graphics text string.",color[15],x_loc,y_loc);
  786.          syspause(0,0,0,20);
  787.      }
  788.      else{
  789.          fhatsay(font,"Large text string.",color[15],x_loc,y_loc);
  790.          syspause(0,0,0,20);
  791.      }
  792.     
  793.      if (font != 4){
  794.          fhatsay(font,"A graphics text string.",color[4],x_loc,y_loc);
  795.          syspause(0,0,0,20);
  796.      }
  797.      else{
  798.          fhatsay(font,"Large text string.",color[4],x_loc,y_loc);
  799.          syspause(0,0,0,20);
  800.      }
  801.   }
  802.  
  803. /* display a full screen of all font characters */
  804.  
  805.   for (font = 0; font < 7; font++){
  806.        clearscr(color[4]);
  807.        font_info(font,&c,&h,&ch,&lf,&vsize,&hsize,&baseline);
  808.        chr = 33;
  809.        for (y_loc = vsize*2; y_loc <= max_y; y_loc += vsize+5){
  810.             fcurloc(hsize,y_loc); x = hsize;
  811.             while (x+hsize < max_x){
  812.                    fcurch(font,chr,0,color[15],0);
  813.                    fcurget(&x,&y);
  814.                    chr++;
  815.                    if (chr >= 100) chr = 33;
  816.            }
  817.       }
  818.         strcpy(str[0],"Font size = ");
  819.         egitoa(strgpt,hsize);
  820.         strcat(str[0],strgpt);
  821.         strcat(str[0]," x ");
  822.         egitoa(strgpt,vsize);
  823.         strcat(str[0],strgpt);
  824.         strcpy(str[1]," ");
  825.         strcpy(str[2],"Hit Return at any time");
  826.         strcpy(str[3],"to move to the next");
  827.         strcpy(str[4],"screen.");
  828.         for (i = 0; i < 5; i++)
  829.                         s[i] = str[i];
  830.  
  831.         switch(dev){
  832.             case 0 :    eg_window(4,1,"ibmrom",200,75,5,s,3,1,1);
  833.                         break;
  834.             case 1 :    eg_window(4,1,"sbo.sms",200,75,5,s,15,1,1);
  835.                         break;
  836.             case 2 :    eg_window(4,1,"sbo.sms",200,75,5,s,15,1,1);
  837.                         break;
  838.             case 3 :    eg_window(4,1,"sbo.sms",200,75,5,s,1,0,1);
  839.                         break;
  840.             case 4 :    eg_window(4,1,"sbo.sms",200,75,5,s,15,1,1);
  841.                         break;
  842.             case 5 :    eg_window(4,1,"sbo.sms",200,75,5,s,15,1,1);
  843.                         break;
  844.             case 6 :
  845.             case 7 :    eg_window(4,1,"roman3.sms",200,75,5,s,15,1,1);
  846.                         break;
  847.         }
  848.     }
  849.     fontquit();
  850. }
  851.  
  852. vector_fonts()
  853. {
  854.     int recs,j,i,col,row,descender,w,h,base_line,desc;
  855.     double size,start;
  856.     char ptr[1000],t[80],font[80];
  857.     struct vfont *fk;
  858.     int height,width;
  859.     double f,ff;
  860.     char strgpt[20];
  861.  
  862. /* load up a font */
  863.     fk = vfontld("s2ur.vec",&j);
  864.     if (j < 0){
  865.        printf("\r\nvfontld return:%d\r\n",j);
  866.         exit(0);
  867.     }
  868.  
  869. /* set up scaling factor */
  870.  
  871.     start = .8; 
  872.     switch(dev){
  873.         case 0 :    start = .35; break;
  874.         case 4 :    
  875.         case 5 :    
  876.         case 6 :
  877.         case 7 :    start = 1.0; break;
  878.     }
  879.  
  880.     strcpy(str[0],"Essential Graphic's comes complete");
  881.     strcpy(str[1],"with 10 vector based fonts.  Unlike");
  882.     strcpy(str[2],"bit mapped fonts, these fonts are");
  883.     strcpy(str[3],"scalable and rotatable.");
  884.     strcpy(str[4]," ");
  885.     strcpy(str[5],"Let's look at some !");
  886.     for (i = 0; i < 6; i++)
  887.             s[i] = str[i];
  888.  
  889.     clearscr(0);
  890.     switch(dev){
  891.         case 0 :    eg_window(2,1,"ibmrom",200,75,6,s,3,2,1);
  892.                     color[15] = 3; color[14] = 2;
  893.                     break;
  894.         case 1 :    eg_window(4,1,"sbo.sms",200,75,6,s,4,15,1);
  895.                     break;
  896.         case 2 :    eg_window(4,1,"sbo.sms",200,75,6,s,4,15,1);
  897.                     break;
  898.         case 3 :    eg_window(4,1,"sbo.sms",200,75,6,s,1,0,1);
  899.                     break;
  900.         case 4 :    eg_window(4,1,"sbo.sms",200,75,6,s,4,15,1);
  901.                     break;
  902.         case 5 :    eg_window(4,1,"sbo.sms",200,75,6,s,4,15,1);
  903.                     break;
  904.         case 6 :
  905.         case 7 :    eg_window(4,1,"roman3.sms",200,75,6,s,4,15,1);
  906.                     break;
  907.     }
  908.  
  909.     descender = j = 0;
  910.     recs = vfchset(fk,ptr);
  911.     while(j < recs){
  912.             vfchinf(fk,ptr[j],&w,&h,&base_line);
  913.             if (base_line > descender)
  914.                  descender = base_line;
  915.             j++;
  916.     }
  917.     desc = descender;
  918.  
  919.     sprintf(t,"==>%%.%ds<==\r\n",recs);
  920.     for (size = (double)start; size <= (double)start*3.0; size += (double)start){
  921.           descender = desc;    
  922.           vfscale(fk,(double)size);
  923.           f = descender * size + .5;
  924.           descender = f;
  925.           f = fk->maxhigh * size + .5;
  926.           height = f;
  927.           f = fk->maxwidth * size + .5;
  928.           width = f;
  929.           j = 0;    
  930.           while(j < recs){
  931.               row = height + 1;
  932.               clearscr(0);
  933.               while(j < recs){
  934.                      col = 10;
  935.                        eg_line(0,row,max_x-1,row,color[14]);
  936.                     while(j < recs){
  937.                           i = vfontch(fk,ptr[j],col,row,color[15],0,&col,&row);
  938.                           if (i == -1){
  939.                              initgraf(3,0,0);
  940.                              printf("return error of %d on vfontch\r\n",i);
  941.                               exit(0);
  942.                             }
  943.                           ++j;
  944.                           if(col+width+1 > max_x-1) break;
  945.                     }
  946.                     row += height + 1 + descender;
  947.                     if(row + descender > max_y-1) break;
  948.                 }
  949.                 putch(7); 
  950.  
  951.                 strcpy(str[0],"Scaled size = ");
  952.                sprintf(strgpt,"%1.3f\n",size);
  953.                 strgpt[strlen(strgpt)-1] = '\0';
  954.                 strcat(str[0],strgpt);
  955.                 strcpy(str[1]," ");
  956.                 strcpy(str[2],"Hit Return at any time");
  957.                 strcpy(str[3],"to move to the next");
  958.                 strcpy(str[4],"screen.");
  959.                 for (i = 0; i < 5; i++)
  960.                         s[i] = str[i];
  961.         
  962.                 switch(dev){
  963.                     case 0 :    eg_window(4,1,"ibmrom",200,75,5,s,3,2,1);
  964.                                 break;
  965.                     case 1 :    eg_window(4,1,"sbo.sms",200,75,5,s,4,15,1);
  966.                                 break;
  967.                     case 2 :    eg_window(4,1,"sbo.sms",200,75,5,s,4,15,1);
  968.                                 break;
  969.                     case 3 :    eg_window(4,1,"sbo.sms",200,75,5,s,1,0,1);
  970.                                 break;
  971.                     case 4 :    eg_window(4,1,"sbo.sms",200,75,5,s,4,15,1);
  972.                                 break;
  973.                     case 5 :    eg_window(4,1,"sbo.sms",200,75,5,s,4,15,1);
  974.                                 break;
  975.                     case 6 :
  976.                     case 7 :    eg_window(4,1,"roman3.sms",200,75,5,s,4,15,1);
  977.                                 break;
  978.                 }
  979.           }
  980.     }
  981.  
  982.     /* rotate a string */
  983.  
  984.     clearscr(0);
  985.     strcpy(ptr,"ABCDE");
  986.    eg_line(max_x/2,max_y/2-10,max_x/2,max_y/2+10,color[14]);
  987.     eg_line(max_x/2-20,max_y/2,max_x/2+20,max_y/2,color[14]);
  988.     for (size = (double)start; size <= (double)start*4.0; size += (double)start){
  989.             vfscale(fk,(double)size);
  990.           for(j = 0; j < 360; j += 60){
  991.                 if (dev ==3)
  992.                     vfsprtc(fk,ptr,max_x/2,max_y/2,1,j);
  993.                 else
  994.                     vfsprtc(fk,ptr,max_x/2,max_y/2,rand()%(max_colors-1)+1,j);
  995.             }
  996.     }
  997.     vfontuld(fk);
  998.     strcpy(str[0],"Hit Return at any time");
  999.     strcpy(str[1],"to move to the next");
  1000.     strcpy(str[2],"screen.");
  1001.     for (i = 0; i < 3; i++)
  1002.             s[i] = str[i];
  1003.         
  1004.     switch(dev){
  1005.         case 0 :    eg_window(4,1,"ibmrom",200,75,3,s,3,2,1);
  1006.                     break;
  1007.         case 1 :    eg_window(4,1,"sbo.sms",200,75,3,s,4,15,1);
  1008.                     break;
  1009.         case 2 :    eg_window(4,1,"sbo.sms",200,75,3,s,4,15,1);
  1010.                     break;
  1011.         case 3 :    eg_window(4,1,"sbo.sms",200,75,3,s,1,0,1);
  1012.                     break;
  1013.         case 4 :    eg_window(4,1,"sbo.sms",200,75,3,s,4,15,1);
  1014.                     break;
  1015.         case 5 :    eg_window(4,1,"sbo.sms",200,75,3,s,4,15,1);
  1016.                     break;
  1017.         case 6 :
  1018.         case 7 :    eg_window(4,1,"roman3.sms",200,75,3,s,4,15,1);
  1019.                     break;
  1020.     }
  1021. }
  1022.  
  1023.  
  1024. two_d_grafs()
  1025. {
  1026.     int pts1[20],pts2[20],pts3[20],pts4[20];    /* arrays of points */
  1027.     int j,i,key,graph,w;
  1028.     int numpts;                            /* number of points to graph */
  1029.     int scatter[50][2];                /* array of scatter points */
  1030.     int hilow[20][3];                    /* array of hi-low-close points */
  1031.     int stack[20][3];                    /* array of stack bar points */
  1032.     char colors[10];                    /* colors */
  1033.     char labels[20][30],*l[20];    /* labels */
  1034.     char title[50];                    /* title string */
  1035.     char x_descrip_label[20];        /* description labels */
  1036.     char y_descrip_label[20];
  1037.     GRAPH_INFO gg;                        /* structures for graphs */
  1038.     EG_AXIS x_axis,y_axis;
  1039.  
  1040. /* symbol functions */
  1041.     extern int symbol_x();
  1042.     extern int symbol_box();
  1043.     extern int symbol_circle();
  1044.     extern int symbol_star();
  1045.     extern int symbol_tri();
  1046.     extern int symbol_plus();
  1047.     extern int symbol_diamd();    
  1048.  
  1049. /* initialize data for the graphs */
  1050.  
  1051.     pts1[0] = 10; pts1[1] = 7; pts1[2] = 80; pts1[3] = 70; pts1[4] = 60; 
  1052.     pts1[5] = 50; pts1[6] = 6; pts1[7] = 99; pts1[8] = 65; pts1[9] = 60; 
  1053.     pts1[10] = 60; pts1[11] = 44;    pts1[12] = 3; pts1[13] = 10; 
  1054.     pts1[14] = 44; pts1[15] = 11;
  1055.  
  1056.     pts2[0] = 5; pts2[1] = 11; pts2[2] = 20; pts2[3] = 30;
  1057.     pts2[4] = 40; pts2[5] = 40; pts2[6] = 60; pts2[7] = 65;
  1058.     pts2[8] = 70; pts2[9] = 80; pts2[10] = 81; pts2[11] = 85;
  1059.     pts2[12] = 90; pts2[13] = 93; pts2[14] = 94; pts2[15] = 97;
  1060.     
  1061.     pts3[0] = 12; pts3[1] = 44; pts3[2] = 32; pts3[3] = 45;
  1062.     pts3[4] = 65; pts3[5] = 70; pts3[6] = 75; pts3[7] = 80;
  1063.     pts3[8] = 70; pts3[9] = 60; pts3[10] = 51; pts3[11] = 45;
  1064.     pts3[12] = 30; pts3[13] = 23; pts3[14] = 14; pts3[15] = 7;
  1065.  
  1066.     pts4[0] = 80; pts4[1] = 80; pts4[2] = 70; pts4[3] = 70;
  1067.     pts4[4] = 60; pts4[5] = 60; pts4[6] = 50; pts4[7] = 50;
  1068.     pts4[8] = 40; pts4[9] = 30; pts4[10] = 20; pts4[11] = 75;
  1069.  
  1070.     stack[0][0] = 30;     stack[0][1] = 20;     stack[0][2] = 10;
  1071.     stack[1][0] = 60;     stack[1][1] = 20;     stack[1][2] = 10;
  1072.     stack[2][0] = 10;     stack[2][1] =  8;     stack[2][2] =  6;
  1073.     stack[3][0] = 60;     stack[3][1] = 40;     stack[3][2] = 8;
  1074.     stack[4][0] = 15;     stack[4][1] = 40;     stack[4][2] = 20;
  1075.     stack[5][0] = 30;     stack[5][1] = 45;     stack[5][2] = 22;
  1076.     stack[6][0] = 11;     stack[6][1] = 22;     stack[6][2] = 33;
  1077.     stack[7][0] = 10;     stack[7][1] = 68;     stack[7][2] = 6;
  1078.     stack[8][0] = 20;     stack[8][1] = 40;     stack[8][2] = 20;
  1079.     stack[9][0] = 30;     stack[9][1] = 30;     stack[9][2] = 30;
  1080.     stack[10][0] = 10;     stack[10][1] = 10;     stack[10][2] = 5;
  1081.     stack[11][0] = 70;     stack[11][1] = 11;     stack[11][2] = 15;
  1082.  
  1083.     hilow[0][0] = 30;     hilow[0][1] = 20;     hilow[0][2] = 30;
  1084.     hilow[1][0] = 90;     hilow[1][1] = 50;     hilow[1][2] = 70;
  1085.     hilow[2][0] = 10;     hilow[2][1] =  8;     hilow[2][2] =  9;
  1086.     hilow[3][0] = 90;     hilow[3][1] = 40;     hilow[3][2] = 50;
  1087.     hilow[4][0] = 100;     hilow[4][1] = 10;     hilow[4][2] = 20;
  1088.     hilow[5][0] = 90;     hilow[5][1] = 45;     hilow[5][2] = 62;
  1089.     hilow[6][0] = 54;     hilow[6][1] = 24;     hilow[6][2] = 34;
  1090.     hilow[7][0] = 97;     hilow[7][1] = 68;     hilow[7][2] = 76;
  1091.     hilow[8][0] = 70;     hilow[8][1] = 40;     hilow[8][2] = 60;
  1092.     hilow[9][0] = 60;     hilow[9][1] = 40;     hilow[9][2] = 50;
  1093.     hilow[10][0] = 90;     hilow[10][1] = 10;     hilow[10][2] = 20;
  1094.     hilow[11][0] = 40;     hilow[11][1] = 12;     hilow[11][2] = 30;
  1095.     hilow[12][0] = 50;     hilow[12][1] = 34;     hilow[12][2] = 41;
  1096.     hilow[13][0] = 75;     hilow[13][1] = 56;     hilow[13][2] = 63;
  1097.     hilow[14][0] = 33;     hilow[14][1] =  5;     hilow[14][2] = 21;
  1098.     hilow[15][0] = 106;     hilow[15][1] = 40;     hilow[15][2] = 70;
  1099.     hilow[16][0] = 87;     hilow[16][1] = 34;     hilow[16][2] = 50;
  1100.     hilow[17][0] = 21;     hilow[17][1] = 12;     hilow[17][2] = 17;
  1101.     hilow[18][0] = 44;     hilow[18][1] = 23;     hilow[18][2] = 31;
  1102.     hilow[19][0] = 56;     hilow[19][1] = 10;     hilow[19][2] = 34;
  1103.  
  1104. /* set up labels, small for CGA */
  1105.     
  1106.     if (dev > 1){    
  1107.         strcpy(labels[0],"January");    strcpy(labels[1],"February");
  1108.         strcpy(labels[2],"March");         strcpy(labels[3],"April");
  1109.         strcpy(labels[4],"May");         strcpy(labels[5],"June");
  1110.         strcpy(labels[6],"July");         strcpy(labels[7],"August");
  1111.         strcpy(labels[8],"September");strcpy(labels[9],"October");
  1112.         strcpy(labels[10],"November");strcpy(labels[11],"December");
  1113.         strcpy(labels[12],"January");    strcpy(labels[13],"February");
  1114.         strcpy(labels[14],"March");
  1115.     }
  1116.     else{
  1117.         strcpy(labels[0],"Jan");    strcpy(labels[1],"Feb");
  1118.         strcpy(labels[2],"Mar");    strcpy(labels[3],"Apr");
  1119.         strcpy(labels[4],"May");      strcpy(labels[5],"Jun");
  1120.         strcpy(labels[6],"Jul");     strcpy(labels[7],"Aug");
  1121.         strcpy(labels[8],"Sep");    strcpy(labels[9],"Oct");
  1122.         strcpy(labels[10],"Nov");    strcpy(labels[11],"Dec");
  1123.         strcpy(labels[12],"Jan");    strcpy(labels[13],"Feb");
  1124.         strcpy(labels[14],"Mar");
  1125.     }
  1126.  
  1127.     /* init for fonts */
  1128.  
  1129.     fontinit();
  1130.  
  1131. /* font for axis labels */ 
  1132.     if (font_load(0,"ibmrom")){
  1133.          printf("IBMROM font not available !!!\n");
  1134.          exit(0);
  1135.     }
  1136.     if (font_load(1,"vga8x16")){
  1137.          printf("VGA8X16 font not available !!!\n");
  1138.          exit(0);
  1139.     }
  1140.     if (font_load(2,"roman3.sms")){
  1141.          printf("ROMAN3.ESI font not available !!!\n");
  1142.          exit(0);
  1143.     }
  1144.     if (font_load(3,"ega8x14")){
  1145.          printf("ega8x14 font not available !!!\n");
  1146.          exit(0);
  1147.     }
  1148.     if (font_load(4,"sbo.sms")){
  1149.          printf("SBO.ESI font not available !!!\n");
  1150.          exit(0);
  1151.     }
  1152.     if (font_load(5,"micprint.sms")){
  1153.          printf("IBMROM font not available !!!\n");
  1154.          exit(0);
  1155.     }
  1156.  
  1157.     font_change(0,-1,-1,-1,0,-1);        /* change the font spacing */
  1158.  
  1159.     /* set up general graph info */
  1160.  
  1161.    gg.title_loc = TOP;                    /* title at top */
  1162.     gg.bar_mid_value = -1;
  1163.     gg.bar_type = 0;                         /* default bar type to 0 */
  1164.     gg.frame_back  =     color[7];        /* frame background is color 7 */    
  1165.     gg.frame_color =     color[15];        /* frame color is color 15 */    
  1166.     gg.frame_width = 1;
  1167.     gg.frame_style = 0xffff;
  1168.     gg.title_gap = -1;    
  1169.     x_axis.axis_gap = -1; 
  1170.     y_axis.axis_gap = -1;
  1171.     gg.line_width = 3;
  1172.     gg.title_color = color[15];
  1173.     gg.symbol_fill = 1;                    /* default to filled symbols */
  1174.     gg.symbol_size = -1;                
  1175.     gg.item_color = color[1]; 
  1176.     gg.symbol_color = color[2];
  1177.     numpts = 12;                             /* number of points = 12 */
  1178.  
  1179.     /* set up Axis description labels */
  1180.  
  1181.      strcpy(x_descrip_label,"Months For 1989");
  1182.     strcpy(y_descrip_label,"Gross   Profits");
  1183.  
  1184.     /* set up X axis */
  1185.  
  1186.     x_axis.label_type = MANUAL_SET;
  1187.     x_axis.axis_width = 1;    
  1188.     x_axis.axis_style = 0xffff;
  1189.     x_axis.label_color = color[15];    
  1190.     x_axis.descrip_color = color[4];    
  1191.     x_axis.grid_color = color[1];
  1192.     x_axis.tick_gap = -1;     
  1193.     x_axis.tick_size = -1;
  1194.     x_axis.grid_width = 1;    
  1195.     x_axis.num_labels = 12;
  1196.     x_axis.num_grids  = 11;      
  1197.     x_axis.grid_style = 0xffff;
  1198.     x_axis.num_ticks = 11;    
  1199.     x_axis.tick_color = color[15];    
  1200.  
  1201.     /* set up Y axis */
  1202.  
  1203.     y_axis.label_type = AUTO_SET;
  1204.     y_axis.axis_width = 1;    
  1205.     y_axis.axis_style = 0xffff;
  1206.     y_axis.label_color = color[14];    
  1207.     y_axis.descrip_color = color[1];    
  1208.     y_axis.grid_color = color[2];
  1209.     y_axis.tick_gap = -1;     
  1210.     y_axis.tick_size = -1;
  1211.     y_axis.grid_width = 1;    
  1212.     y_axis.grid_style = 0xffff;
  1213.     y_axis.num_labels = 11;
  1214.     y_axis.num_grids  = 10;      
  1215.     y_axis.num_ticks = 10;    
  1216.     y_axis.tick_color = color[15];    
  1217.  
  1218.     /* set up label pointers */
  1219.  
  1220.     for (i = 0; i < numpts; i++)
  1221.           l[i] = labels[i];
  1222.     x_axis.labels = l;
  1223.     y_axis.labels = l;
  1224.  
  1225. /* graph 9 items */
  1226.  
  1227.     for (graph = 0; graph < 9; graph++){ 
  1228.           clearscr(0);
  1229.  
  1230.             gg.line_graph_type = LINE_AND_SYMBOL;
  1231.  
  1232.         /* set up pointers to labels */
  1233.             x_axis.descrip_label = x_descrip_label;
  1234.             y_axis.descrip_label = y_descrip_label;
  1235.             gg.title_label  = title;
  1236.         
  1237.         /* set up items specific to cards */
  1238.  
  1239.             switch(dev){
  1240.                 case 0 : color[4] = 2; color[5] = 3; color[15] = 3;
  1241.                             color[9] = 1; color[10] = 2; color[11] = 3;
  1242.                             color[13] = 2;                        
  1243.                             x_axis.grid_color = gg.title_color = 3;
  1244.                             x_axis.label_color = x_axis.tick_color = 3; 
  1245.                             y_axis.label_color = y_axis.tick_color = 3; 
  1246.                             x_axis.descrip_color =    y_axis.descrip_color =    3;
  1247.                             gg.frame_back  =      color[0];
  1248.                             gg.frame_color =     3;
  1249.                             x_axis.grid_color = y_axis.grid_color = color[3];
  1250.                     /* use the ibmrom font for labels */
  1251.                             x_axis.descrip_font = y_axis.descrip_font = 0; 
  1252.                             x_axis.axis_font = y_axis.axis_font = 5;  
  1253.                             gg.title_font = 0; 
  1254.                             x_axis.axis_font = 0;  y_axis.axis_font = 0;  
  1255.                             gg.line_width = 1;
  1256.                             gg.title_color = color[3];
  1257.                             gg.item_color = color[2]; gg.symbol_color = color[3];
  1258.                             color_hatch();
  1259.                             break;
  1260.                 case 1 : color_hatch();
  1261.                             x_axis.descrip_font = y_axis.descrip_font = 0; 
  1262.                             x_axis.axis_font = y_axis.axis_font = 4;  
  1263.                     /* use the rman3.sms font for the title */
  1264.                             gg.title_font = 2; 
  1265.                             gg.bar_mid_width = 2;
  1266.                             break;
  1267.                 case 2 : gg.bar_mid_width = 3;
  1268.                             color_hatch();
  1269.                             x_axis.descrip_font = y_axis.descrip_font = 4; 
  1270.                             x_axis.axis_font = y_axis.axis_font = 1;  
  1271.                             gg.title_font = 2; 
  1272.                             break;
  1273.                 case 3 : color[1] = color[2] = color[3] = color[4] = color[5] = 1;
  1274.                             x_axis.descrip_color = x_axis.tick_color = color[1]; 
  1275.                             y_axis.descrip_color = y_axis.tick_color = color[1]; 
  1276.                             x_axis.label_color =    y_axis.label_color =    color[1];
  1277.                             gg.frame_back  =      color[0];
  1278.                             gg.frame_color =     color[1];
  1279.                             x_axis.grid_color = y_axis.grid_color = color[1];
  1280.                             x_axis.descrip_font = y_axis.descrip_font = 4; 
  1281.                             x_axis.axis_font = y_axis.axis_font = 0;  
  1282.                             gg.title_font = 2; 
  1283.                             gg.line_width = 1;
  1284.                             gg.title_color = x_axis.tick_color = color[1];
  1285.                             y_axis.tick_color = color[1];
  1286.                             gg.item_color = gg.symbol_color = color[1];
  1287.                             mono_hatch();
  1288.                             gg.bar_mid_width = 3;
  1289.                             break;
  1290.                 case 4 : gg.line_width = 5;
  1291.                             gg.bar_mid_width = 5;
  1292.                             x_axis.descrip_font = y_axis.descrip_font = 4; 
  1293.                             x_axis.axis_font = y_axis.axis_font = 1;  
  1294.                     /* use the rman3.sms font for the title */
  1295.                             gg.title_font = 2; 
  1296.                             color_hatch();
  1297.                             break;
  1298.                 case 5 : gg.line_width = 5;
  1299.                             gg.bar_mid_width = 5;
  1300.                             x_axis.descrip_font = y_axis.descrip_font = 4; 
  1301.                             x_axis.axis_font = y_axis.axis_font = 1;  
  1302.                             gg.title_font = 2; 
  1303.                             color_hatch();
  1304.                             break;
  1305.                 case 6 :
  1306.                 case 7 : gg.line_width = 6;
  1307.                             x_axis.descrip_font = y_axis.descrip_font = 4; 
  1308.                             x_axis.axis_font = y_axis.axis_font = 1;  
  1309.                     /* use the rman3.sms font for the title */
  1310.                             gg.title_font = 2; 
  1311.                             gg.bar_mid_width = 5;
  1312.                             color_hatch();
  1313.                             break;
  1314.             }
  1315.  
  1316.     /* use the whole screen as a viewport */
  1317.  
  1318.             setview(0,0,max_x,max_y);
  1319.  
  1320.     /* draw a graph */
  1321.  
  1322.             switch(graph){
  1323.                 case 0 :    gg.graph_type = LINE_GRAPH;         
  1324.                             gg.line_style = 0xffff;
  1325.                             gg.adjust_edges = 0;
  1326.                             x_axis.low = 0;    x_axis.high = numpts;
  1327.                             y_axis.low = 0;    y_axis.high = 110;
  1328.                             gg.line_width = -1;
  1329.                             gg.frame_type = FULL_FRAME;
  1330.                             strcpy(title,"Non-Centered Line Graph");
  1331.                             gg.item_color = color[2]; gg.symbol_color = color[15];
  1332.                             set_graf_symbol(symbol_circle); 
  1333.                             eg_graph(numpts,pts1,WHOLE_GRAPH,gg,x_axis,y_axis);
  1334.                             gg.item_color = color[3]; gg.symbol_color = color[15];
  1335.                             set_graf_symbol(symbol_tri);
  1336.                             eg_graph(numpts,pts2,DATA_ONLY,gg,x_axis,y_axis);
  1337.                             gg.item_color = color[4]; gg.symbol_color = color[15];
  1338.                             set_graf_symbol(symbol_box);
  1339.                             eg_graph(numpts,pts3,DATA_ONLY,gg,x_axis,y_axis);
  1340.                             gg.item_color = color[5]; gg.symbol_color = color[15];
  1341.                             set_graf_symbol(symbol_diamd);
  1342.                             eg_graph(numpts,pts4,DATA_ONLY,gg,x_axis,y_axis);
  1343.                             twod_win(200,75);
  1344.                             break;
  1345.                 case 1 :    gg.graph_type = LINE_GRAPH;         gg.adjust_edges = 1;
  1346.                             gg.line_style = 0xffff;
  1347.                             gg.line_width = 3;
  1348.                             x_axis.low = 0;    x_axis.high = numpts;
  1349.                             y_axis.low = 0;    y_axis.high = 110;
  1350.                             gg.frame_type = HALF_FRAME;
  1351.                             strcpy(title,"Centered Line Graph");
  1352.                             gg.item_color = color[2]; gg.symbol_color = color[15];
  1353.                             set_graf_symbol(symbol_x);
  1354.                             eg_graph(numpts,pts1,WHOLE_GRAPH,gg,x_axis,y_axis);
  1355.                             gg.item_color = color[3]; gg.symbol_color = color[15];
  1356.                             set_graf_symbol(symbol_star);
  1357.                             eg_graph(numpts,pts2,DATA_ONLY,gg,x_axis,y_axis);
  1358.                             gg.item_color = color[4]; gg.symbol_color = color[15];
  1359.                             set_graf_symbol(symbol_plus);
  1360.                             eg_graph(numpts,pts3,DATA_ONLY,gg,x_axis,y_axis);
  1361.                             gg.item_color = color[5]; gg.symbol_color = color[15];
  1362.                             set_graf_symbol(symbol_diamd);
  1363.                             eg_graph(numpts,pts4,DATA_ONLY,gg,x_axis,y_axis);
  1364.                             twod_win(200,75);
  1365.                             break;
  1366.                 case 2 : gg.graph_type = SCATTER_GRAPH;         
  1367.                             x_axis.label_type = 0;
  1368.                             y_axis.label_type = 0;
  1369.                             x_axis.label_type = AUTO_SET;
  1370.                             y_axis.label_type = AUTO_SET;
  1371.                             x_axis.low = 0;    x_axis.high = 1000;
  1372.                             y_axis.low = 0;    y_axis.high = 2000;
  1373.                             gg.adjust_edges = 0;
  1374.                             gg.symbol_color = color[4];
  1375.                             numpts = 50;
  1376.                             gg.symbol_size = max_y / 30;
  1377.                             set_graf_symbol(symbol_star); 
  1378.                             gg.frame_type = FULL_FRAME;
  1379.                             x_axis.num_labels = 21;        
  1380.                             y_axis.num_labels = 11;      
  1381.                             x_axis.num_grids  = 20;      y_axis.num_grids  = 10;
  1382.                             x_axis.num_ticks = 20;      y_axis.num_ticks = 10;
  1383.                             for (i = 0; i < 50; i++){
  1384.                                   scatter[i][0] = rand()%(x_axis.high-x_axis.low);
  1385.                                   scatter[i][1] = rand()%(y_axis.high-y_axis.low);
  1386.                             }
  1387.                             strcpy(x_descrip_label,"Amount of Carbon");
  1388.                             strcpy(y_descrip_label,"Amount of Silsymbol");
  1389.                             strcpy(title,"Scatter Graph");
  1390.                             eg_graph(numpts,scatter,WHOLE_GRAPH,gg,x_axis,y_axis); 
  1391.                             numpts = 12;
  1392.                             x_axis.label_type = 1;
  1393.                             y_axis.label_type = 1;
  1394.                             twod_win(200,75);
  1395.                             gg.symbol_size = -1;
  1396.                             break;
  1397.                 case 3 : gg.graph_type = HI_LOW_GRAPH; 
  1398.                             gg.frame_type = HALF_FRAME;
  1399.                             x_axis.label_type = MANUAL_SET;
  1400.                             y_axis.label_type = AUTO_SET;
  1401.                             gg.adjust_edges = 1;
  1402.                             numpts = 20;
  1403.                             if (!dev || dev ==3)
  1404.                                  gg.line_width = 3;
  1405.                             gg.item_color = color[15]; 
  1406.                             gg.symbol_color = color[13]; 
  1407.                             x_axis.low = 0; x_axis.high = numpts;
  1408.                             y_axis.low = 0; y_axis.high = 110;
  1409.                          x_axis.num_labels = 12;            /* 10 x axis labels */
  1410.                             y_axis.num_labels = 11;            /* 11 x axis labels */
  1411.                             /* same for grids and ticks per axis */
  1412.                             x_axis.num_grids  = 19;      y_axis.num_grids  = 10;
  1413.                             x_axis.num_ticks = 0;      y_axis.num_ticks = 20;
  1414.                             strcpy(title,"Hi-Low-Close Graph");
  1415.                             strcpy(x_descrip_label,"Acme Stock");
  1416.                             strcpy(y_descrip_label,"Stock   Range");
  1417.                             eg_graph(numpts,hilow,WHOLE_GRAPH,gg,x_axis,y_axis); 
  1418.                             twod_win(200,75);
  1419.                             break;
  1420.                 case 4 : gg.graph_type = BAR_GRAPH;         gg.bar_type = VERT_BARS;
  1421.                             numpts = 12;
  1422.                             gg.series_bars = 1;
  1423.                             gg.num_series = 0;
  1424.                             gg.bar_mid_width = -1;
  1425.                          x_axis.num_labels = 12;            /* 12 x axis labels */
  1426.                             y_axis.num_labels = 11;            /* 11 y axis labels */
  1427.                             x_axis.num_grids  = 11;      y_axis.num_grids  = 10;
  1428.                             x_axis.num_ticks = 11;      y_axis.num_ticks = 10;
  1429.                             x_axis.low = 0;    x_axis.high = numpts;
  1430.                             y_axis.low = 0;    y_axis.high = 110;
  1431.                             gg.frame_type = FULL_FRAME;
  1432.                             strcpy(x_descrip_label,"Months For 1989");
  1433.                             strcpy(y_descrip_label,"Gross   Profits");
  1434.                             strcpy(title,"Vertical Bar Graph");
  1435.                             gg.item_color = color[2]; 
  1436.                              eg_graph(numpts,pts3,WHOLE_GRAPH,gg,x_axis,y_axis);
  1437.                             twod_win(200,75);
  1438.                             gg.series_bars = 3;
  1439.                             gg.num_series = 0;
  1440.                             gg.item_color = color[12]; 
  1441.                              eg_graph(numpts,pts3,WHOLE_GRAPH,gg,x_axis,y_axis);
  1442.                             gg.item_color = color[11]; 
  1443.                             gg.num_series = 1;
  1444.                              eg_graph(numpts,pts2,DATA_ONLY,gg,x_axis,y_axis);
  1445.                             gg.item_color = color[14]; 
  1446.                             gg.num_series = 2;
  1447.                              eg_graph(numpts,pts1,DATA_ONLY,gg,x_axis,y_axis);
  1448.                             twod_win(200,75);
  1449.                             break;
  1450.                 case 5 : gg.graph_type = BAR_GRAPH;          gg.bar_type = HORZ_BARS;
  1451.                             x_axis.low = 0; x_axis.high = 110;
  1452.                             y_axis.low = 0;    y_axis.high = numpts;
  1453.                             x_axis.label_type = AUTO_SET;
  1454.                             y_axis.label_type = MANUAL_SET;
  1455.                             gg.frame_type = HALF_FRAME;
  1456.                             y_axis.num_labels = 12; x_axis.num_labels = 11;
  1457.                             y_axis.num_grids  = 11;     x_axis.num_grids  = 10;
  1458.                             y_axis.num_ticks = 11;     x_axis.num_ticks = 10;
  1459.                             strcpy(y_descrip_label,"Months For 1989");
  1460.                             strcpy(x_descrip_label,"Gross Profits");
  1461.                             strcpy(title,"Horizontal Bar Graph");
  1462.                             gg.series_bars = 1;
  1463.                             gg.num_series = 0;
  1464.                             gg.item_color = color[5]; 
  1465.                              eg_graph(numpts,pts3,WHOLE_GRAPH,gg,x_axis,y_axis);
  1466.                             twod_win(200,75);
  1467.                             gg.series_bars = 3;
  1468.                             gg.num_series = 0;
  1469.                             gg.item_color = color[12]; 
  1470.                              eg_graph(numpts,pts3,WHOLE_GRAPH,gg,x_axis,y_axis);
  1471.                             gg.item_color = color[11]; 
  1472.                             gg.num_series = 1;
  1473.                              eg_graph(numpts,pts2,DATA_ONLY,gg,x_axis,y_axis);
  1474.                             gg.item_color = color[14]; 
  1475.                             gg.num_series = 2;
  1476.                              eg_graph(numpts,pts1,DATA_ONLY,gg,x_axis,y_axis);
  1477.                             twod_win(200,75);
  1478.                             break;
  1479.                 case 6 :    gg.graph_type = STACK_BAR_GRAPH; gg.bar_type = VERT_BARS;
  1480.                             x_axis.low = 0;    x_axis.high = numpts;
  1481.                             y_axis.low = 0;    y_axis.high = 110;
  1482.                             x_axis.num_labels = 12;            /* 10 x axis labels */
  1483.                             y_axis.num_labels = 11;            /* 11 x axis labels */
  1484.                             x_axis.num_grids  = 11;     y_axis.num_grids  = 10;
  1485.                             x_axis.num_ticks = 11;     y_axis.num_ticks = 10;
  1486.                             x_axis.label_type = MANUAL_SET;
  1487.                             y_axis.label_type = AUTO_SET;
  1488.                             gg.frame_type = FULL_FRAME;
  1489.                             numpts = 12;
  1490.                             strcpy(title,"Vertical Stack Bar Graph");
  1491.                             gg.stack_bars = 3;
  1492.                             colors[0] = color[4]; colors[1] = color[15]; colors[2] = color[1];
  1493.                             gg.stack_colors = colors;
  1494.                             eg_graph(numpts,stack,WHOLE_GRAPH,gg,x_axis,y_axis); 
  1495.                             twod_win(200,75);
  1496.                             break;
  1497.                 case 7 :    gg.graph_type = STACK_BAR_GRAPH; gg.bar_type = HORZ_BARS;
  1498.                             x_axis.low = 0; x_axis.high = 110;
  1499.                             y_axis.low = 0;    y_axis.high = numpts;
  1500.                             y_axis.label_type = MANUAL_SET;
  1501.                             x_axis.label_type = AUTO_SET;
  1502.                             gg.frame_type = HALF_FRAME;
  1503.                             y_axis.num_labels = 12;
  1504.                             x_axis.num_labels = 11;
  1505.                             y_axis.num_grids  = 11;     x_axis.num_grids  = 10;
  1506.                             y_axis.num_ticks = 11;     x_axis.num_ticks = 10;
  1507.                             strcpy(y_descrip_label,"Months For 1989");
  1508.                             strcpy(x_descrip_label,"Gross   Profits");
  1509.                             strcpy(title,"Horizontal Stack Bar Graph");
  1510.                             gg.stack_bars = 3;
  1511.                             colors[0] = color[4]; colors[1] = color[15]; colors[2] = color[1];
  1512.                             gg.stack_colors = colors;
  1513.                             eg_graph(numpts,stack,WHOLE_GRAPH,gg,x_axis,y_axis); 
  1514.                             twod_win(200,75);
  1515.                             break;
  1516.                 case 8 : gg.graph_type = BAR_GRAPH;         gg.bar_type = VERT_BARS;
  1517.                             x_axis.low = 0;    x_axis.high = numpts;
  1518.                             y_axis.low = 0;    y_axis.high = 110;
  1519.                             gg.frame_type = HALF_FRAME;
  1520.                             gg.bar_mid_width = 3;
  1521.                             gg.series_bars = 1;
  1522.                             gg.num_series = 0;
  1523.                             x_axis.label_type = MANUAL_SET;
  1524.                             y_axis.label_type = AUTO_SET;
  1525.                             gg.bar_mid_color = color[15];
  1526.                             x_axis.num_labels = 12;            /* 10 x axis labels */
  1527.                             y_axis.num_labels = 11;            /* 11 x axis labels */
  1528.                             x_axis.num_grids  = 11;     y_axis.num_grids  = 10;
  1529.                             x_axis.num_ticks = 11;     y_axis.num_ticks = 10;
  1530.                             strcpy(title,"Above / Below Bar Graph");
  1531.                             gg.bar_mid_value = 50;
  1532.                             gg.item_color = color[10]; 
  1533.                              eg_graph(numpts,pts3,WHOLE_GRAPH,gg,x_axis,y_axis);
  1534.                             twod_win(200,75);
  1535.                             break;
  1536.             }            
  1537.     }
  1538.     clipoff();
  1539.     if (color[4] == 1)
  1540.         color[4] = 0;
  1541.     fontquit();
  1542. }
  1543.  
  1544.  
  1545. /* do some 3-D charting */
  1546.  
  1547. three_d_bars(){
  1548.  
  1549.     sphr_crd rela_obj;     /* theta, phi, rho and sd */
  1550.     struct vfont *vfn1;  /* font to use for cga */
  1551.     int font;                 /* font for the title  */
  1552.     int basetype,bar_bott;
  1553.     double barval[12];        /* for cubebar, pyramid and octahdrn */
  1554.     int i,j;
  1555.     /* for the labels */
  1556.     char lab0[1][80],lab1[1][80],lab2[3][80],lab3[4][80];    
  1557.     char lab4[7][20],lab5[7][20];  
  1558.     char title[4][80];
  1559.     char *lab0_p[1],*lab1_p[1],*lab2_p[3],*lab3_p[4],*lab4_p[7],*lab5_p[7];
  1560.     char l[3][80];                        /* for the legend */
  1561.     char *label[3];                    /* for the legend */
  1562.     stack_cr stackc[3];               /* for the stack bar's color */
  1563.     double stack[12][3];                /* check number of bars in the stack */
  1564.     double base_unit_size,height;
  1565.     int bar_area;
  1566.     int bar_segs = 1;
  1567.  
  1568.     stackc[0].leftc  = color[9];
  1569.     stackc[0].rightc = color[1];
  1570.     stackc[1].leftc  = color[10];
  1571.     stackc[1].rightc = color[2];
  1572.     stackc[2].leftc  = color[11];
  1573.     stackc[2].rightc = color[3];
  1574.  
  1575.     /* assign Title labels */
  1576.  
  1577.     strcpy(title[0],"3-D Bar Chart");
  1578.     strcpy(title[1],"3-D Pyramid Chart");
  1579.     strcpy(title[2],"3-D Octahedron Chart");
  1580.     strcpy(title[3],"3-D Stack Bar Chart");
  1581.  
  1582.     /* assign value to Base labels */
  1583.  
  1584.     strcpy(lab0[0],"WIDGETS");
  1585.     lab0_p[0] = lab0[0];
  1586.     strcpy(lab1[0],"QUARTERS");
  1587.     lab1_p[0] = lab1[0];
  1588.  
  1589.     /* assign value to XY left labels */
  1590.  
  1591.     strcpy(lab2[0],"1986");
  1592.     strcpy(lab2[1],"1987");
  1593.     strcpy(lab2[2],"1988");
  1594.     for (i=0; i<3; ++i)
  1595.         lab2_p[i]=lab2[i];
  1596.  
  1597.     /* assign value to XY right labels */
  1598.  
  1599.     strcpy(lab3[0],"JAN-MAR");
  1600.     strcpy(lab3[1],"APR-JUN");
  1601.     strcpy(lab3[2],"JUL-SEP");
  1602.     strcpy(lab3[3],"OCT-DEC");
  1603.     for (i=0; i<4; ++i)
  1604.         lab3_p[i]=lab3[i];
  1605.  
  1606.  
  1607.     bar_area = 2;                
  1608.     basetype = 0;                /* square base type */
  1609.  
  1610.     /* assign the value to each bar */
  1611.  
  1612.     barval[0] = 300.0;    barval[1] = 200.0;
  1613.     barval[2] = 100.0;    barval[3] = 220.0;
  1614.     barval[4] = 150.0;    barval[5] = 120.0;
  1615.     barval[6] = 180.0;    barval[7] = 90.0;
  1616.     barval[8] = 80.0;     barval[9] = 80.0;
  1617.     barval[10] = 190.0;    barval[11] = 100.0;
  1618.  
  1619.     /* assign the value to each bar in the stack */
  1620.  
  1621.     stack[0][0] = 50.0; stack[0][1] = 100.0;     stack[0][2] = 230.0;
  1622.     stack[1][0] = 30.0;     stack[1][1] = 160.0; stack[1][2] = 190.0;
  1623.     stack[2][0] = 40.0;     stack[2][1] =  100.0; stack[2][2] = 200.0;
  1624.     stack[3][0] = 70.0;     stack[3][1] =  100.0; stack[3][2] = 130.0;
  1625.     stack[4][0] = 30.0; stack[4][1]  = 40.0;     stack[4][2] = 180.0;
  1626.     stack[5][0] = 10.0; stack[5][1] = 70.0;  stack[5][2] = 190.0;
  1627.     stack[6][0] = 20.0;     stack[6][1] = 60.0;  stack[6][2] = 190.0;
  1628.     stack[7][0] = 50.0;     stack[7][1] = 70.0; stack[7][2] = 180.0;
  1629.     stack[8][0] = 20.0; stack[8][1] = 40.0;     stack[8][2] = 200.0;
  1630.     stack[9][0] = 40.0;     stack[9][1] = 90.0; stack[9][2] = 120.0;
  1631.     stack[10][0] = 20.0; stack[10][1] = 100.0; stack[10][2] =  170.0;
  1632.     stack[11][0] = 60.0; stack[11][1] = 70.0;  stack[11][2] = 150.0;
  1633.  
  1634.     /* set the value for the legend */
  1635.  
  1636.     strcpy(l[0],"first year");
  1637.     strcpy(l[1],"second year");
  1638.     strcpy(l[2],"third year");
  1639.     for (i = 0; i< 3; ++i)
  1640.         label[i] = l[i];
  1641.  
  1642.     /* load the bit map font */
  1643.  
  1644.     fontinit();
  1645.     if (font_load(0,"ibmrom")){
  1646.         printf("Error loading ibmrom\n");
  1647.         exit(0);
  1648.     }
  1649.     if (font_load(1,"sbo.sms")){
  1650.         printf("Error loading sbo.sms\n");
  1651.         exit(0);
  1652.     }
  1653.     if (font_load(2,"roman3.sms")){
  1654.         printf("Error loading roman3.sms\n");
  1655.         exit(0);
  1656.     }
  1657.  
  1658.     /* load the vector font */
  1659.  
  1660.     vfn1 = (struct vfont *)vfontld("K0UR.VEC",&j);
  1661.     if (j < 0){
  1662.           printf("\r\nvfontld return:%d\r\n",j);
  1663.           exit(0);
  1664.     } 
  1665.  
  1666.     clearscr(0);
  1667.     strcpy(str[0],"Explode your data on screen in 3-D.");
  1668.     strcpy(str[1],"Essential Graphics has 3-D bar, pyramid,");
  1669.     strcpy(str[2],"octahedrens and stack bar graphs ready to go.");
  1670.     strcpy(str[3]," ");
  1671.     strcpy(str[4],"Let's chart !");
  1672.     for (i = 0; i < 5; i++)
  1673.             s[i] = str[i];
  1674.  
  1675.     clearscr(0);
  1676.     switch(dev){
  1677.         case 0 :    max_x = 639; initgraf(6,0,0);
  1678.                     eg_window(4,1,"ibmrom",200,75,5,s,3,2,1);
  1679.                     break;
  1680.         case 1 :    eg_window(4,1,"sbo.sms",200,75,5,s,4,15,1);
  1681.                     break;
  1682.         case 2 :    eg_window(4,1,"sbo.sms",200,75,5,s,4,15,1);
  1683.                     break;
  1684.         case 3 :    eg_window(4,1,"sbo.sms",200,75,5,s,1,0,1);
  1685.                     break;
  1686.         case 4 :    eg_window(4,1,"sbo.sms",200,75,5,s,4,15,1);
  1687.                     break;
  1688.         case 5 :    
  1689.         case 6 :
  1690.         case 7 :    eg_window(4,1,"sbo.sms",200,75,5,s,4,15,1);
  1691.                     break;
  1692.     }
  1693.  
  1694.     rela_obj.theta = 45L;
  1695.     rela_obj.phi = 50L;
  1696.     rela_obj.rho = 1000L;
  1697.     rela_obj.sd = 500L;
  1698.  
  1699.     font = 2;
  1700.     switch(dev){
  1701.         case 0 :    color[6] = 0;
  1702.                     base_unit_size = 70.0;
  1703.                     height = 70.0;
  1704.                     font = 1;
  1705.                     stackc[0].leftc  = stackc[0].rightc = 0;
  1706.                     stackc[1].leftc  = stackc[1].rightc = 0;
  1707.                     stackc[2].leftc  = stackc[2].rightc = 0;
  1708.                     mono_hatch();
  1709.                     break;
  1710.         case 1 : base_unit_size = 90.0;
  1711.                     height = 110.0;
  1712.                     color_hatch();
  1713.                     break;
  1714.         case 2 : base_unit_size = 90.0;
  1715.                     height = 110.0;
  1716.                     color_hatch();
  1717.                     break;
  1718.         case 3 :    color[6] = 0;
  1719.                     base_unit_size = 80.0;
  1720.                     height = 90.0;
  1721.                     font = 1;
  1722.                     stackc[0].leftc  = stackc[0].rightc = 0;
  1723.                     stackc[1].leftc  = stackc[1].rightc = 0;
  1724.                     stackc[2].leftc  = stackc[2].rightc = 0;
  1725.                     mono_hatch();
  1726.                     break;
  1727.         case 4 : 
  1728.         case 5 :
  1729.         case 6 :
  1730.         case 7 : base_unit_size = 200.0;
  1731.                     height = 100.0;
  1732.                     color_hatch();
  1733.                     break;
  1734.     }
  1735.  
  1736. /* set the viewport and world */
  1737.  
  1738.     setview(0,0,max_x,max_y);
  1739.     setworld(0,0,max_x,max_y);
  1740.  
  1741.      strcpy(str[0],"Hit Return at any time");
  1742.     strcpy(str[1],"to move to the next");
  1743.     strcpy(str[2],"screen.");
  1744.     for (i = 0; i < 3; i++)
  1745.             s[i] = str[i];
  1746.  
  1747.     clearscr(0);
  1748.  
  1749.     for (i = 0; i < 4; i++){
  1750.  
  1751.         strcpy(lab4[0],"200");
  1752.         strcpy(lab4[1],"800");
  1753.         for (j=0; j<7; ++j)
  1754.             lab4_p[j]=lab4[j];    
  1755.         strcpy(lab5[0],"200");
  1756.         strcpy(lab5[1],"800");
  1757.         for (j=0; j<7; ++j)
  1758.             lab5_p[j]=lab5[j];    
  1759.  
  1760.         td_bar_set(0,4,3,bar_segs,stackc);
  1761.  
  1762.     /* using the default to set base */
  1763.         
  1764.         td_base_dim((double)-1,base_unit_size,(double)-1);
  1765.         td_base_height(height);
  1766.  
  1767.         /* using the default to set middle plane */
  1768.         
  1769.         td_midplane(-1,-1,-1.0);
  1770.  
  1771.     /* Set the bar and frame colors */
  1772.             if (dev == 0 || dev == 3){
  1773.                 td_frame_color(0,1,0);
  1774.                 td_bar_color(1,1,0,0);
  1775.             }
  1776.             else{
  1777.                 td_frame_color(color[6],color[15],color[6]);
  1778.             }
  1779.               clearscr(0);
  1780.            worldon(1); 
  1781.             if (i == 3)
  1782.                  bar_segs = 3;    
  1783.  
  1784.     /* set up the labels */
  1785.  
  1786.         td_bar_label(BASE_LEFT,color[14],lab0_p,vfn1,1,0);
  1787.         td_bar_label(BASE_RIGHT,color[14],lab1_p,vfn1,1,0); 
  1788.         td_bar_label(XY_PLANE_LEFT,color[15],lab2_p,vfn1,3,0);    
  1789.         td_bar_label(XY_PLANE_RIGHT,color[15],lab3_p,vfn1,4,0); 
  1790.         td_bar_label(XZ_PLANE,color[15],lab4_p,vfn1,7,1); 
  1791.         td_bar_label(YZ_PLANE,color[15],lab5_p,vfn1,7,1); 
  1792.     
  1793.  
  1794.         /* call td_bar_set() to set the attribute of the bar chart */
  1795.  
  1796.             td_bar_set(i,4,3,bar_segs,stackc);
  1797.  
  1798.         /* put the legend */
  1799.  
  1800.             if (dev)
  1801.                 switch(i){
  1802.                     case 0 :    td_legend(3,BOT_CENTER,label,color[15],color[15],
  1803.                                              SINGLE_BORDER,0,vfn1); 
  1804.                                 break;
  1805.                     case 1 :    td_legend(3,BOT_LEFT_VERT,label,color[15],color[15],
  1806.                                              DOUBLE_BORDER,0,vfn1); 
  1807.                                 break;
  1808.                     case 2 :    td_legend(3,BOT_RIGHT_VERT,label,color[15],color[15],
  1809.                                              SINGLE_BORDER,0,vfn1); 
  1810.                                 break;
  1811.                     case 3 :    td_legend(3,BOT_LEFT_HORZ,label,color[15],color[15],
  1812.                                              DOUBLE_BORDER,0,vfn1); 
  1813.                                 break;
  1814.                 }
  1815.  
  1816.         /* put the title */
  1817.  
  1818.             td_title(TOP,title[i],color[15],font,vfn1); 
  1819.  
  1820.  
  1821.         /* call td_chart() to draw the bar chart */
  1822.  
  1823.             if (i == 3)
  1824.                 td_chart(300.0,0.0,basetype,bar_area,rela_obj,HALF_FRAME,stack); 
  1825.             else
  1826.                 td_chart(300.0,0.0,basetype,bar_area,rela_obj,HALF_FRAME,barval); 
  1827.  
  1828.             switch(dev){
  1829.                 case 0 :    eg_window(4,1,"ibmrom",5,25,3,s,1,0,0);
  1830.                             break;
  1831.                 case 1 :    eg_window(4,1,"sbo.sms",5,25,3,s,4,15,0);
  1832.                             break;
  1833.                 case 2 :    eg_window(4,1,"sbo.sms",10,60,3,s,4,15,0);
  1834.                             break;
  1835.                 case 3 :    eg_window(4,1,"sbo.sms",10,60,3,s,1,0,0);
  1836.                             break;
  1837.                 case 4 :    eg_window(4,1,"sbo.sms",10,60,3,s,4,15,0);
  1838.                             break;
  1839.                 case 5 :
  1840.                 case 6 :
  1841.                 case 7 :    eg_window(4,1,"sbo.sms",100,200,6,s,4,15,0);
  1842.                             break;
  1843.             }
  1844.             clearscr(0);
  1845.     }
  1846.     if (!dev){
  1847.         max_x = 319; initgraf(4,cga_pal,0);
  1848.     }
  1849.  
  1850.     /* free the memory */
  1851.     vfontuld(vfn1); 
  1852.     worldon(0);
  1853.     fontquit();
  1854. }
  1855.  
  1856. three_d_pies()
  1857. {
  1858.     int val[13],i,j;
  1859.     int explode,offset,width;
  1860.     int radius,x0,y0,num,den;
  1861.     int linec,labelc,border_color;
  1862.     struct vfont *vfn;            /* font to use */
  1863.     int title_font,xy_label_font;
  1864.     char title[5][80];
  1865.     
  1866.     for (i = 0; i < 13; i++)
  1867.             val[i] = i+1;
  1868.  
  1869.     setaspec(10,25);
  1870.     explode = 0; offset  = 40;
  1871.     num = 10; den = 25;
  1872.     /* assign Title labels */
  1873.  
  1874.     strcpy(title[0],"3-D Exploded Pie Chart");
  1875.     strcpy(title[1],"Labels Inside and Out");
  1876.     strcpy(title[2],"Labels Outside Only");
  1877.     strcpy(title[3],"Legend for Labels");
  1878.  
  1879.     title_font = 2;
  1880.     xy_label_font = 1;
  1881.  
  1882.     clearscr(0);
  1883.     strcpy(str[0],"Charts are as easy as pie with");
  1884.     strcpy(str[1],"Essential Graphics 3-D pie charts.");
  1885.     strcpy(str[2]," ");
  1886.     strcpy(str[3],"Let's chart !");
  1887.     for (i = 0; i < 4; i++)
  1888.             s[i] = str[i];
  1889.  
  1890.     clearscr(0);
  1891.     switch(dev){
  1892.         case 0 :    num = 1; den = 3;
  1893.                     eg_window(4,1,"ibmrom",20,150,4,s,1,0,1);
  1894.                     break;
  1895.         case 1 :    eg_window(4,1,"sbo.sms",20,300,4,s,4,15,1);
  1896.                     break;
  1897.         case 2 :    eg_window(4,1,"sbo.sms",50,400,4,s,4,15,1);
  1898.                     break;
  1899.         case 3 :    eg_window(4,1,"sbo.sms",20,250,4,s,1,0,1);
  1900.                     break;
  1901.         case 4 :    eg_window(4,1,"sbo.sms",100,700,4,s,4,15,1);
  1902.                     break;
  1903.         case 5 :    eg_window(4,1,"sbo.sms",100,300,4,s,4,15,1);
  1904.                     break;
  1905.         case 6 :
  1906.         case 7 :    eg_window(4,1,"sbo.sms",100,300,4,s,4,15,1);
  1907.                     break;
  1908.     }
  1909.  
  1910.     setview(0,0,max_x,max_y);
  1911.     setworld(0,0,max_x,max_y);
  1912.     switch(dev){
  1913.         case 0 : offset = 20;
  1914.                     for (i = 1; i < 7; i++)
  1915.                           color[i] = 1;    
  1916.                     title_font = 1;
  1917.                     xy_label_font = 3;
  1918.                     linec  = labelc = border_color = 2;
  1919.                     x0 = 160;    y0 = 100;    radius = 100;
  1920.                     for (i = 1; i < 16; i++)
  1921.                           color[i] = 1;    
  1922.                     width = 25;
  1923.                     cga_hatch();
  1924.                     break;
  1925.         case 1 : x0 = 320;    y0 = 150;    radius = 125;
  1926.                     width = 40;
  1927.                     color_hatch();
  1928.                     linec  = labelc = border_color = color[15];
  1929.                     break;
  1930.         case 2 : x0 = 300;    y0 = 200;    radius = 140;
  1931.                     width = 60;
  1932.                     linec  = labelc = border_color = color[15];
  1933.                     color_hatch();
  1934.                     break;
  1935.         case 3 : for (i = 1; i < 16; i++)
  1936.                           color[i] = 1;    
  1937.                     x0 = 350;    y0 = 175;    radius = 125;
  1938.                     linec  = labelc = border_color = color[1];
  1939.                     width = 40;
  1940.                     mono_hatch();
  1941.                     break;
  1942.         case 4 : x0 = 320;    y0 = 200;    radius = 160;
  1943.                     width = 60;
  1944.                     linec  = labelc = border_color = color[15];
  1945.                     color_hatch();
  1946.                     break;
  1947.         case 5 : x0 = 400;    y0 = 300;    radius = 220;
  1948.                     width = 80;
  1949.                     linec  = labelc = border_color = color[15];
  1950.                     color_hatch();
  1951.                     break;
  1952.         case 6 :
  1953.         case 7 : x0 = 500;    y0 = 300;    radius = 250;
  1954.                     width = 80;
  1955.                     linec  = labelc = border_color = color[15];
  1956.                     color_hatch();
  1957.                     break;
  1958.     }
  1959.     clearscr(0);
  1960.  
  1961.  
  1962.     /* load the bit map font */
  1963.  
  1964.     fontinit();
  1965.     if (font_load(0,"ibmrom")){
  1966.         printf("Error loading ibmrom\n");
  1967.         exit(0);
  1968.     }
  1969.     if (font_load(1,"sbo.sms")){
  1970.         printf("Error loading sbo.sms\n");
  1971.         exit(0);
  1972.     }
  1973.     if (font_load(2,"roman3.sms")){
  1974.         printf("Error loading roman3.sms\n");
  1975.         exit(0);
  1976.     }
  1977.     if (font_load(3,"micprint.sms")){
  1978.         printf("Error loading roman3.sms\n");
  1979.         exit(0);
  1980.     }
  1981.  
  1982.     /* set aspect ratio */
  1983.     setaspec(num,den);
  1984.  
  1985.      strcpy(str[0],"Hit Return at any time");
  1986.     strcpy(str[1],"to move to the next");
  1987.     strcpy(str[2],"screen.");
  1988.     for (i = 0; i < 3; i++)
  1989.             s[i] = str[i];
  1990.  
  1991.     for (i = 1; i < 4; i++){
  1992.           clearscr(0);
  1993.           worldon(1);
  1994.             if (!dev){
  1995.                 if (i == 3)
  1996.                      td_pie_legend(BOT_LEFT_VERT,SINGLE_BORDER);    
  1997.                   td_pie_set(4,xy_label_font,i,width,linec,labelc);
  1998.                   td_title(TOP,title[i],color[15],title_font,0); 
  1999.                   td_pie_slice(0,color[1],1,"1st");
  2000.                   td_pie_slice(1,color[2],2,"2nd");
  2001.                   td_pie_slice(2,color[3],3,"3rd");
  2002.                   td_pie_slice(3,color[4],4,"4th");
  2003.             }
  2004.             else{
  2005.                 if (i == 3){
  2006.                       j = td_pie_set(8,xy_label_font,i,width,linec,labelc);
  2007.                       td_title(TOP,title[i],color[15],title_font,0); 
  2008.                       td_pie_slice(0,color[1],1,"JAN 1989");
  2009.                       td_pie_slice(1,color[2],2,"FEB 1989");
  2010.                       td_pie_slice(2,color[3],3,"MAR 1989");
  2011.                       td_pie_slice(3,color[4],4,"APR 1989");
  2012.                       td_pie_slice(4,color[5],5,"MAY 1989");
  2013.                       td_pie_slice(5,color[6],6,"JUN 1989");
  2014.                       td_pie_slice(6,color[7],7,"JUL 1989");
  2015.                       td_pie_slice(7,color[8],8,"AUG 1989");
  2016.                 }
  2017.                 else{
  2018.                         td_pie_set(6,xy_label_font,i,width,linec,labelc);
  2019.                       td_title(TOP,title[i],color[15],title_font,0); 
  2020.                       td_pie_legend(BOT_LEFT_VERT,DOUBLE_BORDER);    
  2021.                       td_pie_slice(0,color[1],1,"JAN 1989");
  2022.                       td_pie_slice(1,color[2],2,"FEB 1989");
  2023.                       td_pie_slice(2,color[3],3,"MAR 1989");
  2024.                       td_pie_slice(3,color[4],4,"APR 1989");
  2025.                       td_pie_slice(4,color[5],5,"MAY 1989");
  2026.                       td_pie_slice(5,color[6],6,"JUN 1989");
  2027.                 }
  2028.             }
  2029.             j = td_pie(x0,y0,radius,explode,border_color,0,val); 
  2030.             switch(dev){
  2031.                 case 0 :    eg_window(4,1,"ibmrom",20,135,3,s,1,0,0);
  2032.                             break;
  2033.                 case 1 :    eg_window(4,1,"sbo.sms",20,275,3,s,4,15,0);
  2034.                             break;
  2035.                 case 2 :    eg_window(4,1,"sbo.sms",50,400,3,s,4,15,0);
  2036.                             break;
  2037.                 case 3 :    eg_window(4,1,"sbo.sms",20,350,3,s,1,0,0);
  2038.                             break;
  2039.                 case 4 :    eg_window(4,1,"sbo.sms",100,500,3,s,4,15,0);
  2040.                             break;
  2041.                 case 5 :    eg_window(4,1,"sbo.sms",200,500,3,s,4,15,0);
  2042.                             break;
  2043.                 case 6 :
  2044.                 case 7 :    eg_window(4,1,"sbo.sms",200,600,6,s,4,15,0);
  2045.                             break;
  2046.             }
  2047.     }
  2048. /* explode some slices */
  2049.     setview(0,0,max_x,max_y);
  2050.     setworld(0,0,max_x,max_y);
  2051.    worldon(1);
  2052.     clearscr(0);
  2053.     if (!dev){
  2054.         td_pie_set(4,xy_label_font,2,width,linec,labelc);
  2055.     /* put the title */
  2056.         td_title(TOP,title[0],color[15],title_font,0); 
  2057.         td_pie_slice(0,color[1],1,"1st");
  2058.         td_pie_slice(1,color[2],2,"2nd");
  2059.         td_pie_slice(2,color[3],3,"3rd");
  2060.         td_pie_slice(3,color[4],4,"4th");
  2061.         td_pie(x0,y0,radius,1,border_color,offset,val); 
  2062.     }
  2063.     else{
  2064.         td_pie_set(6,xy_label_font,2,width,linec,labelc);
  2065.     /* put the title */
  2066.         td_title(TOP,title[0],color[15],title_font,0); 
  2067.         td_pie_slice(0,color[1],1,"JAN-FEB");
  2068.         td_pie_slice(1,color[2],2,"MAR-APR");
  2069.         td_pie_slice(2,color[3],3,"MAY-JUN");
  2070.         td_pie_slice(3,color[4],4,"JUL-AUG");
  2071.         td_pie_slice(4,color[5],5,"SEP-OCT");
  2072.         td_pie_slice(5,color[6],6,"NOV-DEC");
  2073.         td_pie(x0,y0,radius,9,border_color,offset,val); 
  2074.     }
  2075.     switch(dev){
  2076.         case 0 :    eg_window(4,1,"ibmrom",20,50,3,s,3,2,0);
  2077.                     break;
  2078.         case 1 :    eg_window(4,1,"sbo.sms",20,60,3,s,4,15,0);
  2079.                     break;
  2080.         case 2 :    eg_window(4,1,"sbo.sms",50,60,3,s,4,15,0);
  2081.                     break;
  2082.         case 3 :    eg_window(4,1,"sbo.sms",20,50,3,s,1,0,0);
  2083.                     break;
  2084.         case 4 :    eg_window(4,1,"sbo.sms",100,50,3,s,4,15,0);
  2085.                     break;
  2086.         case 5 :    eg_window(4,1,"sbo.sms",100,70,3,s,4,15,0);
  2087.                     break;
  2088.         case 6 :
  2089.         case 7 :    eg_window(4,1,"sbo.sms",100,50,3,s,4,15,0);
  2090.                     break;
  2091.     }
  2092.     fontquit();
  2093.     worldon(0);
  2094.     setview(0,0,max_x,max_y);
  2095.     setworld(0,0,max_x,max_y);
  2096.     clipoff();
  2097. }
  2098.  
  2099. /* use PC Paintbrush files for animation */
  2100.  
  2101. animation()
  2102. {
  2103.  
  2104.     int k,i;
  2105.  
  2106.     clearscr(0);
  2107.      strcpy(str[0],"This portion will only");
  2108.     strcpy(str[1]," ");
  2109.     strcpy(str[2],"run in EGA or VGA Mode");
  2110.     strcpy(str[3]," ");
  2111.      strcpy(str[4],"Hit return to start and");
  2112.     strcpy(str[5]," ");
  2113.     strcpy(str[6],"stop animation");
  2114.  
  2115.     for (i = 0; i < 7; i++)
  2116.             s[i] = str[i];
  2117.  
  2118.     switch(dev){
  2119.         case 0 :    eg_window(4,1,"ibmrom",20,50,7,s,3,2,1);
  2120.                     break;
  2121.         case 1 :    eg_window(4,1,"sbo.sms",20,60,7,s,4,15,1);
  2122.                     break;
  2123.         case 2 :    eg_window(4,1,"sbo.sms",50,60,7,s,4,15,1);
  2124.                     break;
  2125.         case 3 :    eg_window(4,1,"sbo.sms",20,50,7,s,1,0,1);
  2126.                     break;
  2127.         case 4 :    eg_window(4,1,"sbo.sms",100,50,7,s,4,15,1);
  2128.                     break;
  2129.         case 5 :    eg_window(4,1,"sbo.sms",100,50,7,s,4,15,1);
  2130.                     break;
  2131.         case 6 :
  2132.         case 7 :    eg_window(4,1,"sbo.sms",100,70,7,s,4,15,1);
  2133.                     break;
  2134.     }
  2135.  
  2136.     /* only if EGA or VGA */
  2137.  
  2138.     if (dev == 2 || dev == 1){
  2139.         clearscr(0);
  2140.     /* loop thru the horse motion */
  2141.         while(1){
  2142.             if (inkey(&k) != -1)
  2143.                 break;
  2144.             pcc_load("h1.pcc",240,150);
  2145.             pcc_load("h2.pcc",240,150);
  2146.             pcc_load("h3.pcc",240,150);
  2147.             pcc_load("h4.pcc",240,150);
  2148.             pcc_load("h5.pcc",240,150);
  2149.             pcc_load("h6.pcc",240,150);
  2150.             pcc_load("h7.pcc",240,150);
  2151.             pcc_load("h8.pcc",240,150);
  2152.             pcc_load("h9.pcc",240,150);
  2153.             pcc_load("h10.pcc",240,150);
  2154.             pcc_load("h11.pcc",240,150);
  2155.         }
  2156.     }
  2157. }
  2158.  
  2159.  
  2160. /* put a window on the screen with text */
  2161.  
  2162. eg_window(horz_pad,wait,font,startx,starty,lines,str,forg,back,center)
  2163.     int horz_pad;            /* number of characters to pad window */
  2164.     int wait;                /* 0 - no keystroke wait, 1 - wait for keystroke */
  2165.     char *font;                /* font to load */
  2166.     int startx,starty;    /* starting locs */
  2167.     int lines;                /* number of text lines */
  2168.     char *str[];            /* text strings */
  2169.     int forg,back;            /* colors */
  2170.     int center;                /* 1 - center box, 0 - no center */
  2171. {
  2172.  
  2173.     int i,j,border,l,size;
  2174.      int w_height,w_width,largest;
  2175.     int c,h,ch,lf,vsize,hsize,baseline;
  2176.  
  2177.     worldon(0);
  2178.     clipoff();
  2179.     if (font_load(7,font)){
  2180.         initgraf(3,0,0);
  2181.         printf("Fonts not In Current Directory!!!\n");
  2182.         printf("Demo Cancelled!!!\n");
  2183.         exit(1);
  2184.     }
  2185.     font_info(7,&c,&h,&ch,&lf,&vsize,&hsize,&baseline);
  2186.  
  2187.     largest = 0; 
  2188.     for (i = 0; i < lines; i++){
  2189.           size = fontpixn(7,str[i],0,strlen(str[i]));
  2190.           if (size > largest)
  2191.                 largest = size;
  2192.     }
  2193.  
  2194.     w_width = largest+(hsize*horz_pad);    
  2195.     w_height = vsize*(lines+2);
  2196.  
  2197.     if (center){
  2198.         startx = (max_x - w_width)/2;
  2199.         starty = (max_y - w_height)/2;
  2200.     }
  2201.         
  2202.     border = 5;
  2203.     eg_rectangle(startx,starty,startx+w_width+border,starty+w_height+border,back,1,-1); 
  2204.  
  2205.     for (i = 0; i < border; i++,starty++,startx++,border--)
  2206.          eg_rectangle(startx,starty,startx+w_width+1+border-i,
  2207.                             starty+w_height+border-i,forg,0,-1);
  2208.  
  2209.     for (i = 0,j = 1; i < lines; i++,j++){
  2210.           size = fontpixn(7,str[i],0,strlen(str[i]));    
  2211.           fhatsay(7,str[i],forg,startx+(w_width-size)/2,starty+j*vsize+vsize/2);
  2212.     }
  2213.     if (wait)
  2214.          esgetkey(&i);
  2215.     font_unload(7);
  2216. }
  2217.  
  2218.  
  2219. /* quick call to eg_window from twod_graphs */
  2220.  
  2221. twod_win(x,y)
  2222.     int x,y;
  2223. {
  2224.  
  2225.     switch(dev){
  2226.         case 0 :    eg_window(4,1,"ibmrom",20,20,3,s,3,2,0);
  2227.                     break;
  2228.         case 1 :    eg_window(4,1,"sbo.sms",x,y,3,s,15,1,0);
  2229.                     break;
  2230.         case 2 :    eg_window(4,1,"sbo.sms",x,y,3,s,15,1,0);
  2231.                     break;
  2232.         case 3 :    eg_window(4,1,"sbo.sms",x,y,3,s,1,0,0);
  2233.                     break;
  2234.         case 4 :    eg_window(4,1,"sbo.sms",x,y,3,s,15,1,0);
  2235.                     break;
  2236.         case 5 :    eg_window(4,1,"sbo.sms",200,100,3,s,15,1,0);
  2237.                     break;
  2238.         case 6 :
  2239.         case 7 :    eg_window(4,1,"sbo.sms",200,100,3,s,15,1,1);
  2240.                     break;
  2241.     }
  2242. }
  2243.  
  2244.  
  2245. /* function for a vertical menu */
  2246.  
  2247. eg_smenu(font,num_choices,choices,startx,starty,forg_color,back_color,
  2248.             shadow_color,cell_pad,do_title,title,t_forg,t_back)
  2249.  
  2250.     int font;                /* font to write text with */
  2251.     int num_choices;        /* number of choices in the menu */
  2252.     char *choices[];        /* array to selections or choices */
  2253.     int startx,starty;    /* location to start menu */
  2254.     int forg_color;        /* foreground color (text) */
  2255.     int back_color;        /* background color */
  2256.     int shadow_color;        /* shadow color */
  2257.     int cell_pad;            /* space to add between text and cell border */ 
  2258.     int do_title;            /* 0 - no | 1 - Yes */
  2259.     char *title;            /* title string */
  2260.     int t_forg;                /* foreground color (text) */
  2261.     int t_back;        /* background color */
  2262. {
  2263.     int topy,boty;            /* top and bottom of selection cell */
  2264.     int pixels[15];
  2265.     int startfntx[15];
  2266.     int startfnty[15];
  2267.     int c,h,ch,lf,x;
  2268.     int vsize,hsize,baseline;
  2269.     int menu_width,menu_height;    /* height and width of the menu    */
  2270.     int shadowx,shadowy;                /* location to draw shadow         */
  2271.     int curlen,maxlen;
  2272.     int max_strlen;
  2273.     int mouse_x,mouse_y;
  2274.     int key,size;
  2275.     int fontnum;
  2276.     int i,j,k,y,y2,l;
  2277.     struct egstatus stat;    /* graphic status */
  2278.     int border_size;         /* border width */
  2279.     int cell_height;        /* heigh of a menu selection cell */
  2280.     int bl,br;
  2281.  
  2282.  
  2283. /* turn off while drawing */
  2284.     if (mouse)
  2285.         m_curoff();
  2286.  
  2287.     eg_status(&stat);
  2288.  
  2289.     border_size = 5;
  2290.  
  2291. /* get the font info */
  2292.  
  2293.     font_info(font,&c,&h,&ch,&lf,&vsize,&hsize,&baseline);
  2294.    cell_height = vsize + cell_pad + (vsize-baseline);
  2295.   
  2296.     clipoff();
  2297.     max_strlen = 0;
  2298.  
  2299. /* get max string length */
  2300.  
  2301.     for (i = 0; i < num_choices; i++){
  2302.        curlen = fontpixn(font,choices[i],0,strlen(choices[i]));
  2303.        if (curlen > max_strlen) 
  2304.               max_strlen = curlen;
  2305.     }
  2306.  
  2307. /* get the menu length and height */
  2308.  
  2309.    menu_width = max_strlen+(hsize*4);
  2310.    menu_height = cell_height*num_choices+num_choices;
  2311.  
  2312.     shadowx = shadowy = cell_height;
  2313.  
  2314.     if (shadowx > startx)
  2315.         shadowx = startx;
  2316.  
  2317.     if (shadowy > starty)
  2318.         shadowy = starty;
  2319.  
  2320.     if (startx+menu_width > stat.x_res)
  2321.          return(-2);
  2322.  
  2323.     if (starty+menu_height > stat.y_res)
  2324.          return(-3);
  2325.  
  2326. /* put up the menu shadow */
  2327.  
  2328.     if (shadow_color != -1)
  2329.         eg_rectangle(startx-shadowx,starty+shadowy,startx+menu_width-shadowx,
  2330.                        starty+menu_height+shadowy+border_size,shadow_color,1,-1);
  2331.  
  2332. /* draw the menu border */
  2333.  
  2334.     for (i = 0; i < border_size; i++,starty++,startx++,border_size--)
  2335.          eg_rectangle(startx,starty,startx+menu_width+1+border_size-i,
  2336.                             starty+menu_height+border_size-i,forg_color,0,-1);
  2337.  
  2338.     if (do_title){
  2339.          eg_rectangle(startx,starty-(vsize+4),startx+menu_width+1+border_size-i,
  2340.                             starty,t_back,1,-1);
  2341.          eg_rectangle(startx,starty-(vsize+4),startx+menu_width+1+border_size-i,
  2342.                             starty,t_forg,0,-1);
  2343.           i = fontpixn(font,title,0,strlen(title));    
  2344.         x =  startx + ((menu_width - i)/2);
  2345.          fhatsay(font,title,t_forg,x,starty-4);
  2346.     }
  2347.  
  2348. /* put up the menu background */
  2349.  
  2350.     eg_rectangle(startx,starty,startx+menu_width,starty+menu_height,back_color,1,-1);
  2351.  
  2352.  
  2353. /* put up the cell seperation lines */
  2354.  
  2355.     size = menu_height / num_choices;
  2356.    for (i = 0, y = starty; i <= num_choices; i++, y += size)
  2357.         eg_line(startx,y,startx+menu_width,y,forg_color);
  2358.  
  2359.  
  2360. /* fill in the cells */
  2361.  
  2362.     y = starty + size;
  2363.    for (i = 0,j = 1; i < num_choices; i++,j++, y += size){
  2364.         pixels[i]       =  fontpixn(font,choices[i],0,strlen(choices[i]));
  2365.         startfntx[i]  =  startx + ((menu_width - pixels[i])/2);
  2366.         startfnty[i]  =  y-(cell_height-vsize)/2-cell_pad/2; 
  2367.         fhatsay(font,choices[i],forg_color,startfntx[i],startfnty[i]);
  2368.    }
  2369.  
  2370.     i = 0; y = 1;
  2371.     eg_rectangle(startx,starty,startx+menu_width,starty+cell_height,forg_color,1,-1);
  2372.    fhatsay(font,choices[i],back_color,startfntx[i],startfnty[i]);
  2373.     if (mouse){
  2374.        m_setcur(startx+menu_width/2,(starty+y*vsize)-1);
  2375.        m_curon();
  2376.     }
  2377.  
  2378.     i = 0;
  2379.     topy = starty+(i*cell_height)+i+1;
  2380.     boty = topy+cell_height-1;
  2381.  
  2382.     while (1){
  2383.         j = inkey(&key);
  2384.     /* if key hit */
  2385.         if (j != -1){
  2386.             if (j == 1)
  2387.                  key = -key;
  2388.             if (key == ESCAPE) 
  2389.                  return(-1);
  2390.             if (key == CURUP || key == CURDN || key == HOME || key == END){
  2391.                 if (mouse)    m_curoff();
  2392.               eg_rectangle(startx,topy,startx+menu_width,boty,back_color,1,-1);
  2393.               fhatsay(font,choices[i],forg_color,startfntx[i],startfnty[i]);
  2394.             }        
  2395.             switch(key){
  2396.                 case CURUP        :    if (i > 0)
  2397.                                             i--; 
  2398.                                         else
  2399.                                             i = num_choices-1; 
  2400.                                         break;
  2401.                 case CURDN        :    if (i < num_choices-1)
  2402.                                             i++;    
  2403.                                         else
  2404.                                             i = 0;
  2405.                                         break;
  2406.                 case HOME        :  i = 0; break;
  2407.                 case END            :  i = num_choices-1; break;
  2408.                 case RETURN        :    return(i);
  2409.             }        
  2410.             y = i+1;
  2411.             topy = starty+(i*cell_height)+i+1;
  2412.             boty = topy+cell_height-1;
  2413.             eg_rectangle(startx,topy,startx+menu_width,boty,forg_color,1,-1);
  2414.           fhatsay(font,choices[i],back_color,startfntx[i],startfnty[i]);
  2415.           if (mouse){
  2416.                  m_setcur(startx+menu_width/2,(starty+y*cell_height)-1);
  2417.                 m_curon();
  2418.             }
  2419.         }
  2420.         if (!mouse)
  2421.              continue;
  2422.     /* else check mouse position */
  2423.         m_posbut(&mouse_x,&mouse_y,&bl,&br);
  2424.           if (mouse_x >= startx && mouse_x <= startx+menu_width){
  2425.               size = menu_height / num_choices;
  2426.              for (l = 0, y2 = starty; l < num_choices; l++, y2 += size){
  2427.                     if (mouse_y >= y2 && mouse_y < y2 + size && l != i){
  2428.                           m_curoff();
  2429.                     /* turn old choice off */
  2430.                       eg_rectangle(startx,topy,startx+menu_width,boty,back_color,1,-1);
  2431.                       fhatsay(font,choices[i],forg_color,startfntx[i],startfnty[i]);
  2432.                         i = l;
  2433.                         topy = starty+(i*cell_height)+i+1;
  2434.                         boty = topy+cell_height-1;
  2435.                     /* highlight new choice */
  2436.                       eg_rectangle(startx,topy,startx+menu_width,boty,forg_color,1,-1);
  2437.                       fhatsay(font,choices[l],back_color,startfntx[l],startfnty[l]);
  2438.                        m_curon();
  2439.                     }
  2440.                 /* if left button hit return */
  2441.                     if (bl == 1){
  2442.                           return(i);
  2443.                     }
  2444.              }
  2445.         }
  2446.     }
  2447. }
  2448.  
  2449. /* set up default hatch styles */
  2450.  
  2451. hatch_init()
  2452. {
  2453.  
  2454.     htinit();               /* initialize hatch definition space */
  2455.     htdefind(0,0,5);        /* 2 pixels of background */
  2456.     htdefind(1,1,5);        /* 2 pixels of color 1 */
  2457.     htdefind(2,2,5);        /* 2 pixels of color 2 */
  2458.     htdefind(3,3,5);        /* 2 pixels of color 3 */
  2459.     htdefind(4,4,5);        /* 2 pixels of background */
  2460.     htdefind(5,5,5);        /* 2 pixels of color 1 */
  2461.     htdefind(6,6,5);        /* 2 pixels of color 2 */
  2462.     htdefind(7,7,5);        /* 2 pixels of color 3 */
  2463.     htdefind(8,8,5);        /* 2 pixels of background */
  2464.     htdefind(9,9,5);        /* 2 pixels of color 1 */
  2465.     htdefind(10,10,5);        /* 2 pixels of color 2 */
  2466.     htdefind(11,11,5);        /* 2 pixels of color 3 */
  2467.     htdefind(12,12,5);        /* 2 pixels of color 3 */
  2468.     htdefind(13,13,5);        /* 2 pixels of color 3 */
  2469.     htdefind(14,14,5);        /* 2 pixels of color 3 */
  2470.     htdefind(15,15,5);        /* 2 pixels of color 3 */
  2471.  
  2472.     htdefstl(0,2,4,2,3,0,9);   /* style 0 = solid color 1 */
  2473.     htdefstl(1,2,3,4,15,1);     /* style 1 = solid color 2 */
  2474.     htdefstl(2,2,4,1,0,5,3);    /* style 3 = horizontal stripes of color */
  2475.     htdefstl(3,2,3,11,14,13);   /* style 3 = horizontal stripes of color */
  2476.  
  2477. }
  2478.  
  2479.  
  2480.