#include<math.h>
#include<mem.h>
#include<dos.h>
#include<stdlib.h>
#define p_num 2000
struct _Particle
{
float vx,vy,ax,ay,x,y;
unsigned char c;
};
void SetColor(int c,int r,int g,int b)
{
outportb(0x3c6,255);
outportb(0x3c8,c);
outportb(0x3c9,r>>2);
outportb(0x3c9,g>>2);
outportb(0x3c9,b>>2);
}
char far *GetBuffer(long x,long y)
{
return (char far *)(0xa0000000L+x+y*320);
}
void blur()
{
unsigned char far *p, far *q;
for(p=GetBuffer(1,1),q=GetBuffer(318,198);p<q;p++) *p=*(p-1)+*(p+1)+*(p-320)+*(p+320)>>2;
}
void main()
{
struct _Particle pg[p_num];
float fcos,fsin,t=0.01,angle=0.0;
float RGB[256][3];
int i;
int dx,dy;
memset(pg,0,p_num*sizeof(struct _Particle));
for(i=0;i<p_num;i++)
{
pg[i].x=160;
pg[i].y=100;
pg[i].c=255;
pg[i].ax=rand()%10191/1000.0-5;
pg[i].ay=rand()%8191/1000.0-4;
}
for(i=0;i<256;i++) RGB[i][0]=sqrt(i)/16.0;
for(i=0;i<256;i++) RGB[i][1]=pow(i,0.7)/48.5;
for(i=0;i<256;i++) RGB[i][2]=(i*i)/65536.0;
_AX=0x13;
asm int 0x10;
for(i=0;i<256;i++) SetColor(i,RGB[i][0]*256,RGB[i][1]*256,RGB[i][2]*256);
while(inportb(0x60)!=1)
{
fcos=cos(angle);
fsin=sin(angle);
for(i=0;i<p_num;i++)
{
pg[i].vx+=pg[i].ax*t;
pg[i].vy+=pg[i].ay*t;
pg[i].x+=pg[i].vx*t;
pg[i].y+=pg[i].vy*t;
dx=(pg[i].x-160)*fcos-(100-pg[i].y)*fsin+160;
dy=(pg[i].x-160)*fsin+(100-pg[i].y)*fcos+100;
if(dx>0&&dx<319&&dy>0&&dy<199) *GetBuffer(dx,dy)=pg[i].c;
if(dx<0||dx>=320) pg[i].vx=-pg[i].vx;
if(dy<0||dy>=200) pg[i].vy=-pg[i].vy;
}
blur();
angle+=0.01;
}
_AX=0x03;
asm int 0x10;
}
for tC + dos