Exemplo n.º 1
0
int main(int argc, char* argv[])
{ 
   int      i=1;
   double   last_ts = 0.0, ts;
   char     lmsg[24];

   srandom (getpid());
   init_communication (LPNAME);
	
   while (!end_reached) {
      queue = receive_event ();
      if (queue != NULL) {
         msg = (MsgHeaderIPC *)g_queue_pop_head (queue);
         clock = msg->time_stamp;
         if (clock >= end_clock) {
             printf ("[%s]: -- end condition reached, clock=%.2f --\n", LPNAME, clock);
             end_reached = TRUE;
         } else {
            printf ("[%s]: Received from %s, '%.2f %s'\n", 
                      LPNAME, msg->target, msg->time_stamp, msg->msg);
            ts = clock + 0.7 + rnd(0,2);
            schedule_extern_event (ts, NEIGHBOUR1, msg->msg);
            printf ("[%s]:   Scheduled '%.2f %s' for %s\n", LPNAME, ts, msg->msg, NEIGHBOUR1);
         }
         g_queue_free (queue);
      }
      sim_V ();
   }
   
   close_communication ();
}
Exemplo n.º 2
0
int main(int argc, char* argv[])
{ 
   srandom (getpid());
   init_communication (LPNAME);
   runwayfree = TRUE;
   on_the_ground = 1;
   in_the_air = 0;
	
   sim_P ();
   schedule_local_event (clock+rnd(0,5), create_submsg ("DEP", ""));
   sim_V ();
	
   while (!end_reached) {
       queue = receive_event ();
       if (queue != NULL) {
          msg = (MsgHeaderIPC *)g_queue_pop_head (queue);
          submsg = (SubMsgHeader *)msg->msg;
          clock = msg->time_stamp;

          if (clock <= end_clock) { 
             if (strcmp (submsg->event_type, "ARR")==0)  arrival_event_handler ();
             if (strcmp (submsg->event_type, "LAN")==0)  landed_event_handler ();
             if (strcmp (submsg->event_type, "DEP")==0)  departure_event_handler ();
          } else {
             printf ("[%s]: -- Stop condition reached, clock=%.2f\n", LPNAME, clock);
             end_reached = TRUE;
          }
          g_queue_free (queue);
       }
       sim_V ();
   }
	
   close_communication ();
}
Exemplo n.º 3
0
int main(int argc, char *argv[])
{
    int redemarrage = atoi(argv[7]);
    int position = atoi(argv[6]);
    GUI_ARINC_partition("Partition1", position, redemarrage);

    int nbarg = argc;
    char **argument = new char*[argc];
    int i = 0;
    for (i = 0; i <= nbarg; i++) {
        argument[i] = argv[i];
    }
    COMMUNICATION_VECTOR myCvector;
    myCvector = init_communication(argument, NULL);
        
        std::string name = argv[0];
        int portID;
        int sock;
        vector_get(&(myCvector.vqueuing_port), 0, &portID);
        std::cout << "QueingPort : " << portID << std::endl;
        vector_get(&(myCvector.vqueuing_socket), 0, &sock);
        std::cout << "Queuing socket : " << sock << std::endl;
        std::string emetteur = myCvector.emetteur;
        
        std::string commande = "java TestJNI " + name + " " + convertInt(portID) + " " + convertInt(sock) + " " + emetteur;
        system(commande.c_str());
    
}
Exemplo n.º 4
0
int main(int argc, char *argv[]) {

    int redemarrage = atoi(argv[7]);
    int position = atoi(argv[6]);
    GUI_ARINC_partition("Partition3", position, redemarrage);
    if (argc > 1) // if there is any communication, the configuration will be given in argument
    {
        int nbarg = argc;
        char **argument = new char*[argc];
        int i = 0;
        for (i = 0; i <= nbarg; i++) {
            argument[i] = argv[i];
        }
        COMMUNICATION_VECTOR myCvector;
        myCvector = init_communication(argument, NULL);
    }

    int t = 0;
    while (1) {
        std::cout << "je bosse :" << std::endl;
        for (t = 1; t < 100; t++) {
            std::cout << "time = " << t << std::endl;
            sleep(1);
        }

    }

}
Exemplo n.º 5
0
Arquivo: main.c Projeto: mabm/Rush-js
int		main(int ac, char **argv)
{
  if (ac == 3)
    init_communication(argv[1], atoi(argv[2]));
  else
    printf("Usage : %s <IP_addr> <Port>\n", argv[0]);
  return (EXIT_SUCCESS);
}
Exemplo n.º 6
0
int main(int argc, char *argv[]) {
    int redemarrage = atoi(argv[7]);
    int position = atoi(argv[6]);
    GUI_ARINC_partition("Partition2", position, redemarrage);
    int nbarg = argc;
    char **argument = new char*[argc];
    int i = 0;
    for (i = 0; i <= nbarg; i++) {
        argument[i] = argv[i];
    }
    COMMUNICATION_VECTOR myCvector;
    myCvector = init_communication(argument, NULL);
    Type_Message rMessage;
    int portID;
    int sock;
    vector_get(&(myCvector.vqueuing_port), 0, &portID);
    std::cout << "QueingPort : " << portID << std::endl;
    vector_get(&(myCvector.vqueuing_socket), 0, &sock);
    std::cout << "Queuing socket : " << sock << std::endl;
    //    CQueuing Qservice;

    int ifmessage = 0;
    int cptMessage = 0;
    for (ifmessage=0; ifmessage < 10 ; ifmessage++){
            char sMessage[256];
            std::cout << "Sending queuing message numero " << ifmessage << std::endl;
            sprintf(sMessage, "Message envoye depuis f2 numero %d", ifmessage);
            SEND_QUEUING_MESSAGE(argv[0], portID, sock, myCvector.emetteur, sMessage);
    }
    for (;;) {
       // std::cout << "debur boucle for, vqueuing_socket[0] : " << sock << std::endl;
        ifmessage = RECEIVE_QUEUING_MESSAGE(sock, &rMessage);
        if (ifmessage > 0) {
            //            Qservice.Display_Message();
            std::cout << "			" << std::endl;
            std::cout << "Display message : " << rMessage.m_message << std::endl;
            std::cout << "length " << rMessage.m_length << std::endl;
            std::cout << "total length " << sizeof (rMessage) << std::endl;
            std::cout << "receive :" << rMessage.m_message << std::endl;
            std::cout << "			" << std::endl;
        }else{
            std::cout << "No new queuing message" << std::endl;
        }
        sleep(1);

    }
    return 0;
}
Exemplo n.º 7
0
int main(int argc, char* argv[])
{ 
   int      i=1;
   double   last_ts = 0.0, ts;
   char     lmsg[24];
   
   srandom (getpid());
   init_communication (LPNAME);
	
   sim_P ();
   last_ts = clock;
   do {
      ts = last_ts+rnd(0,2);
      last_ts = ts;
      sprintf (lmsg, "msg%d", i);
      printf ("[%s]: local event scheduled %.2f\n", LPNAME, ts);
      schedule_local_event (ts, lmsg);
      i++;
   } while (last_ts < end_clock);
   sim_V ();
   
   while (!end_reached) {
      queue = receive_event ();
      if (queue != NULL) {
         msg = (MsgHeaderIPC *)g_queue_pop_head (queue);
         clock = msg->time_stamp;
         if (clock >= end_clock) {
            printf ("[%s]: -- end condition reached, clock=%.2f --\n", LPNAME, clock);
            end_reached = TRUE;
         } else {
            ts = clock + 0.5 + rnd(0,1);
            schedule_extern_event (ts, "LP2", msg->msg);
            printf ("[%s]: Scheduled '%.2f %s' for LP2\n", LPNAME, ts, msg->msg);
         }
         g_queue_free (queue);
      }
      sim_V ();
   }
   
   close_communication ();
}
int main(int argc, char *argv[])
{
	//The simulator isn't able to find the machine name alone, we have to hardcode it 
	char * name_machine = "192.168.1.1";
	int nbarg = argc;
	char **argument = new char*[argc];
	int i = 0;
	for (i = 0; i <= nbarg; i++) 
	{
		argument[i] = argv[i];
	}

	//Communication initialization
	COMMUNICATION_VECTOR myCvector;
	
	myCvector = init_communication(argument, NULL);

	int ifmsg = 0;

	int portID0;
	int sock0;

	vector_get(&(myCvector.vqueuing_port), 0, &portID0); 
	vector_get(&(myCvector.vqueuing_socket), 0, &sock0); 

	char sMessage[messageSize];
	const int c_takeoff_ms = 4*1000;
	const int c_land_ms = 3*1000;

	const int c_interval_ms = 15;
	const int c_interval_us = c_interval_ms*1000;

	int sequence = 1; //Keep tracks of number of packet sent
 	
	//Initialization of the drone
	char ftrim[] = "AT*FTRIM=1,\r";
	
	sequence++;
	SEND_QUEUING_MESSAGE(name_machine, portID0, sock0, myCvector.emetteur, ftrim, messageSize);

	usleep(100*1000);

	const int c_takeoff = (1<<9)|(1<<18)|(1<<20)|(1<<22)|(1<<24)|(1<<28);
	const int c_land = (1<<18)|(1<<20)|(1<<22)|(1<<24)|(1<<28);
	
	//We have to send several time the same command to be sure that the drone didn't miss it
	//Take off command
	for (int i = 0; i < c_takeoff_ms; i+=c_interval_ms)
	{
		sprintf(sMessage, "AT*REF=%d,%d\r", sequence++, c_takeoff);
		SEND_QUEUING_MESSAGE(name_machine, portID0, sock0, myCvector.emetteur, sMessage, messageSize);
		usleep(c_interval_us);
		memset(sMessage, 0, 30); 
	}

	//Landing command
	for (int i = 0; i < c_land_ms; i+=c_interval_ms)
	{
		sprintf(sMessage, "AT*REF=%d,%d\r", sequence++, c_land);
		SEND_QUEUING_MESSAGE(name_machine, portID0, sock0, myCvector.emetteur, sMessage, messageSize);
		usleep(c_interval_us);
		memset(sMessage, 0, 30); 
	}

	//We put the partition in an infinite loop because the simulator keeps working
	while(1)
	{
	 std::cout<<" End of control partition " <<std::endl;
	}

	return 0;
}
int main(int argc, char *argv[])
{
	//The simulator isn't able to find the machine name alone, we have to hardcode it
	char * name_machine = "127.0.0.1";
	int nbarg = argc;
	char **argument = new char*[argc];
	int i = 0;
    Type_Message rMessage;

	for (i = 0; i <= nbarg; i++)
	{
		argument[i] = argv[i];
	}

    printf("Initialisation ARINC653\n");

	//Communication initialization
	COMMUNICATION_VECTOR myCvector;

	myCvector = init_communication(argument, NULL);

	int portID;
	int sock;

    char messageReceived[256];
    char sMessage[256];
    char sMessage_rcv[256];

	vector_get(&(myCvector.vqueuing_port), 0, &portID);
	vector_get(&(myCvector.vqueuing_socket), 0, &sock);

    int INIT_DONE = 0;

    i = 0;

    memset(sMessage, 0, 256);





#if 1
	while(1)
	{

        if (RECEIVE_QUEUING_MESSAGE(sock, &rMessage) > 0)
        {
            printf("P2 received: %s\n", rMessage.m_message);
            i++;
            sprintf(sMessage,"P2 send No %d", i);
            SEND_QUEUING_MESSAGE(name_machine, portID, sock, myCvector.emetteur, sMessage, sizeof(sMessage));
        }
        else
        {
            printf("P2 received nothing\n");
            sleep(1);
        }
	}
#else  //drone Msg Control


    while(RECEIVE_QUEUING_MESSAGE(sock, &rMessage) <= 0) {
        ;
    }

    if(strcmp(rMessage.m_message,"P1 INIT_DONE") == 0) {
        printf("P2 Beginning of command loop... \n");
    }
    else
    {
        printf("p2 failed : Received %s from P1\n", rMessage.m_message);
        return 0;
    }

    sleep(1);
    msgID = DRONE_MSG_CMD;
    msgCont = 1;  //take off
    memcpy(sMessage,&msgID, 4);
    memcpy(sMessage+4, &msgCont, 4);
    printf("p2 send takeoff cmd = %d\n", msgCont);
    SEND_QUEUING_MESSAGE(name_machine, portID, sock, myCvector.emetteur, sMessage, sizeof(sMessage));

    for (i=0; i<400 ; i++) {
        if(RECEIVE_QUEUING_MESSAGE(sock, &rMessage)>0)
        {
            //TEST
            memcpy(&msgID, rMessage.m_message, 4);
            memcpy(&msgCont, rMessage.m_message+4, 4);
            printf("P2 received msg ID=%d; msgCont=%d\n", msgID, (int)msgCont);

            switch(msgID)
            {
            case DRONE_MSG_ALT:
            //TEST
               // memcpy(&msgCont, rMessage.m_message+4, 4);
               // printf("P2 received height= %d cm\n", (int)msgCont);
                break;
            default:
                break;
            }
        }

        usleep(100000);
    }

    msgID = DRONE_MSG_CMD;
    msgCont = 2; //land
    memcpy(sMessage,&msgID, 4);
    memcpy(sMessage+4, &msgCont, 4);
    SEND_QUEUING_MESSAGE(name_machine, portID, sock, myCvector.emetteur, sMessage, sizeof(sMessage));

    while(1)
        sleep(10);

#endif

	return 0;
}
Exemplo n.º 10
0
int
main (int argc, char *argv[])
{
	struct options_struct options = {
		/* .logFile = */            NULL,
		/* .runMode = */            runMode_normal,
		/* .gfxdriver = */          TFB_GFXDRIVER_SDL_PURE,
		/* .gfxflags = */           0,
		/* .soundDriver = */        audio_DRIVER_MIXSDL,
		/* .soundFlags = */         audio_QUALITY_MEDIUM,
		/* .width = */              640,
		/* .height = */             480,
		/* .configDir = */          NULL,
		/* .contentDir = */         NULL,
		/* .addons = */             NULL,
		/* .numAddons = */          0,
		/* .gammaSet = */           0,
		/* .gamma = */              0.0f,
		/* .whichMusic = */         OPT_3DO,
		/* .whichCoarseScan = */    OPT_PC,
		/* .whichMenu = */          OPT_PC,
		/* .whichFont = */          OPT_PC,
		/* .whichIntro = */         OPT_3DO,
		/* .whichShield	= */        OPT_PC,
		/* .smoothScroll = */       OPT_PC,
		/* .meleeScale = */         TFB_SCALE_TRILINEAR,
		/* .subtitles = */          TRUE,
		/* .stereoSFX = */          FALSE,
		/* .musicVolumeScale = */   1.0f,
		/* .sfxVolumeScale = */     1.0f,
		/* .speechVolumeScale = */  1.0f,
	};
	int optionsResult;

	log_init (15);

	optionsResult = preParseOptions (argc, argv, &options);
	if (optionsResult != 0)
	{
		// TODO: various uninitialisations
		return optionsResult;
	}

	if (options.logFile != NULL)
	{
		int i;
		freopen (options.logFile, "w", stderr);
		for (i = 0; i < argc; ++i)
			log_add (log_User, "argv[%d] = [%s]", i, argv[i]);
	}

	if (options.runMode == runMode_version)
	{
 		printf ("%d.%d.%d%s\n", UQM_MAJOR_VERSION, UQM_MINOR_VERSION,
				UQM_PATCH_VERSION, UQM_EXTRA_VERSION);
		log_showBox (false, false);
		return EXIT_SUCCESS;
	}
	
	log_add (log_User, "The Ur-Quan Masters v%d.%d.%d%s (compiled %s %s)\n"
	        "This software comes with ABSOLUTELY NO WARRANTY;\n"
			"for details see the included 'COPYING' file.\n",
			UQM_MAJOR_VERSION, UQM_MINOR_VERSION,
			UQM_PATCH_VERSION, UQM_EXTRA_VERSION,
			__DATE__, __TIME__);
#ifdef NETPLAY
	log_add (log_User, "Netplay protocol version %d.%d. Requiring remote "
			"UQM version %d.%d.%d.",
			NETPLAY_PROTOCOL_VERSION_MAJOR, NETPLAY_PROTOCOL_VERSION_MINOR,
			NETPLAY_MIN_UQM_VERSION_MAJOR, NETPLAY_MIN_UQM_VERSION_MINOR,
			NETPLAY_MIN_UQM_VERSION_PATCH);
#endif

	if (options.runMode == runMode_usage)
	{
		usage (stdout, &options);
		log_showBox (true, false);
		return EXIT_SUCCESS;
	}

	/* mem_init () uses mutexes.  Mutex creation cannot use
	   the memory system until the memory system is rewritten
	   to rely on a thread-safe allocator.
	*/
	TFB_PreInit ();
	mem_init ();
	InitThreadSystem ();
	log_initThreads ();
	initIO ();
	prepareConfigDir (options.configDir);

	PlayerOne = CONTROL_TEMPLATE_KB_1;
	PlayerTwo = CONTROL_TEMPLATE_JOY_1;

	// Fill in the options struct based on uqm.cfg
	res_LoadFilename (configDir, "uqm.cfg");
	if (res_HasKey ("config.reswidth"))
	{
		options.width = res_GetInteger ("config.reswidth");
	}
	if (res_HasKey ("config.resheight"))
	{
		options.height = res_GetInteger ("config.resheight");
	}
	if (res_HasKey ("config.alwaysgl"))
	{
		if (res_GetBoolean ("config.alwaysgl"))
		{
			options.gfxDriver = TFB_GFXDRIVER_SDL_OPENGL;
		}
	}
	if (res_HasKey ("config.usegl"))
	{
		options.gfxDriver = res_GetBoolean ("config.usegl") ? TFB_GFXDRIVER_SDL_OPENGL :
			TFB_GFXDRIVER_SDL_PURE;
	}
	if (res_HasKey ("config.scaler"))
	{
		const char *optarg = res_GetString ("config.scaler");

		if (!strcmp (optarg, "bilinear"))
			options.gfxFlags |= TFB_GFXFLAGS_SCALE_BILINEAR;
		else if (!strcmp (optarg, "biadapt"))
			options.gfxFlags |= TFB_GFXFLAGS_SCALE_BIADAPT;
		else if (!strcmp (optarg, "biadv"))
			options.gfxFlags |= TFB_GFXFLAGS_SCALE_BIADAPTADV;
		else if (!strcmp (optarg, "triscan"))
			options.gfxFlags |= TFB_GFXFLAGS_SCALE_TRISCAN;
		else if (!strcmp (optarg, "hq"))
			options.gfxFlags |= TFB_GFXFLAGS_SCALE_HQXX;	
	}
	if (res_HasKey ("config.scanlines") && res_GetBoolean ("config.scanlines"))
	{
		options.gfxFlags |= TFB_GFXFLAGS_SCANLINES;
	}
	if (res_HasKey ("config.fullscreen") && res_GetBoolean ("config.fullscreen"))
	{
		options.gfxFlags |= TFB_GFXFLAGS_FULLSCREEN;
	}
	if (res_HasKey ("config.subtitles"))
	{
		options.subTitles = res_GetBoolean ("config.subtitles");
	}
	if (res_HasKey ("config.textmenu"))
	{
		options.whichMenu = res_GetBoolean ("config.textmenu") ? OPT_PC : OPT_3DO;
	}
	if (res_HasKey ("config.textgradients"))
	{
		options.whichFonts = res_GetBoolean ("config.textgradients") ? OPT_PC : OPT_3DO;
	}
	if (res_HasKey ("config.iconicscan"))
	{
		options.whichCoarseScan = res_GetBoolean ("config.iconicscan") ? OPT_3DO : OPT_PC;
	}
	if (res_HasKey ("config.smoothscroll"))		
	{
		options.smoothScroll = res_GetBoolean ("config.smoothscroll") ? OPT_3DO : OPT_PC;
	}
	if (res_HasKey ("config.3domusic"))
	{
		options.whichMusic = res_GetBoolean ("config.3domusic") ? OPT_3DO : OPT_PC;
	}
	if (res_HasKey ("config.3domovies"))
	{
		options.whichIntro = res_GetBoolean ("config.3domovies") ? OPT_3DO : OPT_PC;
	}
	if (res_HasKey ("config.showfps") && res_GetBoolean ("config.showfps"))
	{
		options.gfxFlags |= TFB_GFXFLAGS_SHOWFPS;
	}
	if (res_HasKey ("config.smoothmelee"))
	{
		options.meleeScale = res_GetBoolean ("config.smoothmelee") ? TFB_SCALE_TRILINEAR : TFB_SCALE_STEP;
	}
	if (res_HasKey ("config.positionalsfx"))
	{
		options.stereoSFX = res_GetBoolean ("config.positionalsfx");
	}
	if (res_HasKey ("config.audiodriver"))
	{
		const char *driverstr = res_GetString ("config.audiodriver");
		if (!strcmp (driverstr, "openal"))
		{
			options.soundDriver = audio_DRIVER_OPENAL;
		}
		else if (!strcmp (driverstr, "none"))
		{
			options.soundDriver = audio_DRIVER_NOSOUND;
			options.speechVolumeScale = 0.0f;
		}
		else if (!strcmp (driverstr, "mixsdl"))
		{
			options.soundDriver = audio_DRIVER_MIXSDL;
		}
		else
		{
			/* Can't figure it out, leave as initial default */
		}
	}
	if (res_HasKey ("config.audioquality"))
	{
		const char *qstr = res_GetString ("config.audioquality");
		if (!strcmp (qstr, "low"))
		{
			options.soundFlags &=
					~(audio_QUALITY_MEDIUM | audio_QUALITY_HIGH);
			options.soundFlags |= audio_QUALITY_LOW;
		}
		else if (!strcmp (qstr, "medium"))
		{
			options.soundFlags &=
					~(audio_QUALITY_HIGH | audio_QUALITY_LOW);
			options.soundFlags |= audio_QUALITY_MEDIUM;
		}
		else if (!strcmp (qstr, "high"))
		{
			options.soundFlags &=
					~(audio_QUALITY_MEDIUM | audio_QUALITY_LOW);
			options.soundFlags |= audio_QUALITY_HIGH;
		}
		else
		{
			/* Can't figure it out, leave as initial default */
		}
	}
	if (res_HasKey ("config.pulseshield"))
	{
		options.whichShield = res_GetBoolean ("config.pulseshield") ? OPT_3DO : OPT_PC;
	}
	if (res_HasKey ("config.player1control"))
	{
		PlayerOne = res_GetInteger ("config.player1control");
		/* This is an unsigned, so no < 0 check is necessary */
		if (PlayerOne >= NUM_TEMPLATES)
		{
			log_add (log_Error, "Illegal control template '%d' for Player One.", PlayerOne);
			PlayerOne = CONTROL_TEMPLATE_KB_1;
		}
	}
	if (res_HasKey ("config.player2control"))
	{
		/* This is an unsigned, so no < 0 check is necessary */
		PlayerTwo = res_GetInteger ("config.player2control");
		if (PlayerTwo >= NUM_TEMPLATES)
		{
			log_add (log_Error, "Illegal control template '%d' for Player Two.", PlayerTwo);
			PlayerTwo = CONTROL_TEMPLATE_JOY_1;
		}
	}
	if (res_HasKey ("config.musicvol"))
	{
		parseVolume (res_GetString ("config.musicvol"), 
				&options.musicVolumeScale, "music volume");
	}		
	if (res_HasKey ("config.sfxvol"))
	{
		parseVolume (res_GetString ("config.sfxvol"), 
				&options.sfxVolumeScale, "SFX volume");
	}		
	if (res_HasKey ("config.speechvol"))
	{
		parseVolume (res_GetString ("config.speechvol"), 
				&options.speechVolumeScale, "speech volume");
	}		

	{	/* init control template names */
		static const char* defaultNames[] =
		{
			"Arrows", "WASD", "Arrows (2)",
			"ESDF", "Joystick 1", "Joystick 2"
		};
		int i;

		for (i = 0; i < 6; ++i)
		{
			char cfgkey[64];

			snprintf(cfgkey, sizeof(cfgkey), "config.keys.%d.name", i + 1);
			cfgkey[sizeof(cfgkey) - 1] = '\0';

			if (res_HasKey (cfgkey))
			{
				strncpy (input_templates[i].name, res_GetString (cfgkey), 30);
				input_templates[i].name[29] = 0;
			}
			else
			{
				strcpy (input_templates[i].name, defaultNames[i]);
				res_PutString (cfgkey, input_templates[i].name);
			}
		}
	}

	optionsResult = parseOptions (argc, argv, &options);
	if (optionsResult != 0)
	{
		// TODO: various uninitialisations
		return optionsResult;
	}


	/* TODO: Once threading is gone, these become local variables
	   again.  In the meantime, they must be global so that
	   initAudio (in StarCon2Main) can see them.  initAudio needed
	   to be moved there because calling AssignTask in the main
	   thread doesn't work */
	snddriver = options.soundDriver;
	soundflags = options.soundFlags;

	// Fill in global variables:
	optWhichMusic = options.whichMusic;
	optWhichCoarseScan = options.whichCoarseScan;
	optWhichMenu = options.whichMenu;
	optWhichFonts = options.whichFonts;
	optWhichIntro = options.whichIntro;
	optWhichShield = options.whichShield;
	optSmoothScroll = options.smoothScroll;
	optMeleeScale = options.meleeScale;
	optSubtitles = options.subTitles;
	optStereoSFX = options.stereoSFX;
	musicVolumeScale = options.musicVolumeScale;
	sfxVolumeScale = options.sfxVolumeScale;
	speechVolumeScale = options.speechVolumeScale;

	prepareContentDir (options.contentDir, options.addons);
	HFree ((void *) options.addons);
	prepareMeleeDir ();
	prepareSaveDir ();
	initTempDir ();

	InitTimeSystem ();
	InitTaskSystem ();

#ifdef NETPLAY
	Network_init ();
	Alarm_init ();
	Callback_init ();
	NetManager_init ();
#endif

	GraphicsLock = CreateMutex ("Graphics",
			SYNC_CLASS_TOPLEVEL | SYNC_CLASS_VIDEO);

	TFB_InitGraphics (options.gfxDriver, options.gfxFlags,
			options.width, options.height);
	if (options.gammaSet)
		TFB_SetGamma (options.gamma);
	InitColorMaps ();
	init_communication ();
	/* TODO: Once threading is gone, restore initAudio here.
	   initAudio calls AssignTask, which currently blocks on
	   ProcessThreadLifecycles... */
	// initAudio (snddriver, soundflags);
	TFB_InitInput (TFB_INPUTDRIVER_SDL, 0);

	StartThread (Starcon2Main, NULL, 1024, "Starcon2Main");

	for (;;)
	{
		TFB_ProcessEvents ();
		ProcessThreadLifecycles ();
		TFB_FlushGraphics ();
	}

	unInitTempDir ();
	uninitIO ();

#ifdef NETPLAY
	Network_uninit ();
#endif
	
	return EXIT_SUCCESS;
}