home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_07_06 / v7n6052a.txt < prev    next >
Text File  |  1989-07-25  |  2KB  |  66 lines

  1.  
  2.                            Listing 3 
  3.  
  4.  
  5. /*
  6.     fillOval() = draws an oval centered at (x,y) with    
  7.                  radius in y direction of 'b' with       
  8.                  aspect ratio 'aspect' and fills it      
  9.                  with color 'color'.                     
  10.                                                          
  11. */
  12.  
  13.  
  14.  
  15. void fillOval(float x_cen, float y_cen, float radius, 
  16.     int color, float aspect)
  17. {
  18.     union REGS reg;
  19.  
  20.     #define seq_out(index,val)  {outp(0x3C4,index);\
  21.                      outp(0x3C5,val);}
  22.     #define graph_out(index,val)  {outp(0x3CE,index);\
  23.                      outp(0x3CF,val);}
  24.  
  25.     unsigned int offset;
  26.     char far * mem_address;
  27.     float a,b,aspect_square;
  28.     int x,y,col,row,dummy,mask,start_x, start_y,end_x,end_y;
  29.     float a_square,b_square,b_test;
  30.  
  31.     a = radius/aspect;
  32.     a_square = a*a;
  33.     b = .729*radius;
  34.     b_square = b*b;
  35.     x = x_cen;;
  36.     y = y_cen);
  37.     start_x = max(0,x-a);
  38.     end_x = min (639,x+a);
  39.     start_y = max(0,y-b);
  40.     end_y = min(349,y+b);
  41.  
  42.     for (col=start_x; col<=end_x; col++)
  43.     {
  44.         b_test = b_square - (b_square*(col-x)*(col-x))/a_square;
  45.         mask = 0x80 >> ((col) % 8);
  46.         graph_out(8,mask);
  47.         seq_out(2,0x0F);
  48.         for (row=start_y; row<=end_y; row++)
  49.             if ((long)(row-y)*(row-y) <= b_test)
  50.             {
  51.                 offset = (long)row*80L + ((long)(col)/8L);
  52.                 mem_address = (char far *) 0xA0000000L +
  53.                     offset;
  54.                 dummy = *mem_address;
  55.                 *mem_address = 0;
  56.                 seq_out(2,color);
  57.                 *mem_address = 0xFF;
  58.                 seq_out(2,0x0F);
  59.             }
  60.     }
  61.     graph_out(3,0);
  62.     graph_out(8,0xFF);
  63. }
  64.  
  65.  
  66.