Скачиваний:
34
Добавлен:
15.09.2014
Размер:
2.18 Кб
Скачать
#include <dos.h>
#include <conio.h>
#include <stdlib.h>
#include <stdio.h>

void set_mode(int mode)
{
_AH = 0x00;
_AL = mode;
geninterrupt(0x10);
}

void goto_xy(int x, int y)
{
_AH = 0x02;
_BH = 0;
_DH = y;
_DL = x;
geninterrupt(0x10);
}

int colour()
{
  int a = random(16);
  while (a == 0)
  a = random(16);
  return 2;
}

void set_video(int nomer)
{
_AH = 0x05;
_AL = nomer;
}

char read_sim()
{
char x;
_AH = 0x08;
_BH = 0;
geninterrupt(0x10);
x = _AL;
return x;
}

void print_sim(char *str, int atr)
{
_AH = 0x09;
_BH = 0;
_AL = *str;
_CX = 1;
_BL = atr;
geninterrupt(0x10);
}

main()
{
char *ch, buf;
char str[26] = "Demidovec Alexandr 750501";
char st[25];
int p[80];
int i, j, a, g = 0, kk, t, k;

set_mode(2);
set_video(0);

cputs("Vvedite vremya raboti programmi v sekyndah!\n\r");
scanf("%d",&t);
t = t* 10;
clrscr();
randomize();
for (g=0; g<80; g+=2)
{
  p[g] = random(25);
  i = 0;
  for (j=p[g]; j>=0; j--)
  {
    st[j] = str[i];
    i++;
    *ch = st[j];
    a = colour();
    goto_xy(g, j);
    print_sim(ch, a);
  }
}


goto_xy(25,24);
cputs("Press any key to enter matrix!");
getch();

while(t>=0)
{
for (g=0; g<80; g++)
{
  if (p[g]<24)
  {
  k = 0;
  for (j=p[g]; j>=0; j--)
  {
    if((j+3)>25)
     st[j] = str[k];
    else
     st[j+3] = str[k];
    k++;
  }
  for (i=p[g]; i>=0; i--)
  {
    goto_xy(g, i);
    *ch = read_sim();
    a = colour();
    goto_xy(g, i);
    st[i] = *ch;
    print_sim(ch, a);
    if (i == 0)
    {
      goto_xy(g, i);
      a = colour();
      kk = p[g] + 1;
      st[0] = str[kk];
      p[g] = kk;
      *ch = st[0];
      print_sim(ch, a);
   }
  }
  }
  else
  {
    for (i=0; i<25; i++)
    {
      goto_xy(g, i);
      st[i] = read_sim();
    }
    buf = st[24];
    for (i = 24; i>0; i--)
      st[i]=st[i-1];
    st[0] = buf;
    for (i = 0; i<25; i++)
    {
      goto_xy(g, i);
      *ch = st[i];
      a = colour();
      print_sim(ch, a);
    }
  }
}
delay(50);
t--;
}

//getch();
clrscr();
goto_xy(0, 0);
cputs("Press any key to exit!");
getch();
return 0;
}