home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / 2d / disc.c < prev    next >
Text File  |  1998-06-08  |  3KB  |  121 lines

  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  12. */
  13. /*
  14.  * $Source: f:/miner/source/2d/rcs/disc.c $
  15.  * $Revision: 1.5 $
  16.  * $Author: john $
  17.  * $Date: 1994/11/18 22:50:16 $
  18.  *
  19.  * Graphical routines for drawing a disk.
  20.  *
  21.  * $Log: disc.c $
  22.  * Revision 1.5  1994/11/18  22:50:16  john
  23.  * Changed shorts to ints in parameters.
  24.  * 
  25.  * Revision 1.4  1994/05/06  12:50:12  john
  26.  * Added supertransparency; neatend things up; took out warnings.
  27.  * 
  28.  * Revision 1.3  1994/04/22  11:16:04  john
  29.  * *** empty log message ***
  30.  * 
  31.  * Revision 1.2  1993/10/15  16:22:24  john
  32.  * *** empty log message ***
  33.  * 
  34.  * Revision 1.1  1993/09/08  11:43:24  john
  35.  * Initial revision
  36.  * 
  37.  *
  38.  */
  39.  
  40. #include "mem.h"
  41.  
  42. #include "gr.h"
  43. #include "grdef.h"
  44.  
  45. int gr_disk(fix xc1,fix yc1,fix r1)
  46. {
  47.     int p,x, y, xc, yc, r;
  48.  
  49.     r = f2i(r1);
  50.     xc = f2i(xc1);
  51.     yc = f2i(yc1);
  52.     p=3-(r*2);
  53.     x=0;
  54.     y=r;
  55.  
  56.     // Big clip
  57.     if ( (xc+r) < 0 ) return 1;
  58.     if ( (xc-r) > WIDTH ) return 1;
  59.     if ( (yc+r) < 0 ) return 1;
  60.     if ( (yc-r) > HEIGHT ) return 1;
  61.  
  62.     while(x<y)
  63.     {
  64.         // Draw the first octant
  65.         gr_scanline( xc-y, xc+y, yc-x );
  66.         gr_scanline( xc-y, xc+y, yc+x );
  67.  
  68.         if (p<0) 
  69.             p=p+(x<<2)+6;
  70.         else    {
  71.             // Draw the second octant
  72.             gr_scanline( xc-x, xc+x, yc-y );
  73.             gr_scanline( xc-x, xc+x, yc+y );
  74.             p=p+((x-y)<<2)+10;
  75.             y--;
  76.         }
  77.         x++;
  78.     }
  79.     if(x==y)    {
  80.         gr_scanline( xc-x, xc+x, yc-y );
  81.         gr_scanline( xc-x, xc+x, yc+y );
  82.     }
  83.     return 0;
  84. }
  85.  
  86. int gr_udisk(fix xc1,fix yc1,fix r1)
  87. {
  88.     int p,x, y, xc, yc, r;
  89.  
  90.     r = f2i(r1);
  91.     xc = f2i(xc1);
  92.     yc = f2i(yc1);
  93.     p=3-(r*2);
  94.     x=0;
  95.     y=r;
  96.  
  97.     while(x<y)
  98.     {
  99.         // Draw the first octant
  100.         gr_uscanline( xc-y, xc+y, yc-x );
  101.         gr_uscanline( xc-y, xc+y, yc+x );
  102.  
  103.         if (p<0) 
  104.             p=p+(x<<2)+6;
  105.         else    {
  106.             // Draw the second octant
  107.             gr_uscanline( xc-x, xc+x, yc-y );
  108.             gr_uscanline( xc-x, xc+x, yc+y );
  109.             p=p+((x-y)<<2)+10;
  110.             y--;
  111.         }
  112.         x++;
  113.     }
  114.     if(x==y)    {
  115.         gr_uscanline( xc-x, xc+x, yc-y );
  116.         gr_uscanline( xc-x, xc+x, yc+y );
  117.     }
  118.     return 0;
  119. }
  120. 
  121.