home *** CD-ROM | disk | FTP | other *** search
- #include <time.h>
- #include <stdlib.h>
- #include <conio.h>
- #include <math.h>
-
- #define MAXS 300
-
- void open(void);
- void close(void);
- void pset(int x,int y,unsigned char c);
- void putp(unsigned int ad,unsigned char c);
- void initpal(void);
- void inittables(void);
-
- int sint[256],cost[256]; // sin & cos tables
-
- void main(void)
- {
- int x[MAXS],y[MAXS],z[MAXS];
- unsigned char angle=0;
-
- unsigned int ids[MAXS]={0};
-
- int apu;
-
- randomize();
- inittables();
-
- for(apu=0;apu<MAXS;apu++)
- {
- x[apu] = -750 + random(1500);
- y[apu] = -750 + random(1500);
- z[apu] = 1+random(255);
- }
- open(); // open-graphics 320x200
- initpal(); // palette..
-
- apu=0;
- while(!kbhit())
- {
- int xx,yy,xxx,yyy;
- if(ids[apu]!=65000)
- putp(ids[apu],0);
-
- z[apu]--;
-
- if(z[apu])
- {
-
- xxx = (x[apu]/z[apu]);
- yyy = (y[apu]/z[apu]);
-
- // rotation
- xx = (xxx*cost[angle]-yyy*sint[angle]) / 256;
- yy = (xxx*sint[angle]+yyy*cost[angle]) / 256;
-
- xx += 160;
- yy += 100;
-
- if((xx<320 && xx >= 0) && (yy<200 && yy>=0))
- { ids[apu] = yy*320+xx;
- putp(ids[apu],z[apu]);
- }
- else
- {
- ids[apu] = 65000;
- }
- }
- else
- {
- x[apu] = -750+random(1500);
- y[apu] = -750+random(1500);
- z[apu] = 100+random(400);
- }
- apu++;
- if(apu==MAXS){
- apu=0;
- angle++;
- angle++;
- }
-
- }
-
-
- close(); // close & set 80x25 mode..
- }
-
- void open(void)
- {
- asm mov ax,0x13
- asm int 0x10
- }
-
- void close(void)
- {
- asm mov ax,0x3
- asm int 0x10
- }
-
- void pset(int x,int y,unsigned char c)
- {
- char far * paikka = (char far *)(0xa0000000 + y*320 +x);
- *paikka = c;
- }
-
- void putp(unsigned int ad,unsigned char c)
- {
- char far *paikka = (char far *)(0xa0000000+ad);
-
- *paikka = c;
- }
-
- void initpal(void)
- {
- int x;
-
- asm mov al,1 // valitse ensimmäinen rgb..
- asm mov dx,0x3c8
- asm out dx,al
- asm inc dx
- // aseta koko paletti uusix, harmaasävy..
- for(x=256;x>0;x--)
- {
- asm mov ax,x
- asm shr al,2
- asm out dx,al
- asm out dx,al
- asm out dx,al
- }
- }
-
- void inittables(void)
- {
- int i;
-
- for(i=0;i<256;i++)
- {
- sint[i] = sin(2*3.14*i/256)*256;
- cost[i] = cos(2*3.14*i/256)*256;
- }
- }