]> icculus.org git repositories - btb/d2x.git/blob - 2d/disc.c
make gr_remap_font just reload the whole thing
[btb/d2x.git] / 2d / disc.c
1 /* $Id: disc.c,v 1.3 2002-07-17 21:55:19 bradleyb Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
12 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 #ifdef HAVE_CONFIG_H
16 #include <conf.h>
17 #endif
18
19 #include "u_mem.h"
20
21 #include "gr.h"
22 #include "grdef.h"
23
24 int gr_disk(fix xc1,fix yc1,fix r1)
25 {
26         int p,x, y, xc, yc, r;
27
28         r = f2i(r1);
29         xc = f2i(xc1);
30         yc = f2i(yc1);
31         p=3-(r*2);
32         x=0;
33         y=r;
34
35         // Big clip
36         if ( (xc+r) < 0 ) return 1;
37         if ( (xc-r) > GWIDTH ) return 1;
38         if ( (yc+r) < 0 ) return 1;
39         if ( (yc-r) > GHEIGHT ) return 1;
40
41         while(x<y)
42         {
43                 // Draw the first octant
44                 gr_scanline( xc-y, xc+y, yc-x );
45                 gr_scanline( xc-y, xc+y, yc+x );
46
47                 if (p<0) 
48                         p=p+(x<<2)+6;
49                 else    {
50                         // Draw the second octant
51                         gr_scanline( xc-x, xc+x, yc-y );
52                         gr_scanline( xc-x, xc+x, yc+y );
53                         p=p+((x-y)<<2)+10;
54                         y--;
55                 }
56                 x++;
57         }
58         if(x==y)        {
59                 gr_scanline( xc-x, xc+x, yc-y );
60                 gr_scanline( xc-x, xc+x, yc+y );
61         }
62         return 0;
63 }
64
65 int gr_udisk(fix xc1,fix yc1,fix r1)
66 {
67         int p,x, y, xc, yc, r;
68
69         r = f2i(r1);
70         xc = f2i(xc1);
71         yc = f2i(yc1);
72         p=3-(r*2);
73         x=0;
74         y=r;
75
76         while(x<y)
77         {
78                 // Draw the first octant
79                 gr_uscanline( xc-y, xc+y, yc-x );
80                 gr_uscanline( xc-y, xc+y, yc+x );
81
82                 if (p<0) 
83                         p=p+(x<<2)+6;
84                 else    {
85                         // Draw the second octant
86                         gr_uscanline( xc-x, xc+x, yc-y );
87                         gr_uscanline( xc-x, xc+x, yc+y );
88                         p=p+((x-y)<<2)+10;
89                         y--;
90                 }
91                 x++;
92         }
93         if(x==y)        {
94                 gr_uscanline( xc-x, xc+x, yc-y );
95                 gr_uscanline( xc-x, xc+x, yc+y );
96         }
97         return 0;
98 }
99