#include <stdio.h>
#include <snd.h>
#include <egb.h>

#include <\src\ysuty2\ysuty2.h>

char EGB_work[EgbWorkSize];
char SND_work[16384];


void circle(int x,int y,int r)
{
	int ro,rf,mx,my;

	ro=r*r;
	rf=ro;
	mx=r;
	my=0;

	while(mx>=0)
	{
		YGB_pset(EGB_work,x+mx,y+my);
		YGB_pset(EGB_work,x-mx,y+my);
		YGB_pset(EGB_work,x+mx,y-my);
		YGB_pset(EGB_work,x-mx,y-my);
		if(rf==ro)
		{
			rf+=(1-mx-mx)+(1+my+my);
			mx--;
			my++;
		}
		else if(rf>ro)
		{
			rf+=(1-mx-mx);
			mx--;
		}
		else if(rf<ro)
		{
			rf+=(1+my+my);
			my++;
		}
	}
}




void main()
{
	int pad,x,y,r;

	SND_init(SND_work);
	YGB_init(EGB_work,17,17);

	pad=255;
	while(pad==255)
	{
		SND_joy_in_2(0,&pad);

		x=rand()%512;
		y=rand()%512;
		r=rand()%100;
		circle(x,y,r);
	}

	SND_end();
}
