/*
===================
=
= ShutDown
=
===================
*/

void ShutDown( void )
{
   if(option[4])
   {
       sendlogoff();
       uninitmultiplayers();
   }

   CONTROL_Shutdown();
   KB_Shutdown();
   SoundShutdown();
   MusicShutdown();
   uninittimer();
   uninitengine();
   uninitgroupfile();
   CONFIG_WriteSetup();
}


void SetupGameButtons( void )
   {
   CONTROL_DefineFlag(gamefunc_Move_Forward,      false );
   CONTROL_DefineFlag(gamefunc_Move_Backward,     false );
   CONTROL_DefineFlag(gamefunc_Turn_Left,         false );
   CONTROL_DefineFlag(gamefunc_Turn_Right,        false );
   CONTROL_DefineFlag(gamefunc_Strafe,            false );
   CONTROL_DefineFlag(gamefunc_Strafe_Left,       false );
   CONTROL_DefineFlag(gamefunc_Strafe_Right,      false );
   CONTROL_DefineFlag(gamefunc_TurnAround,        false );
   CONTROL_DefineFlag(gamefunc_Jump,              false );
   CONTROL_DefineFlag(gamefunc_Crouch,            false );
   CONTROL_DefineFlag(gamefunc_Fire,              false );
   CONTROL_DefineFlag(gamefunc_Open,              false );
   CONTROL_DefineFlag(gamefunc_Look_Up,           false );
   CONTROL_DefineFlag(gamefunc_Look_Down,         false );
   CONTROL_DefineFlag(gamefunc_Aim_Up,            false );
   CONTROL_DefineFlag(gamefunc_Aim_Down,          false );
   CONTROL_DefineFlag(gamefunc_Run,               false );
   CONTROL_DefineFlag(gamefunc_SendMessage,       false );
   CONTROL_DefineFlag(gamefunc_Weapon_1,          false );
   CONTROL_DefineFlag(gamefunc_Weapon_2,          false );
   CONTROL_DefineFlag(gamefunc_Weapon_3,          false );
   CONTROL_DefineFlag(gamefunc_Weapon_4,          false );
   CONTROL_DefineFlag(gamefunc_Weapon_5,          false );
   CONTROL_DefineFlag(gamefunc_Weapon_6,          false );
   CONTROL_DefineFlag(gamefunc_Weapon_7,          false );
   CONTROL_DefineFlag(gamefunc_Weapon_8,          false );
   CONTROL_DefineFlag(gamefunc_Weapon_9,          false );
   CONTROL_DefineFlag(gamefunc_Weapon_10,         false );
   CONTROL_DefineFlag(gamefunc_Pause,             false );
   CONTROL_DefineFlag(gamefunc_Map,               false );
   CONTROL_DefineFlag(gamefunc_Look_Left,         false );
   CONTROL_DefineFlag(gamefunc_Look_Right,        false );
   CONTROL_DefineFlag(gamefunc_Gamma_Correction,  false );
   CONTROL_DefineFlag(gamefunc_Escape,            false );
   CONTROL_DefineFlag(gamefunc_Shrink_Screen,     false );
   CONTROL_DefineFlag(gamefunc_Enlarge_Screen,    false );
   CONTROL_DefineFlag(gamefunc_ScreenPeek,        false );
   CONTROL_DefineFlag(gamefunc_Transparent_Mode,  false );
   CONTROL_DefineFlag(gamefunc_AutoRun,           false );
   CONTROL_DefineFlag(gamefunc_Virtual_Mode,      false );
   CONTROL_DefineFlag(gamefunc_Center_View,       false );
   CONTROL_DefineFlag(gamefunc_Holster_Weapon,    false );
   CONTROL_DefineFlag(gamefunc_Inventory_Left,    false );
   CONTROL_DefineFlag(gamefunc_Inventory_Right,   false );
   CONTROL_DefineFlag(gamefunc_Holo_Duke,         false );
   CONTROL_DefineFlag(gamefunc_Jetpack,           false );
   CONTROL_DefineFlag(gamefunc_Powerup_Toggle,    false );
   CONTROL_DefineFlag(gamefunc_Inventory,         false );
   CONTROL_DefineFlag(gamefunc_Remote_Ridicule_1, false );
   CONTROL_DefineFlag(gamefunc_Remote_Ridicule_2, false );
   CONTROL_DefineFlag(gamefunc_Remote_Ridicule_3, false );
   CONTROL_DefineFlag(gamefunc_Remote_Ridicule_4, false );
   CONTROL_DefineFlag(gamefunc_Remote_Ridicule_5, false );
   CONTROL_DefineFlag(gamefunc_Remote_Ridicule_6, false );
   CONTROL_DefineFlag(gamefunc_Remote_Ridicule_7, false );
   CONTROL_DefineFlag(gamefunc_Remote_Ridicule_8, false );
   CONTROL_DefineFlag(gamefunc_Remote_Ridicule_9, false );
   CONTROL_DefineFlag(gamefunc_Remote_Ridicule_10,false );
   }

/*
===================
=
= GetTime
=
===================
*/

long GetTime(void)
   {
   return totalclock;
   }

/*
===================
=
= Startup
=
===================
*/

void Startup(void)
   {
   long fil;

   if ((fil = kopen4load("setup.dat",loadfromgrouponly)) != -1)
      {
      kread(fil,&option[0],NUMOPTIONS);
      kclose(fil);
      }

   KB_Startup();
   CONFIG_GetSetupFilename();
   CONFIG_ReadSetup();
   CONTROL_Startup( ControllerType, &GetTime, TICRATE );
   SetupGameButtons();
   MusicStartup();
   SoundStartup();
   initengine(ScreenMode,ScreenWidth,ScreenHeight);
   inittimer();
   }

