Uses Crt,Dos,Graphics,General,Sound,Keyb,Perspect,Joys,Road,ConfUnit,CdUnit,CdVars,NetUnit,SelCarUn;

Const Ncurs = 70;

Label RESELECT;

Var   Esc,infos                   :Boolean;
      Cnt,angle,Angle2,Auxi,Waiter:Integer;
      F                           :File;
      CurrDirectory               :String;
      MyTrack                     :word;
      Attribs                     :array[0..2] of string[5];



Function EnterId(num:byte):string;
Var Lung:Byte;
    a:char;
    LId:string[3];
begin
LId:='-X-';
LoadLogo(MaxBobs-1);
Loadpic('Pics\BackMen2.pcx',Pseg,Pofs);
LoadPal('Pics\BackMen2.pcx',20,255);
PlaceLogo;
getfbob(MaxBobs,0,0,319 shl SVGA,199 shl SVGA);
CLR(0);Lung:=1;
repeat
repeat
Fbob(MaxBobs,0,0);
Text(50 shl SVGA,100 shl SVGA,'Enter Your Id Player '+Tostr(Num,-15)+': '+Lid,True);
scrswap;
a:=readkey;
until (a='a') or (a='b') or (a='c') or (a='d') or
      (a='e') or (a='f') or (a='g') or (a='h') or
      (a='i') or (a='j') or (a='k') or (a='l') or
      (a='l') or (a='m') or (a='n') or (a='o') or
      (a='p') or (a='q') or (a='r') or (a='s') or
      (a='t') or (a='u') or (a='v') or (a='w') or
      (a='x') or (a='y') or (a='z') ;

LId[Lung]:=a;
inc(Lung);
until (Lung=4);
Fbob(MaxBobs,0,0);
Text(50 shl SVGA,100 shl SVGA,'Enter Your Id Player '+Tostr(Num,-15)+': '+Lid,True);
scrswap;
EnterId:=LId;
end;

Procedure SelSlotNet;
Var
    NameSlot:string[3];
    cnt,cnt2:integer;
    ConProg :longint;
    Assigned:Boolean;

begin
MyId:=EnterId(1);
MySlot:=1;
ConProg:=0;
for cnt:=1 to 8 do ids[cnt]:='---';
ClearNet;
repeat
inc(ConProg);
Fbob(MaxBobs,0,0);

if RecData then begin
MySlot:=0;
Assigned:=False;
for cnt:=1 to 8 do begin
 ids[cnt]:=GetId(cnt);
 if ((ids[cnt]='---') or (ids[cnt]=Myid)) and Not Assigned then Begin Assigned:=True; MySlot:=Cnt; end else
 if  (ids[cnt]=MyId ) and Assigned then ClearId(cnt);
end;
end;

PutId(Myslot);

MaxNetPl:=0;
For Cnt:=1 to 8 do if (ids[cnt]<>'---') and (ids[cnt]<>'') then Inc(MaxNetPl);
Solo:=MaxNetPl=1;

For cnt:=1 to 8 do begin
Text( 35 shl SVGA,(cnt*20) shl SVGA,'Net Slot '+Tostr(cnt,-15)+']',True);
Text(130 shl SVGA,(cnt*20) shl SVGA,'Occupied by -'+ids[cnt]+'-',True);
Text(200 shl SVGA,10 shl SVGA,'Players:'+Tostr(MaxNetPl,-15),true);
end;

SenData;

Text(10,10,tostr(ConProg,0),true);
scrswap;
Esc:=Keystate(1);
until Keystate(57) or Keystate(28) or Esc;

if Esc then exit;

repeat
Fbob(MaxBobs,0,0);
RecData;
PutVal(MySlot,4,1);
SenData;
Text(35 shl SVGA,90 shl SVGA,'Waiting for others players...',True);

AllOk:=True;
For Cnt:=1 to MaxNetPl do AllOk:=AllOk and (GetVal(cnt,4)=1);

scrswap;
Esc:=Keystate(1);
until AllOk or Esc;
if Esc then Exit;

For cnt:=1 to 1000 do begin
 RecData;
 PutVal(MySlot,4,1);
 SenData;
end;

fade(4);
clr(0);
scrswap;
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;

Function KeyState2(Num:byte): Boolean;
begin
if Keystate(Num) then begin if Ch[1].st=0 then PlaySample(1,1,64,100,100); Keystate2:=True; WaitSil; end else Keystate2:=False;
end;

Procedure VmapbobFreeS(xa,xb,y1,y2,y3,y4,num:integer);
begin
TMapbob(xa,y1,xb,y2,xb,y3,xa,y4,num);
end;

Procedure RotationItem(numbob,x,y:integer);
Var Kx1,Ky1,Aux:integer;
begin
 inc(angle2,Timing div 4); if angle2>359 then Dec(angle2,359);
 Aux:=(GetHy(NumBob) div 2) ;
 Kx1:=(cs[angle2]*GetHx(NumBob) div 256 ) ;
 Ky1:=(sn[angle2]*GetHx(NumBob) div 2560) ;
VMapbobFreeS((x-kx1    ),(x+kx1    ),
             (y+ky1-Aux),(y-ky1-Aux),
             (y+ky1+Aux),(y-ky1+Aux),numbob);
end;

Procedure SelCar;
var
Selectable    :Boolean;
x1,y1         :integer;
CurCar        :shortint;
ExCar         :shortint;
SelCar        :boolean;
Xdest         :integer;
begin
if CarPl1=0 then CarPl1:=1;
if CarPl2=0 then CarPl2:=2;

if GameMode=3 then SelSlotNet else begin MaxNetPl:=0; Ids[1]:=EnterId(1); end;

Lbob('Pics/SelBox.pcx','Data/Selbox.Dat',1);

(********************************* SELCAR1 ***********************************)
fade(4); clr(0); scrswap;
LoadLogo(MaxBobs-1);
Loadpic('Pics\selcar1.pcx',Pseg,Pofs);
PlaceLogo;
getfbob(MaxBobs,0,0,319 shl SVGA,199 shl SVGA);

LoadCar(1,100,Carname[CarPl1]);
LoadWir(2,  0,'3Data\Shadow.obj');
LoadPal('Pics\selcar1.pcx',20,255);
Clr(0);

x1:=380;
Xdest:=160;
y1:=70;
angle:=0;
CurCar:=CarPl1;
ExCar:=CurCar;
resettime;
SelCar:=False;infos:=False;
Selectable:=True;
repeat
if keypush>0 then empty;
fbob(MaxBobs,0,0);

