#include "maps\header.ini"

int i;
int time;
string demomap;

main()
{
//  iff(1) { Effect(eff_none);return; }
//  iff(old_n_map!=27) { StopMusic();PlayAVI("avi\\sunmoon.avi");return; }
  iff(1)
  {
    demomap="";
//    PrintText(0,0,"Beta version 2.1        Copyright (c) Gromada, 1998,1999",V_FONT);
    ScrollLock(1);
    MenuCreate(136,0,320,240);
    n_map=1;win=0;map=0;time=GetTime();
    if(count=FOpen("fw.ini"))
    {
      opt_resolution=FRead(count);opt_detail=FRead(count);
      opt_sound=FRead(count);opt_music=FRead(count);
      opt_scrolling=FRead(count);
      FClose(count);
    } else { opt_detail=1;opt_resolution=0;opt_sound=50;opt_music=50; }
    if(opt_resolution) { centr_x=400;centr_y=300; }
    else { centr_x=320;centr_y=240; }
    SetGraphDetail(opt_detail);SetAutoScroll(opt_scrolling);
    SetSound(opt_sound);SetMusic(opt_music);
  }
  if(GetKey()==' ' || GetKey()==13 || MenuVid())
    NextMap("maps\\player.map",eff_fade);//play
  else if(GetKey()==27 || (GetInputState()&INPUT_RCLICK))
    NextMap("maps\\credits.map",eff_fade);
  if(nextmap!="")
    if((GetTime()-startnextmap)>700)
    {
      if(nextmap!="exit")
      {
        iff(old_n_map!=27 && demomap=="") { StopMusic();PlayAVI("avi\\sunmoon.avi");return; }
        PlaySFX(19);
        if(demomap=="") SetGraphMode(opt_resolution+1);
        Load(nextmap);
      } else Exit();
      return;
    } else;
  else if((GetTime()-time)>30000)
  {
    demomap="maps\\demo1.dem";demomap[9]='1'+Random(2);
    NextMap(demomap);
  }
}
