]> icculus.org git repositories - btb/d2x.git/blob - 2d/disc.c
free OGL font data when rereading
[btb/d2x.git] / 2d / disc.c
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 #ifdef HAVE_CONFIG_H
15 #include <conf.h>
16 #endif
17
18 #include "u_mem.h"
19
20 #include "gr.h"
21 #include "grdef.h"
22
23 int gr_disk(fix xc1,fix yc1,fix r1)
24 {
25         int p,x, y, xc, yc, r;
26
27         r = f2i(r1);
28         xc = f2i(xc1);
29         yc = f2i(yc1);
30         p=3-(r*2);
31         x=0;
32         y=r;
33
34         // Big clip
35         if ( (xc+r) < 0 ) return 1;
36         if ( (xc-r) > GWIDTH ) return 1;
37         if ( (yc+r) < 0 ) return 1;
38         if ( (yc-r) > GHEIGHT ) return 1;
39
40         while(x<y)
41         {
42                 // Draw the first octant
43                 gr_scanline( xc-y, xc+y, yc-x );
44                 gr_scanline( xc-y, xc+y, yc+x );
45
46                 if (p<0) 
47                         p=p+(x<<2)+6;
48                 else    {
49                         // Draw the second octant
50                         gr_scanline( xc-x, xc+x, yc-y );
51                         gr_scanline( xc-x, xc+x, yc+y );
52                         p=p+((x-y)<<2)+10;
53                         y--;
54                 }
55                 x++;
56         }
57         if(x==y)        {
58                 gr_scanline( xc-x, xc+x, yc-y );
59                 gr_scanline( xc-x, xc+x, yc+y );
60         }
61         return 0;
62 }
63
64 int gr_udisk(fix xc1,fix yc1,fix r1)
65 {
66         int p,x, y, xc, yc, r;
67
68         r = f2i(r1);
69         xc = f2i(xc1);
70         yc = f2i(yc1);
71         p=3-(r*2);
72         x=0;
73         y=r;
74
75         while(x<y)
76         {
77                 // Draw the first octant
78                 gr_uscanline( xc-y, xc+y, yc-x );
79                 gr_uscanline( xc-y, xc+y, yc+x );
80
81                 if (p<0) 
82                         p=p+(x<<2)+6;
83                 else    {
84                         // Draw the second octant
85                         gr_uscanline( xc-x, xc+x, yc-y );
86                         gr_uscanline( xc-x, xc+x, yc+y );
87                         p=p+((x-y)<<2)+10;
88                         y--;
89                 }
90                 x++;
91         }
92         if(x==y)        {
93                 gr_uscanline( xc-x, xc+x, yc-y );
94                 gr_uscanline( xc-x, xc+x, yc+y );
95         }
96         return 0;
97 }
98