예제 #1
0
int main(int argc, char **argv)
{
    // inicia o allegro
    gdp_init();
    // inicia os eventos
    gdp_initevents();

    // inicia o timer
    gdp_timer();

    // exibe splash
   //gdp_splash();

    // se fechou a tela não faz nada
    if(nclose_game==0){
        // exibe o menu
        //gdp_menu();
        opmenu = 1;
        // opção 1 inicia o jogo
        if(opmenu==1){
            //tela de loaging
            //gdp_intro();
            if(nclose_game==0){
                gdp_loaging();
                teste();
            }
            //gdp_game();
        }
    }
    gdp_close();

    return EXIT_SUCCESS;
}
예제 #2
0
파일: pi-writer.c 프로젝트: jugador87/gdp
int
main(int argc, char **argv)
{
	EP_STAT estat;
	gcl_name_t gclname;
	char *gclpname = LOG_NAME;
	bool show_usage = false;
	char *log_file_name = NULL;
	int opt;

	while ((opt = getopt(argc, argv, "D:g:L:p:")) > 0)
	{
		switch (opt)
		{
		  case 'D':
			ep_dbg_set(optarg);
			break;

		  case 'g':
			gclpname = optarg;
			break;

		  case 'L':
			log_file_name = optarg;
			break;

		  case 'p':
			ButtonPin = atoi(optarg);
			break;

		  default:
			show_usage = true;
			break;
		}
	}
	argc -= optind;
	argv += optind;

	if (show_usage || argc > 0)
	{
		fprintf(stderr,
			"Usage: %s [-D dbgspec] [-g gclname] [-p buttonpin]\n",
			ep_app_getprogname());
		exit(EX_USAGE);
	}

	// initialize wiringPi library (must be root!)
	printf("Initializing wiringPi library:\n");
	wiringPiSetupGpio();
	pinMode(ButtonPin, INPUT);
	pullUpDnControl(ButtonPin, PUD_UP);

	//XXX should probably give up root privileges here

	if (log_file_name != NULL)
	{
		// open a log file (for timing measurements)
		printf("Opening log file:\n");
		LogFile = fopen(log_file_name, "a");
		if (LogFile == NULL)
			printf("Cannot open log file: %s\n", strerror(errno));
		setlinebuf(LogFile);
	}

	// initialize the GDP library
	printf("Initializing GDP library:\n");
	estat = gdp_init(NULL);
	if (!EP_STAT_ISOK(estat))
	{
		ep_app_error("GDP Initialization failed");
		exit(EX_UNAVAILABLE);
	}

	// convert the name to internal form
	printf("Converting name %s to internal form:\n", gclpname);
	estat = gdp_gcl_parse_name(gclpname, gclname);
	if (!EP_STAT_ISOK(estat))
	{
		ep_app_error("Illegal GCL name syntax:\n\t%s",
			gclpname);
		exit(EX_NOINPUT);
	}

	// open the GCL for writing
	printf("Opening GCL for writing:\n");
	estat = gdp_gcl_open(gclname, GDP_MODE_AO, &PiGcl);
	if (!EP_STAT_ISOK(estat))
	{
		char sbuf[100];

		ep_app_error("Cannot open GCL:\n    %s",
			ep_stat_tostr(estat, sbuf, sizeof sbuf));
		exit(EX_NOINPUT);
	}

	// arrange to call a function on edge triggers
	(void) wiringPiISR(ButtonPin, INT_EDGE_BOTH, &changefunc);

	while (true)
		sleep(3600);

	ep_app_abort("Impossible exit");
}
예제 #3
0
int
main(int argc, char **argv)
{
	int opt;
	bool show_usage = false;
	EP_STAT estat;
	gdp_gcl_t *gcl;
	char *gdpd_addr = NULL;
	char buf[200];
	const char *lname;
	gdp_name_t gcliname;
	const char *phase;

	while ((opt = getopt(argc, argv, "D:G:")) > 0)
	{
		switch (opt)
		{
		 case 'D':
			ep_dbg_set(optarg);
			break;

		 case 'G':
			gdpd_addr = optarg;
			break;

		 default:
			show_usage = true;
			break;
		}
	}
	argc -= optind;
	argv += optind;

	if (show_usage || argc != 1)
		usage();

	// initialize GDP library
	estat = gdp_init(gdpd_addr);
	if (!EP_STAT_ISOK(estat))
	{
		ep_app_error("GDP Initialization failed");
		goto fail0;
	}

	// allow thread to settle to avoid interspersed debug output
	ep_time_nanosleep(INT64_C(100000000));

	// open target GCL (must already exist)
	lname = argv[0];
	gdp_parse_name(lname, gcliname);
	phase = "open";
	estat = gdp_gcl_open(gcliname, GDP_MODE_AO, NULL, &gcl);
	EP_STAT_CHECK(estat, goto fail1);

	// create new extent
	phase = "create new extent for";
	estat = gdp_gcl_newextent(gcl);
	EP_STAT_CHECK(estat, goto fail1);

	// close GCLs / release resources
	estat = gdp_gcl_close(gcl);

	if (!EP_STAT_ISOK(estat))
	{
fail1:
		ep_app_error("could not %s %s", phase, lname);
	}

fail0:
	fprintf(stderr, "exiting with status %s\n",
			ep_stat_tostr(estat, buf, sizeof buf));
	return EP_STAT_ISOK(estat) ? EX_OK : EX_UNAVAILABLE;
}