if GameMode=2 then begin
if CurCar<4 then RotationItem(558,30 shl SVGA,175 shl SVGA)
            else RotationItem(559,30 shl SVGA,175 shl SVGA);
end;

inc(angle,2*Timing div 10); if angle>359 then Dec(angle,359);

if ((x1>380) or (x1<-160)) and SelCar then Begin SelCar:=False;Infos:=false;
                                           loadcar(1,100,Carname[CurCar]);clr(0);
                                           fbob(MaxBobs,0,0); Xdest:=160;
                                           resettime;
                                           end;

if x1>Xdest+Timing then dec(x1,10*Timing div 10) else
if x1<Xdest-Timing then inc(x1,10*Timing div 10) else begin
 X1:=Xdest;
 ExCar:=CurCar;
 if Keystate2(Lf1) or Keystate2(75) then inc(CurCar) else
 if Keystate2(Rg1) or Keystate2(77) then dec(CurCar);
 if CurCar< 1 then CurCar:=10 else
 if CurCar>10 then CurCar:= 1;
 if ExCar<>CurCar then begin
 SelCar:=True;
 if Random(2)=1 then xdest:=480 else xdest:=-260
 end;
end;

bob(1,(x1-60) shl SVGA,(y1+5) shl SVGA);
 putobj(2,0,100,430,angle,0,0,x1 shl SVGA,y1 shl SVGA);
 putobj(1,0,100,430,angle,0,0,x1 shl SVGA,y1 shl SVGA);

if infos and (x1=160) then begin
 bar(103 shl SVGA,80 shl SVGA,215 shl SVGA, 150 shl SVGA,74);
 bob(3,(X1-59) shl SVGA,(y1+5) shl SVGA);
 putobjWir(1,20,0,100,430,angle,0,0,x1 shl SVGA,y1 shl SVGA);
 bob(2,X1 shl SVGA-GetHx(2) div 2-SVGA*7,(y1+5) shl SVGA);

 Bar(110 shl SVGA, 82 shl SVGA,(110+(Car[1].Accel - 50)   div 2) shl SVGA, 87 shl SVGA,55);
 Bar(185 shl SVGA, 82 shl SVGA,(185+(Car[1].MaxSpd-130)   div 4) shl SVGA, 87 shl SVGA,55);
 Bar(110 shl SVGA,133 shl SVGA,(110+(Car[1].Energy-130)   div 6) shl SVGA,138 shl SVGA,55);
 Bar(185 shl SVGA,133 shl SVGA,(185+(Car[1].Mass  -  5)*5 div 6) shl SVGA,138 shl SVGA,55);
 Box(110 shl SVGA, 82 shl SVGA,(135                            ) shl SVGA, 87 shl SVGA,0);
 Box(185 shl SVGA, 82 shl SVGA,(210                            ) shl SVGA, 87 shl SVGA,0);
 Box(110 shl SVGA,133 shl SVGA,(135                            ) shl SVGA,138 shl SVGA,0);
 Box(185 shl SVGA,133 shl SVGA,(210                            ) shl SVGA,138 shl SVGA,0);

 for cnt:=0 to 4 do begin
 line((110+cnt*5) shl SVGA, 82 shl SVGA,(110+cnt*5) shl SVGA, 87 shl SVGA,0);
 line((185+cnt*5) shl SVGA, 82 shl SVGA,(185+cnt*5) shl SVGA, 87 shl SVGA,0);
 line((110+cnt*5) shl SVGA,133 shl SVGA,(110+cnt*5) shl SVGA,138 shl SVGA,0);
 line((185+cnt*5) shl SVGA,133 shl SVGA,(185+cnt*5) shl SVGA,138 shl SVGA,0);
 end;

end;

if DemoRel=1 then begin
if (CurCar<>1) and (CurCar<>4) then Text(70 shl SVGA,100 shl SVGA,' Not Available On Demo',True);
Selectable:=not ((CurCar<>1) and (CurCar<>4));
end;

if GameMode=3 then begin
 Recdata;
 For cnt:=1 to MaxNetPl do begin
  if (CurCar=GetVal(cnt,1)) and (GetVal(9,1)<>Myslot) and (GetVal(cnt,4)=50) then Begin
   Selectable:=False;
   Text(70 shl SVGA,100 shl SVGA,' Car Already Selected',True);
  end else Selectable:=True;
 end;
end;

if (x1=160) and not Infos and (Keystate2(Ba1) or Keystate2(Bb1) or Keystate2(28) or Keystate2(57)) then begin
infos:=True;
repeat NextSound until not (Keystate2(Ba1) or Keystate2(Bb1) or Keystate2(28) or Keystate2(57))
end;

Esc:=Keystate2(1);

repeat NextSound until time>25;
Auxi:=time;
ReCd;
Timing:=10 * Auxi div 25;
resettime;
scrswap;
until (infos and Selectable and (Keystate2(Ba1) or Keystate2(Bb1) or Keystate2(28) or Keystate2(57))) or Esc;
if Esc then exit;
CarPl1:=CurCar;

if GameMode=3 then begin
 Fbob(MaxBobs,0,0);
 Text(40 shl SVGA,90 shl SVGA,'Waiting for others players...',True);
 scrswap;
 For cnt:=1 to 8 do Ok[cnt]:=false;
 AllOk:=false;
 AllOkcnt:=0;
 repeat

 if Recdata then
   if (GetVal(9,1)<>Myslot) then begin
    For cnt:=1 to MaxNetPl do if GetVal(cnt,4)=50 then Ok[cnt]:=True;
   end;

 Putval(Myslot,1,Curcar);
 Putval(Myslot,4,50);
 PutVal(9,1,Myslot);
 Sendata;

 AllOk:=True;
 for cnt:=1 to MaxNetPl do AllOk:=AllOk and Ok[cnt];
 if AllOk then inc(AllOkcnt);

 until (AllOkcnt>100) or Solo;

 for cnt:=1 to MaxnetPl do Car[cnt].Chassis:=GetVal(cnt,1);
end;

(********************************* SELCAR2 ***********************************)
repeat Nextsound until not Keystate2(28) and not Keystate2(57);
if NumPla=2 then begin
fade(4); clr(0); scrswap;
Ids[2]:=EnterId(2);
LoadLogo(MaxBobs-1);
Loadpic('Pics\selcar2.pcx',Pseg,Pofs);
PlaceLogo;
getfbob(MaxBobs,0,0,319 shl SVGA,199 shl SVGA);
LoadCar(1,100,Carname[CarPl2]);
LoadWir(2,  0,'3Data\Shadow.obj');

