/*huellas con paleta de colores 25/iii/96*/
/*Fernando Galindo Soria*/

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

void inicia(int);
void escribecolor(int);

int i,j,color,rojo,verde,azul;
char far *apun= (char far *) 0xA0000000;

void main()
{ int k,inc=129,l,ir;
  inicia(0x13);randomize();

    ir++;
    for (inc=0;inc<200;inc++){
      for (k=0;k<320;k++) *(apun+inc*320+k)=inc*k*ir;
      for (k=0;k<320;k++) *(apun+(200-inc)*320+k)=(200-inc)*k*ir;
      delay(1);}
    {i=256;j=0;l=0;
    while ((l<4)&&!kbhit()){
      for (k=0;k<64;k++) {azul++;escribecolor(i-=19);escribecolor(j+=7);}
      rojo+=17;verde+=11;l++;}}

   while(!kbhit()){
    if(random(7)==3){i=256;j=0;l=0;
    while ((l<15)&&!kbhit()){
      for (k=0;k<64;k++) {azul++;escribecolor(i-=19);escribecolor(j+=7);}
      rojo+=17;verde+=11;l++;}}

    ir++;
    for (inc=0;inc<200;inc++){
      for (k=0;k<320;k++) *(apun+inc*320+k)=inc*k*ir;
      for (k=0;k<320;k++) *(apun+(200-inc)*320+k)=(200-inc)*k*ir;
      delay(1);}

    ir++;
    for (k=0;k<160;k++){
      for (inc=0;inc<200;inc++) *(apun+inc*320+160-k)=inc*(160-k)*ir;
      for (inc=0;inc<200;inc++) *(apun+(200-inc)*320+160+k)=(200-inc)*(160+k)*ir;
      delay(1);}
    }

  getch();
  inicia(0x12);
  textmode(C80);
}

void inicia(modo)
{
 union REGS reg;
 reg.h.ah=0;
 reg.h.al=modo;
 int86(0x10,&reg,&reg);
}

void escribecolor(color)
{
 union REGS reg;
 reg.h.ah=0x10;
 reg.h.al=0x10;
 reg.x.bx=color;
 reg.h.dh=rojo;
 reg.h.ch=verde;
 reg.h.cl=azul;
 int86(0x10,&reg,&reg);
}