You are on page 1of 1

//THE CODE

typedef long
fixed16_16;
fixed16_16 SIN_ACOS[1024];
/**************************************************************************
* circle_fast
*
*
Draws a circle by using fixed point numbers and a trigonometry
*
*
table.
*
**************************************************************************/
void circle(int x,int y, int radius, byte color)
{
fixed16_16 n=0,invradius=(1/(float)radius)*0x10000L;
int dx=0,dy=radius-1;
word dxoffset,dyoffset,offset = (y<<8)+(y<<6)+x;

}

while (dx<=dy)
{
dxoffset = (dx<<8) + (dx<<6);
dyoffset = (dy<<8) + (dy<<6);
VGA[offset+dy-dxoffset] = color; /*
VGA[offset+dx-dyoffset] = color; /*
VGA[offset-dx-dyoffset] = color; /*
VGA[offset-dy-dxoffset] = color; /*
VGA[offset-dy+dxoffset] = color; /*
VGA[offset-dx+dyoffset] = color; /*
VGA[offset+dx+dyoffset] = color; /*
VGA[offset+dy+dxoffset] = color; /*
dx++;
n+=invradius;
dy = (radius * SIN_ACOS[n>>6]) >>16;
}

octant
octant
octant
octant
octant
octant
octant
octant

0
1
2
3
4
5
6
7

*/
*/
*/
*/
*/
*/
*/
*/

void main()
{
int i;
setvmode(0x13);
for(i=0;i<1024;i++)
/* create the sin(arccos(x)) table. */
SIN_ACOS[i]=sin(acos((float)i/1024)) * 0x10000L;
circle(160, 100, 50, 7);
setvmode(0x03);
}
//