Clr(0);
x1:=380;
y1:=70;
angle:=2;
Curcar:=CarPl2;
ExCar:=CurCar;
SelCar:=False;
resettime;
LoadPal('Pics\selcar2.pcx',20,255);
Selectable:=True;infos:=False;
repeat
if keypush>0 then empty;
fbob(MaxBobs,0,0);

if GameMode=2 then begin
if CurCar<4 then RotationItem(558,30 shl SVGA,175 shl SVGA)
            else RotationItem(559,30 shl SVGA,175 shl SVGA);
end;

Selectable:=True;

if (GameMode=2) and (CurCar>3) and (CarPl1>3) then Selectable:=False;

inc(angle,2*Timing div 10); if angle>359 then Dec(angle,359);


if ((x1>380) or (x1<-160)) and SelCar then Begin SelCar:=False;infos:=False;
                                           loadcar(1,100,Carname[CurCar]);clr(0);
                                           fbob(MaxBobs,0,0); Xdest:=160;
                                           resettime;
                                           end;
if x1>Xdest+Timing then dec(x1,10*Timing div 10) else
if x1<Xdest-Timing then inc(x1,10*Timing div 10) else begin
 X1:=Xdest;
 ExCar:=CurCar;
 if Keystate2(Lf2) or Keystate2(75) then inc(CurCar) else
 if Keystate2(Rg2) or Keystate2(77) then dec(CurCar);
 if CurCar< 1 then CurCar:=10 else
 if CurCar>10 then CurCar:= 1;
 if ExCar<>CurCar then begin
 SelCar:=True;
 if Random(2)=1 then xdest:=480 else xdest:=-260
 end;
end;

bob(1,(x1-60) shl SVGA,(y1+5) shl SVGA);
 putobj(2,0,100,430,angle,0,0,x1 shl SVGA,y1 shl SVGA);
 putobj(1,0,100,430,angle,0,0,x1 shl SVGA,y1 shl SVGA);
if infos and (x1=160) then begin
 bar(103 shl SVGA,80 shl SVGA,215 shl SVGA, 150 shl SVGA,74);
 bob(3,(X1-59) shl SVGA,(y1+5) shl SVGA);
 putobjWir(1,20,0,100,430,angle,0,0,x1 shl SVGA,y1 shl SVGA);
 bob(2,X1 shl SVGA-GetHx(2) div 2-SVGA*7,(y1+5) shl SVGA);

 Bar(110 shl SVGA, 82 shl SVGA,(110+(Car[1].Accel - 50)   div 2) shl SVGA, 87 shl SVGA,55);
 Bar(185 shl SVGA, 82 shl SVGA,(185+(Car[1].MaxSpd-130)   div 4) shl SVGA, 87 shl SVGA,55);
 Bar(110 shl SVGA,133 shl SVGA,(110+(Car[1].Energy-130)   div 6) shl SVGA,138 shl SVGA,55);
 Bar(185 shl SVGA,133 shl SVGA,(185+(Car[1].Mass  -  5)*5 div 6) shl SVGA,138 shl SVGA,55);
 Box(110 shl SVGA, 82 shl SVGA,(135                            ) shl SVGA, 87 shl SVGA,0);
 Box(185 shl SVGA, 82 shl SVGA,(210                            ) shl SVGA, 87 shl SVGA,0);
 Box(110 shl SVGA,133 shl SVGA,(135                            ) shl SVGA,138 shl SVGA,0);
 Box(185 shl SVGA,133 shl SVGA,(210                            ) shl SVGA,138 shl SVGA,0);

 for cnt:=0 to 4 do begin
 line((110+cnt*5) shl SVGA, 82 shl SVGA,(110+cnt*5) shl SVGA, 87 shl SVGA,0);
 line((185+cnt*5) shl SVGA, 82 shl SVGA,(185+cnt*5) shl SVGA, 87 shl SVGA,0);
 line((110+cnt*5) shl SVGA,133 shl SVGA,(110+cnt*5) shl SVGA,138 shl SVGA,0);
 line((185+cnt*5) shl SVGA,133 shl SVGA,(185+cnt*5) shl SVGA,138 shl SVGA,0);
 end;
end;

if (x1=160) and not Infos and (Keystate2(Ba1) or Keystate2(Bb1) or Keystate2(28) or Keystate2(57)) then begin
infos:=True;
repeat NextSound until not (Keystate2(Ba1) or Keystate2(Bb1) or Keystate2(28) or Keystate2(57))
end;

esc:=Keystate2(1);

repeat NextSound until time>25;
Auxi:=time;
reCd;
Timing:=10 * auxi div 25;

resettime;

if (GameMode=2) and (CurCar<4) and (CarPl1<4) then Text(50 shl SVGA,100 shl SVGA,' Team Chase Mode Activated',True);
if Not Selectable and (CurCar>3) then Text(45 shl SVGA,100 shl SVGA,'Player One is already a Bandit',True);

if DemoRel=1 then begin
if (CurCar<>1) and (CurCar<>4) then Text(70 shl SVGA,100 shl SVGA,' Not Available On Demo',True);
Selectable:=not ((CurCar<>1) and (CurCar<>4)) and Selectable;
end;
scrswap;
until (infos and Selectable and (Keystate2(Ba2) or Keystate2(Bb2) or Keystate2(28))) or Keystate2(57) or Esc;

if Esc then Exit;

CarPl2:=CurCar;
end
end;


Procedure SelGear;

var
x1,y1,Xdest     :integer;
begin
repeat NextSound until not Keystate(75) and not Keystate(77);
repeat NextSound until not Keystate(28) and not Keystate(57);
repeat NextSound until not Keystate(Ba2) and not Keystate(Bb2);
Lfbob('Pics/SelBox.pcx','Data/Selbox.Dat',1);

(********************************* SELGear1 ***********************************)
fade(4); clr(0); scrswap;
LoadLogo(MaxBobs-1);
Loadpic('Pics\selcam1.pcx',Pseg,Pofs);
Loadpal('Pics\selcam1.pcx', 20,255);
PlaceLogo;
getfbob(MaxBobs,0,0,319 shl SVGA,199 shl SVGA);
CLR(0);

Lfbob('Pics/Cambi.pcx','Data/Cambi.Dat',2);

x1:=360;
y1:=70;
Xdest:=160;
resettime;
repeat

fbob(MaxBobs,0,0);
if ((x1<-160) or (x1>380)) then begin Xdest:=160; Car[1].AutoMatic:=Not Car[1].AutoMatic end;
 if x1>Xdest+Timing then dec(x1,10*Timing div 10) else
 if x1<Xdest-Timing then inc(x1,10*Timing div 10) else
   X1:=Xdest;
   if X1=Xdest then
   if Keystate2(75) or Keystate2(77) or Keystate2(Lf1) or Keystate2(Rg1) then begin
    if Random(2)=1 then xdest:=480 else xdest:=-260;
    fbob(MaxBobs,0,0)
   end;
