Uses Crt,Dos,Perspect,Graphics,General,Keyb,Joys,Xms,Sound,Road,Confunit,CdUnit,CdVars;

Const Silence=True;
      MXS=11;
      Z=430;
      Mes=10;
      DemoStatus=0;

var
F                                   :File;
CurrDirectory                       :string;
Nmess,Auxi,RS,ExRS,Waiter,MessTime,Xmess:integer;
xs,ys,xsb                           :array[0..MXS+1] of Longint;
Incr,X,Xlimit,Y,angle               :array[0..MXS+1] of Longint;
Mess                                :array[0..Mes+1] of String[40];
Mytrack                             :byte;
cnt                                 :word;

Procedure AnimCar;
begin
chgface(1,Car[1].rr, 7+3);
chgface(1,Car[1].lr, 7+3);
chgface(1,Car[1].rf, 3+3);
chgface(1,Car[1].lf, 3+3);
end;

Procedure Recd;
Begin
inc(Waiter);
if (Waiter>50) then Begin
  DeviceStatus;
  Waiter:=0;
  if Audio and DiscinDrive then begin
  Audio_Disk_info;
   if not Busy then begin InitCD; PlayTrack(MyTrack); end;
   ResetTime;
  end
 end
end;

begin
GetDir(0,CurrDirectory);
chdir(CurrDirectory);

InitCD;
Mytrack:=5+1;
PlayTrack(MyTrack);

LoadConfig;
Demorel:=DemoStatus;
SaveConfig;

Initgraph(3000);

initsound(2000);

Initkeyb;
Initfont;
Initpros;
InitMisc;

loadfont('PICS\FontRel.Pcx');

LoadLogo(MaxBobs-1);
Lbob('Pics\Release.pcx','Data\Release.Dat',1);
loadpic('Pics\BackRele.pcx',Pseg,Pofs);
loadpal('Pics\BackRele.pcx',0,255);
getfbob(MaxBobs,0,0,319 shl SVGA+SVGA,199 shl SVGA+SVGA);
clr(0);
scrswap;

loadsample(1 ,'Samples\CarZoom.Raw');

resettime;

For Auxi:=1 to MXS do begin
Ys[auxi]:=500;
Xs[auxi]:=-400;
end;

     X[1]:=400;
     Y[1]:= 2;
  Incr[1]:=-1;
 Angle[1]:=90;
Xlimit[1]:=-250;

     X[2]:=-400;
     Y[2]:=40;
  Incr[2]:=1;
 Angle[2]:=270;
Xlimit[2]:=300;

     X[3]:=400;
     Y[3]:=55;
  Incr[3]:=-1;
 Angle[3]:=90;
Xlimit[3]:=-350;

     X[4]:=-400;
     Y[4]:=70;
  Incr[4]:=1;
 Angle[4]:=270;
Xlimit[4]:=400;

     X[5]:=400;
     Y[5]:=85;
  Incr[5]:=-1;
 Angle[5]:=90;
Xlimit[5]:=-350;

     X[6]:=-400;
     Y[6]:=100;
  Incr[6]:=1;
 Angle[6]:=270;
Xlimit[6]:=400;

     X[7]:=400;
     Y[7]:=115;
  Incr[7]:=-1;
 Angle[7]:=90;
Xlimit[7]:=-350;

     X[8]:=-400;
     Y[8]:=130;
  Incr[8]:=1;
 Angle[8]:=270;
Xlimit[8]:=400;

     X[9]:=400;
     Y[9]:=130;
  Incr[9]:=-1;
 Angle[9]:=90;
Xlimit[9]:=-350;

     X[10]:=400;
     Y[10]:=145;
  Incr[10]:=-1;
 Angle[10]:=90;
Xlimit[10]:=-350;

