program binary_scrool;

uses crush13h,crt;

var a,b:integer;
    c:char;
    count:integer;
    message:string[63];

procedure scrooldown (where:word);
begin
     move (mem[where:0],mem[where:320],63680);
end;

procedure buildmessage;
var i:integer;
begin
     message:='';
     for a:=1 to 63 do
         begin
              i:=random(2);
              if i=0 then message:=message+'0';
              if i=1 then message:=message+'1';
         end;
end;

begin
     video_mode ( $13);
     initvirt;

     loadfont ('..\fonts\5x5caps.fnt',1);

     randomize;
     cls (0,vga);
     cls (3,vp[1]);

     message:='Subliminar contents is everywhere!';

     repeat
     inc(count,1);
     if count>5 then count:=0;
     scrooldown (vp[1]);
     move (mem[vp[1]:0],mem[vp[2]:0],64000);

     for a:=0 to 5 do for b:=0 to 319 do putpixel (b,a,8,vp[2]);
     move (mem[vp[2]:0],mem[vga:0],64000);
     waitvbl;
     waitvbl;
     if count=5 then buildmessage;
     if count=5 then putstring (2,1,0,5,0,message,1,vp[1]);
     if keypressed=true then c:=readkey;
     until c=#27;

     closevirt;
     video_mode ( 03);
end.