fbob(1,(x1-60) shl SVGA,(y1+5) shl SVGA);
if Car[1].automatic then fbob(3,(x1-45) shl SVGA,(y1+10) shl SVGA) else fbob(2,(x1-34) shl SVGA,(y1+10) shl SVGA);
if keypush>0 then empty;
repeat NextSound until time>25;
Auxi:=time;
ReCD;
Timing:=10 * auxi div 25;
resettime;
esc:=Keystate2(1);
scrswap;
until Keystate2(28) or Keystate2(57) or Keystate2(Ba1) or Keystate2(Bb1) or Esc;
if Esc then Exit;

if NumPla=2 then begin
(********************************* SELGear2 ***********************************)
fade(4); clr(0); scrswap;
LoadLogo(MaxBobs-1);
Loadpic('Pics\selcam2.pcx',Pseg,Pofs);
Loadpal('Pics\selcam2.pcx', 20,255);
PlaceLogo;
getfbob(MaxBobs,0,0,319 shl SVGA,199 shl SVGA);
CLR(0);

Lfbob('Pics/Cambi.pcx','Data/Cambi.Dat',2);

x1:=360;
y1:=70;
Xdest:=160;
resettime;
repeat

fbob(MaxBobs,0,0);
if ((x1<-160) or (x1>380)) then begin Xdest:=160; Car[2].AutoMatic:=Not Car[2].AutoMatic end;
 if x1>Xdest+Timing then dec(x1,10*Timing div 10) else
 if x1<Xdest-Timing then inc(x1,10*Timing div 10) else
  X1:=Xdest;
  if X1=Xdest then
  if Keystate2(75) or Keystate2(77) or Keystate2(Lf2) or Keystate2(Rg2) then begin
   if Random(2)=1 then xdest:=480 else xdest:=-260;
  end;

fbob(1,(x1-60) shl SVGA,(y1+5) shl SVGA);
if Car[2].automatic then fbob(3,(x1-45) shl SVGA,(y1+10) shl SVGA) else fbob(2,(x1-34) shl SVGA,(y1+10) shl SVGA);
if keypush>0 then empty;
repeat NextSound until time>25;
Auxi:=time;
ReCD;
Timing:=10 * auxi div 25;

resettime;

esc:=Keystate2(1);

scrswap;
until Keystate2(28) or Keystate2(57) or Keystate2(Ba2) or Keystate2(Bb2) or Esc;
if Esc then Exit;
end;
fade(4); clr(0); scrswap;
end;

Procedure Menu;
label MAIN,Main2,OPTIONS,HELPKEY,GAMETYPE,DETAILS,CONTROLS,CONFIGURE,CALIBRATE,GETKEY1,GETKEY2;
var
x1,y1,kx1,ky1                :integer;
x2,y2                        :integer;
x3,y3                        :integer;
x4,y4                        :integer;
x5,y5                        :integer;
MaxSelect,Select,Select1     :byte;
start,ok1,ok2,ok3,ok4,ok5    :boolean;
Dx,Dy                        :Longint;
SoundCardLoc                 :byte;

Function SelectItem(numsel,numbob,x,y:integer): boolean;
begin
SelectItem:=False;
if select=NumSel then begin
bob(NCurs,x shl SVGA-GetHx(NCurs) shr 1,y shl SVGA-GetHy(NCurs) shr 1);
VMapbobFree((x-kx1)   shl SVGA,(x+kx1)   shl SVGA,
            (y-8+ky1) shl SVGA,(y-8-ky1) shl SVGA,
            (y+8+ky1) shl SVGA,(y+8-ky1) shl SVGA,numbob);
            if Keystate2(57) or Keystate2(28) then SelectItem:=True;
end else fbob(numbob,(x-50) shl SVGA,(y-8) shl SVGA);
end;

