program CCCGCCTGTATGGCCAAT;

uses
  OpenGL
  ,eXgine
  ,Windows
  ,Graphics
  ,Classes
  ,_scd
  ,_var
  ,_load
  ,_render
  ,_update
  ,SysUtils
;


//----------------------------------------------------------------------------------------------------------------------------------------------------

procedure Update; //
begin

  input.Up:=(GetAsyncKeyState(VK_Up) and $8000)=$8000;
  input.Right:=(GetAsyncKeyState(VK_Right) and $8000)=$8000;
  input.Down:=(GetAsyncKeyState(VK_Down) and $8000)=$8000;
  input.Left:=(GetAsyncKeyState(VK_LEFT) and $8000)=$8000;
//  input.B1:=(GetAsyncKeyState(VK_Space) and $8000)=$8000;
//  input.B2:=(GetAsyncKeyState(VK_SHIFT) and $8000)=$8000;
//  input.PAUSE:=(GetAsyncKeyState(VK_PAUSE) and $8000)=$8000;
//  input.Ent:=(GetAsyncKeyState(VK_RETURN) and $8000)=$8000;
  input.ESC:=(GetAsyncKeyState(VK_ESCAPE) and $8000)=$8000;

  if input.Esc then ex.Quit;
  if (GetAsyncKeyState(VK_Up) and $8000)=$8000 then
    begin
      input.delay_u:=300;
      input._Up:=true;
      input.delay_r:=1;
      input.delay_l:=1;
      input.delay_d:=1;
    end;

  if (GetAsyncKeyState(VK_Right) and $8000)=$8000 then
    begin
      input.delay_r:=300;
      input._Right:=true;
      input.delay_u:=1;
      input.delay_l:=1;
      input.delay_d:=1;
    end;

  if (GetAsyncKeyState(VK_Down) and $8000)=$8000 then
    begin
      input.delay_d:=300;
      input._Down:=true;
      input.delay_r:=1;
      input.delay_l:=1;
      input.delay_u:=1;
    end;

  if (GetAsyncKeyState(VK_LEFT) and $8000)=$8000 then
      begin
      input.delay_l:=300;
      input._Left:=true;
      input.delay_r:=1;
      input.delay_u:=1;
      input.delay_d:=1;
    end;


  if input.delay_u>0 then dec (input.delay_u);
  if input.delay_r>0 then dec (input.delay_r);
  if input.delay_l>0 then dec (input.delay_l);
  if input.delay_d>0 then dec (input.delay_d);

  if input.delay_u=0 then input._Up:=false;
  if input.delay_r=0 then input._Right:=false;
  if input.delay_l=0 then input._Left:=false;
  if input.delay_d=0 then input._Down:=false;

input.Up:=input._Up;
input.Right:=input._right;
input.Left:=input._left;
input.Down:=input._down;

{  if input.B2 and (ex.GetTime-shdelay>300) then
    begin
      ogl.ScreenShot(pchar('shot'+inttostr(sh)+'.bmp'));
      inc(sh);
      shdelay:=ex.GetTime;
    end;
}
  case GameState of
    gsMenu:   update_menu;
    gsGame:   update_game;
  end;

end;

//----------------------------------------------------------------------------------------------------------------------------------------------------

procedure Render;
//var a,b,c:byte;
begin
  ogl.Clear(True, True);
  tex.Disable;
  case GameState of
    gsMenu:   render_menu;
    gsGame:   render_game;
  end;

end;

//----------------------------------------------------------------------------------------------------------------------------------------------------

begin
  //ex.log.Free;
  wnd.Create('CCC GCC TGT-ATG GCC AAT');
//  RandSeed:=1;
//  randomize;

  ms:=tmemorystream.Create;
  tsl:=tstringlist.Create;
//  tech_replica.e:=tstringlist.Create;

  eX.SetProc(PROC_UPDATE, @Update);
  eX.SetProc(PROC_RENDER, @Render);

  fnt8:=ogl.Font.Create(PChar('Arial'),8);
  fnt10:=ogl.Font.Create(PChar('Arial'),10);
  fnt12:=ogl.Font.Create(PChar('Courier New'),12,false);
  fnt16:=ogl.Font.Create(PChar('Arial'),16,false);
  fntL:=ogl.Font.Create(PChar('Arial'),20);

  ogl.VSync(true);
//  ogl.AntiAliasing(0);

  wnd.Mode(false, 1024, 768, 32, 85);
  ogl.Set2D(0, 0, 1024, 768);
  LoadData;

//  assignfile(f,'cr.hsc');
//  reset(f);
//  read(f,player.hiscore);
//  close(f);

  GameState:=gsMenu;

  player.lvl:=-1;
  loadlevel(player.lvl);
  snd.Play(sn[s_amb],0,0,0,true);
  eX.MainLoop(FRate);

end.

//----------------------------------------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------------------------------------