Mess[1] :='       ...Silvio Ciri...       ';
Mess[2] :='     ...Fabrizio Saglio...     ';
Mess[3] :='     ...Diego Iacobucci...     ';
Mess[4] :='      ...Silvy Arcara...       ';
Mess[5] :='       ...Luca Arcara...';
Mess[6] :='     ...Luca Tartarone...';
Mess[7] :='      ...Raoul Scerra...';
Mess[8] :='   ...Massimiliano & Nico...';
Mess[9] :='     ...Daniele Paglia....';
Mess[10]:='  ...And All Other Friends...';
NMess:=1;
Xmess:=-200;
Rs:=1;
ExRs:=0;
SoundOn:=Sbon;
(*StartBlaster;*)

LoadWir(2,  0,'3Data\Shadow.obj');
ResetTime;

For auxi:=1 to Mxs do Xsb[Auxi]:=Xs[Auxi];
repeat

if Rs<11 then begin
if ((x[RS]<-400) and (Incr[RS]<0)) or
   ((x[RS]> 400) and (Incr[RS]>0)) then Begin
   Inc(RS); if Rs=9 then Rs:=10;
   end;
end;

if Rs<11 then begin
 if ExRs<>RS then begin
  ExRS:=Rs;
  AutoOn;
  LoadCar(1,100,Carname[RS]);
  Playsample(GetChFree,1,64,90+Random(3)*10,400);
  AutoOff;
  AnimCar;
  Clr(0);
  ResetTime;
 end;

 inc(x[Rs],Timing*Incr[Rs]);
 Ys[RS]:=Y[RS] shl SVGA+60 shl (5+SVGA) div (z shr 3)-GetHy(RS) div 2;
 Xs[RS]:=X[RS];

 if (Incr[Rs]>0) and (Xs[Rs]>Xlimit[Rs]) then Xs[Rs]:=Xlimit[Rs];
 if (Incr[Rs]<0) and (Xs[Rs]<Xlimit[Rs]) then Xs[Rs]:=Xlimit[Rs];

 if Incr[Rs]>0 then Xsb[RS  ]:=Xs    [RS  ] shl (5+SVGA) div (Z shr 3)+80  shl SVGA-integer(GetHx(RS))
               else Xsb[RS  ]:=Xs    [RS  ] shl (5+SVGA) div (Z shr 3)+220 shl SVGA;
end;
fbob(MaxBobs,0,0);

For Auxi:=1 to Rs-1 do
 if Incr[Auxi]>0 then Xsb[Auxi]:=XLimit[Auxi] shl (5+SVGA) div (Z shr 3)+80  shl SVGA-integer(GetHx(Auxi))
                 else Xsb[Auxi]:=XLimit[Auxi] shl (5+SVGA) div (Z shr 3)+220 shl SVGA;

For Auxi:=1 to Rs do bob(Auxi,xsb[Auxi]-5 shl SVGA,ys[Auxi]);
Bob(MaxBobs-1,Xsb[1]-5 shl SVGA,Ys[1]-10 shl SVGA);

if Rs<11 then begin
putobj(2,x[RS],80,Z,angle[Rs],0,0,160 shl SVGA,Y[RS] shl SVGA);
putobj(1,x[RS],80,Z,angle[Rs],0,0,160 shl SVGA,Y[RS] shl SVGA);
end;

(*if Rs=11 then Begin
Text(xmess shl SVGA,190 shl SVGA,Mess[NMess],True);
if Xmess<75 then inc(Xmess,Timing) else Xmess:=75;
inc(MessTime); if MessTime>100 then begin Xmess:=-200; MessTime:=0;Inc(Nmess); if Nmess>Mes then Nmess:=1; end;
end;*)

Repeat NextSound until time>25;
Auxi:=time;
Timing:=10 * Auxi div 25;
ReCd;
resettime;
scrswap;
until keystate(1) or keystate(28) or keystate(57);
Fade(4);
FadeAudio(100);
clr(0);
(********* EXIT *************)
  assign(F,'password.WWW');
  rewrite(f,1);
  writefile('Demo',8,f);
  close(f);
(****************************)

StopAudio;
KillFont;
KillSound;
KillGraph;
KillKeyb;
end.
