program playRCV;
uses crt,gfx3;

var l1,l2:integer;
     f:text;


procedure rnframe(where:word);
var w1,w2:word;
    c1,c2,loop:byte;
    ch:char;

begin
{  assign(f,s);
  reset(f);}
  w1:=0;
  repeat
    read(f,ch);
    c1:=ord(ch);
    if c1=64 then begin
      read(f,ch);
      loop:=ord(ch);
      if loop<254 then
      loop:=loop+1;
      read(f,ch);
      c1:=ord(ch);
      if w1+loop>63999 then loop:=63999-w1;
      for w2:=w1 to w1+loop do begin
         if c1<>128 then
         mem[where:w2]:=c1+random(1);
      end;
    end
    else begin
      loop:=1;
      if c1<>128 then
      mem[where:w1]:=c1;
   end;
    w1:=w1+loop;
  until w1>63998;
end;

procedure readpal;
var r,g,b:byte;
ch:char;
begin
  for l1:=1 to 255 do begin
     read(f,ch);
     r:=ord(ch);

     read(f,ch);
     g:=ord(ch);

     read(f,ch);
     b:=ord(ch);
     pal(l1,r,g,b);
  end;
end;

begin
  assign(f,'desol.rcv');
  reset(f);
  setmcga;
  readpal;
  repeat
    rnframe(sega000);
    if eof(f) then begin
       reset(f);
       readpal;
    end;
 until keypressed;
 close(f);
 settext;
end.