begin
(*if SbOn then PlaySampleRam('Samples\'+RanMusic,True);*)
Main2:

Lfbob('Pics\Writed.pcx','Data\Writed.Dat',1);
Lfbob('Pics\Write2.pcx','Data\Write2.Dat',44);
 Lbob('Pics\Write2.pcx','Data\Cursore.Dat',70);
Lfbob('Pics\Acces.pcx' ,'Data\Position.dat' ,550);
Lfbob('Pics\Write2.pcx','Data\Logo.dat' ,550);

(********************************* MAIN MENU **********************************)
MAIN:
Fade(4);clr(0);scrswap;
LoadLogo(MaxBobs-1);
Loadpic('Pics\BackMen1.pcx',Pseg,Pofs);
PlaceLogo;
getfbob(MaxBobs,0,0,319 shl SVGA,199 shl SVGA);
CLR(0);
LoadPal('Pics\BackMen1.pcx',0,255);
if keypush>0 then empty;
repeat NextSound until not(Keystate(57)) and not(Keystate(28));
repeat NextSound until not(Keystate(1));
start:=false;
y1:=110;
y2:=140;
x1:= 320;
x2:=-320;
angle:=0;
resettime;
Select1:=1;
Select:=1;
MaxSelect:=2;
ok1:=False;ok2:=False;ok3:=true;ok4:=true;ok5:=true;
repeat

if x1>160+Timing then dec(x1,10*Timing div 10) else begin X1:=160; ok1:=true; end;
if x2<160-Timing then inc(x2,10*Timing div 10) else Begin X2:=160; ok2:=true; end;

 inc(angle,5*Timing div 10); if angle>360 then begin select:=select1;Dec(angle,360); end;
 select:=select1;
 Kx1:=cs[angle]*50 div 128;
 Ky1:=sn[angle]*4  div 128;

Fbob(MaxBobs,0,0);

if Selectitem(1,1,x1,y1) then Start:=True;
if Selectitem(2,2,x2,y2) then Goto OPTIONS;

if ok1 and ok2 and ok3 and ok4 and ok5 then begin
if Keystate2(72) or Keystate2(75) then dec(Select1) else
if Keystate2(80) or Keystate2(77) then inc(Select1);
if Keystate2(35) then goto HELPKEY;

if Keystate2(1) then begin
Fade(4);clr(0);scrswap;
Empty;
EraseAllbob;
EraseAllObjs;
StopAudio;
KillFont;
killSound;
KillGraph;
KillKeyb;
KillMisc;
(********* EXIT *************)
  assign(F,'password.WWW');
  rewrite(f,1);
  writefile('Exit',8,f);
  close(f);
(****************************)
TextMode(2);
halt(1);
end;

repeat NextSound until not(Keystate(75)) and not(Keystate(77));
repeat NextSound until not(Keystate(72)) and not(Keystate(80));
repeat NextSound until not(Keystate(57)) and not(Keystate(28));
end;

if Select1>Maxselect then Select1:=1 else
if Select1<1 then Select1:=MaxSelect;

RotationItem(550,275 shl SVGA,60 shl SVGA);
RotationItem(550, 45 shl SVGA,60 shl SVGA);

if keypush>0 then empty;
repeat NextSound until time>25;
Auxi:=time;
ReCD;
Timing:=10 * auxi div 25;

ResetTime;

scrswap;
until start;
fade(4);
clr(0);
scrswap;
exit;

(********************************* OPTIONS MENU **********************************)
OPTIONS:
if keypush>0 then empty;
repeat NextSound until not(Keystate(57)) and not(Keystate(28));
repeat NextSound until not(Keystate(1));
fade(4);
clr(0);scrswap;
LoadLogo(MaxBobs-1);
Loadpic('Pics\BackMen2.pcx',Pseg,Pofs);
PlaceLogo;
getfbob(MaxBobs,0,0,319 shl SVGA,199 shl SVGA);
CLR(0);
LoadPal('Pics\BackMen2.pcx',0,255);

y1:=120;
y2:=120;
y3:=150;
y4:=150;
x1:=-100;
x2:= 320;
x3:=-50;
x4:= 350;
angle:=0;
resettime;
Select1:=1;
Select:=1;
MaxSelect:=4;
ok1:=False;ok2:=False;ok3:=False;ok4:=False;
repeat

fbob(MaxBobs,0,0);
fbob(2,110 shl SVGA,70 shl SVGA);
if x1< 80 then inc(x1,10*Timing div 10) else Begin X1:=80;  ok1:=true; end;
if x2>240 then dec(x2,10*Timing div 10) else Begin X2:=240; ok2:=true; end;
if x3< 80 then inc(x3,10*Timing div 10) else Begin X3:=80;  ok3:=true; end;
if x4>240 then dec(x4,10*Timing div 10) else Begin X4:=240; ok4:=true; end;

 inc(angle,5*Timing div 10); if angle>360 then begin select:=select1;Dec(angle,360) end;
 select:=select1;
 Kx1:=cs[angle]*50 div 128;
 Ky1:=sn[angle]*4  div 128;

if Selectitem(1,4       ,x1,y1) then Goto DETAILS;
if Selectitem(3,4+NumPla,x2,y2) then if NumPla=1 then NumPla:=2 else NumPla:=1;
if Selectitem(2,7       ,x3,y3) then Goto CONTROLS;
if Selectitem(4,44      ,x4,y4) then Goto GAMETYPE;

if GameMode=3 then Begin NumPla:=1;AllCars:=True; end;

if ok1 and ok2 and ok3 and ok4 then begin
if Keystate2(72) or Keystate2(75) then dec(Select1) else
if Keystate2(80) or Keystate2(77) then inc(Select1);
if Keystate2 (1) then begin FastEraseAllBob; goto MAIN2; end;
repeat NextSound  until not(Keystate(75)) and not(Keystate(77));
repeat NextSound  until not(Keystate(72)) and not(Keystate(80));
repeat NextSound  until not(Keystate(57)) and not(Keystate(28));
end;

if Select1>Maxselect then Select1:=1 else
if Select1<1 then Select1:=MaxSelect;

if keypush>0 then empty;
repeat NextSound  until time>25;
Auxi:=time;
RECD;
Timing:=10 * auxi div 25;

ResetTime;

scrswap;
until false;

(********************************* HELPKEYS MENU **********************************)
HELPKEY:

if keypush>0 then empty;
repeat NextSound  until not(Keystate(1));
fade(4);
clr(0);scrswap;

LoadCar(1,100,Carname[WinCars[1]]);
LoadCar(2,150,Carname[WinCars[2]]);
LoadCar(3,200,Carname[WinCars[3]]);

Loadpic('Pics\WinEasy.pcx',Pseg,Pofs);
getfbob(MaxBobs,0,0,319 shl SVGA,199 shl SVGA);
CLR(0);
LoadPal('Pics\WinEasy.pcx',20,255);
resettime;
repeat
 fbob(MaxBobs,0,0);
 inc(angle,2);Angle:=angle mod 360;
 putobj(1,0,30,400,angle,0,0,200 shl SVGA, 70 shl SVGA);
 putobj(2,0,30,400,360-angle,0,0,200 shl SVGA,110 shl SVGA);
 putobj(3,0,30,400,angle,0,0,200 shl SVGA,150 shl SVGA);
 Text(270 shl SVGA, 70 shl SVGA,Winners[1],true);
 Text(270 shl SVGA,115 shl SVGA,Winners[2],true);
 Text(270 shl SVGA,160 shl SVGA,Winners[3],true);
 repeat NextSound  until time>25;
 Auxi:=time;
 RECD;
 Timing:=10 * auxi div 25;
 ResetTime;
 scrswap;
until keypush>0;
Fade(4);

FastEraseAllBob;

LoadCar(1,100,Carname[WinCars[4]]);
LoadCar(2,150,Carname[WinCars[5]]);
LoadCar(3,200,Carname[WinCars[6]]);

Loadpic('Pics\WinMedi.pcx',Pseg,Pofs);
getfbob(MaxBobs,0,0,319 shl SVGA,199 shl SVGA);
CLR(0);
LoadPal('Pics\WinEasy.pcx',20,255);
resettime;
repeat
 fbob(MaxBobs,0,0);
 inc(angle,2);Angle:=angle mod 360;
 putobj(1,0,30,400,angle,0,0,200 shl SVGA, 70 shl SVGA);
 putobj(2,0,30,400,360-angle,0,0,200 shl SVGA,115 shl SVGA);
 putobj(3,0,30,400,angle,0,0,200 shl SVGA,160 shl SVGA);
 Text(270 shl SVGA, 70 shl SVGA,Winners[4],true);
 Text(270 shl SVGA,115 shl SVGA,Winners[5],true);
 Text(270 shl SVGA,160 shl SVGA,Winners[6],true);
 repeat NextSound  until time>25;
 Auxi:=time;
 RECD;
 Timing:=10 * auxi div 25;
 ResetTime;
 scrswap;
until keypush>0;
Fade(4);

FastEraseAllBob;

LoadCar(1,100,Carname[WinCars[7]]);
LoadCar(2,150,Carname[WinCars[8]]);
LoadCar(3,200,Carname[WinCars[9]]);

Loadpic('Pics\WinHard.pcx',Pseg,Pofs);
getfbob(MaxBobs,0,0,319 shl SVGA,199 shl SVGA);
CLR(0);
LoadPal('Pics\WinHard.pcx',20,255);
resettime;
repeat
 fbob(MaxBobs,0,0);
 inc(angle,2);Angle:=angle mod 360;
 putobj(1,0,30,400,angle,0,0,200 shl SVGA, 70 shl SVGA);
 putobj(2,0,30,400,360-angle,0,0,200 shl SVGA,115 shl SVGA);
 putobj(3,0,30,400,angle,0,0,200 shl SVGA,160 shl SVGA);
 Text(270 shl SVGA, 70 shl SVGA,Winners[7],true);
 Text(270 shl SVGA,115 shl SVGA,Winners[8],true);
 Text(270 shl SVGA,160 shl SVGA,Winners[9],true);
 repeat NextSound  until time>25;
 Auxi:=time;
 RECD;
 Timing:=10 * auxi div 25;
 ResetTime;
 scrswap;
until keypush>0;
fade(4);

FastEraseAllBob;

goto main2;

(********************************* DETAILS MENU **********************************)
DETAILS:
if keypush>0 then empty;
repeat NextSound until not(Keystate(57)) and not(Keystate(28));
repeat NextSound until not(Keystate(1));

y1:=120;
y2:=150;
y3:=150;
y4:=150;
x1:=-100;
x2:= 320;
x3:=-50;
x4:= 350;
angle:=0;
resettime;
Select1:=1;
Select:=1;
MaxSelect:=2;
ok1:=False;ok2:=False;ok3:=true;ok4:=true;ok5:=true;
if Detail>1 then Detail:=1;
repeat

fbob(MaxBobs,0,0);
fbob(4,110 shl SVGA,70 shl SVGA);
if x1<160  then inc(x1,10*Timing div 10) else Begin x1:=160; ok1:=true; end;
if x2>160  then dec(x2,10*Timing div 10) else Begin x2:=160; ok2:=true; end;

 inc(angle,5*Timing div 10); if angle>360 then begin select:=select1;Dec(angle,360) end;
 select:=select1;

 Kx1:=cs[angle]*50 div 128;
 Ky1:=sn[angle]*4  div 128;

if Selectitem(1,41-Detail       ,x1,y1) then Detail:=1-Detail;

if Maxdistance=20 then x3:=43 else x3:=42;

if Selectitem(2,x3              ,x2,y2) then if MaxDistance=25 then Maxdistance:=20 else Maxdistance:=25;

if ok1 and ok2 and ok3 and ok4 and ok5 then begin
if Keystate2(72) or Keystate2(75) then dec(Select1) else
if Keystate2(80) or Keystate2(77) then inc(Select1);
if Keystate2 (1) then goto OPTIONS;
repeat NextSound  until not(Keystate(75)) and not(Keystate(77));
repeat NextSound  until not(Keystate(72)) and not(Keystate(80));
repeat NextSound  until not(Keystate(57)) and not(Keystate(28));
end;

if Select1>Maxselect then Select1:=1 else
if Select1<1 then Select1:=MaxSelect;

if Keystate2 (1) then goto OPTIONS;

repeat NextSound  until not(Keystate(57)) and not(Keystate(28));

if keypush>0 then empty;
repeat NextSound  until time>25;
Auxi:=time;
ReCD;
Timing:=10 * auxi div 25;

ResetTime;

scrswap;
until false;

(********************************* CONTROLS MENU **********************************)
CONTROLS:
if keypush>0 then empty;
repeat NextSound  until not(Keystate(57)) and not(Keystate(28));
repeat NextSound  until not(Keystate(1));
y1:=120;
y2:=120;
y3:=150;
y4:=150;
x1:=-100;
x2:= 320;
x3:=-50;
x4:= 350;
angle:=0;
resettime;
Select1:=1;
Select:=1;
MaxSelect:=3;
ok1:=False;ok2:=False;ok3:=False;ok4:=true;ok5:=true;
AutoOff;
repeat

fbob(MaxBobs,0,0);
fbob(7,110 shl SVGA,70 shl SVGA);
if x1< 80 then inc(x1,10*Timing div 10) else Begin X1:= 80; ok1:=true; end;
if x2>240 then dec(x2,10*Timing div 10) else Begin X2:=240; ok2:=true; end;
if x3<160 then inc(x3,10*Timing div 10) else Begin X3:=160; ok3:=true; end;

 inc(angle,5*Timing div 10); if angle>360 then begin select:=select1;Dec(angle,360) end;
 select:=select1;
 Kx1:=cs[angle]*50 div 128;
 Ky1:=sn[angle]*4  div 128;

if Selectitem(1, 8+TypeCon1,x1,y1) then begin inc(Typecon1); if Typecon1>1 then Typecon1:=0; end;
if Selectitem(2,10+TypeCon2,x2,y2) then begin inc(Typecon2); if Typecon2>1 then Typecon2:=0; end;
if Selectitem(3,12         ,x3,y3) then Goto CONFIGURE;

if ok1 and ok2 and ok3 and ok4 and ok5 then begin
if Keystate2(72)or Keystate2(75) then dec(Select1) else
if Keystate2(80)or Keystate2(77) then inc(Select1);
if Keystate2 (1) then goto OPTIONS;
repeat NextSound  until not(Keystate(75)) and not(Keystate(77));
repeat NextSound  until not(Keystate(72)) and not(Keystate(80));
repeat NextSound  until not(Keystate(57)) and not(Keystate(28));
end;

if Select1>Maxselect then Select1:=1 else
if Select1<1 then Select1:=MaxSelect;

if keypush>0 then empty;
repeat NextSound  until time>25;
Auxi:=time;
ReCD;
Timing:=10 * auxi div 25;

ResetTime;

scrswap;
until false;

(********************************* CONFIGURE MENU **********************************)
CONFIGURE:
if keypush>0 then empty;
repeat NextSound  until not(Keystate(57)) and not(Keystate(28));
repeat NextSound  until not(Keystate(1));
JoyOn1:=CheckJoy1;
y1:=120;
y2:=120;
y3:=150;
y4:=150;
x1:=-100;
x2:= 320;
x3:=-50;
x4:= 350;
angle:=0;
resettime;
Select1:=1;
Select:=1;
MaxSelect:=3;
ok1:=False;ok2:=False;ok3:=False;ok4:=true;ok5:=true;
repeat

fbob(MaxBobs,0,0);
fbob(12,110 shl SVGA,70 shl SVGA);
if x1< 80 then inc(x1,10*Timing div 10) else Begin X1:= 80; ok1:=true; end;
if x2>240 then dec(x2,10*Timing div 10) else Begin X2:=240; ok2:=true; end;
if x3<160 then inc(x3,10*Timing div 10) else Begin X3:=160; ok3:=true; end;

 inc(angle,5*Timing div 10); if angle>360 then begin select:=select1;Dec(angle,360) end;
 select:=select1;
 Kx1:=cs[angle]*50 div 128;
 Ky1:=sn[angle]*4  div 128;

if Selectitem(1,13,x1,y1) then Goto GETKEY1;
if Selectitem(2,14,x2,y2) then Goto GETKEY2;
if Selectitem(3,15,x3,y3) then if JoyOn1 then Goto CALIBRATE;
if not joyOn1 and (select=3) then Fbob(24,210 shl SVGA,180 shl SVGA);

if ok1 and ok2 and ok3 and ok4 and ok5 then begin
if Keystate2(72)or Keystate2(75) then dec(Select1) else
if Keystate2(80)or Keystate2(77) then inc(Select1);
if Keystate2 (1) then goto CONTROLS;
repeat NextSound  until not(Keystate(75)) and not(Keystate(77));
repeat NextSound  until not(Keystate(72)) and not(Keystate(80));
repeat NextSound  until not(Keystate(57)) and not(Keystate(28));
end;

if Select1>Maxselect then Select1:=1 else
if Select1<1 then Select1:=MaxSelect;

if keypush>0 then empty;
repeat NextSound  until time>25;
Auxi:=time;
ReCd;
Timing:=10 * auxi div 25;

ResetTime;

scrswap;
until false;

(********************************* GETKEY1 MENU **********************************)
GETKEY1:
if keypush>0 then empty;
repeat NextSound  until not(Keystate(57)) and not(Keystate(28));
repeat NextSound  until not(Keystate(1));
y1:=120;
y2:=120;
y3:=150;
y4:=150;
x1:=-100;
x2:= 320;
x3:=-50;
x4:= 350;
angle:=0;
resettime;
Select1:=1;
Select:=1;
MaxSelect:=6;
ok1:=False;ok2:=true;ok3:=true;ok4:=true;ok5:=true;
repeat

fbob(MaxBobs,0,0);
fbob(13,110 shl SVGA,70 shl SVGA);
if x1<160-Timing then inc(x1,10*Timing div 10) else
if x1>160+Timing then dec(x1,10*Timing div 10) else Begin X1:=160; ok1:=true; end;
Fbob(Select+15,(x1-50) shl SVGA,y1 shl SVGA);
if keypush>0 then empty;

if (keypush>0) and (Select=1) then begin inc(Select);x1:=-100; Up1:=KeyPush; KeyClear end else
if (keypush>0) and (Select=2) then begin inc(Select);x1:= 320; Dw1:=KeyPush; KeyClear end else
if (keypush>0) and (Select=3) then begin inc(Select);x1:=-150; Lf1:=KeyPush; KeyClear end else
if (keypush>0) and (Select=4) then begin inc(Select);x1:=-350; Rg1:=KeyPush; KeyClear end else
if (keypush>0) and (Select=5) then begin inc(Select);x1:=-150; Ba1:=KeyPush; KeyClear end else
if (keypush>0) and (Select=6) then begin inc(Select);x1:=-350; Bb1:=KeyPush; KeyClear end;

if (Select=7) or Keystate2(1) then goto CONFIGURE;

repeat NextSound  until time>25;
Auxi:=time;
ReCd;
Timing:=10 * auxi div 25;

ResetTime;

scrswap;
until false;

(********************************* GETKEY2 MENU **********************************)
GETKEY2:
if keypush>0 then empty;
repeat NextSound  until not(Keystate(57)) and not(Keystate(28));
repeat NextSound until not(Keystate(1));
y1:=120;
y2:=120;
y3:=150;
y4:=150;
x1:=-100;
x2:= 320;
x3:=-50;
x4:= 350;
angle:=0;
resettime;
Select1:=1;
Select:=1;
MaxSelect:=6;
ok1:=False;ok2:=true;ok3:=true;ok4:=true;ok5:=true;
repeat

fbob(Maxbobs,0,0);
fbob(14,110 shl SVGA,70 shl SVGA);
if x1<160-Timing then inc(x1,10*Timing div 10) else
if x1>160+Timing then dec(x1,10*Timing div 10) else Begin X1:=160; ok1:=true; end;
Fbob(Select+15,(x1-50) shl SVGA,y1 shl SVGA);
if keypush>0 then empty;
if (keypush>0) and (Select=1) then begin inc(Select);x1:=-100; Up2:=KeyPush; KeyClear end else
if (keypush>0) and (Select=2) then begin inc(Select);x1:= 320; Dw2:=KeyPush; KeyClear end else
if (keypush>0) and (Select=3) then begin inc(Select);x1:=-150; Lf2:=KeyPush; KeyClear end else
if (keypush>0) and (Select=4) then begin inc(Select);x1:=-350; Rg2:=KeyPush; KeyClear end else
if (keypush>0) and (Select=5) then begin inc(Select);x1:=-150; Ba2:=KeyPush; KeyClear end else
if (keypush>0) and (Select=6) then begin inc(Select);x1:=-350; Bb2:=KeyPush; KeyClear end;
if (Select=7) or Keystate2(1) then goto CONFIGURE;

repeat NextSound  until time>25;
Auxi:=time;
ReCD;
Timing :=10 * auxi div 25;

ResetTime;

scrswap;
until false;

(********************************* CALIBRATE MENU **********************************)
CALIBRATE:
GetCenter1;
if keypush>0 then empty;
repeat NextSound until not(Keystate(57)) and not(Keystate(28));
repeat NextSound until not(Keystate(1));
y1:=140;
y2:=120;
y3:=150;
y4:=150;
x1:= 160;
x2:= 100;
x3:=-50;
x4:= 350;
angle:=0;
resettime;
Select1:=1;
Select:=1;
MaxSelect:=1;
MaxX1:=-10000;
MinX1:= 10000;
MaxY1:=-10000;
MinY1:= 10000;
Dx:=0;
Dy:=0;
repeat

resettime;
JoyX1;
repeat NextSound  until time>25;

fbob(MaxBobs,0,0);
Fbob(15,110 shl SVGA,70 shl SVGA);

if x2>10 then dec(x2,5);

Frbob(22,(x1-160 div x2) shl SVGA,(y1-160 div x2) shl SVGA,
         (x1+150 div x2) shl SVGA,(y1+150 div x2) shl SVGA,0);

line((x1    +15  div x2) shl SVGA,(y1    +20  div x2) shl SVGA,
     (x1+(Dx+15) div x2) shl SVGA,(y1+(Dy+20) div x2) shl SVGA,28);

line((x1+ 5 div x2) shl SVGA,(y1+20 div x2) shl SVGA,(x1+(Dx+ 5) div x2) shl SVGA,(y1+(Dy+20) div x2) shl SVGA,26);
line((x1+15 div x2) shl SVGA,(y1+10 div x2) shl SVGA,(x1+(Dx+15) div x2) shl SVGA,(y1+(Dy+10) div x2) shl SVGA,28);
line((x1+25 div x2) shl SVGA,(y1+20 div x2) shl SVGA,(x1+(Dx+25) div x2) shl SVGA,(y1+(Dy+20) div x2) shl SVGA,30);
line((x1+15 div x2) shl SVGA,(y1+30 div x2) shl SVGA,(x1+(Dx+15) div x2) shl SVGA,(y1+(Dy+30) div x2) shl SVGA,32);

Frbob(23,(x1+(Dx-15) div x2) shl SVGA,(y1+(Dy-15) div x2) shl SVGA,
         (x1+(45+Dx) div x2) shl SVGA,(y1+(45+Dy) div x2) shl SVGA,0);

if Xvalue1>MaxX1 then MaxX1:=Xvalue1;
if Xvalue1<MinX1 then MinX1:=Xvalue1;
if Yvalue1>MaxY1 then MaxY1:=Yvalue1;
if Yvalue1<MinY1 then MinY1:=Yvalue1;

if (Xvalue1>0) and (MaxX1>3) then Dx:=Longint( Xvalue1)*30 div (MaxX1 div 3+1) ;
if (Xvalue1<0) and (MinX1<3) then Dx:=Longint(-Xvalue1)*30 div (MinX1 div 3-1) ;
if (Yvalue1>0) and (MaxY1>3) then Dy:=Longint( Yvalue1)*30 div (MaxY1 div 3+1) ;
if (Yvalue1<0) and (MinY1<3) then Dy:=Longint(-Yvalue1)*30 div (MinY1 div 3-1) ;

if Keystate2(1) or Joy11 or Joy12 then begin
 XPosTol1:=MaxX1 div 5;
 XNegTol1:=MinX1 div 5;
 YPosTol1:=MaxY1 div 5;
 YNegTol1:=MinY1 div 5;
 MaxX1:=MaxX1 div 10;
 MinX1:=MinX1 div 10;
 MaxY1:=MaxY1 div 10;
 MinY1:=MinY1 div 10;
 goto CONFIGURE;
end;

if keypush>0 then empty;

resettime;
JoyY1;
repeat NextSound  until time>25;
Auxi:=time;
ReCd;

Timing:=10 * auxi div 25;
ResetTime;

scrswap;
until false;

(********************************* GAMETYPE MENU **********************************)
GAMETYPE:
if keypush>0 then empty;
repeat NextSound  until not(Keystate(57)) and not(Keystate(28));
repeat NextSound  until not(Keystate(1));
y1:=120;
y2:=120;
y3:=150;
y4:=150;
x1:=-100;
x2:= 320;
x3:=-50;
x4:= 350;
angle:=0;
resettime;
Select1:=1;
Select:=1;
MaxSelect:=3;
ok1:=False;ok2:=False;ok3:=False;ok4:=true;ok5:=true;
repeat
fbob(MaxBobs,0,0);
fbob(44,110 shl SVGA,70 shl SVGA);
if x1< 80 then inc(x1,10*Timing div 10) else Begin X1:= 80; ok1:=true; end;
if x2>240 then dec(x2,10*Timing div 10) else Begin X2:=240; ok2:=true; end;
if x3<160 then inc(x3,10*Timing div 10) else Begin X3:=160; ok3:=true; end;

 inc(angle,5*Timing div 10); if angle>360 then begin select:=select1;Dec(angle,360) end;
 select:=select1;
 Kx1:=cs[angle]*50 div 128;
 Ky1:=sn[angle]*4  div 128;

if Selectitem(1,46-ord(AllCars),x1,y1) then AllCars:=Not(AllCars);
if Selectitem(2,47+GameMode    ,x2,y2) then begin inc(GameMode);if GameMode>3 then GameMode:=0; end;
if Selectitem(3,50+Difficulty  ,x3,y3) then inc(Difficulty);
if Difficulty>3 then Difficulty:=1;

If GameMode=3 then Begin AllCars:=True; NumPla:=1;Difficulty:=1; end;

if ok1 and ok2 and ok3 and ok4 and ok5 then begin
if Keystate2(72)or Keystate2(75) then dec(Select1) else
if Keystate2(80)or Keystate2(77) then inc(Select1);
if Keystate2 (1) then goto OPTIONS;
repeat NextSound  until not(Keystate(75)) and not(Keystate(77));
repeat NextSound  until not(Keystate(72)) and not(Keystate(80));
repeat NextSound  until not(Keystate(57)) and not(Keystate(28));
end;

if Select1>Maxselect then Select1:=1 else
if Select1<1 then Select1:=MaxSelect;

if keypush>0 then empty;
repeat NextSound  until time>25;
Auxi:=time;
ReCD;
Timing:=10 * auxi div 25;

ResetTime;

scrswap;
until false;
end;

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

For cnt:=1 to 8 do Ids[cnt]:='CPU';

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

InitNet;

Initgraph(3000);
Clipgraph(0,0,319 shl SVGA,199 shl SVGA);

Attribs[0]:='Min';
Attribs[1]:='Med';
Attribs[2]:='Max';

Initkeyb;
InitMisc;
InitPros;
initfont;
Loadfont('Pics\Font.pcx');

LoadConfig;
LoadWinner;

initsound(512);
SoundOn:=Sbon;
Loadsample(1 ,'Samples\CDClick.Raw');


RESELECT:
FastEraseAllBob;

(*ResVirBuf(1024);*)

Menu;

SelCar;

if Esc then goto RESELECT;

SelGear;

if Esc then goto RESELECT;

if GameMode<>3 then MySlot:=1;
SaveConfig;
SaveStatus;
for Cnt:=1 to 8 do Car[cnt].Points:=0;
Safe:=0;
SaveSlot;
SaveRace;
FadeAudio(100);
StopAudio;
Cround:=0;
EraseAllBob;
EraseAllObjs;
(********* EXIT *************)
  assign(F,'password.WWW');
  rewrite(f,1);
  writefile('Round',8,f);
  close(f);
(****************************)
killSound;
Killfont;
KillGraph;
KillNet;
KillKeyb;
KillMisc;
end.