#include<graphics.h>
#include<math.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>

void Putpixel( int x, int y, char c)
{
 if ( x < 0 || x >= 320 ) return;
 if ( y < 0 || y >= 200 ) return;

 // { Written by Matt Sottile }
 asm mov ax,y
 asm mov bx,ax
 asm shl ax,8
 asm shl bx,6
 asm add bx,ax
 asm add bx,x
 asm mov ax,0xa000
 asm mov es,ax
 asm mov al,c
 asm mov es:[bx],al
};


void main(void)
{
 int a=0,b=90;
 int i;
 float ca, vsin[360];

 int gdriver=1,gmode=0;
 initgraph(&gdriver,&gmode,"d:\\program\\borlandc\\bgi");
/*
 asm mov ax, 0x13
 asm int 0x10
*/
 for(ca=0;a<360;ca=ca+0.0174533)
	{
	vsin[a]=sin(ca);
	a++;
	}

 int Mov = 0, SMov=0;
 int oldMov, MULTI;
 int X, Y, X1, Y1;

 while(kbhit())getch();
 while( !kbhit() )
 {
  oldMov = SMov;

  SMov = (SMov++) % 360;

  Mov = SMov;


 #define SEPARACION  7
 for(a=0;a< 18;a++)
 {
  Mov = (Mov + 25)%360;
  oldMov = (oldMov + 25)%360;

        X = 160+vsin[(oldMov)]*40;
        Y = 100+vsin[(oldMov)]*10;

        X1 = 160+vsin[(Mov)]*40;
        Y1 = 100+vsin[(Mov)]*10;
        MULTI = (140-a*SEPARACION);

	for(i=0;i<360;i+=4)
	{
 	if(b>=360) b=0;
//	putpixel( a+ ceil(90*vsin[b]),ceil(200+50*vsin[a])+ceil(90*vsin[i]),10);
	putpixel( X + MULTI*vsin[b], Y + MULTI*vsin[i], 0);

	putpixel( X1 + MULTI*vsin[b], Y1 + MULTI*vsin[i],10);

	b+=4;
	}
//        getch();
//	delay(10);
	b=90;
	}

 }
/*
 asm mov ax, 3
 asm int 0x10
*/

 restorecrtmode();
 closegraph();
 getch();

}
