Пример #1
0
static void
global_setup (void)
{
    setup_stack (&parse_stack, parse_stack_buffer,
                 sizeof (parse_stack_buffer));
    setup_display ();
    setup_sgf ();

    set_defaults();
    if (configfile_load(SETTINGS_FILENAME, config,
                        sizeof(config)/sizeof(*config),
                        SETTINGS_MIN_VERSION ) < 0)
    {
        /* If the loading failed, save a new config file (as the disk is
           already spinning) */

        /* set defaults again just in case (don't know if they can ever
         * be messed up by configfile_load, and it's basically free anyway)
         */
        set_defaults();

        configfile_save(SETTINGS_FILENAME, config,
                        sizeof(config)/sizeof(*config),
                        SETTINGS_VERSION);
    }
}
Пример #2
0
/* this is the plugin entry point */
enum plugin_status plugin_start(const void* parameter)
{
    (void)parameter;
    int ret;

    rb->lcd_setfont(FONT_SYSFIXED);
#if LCD_DEPTH > 1
    rb->lcd_set_backdrop(NULL);
#endif
#ifdef HAVE_LCD_COLOR
    rb->lcd_set_background(LCD_BLACK);
    rb->lcd_set_foreground(LCD_WHITE);
#endif

    /* Turn off backlight timeout */
    backlight_ignore_timeout();

    rb->srand( *rb->current_tick );

    configfile_load(CFG_FILE, config, 1, 0);

    chopper_load(true);
    ret = chopGameLoop();

    configfile_save(CFG_FILE, config, 1, 0);

    rb->lcd_setfont(FONT_UI);
    /* Turn on backlight timeout (revert to settings) */
    backlight_use_settings();

    return ret;
}
Пример #3
0
enum plugin_status plugin_start(const void* parameter)
{
    (void)parameter;

    configfile_load(CONFIG_FILE_NAME, config, 1, 0);
    highscore_load(SCORE_FILE, highscores, NUM_SCORES);
    rb->lcd_clear_display();
    ingame = false;
    while(snake_game_loop() == 0)
        ;
    configfile_save(CONFIG_FILE_NAME, config, 1, 0);
    highscore_save(SCORE_FILE, highscores, NUM_SCORES);
    return PLUGIN_OK;
}
Пример #4
0
/**
 * The main function is where the program starts execution.
 */
Sint32
main (Sint32 args_count, char **arguments)
{
#if defined(POWERMANGA_LOG_ENABLED)
  LOG_LEVELS log_level = LOG_NOTHING;
#endif
  /* GP2X or PSP port */
#ifdef POWERMANGA_HANDHELD_CONSOLE
  /* Use atexit() to call the return-to-menu function,
   * in case of crashes, etc. */
  atexit (returnToMenu);
#endif


  /* allocate memory table */
#if defined (USE_MALLOC_WRAPPER)
  if (!memory_init (22000))
    {
      exit (0);
    }
#endif
#if defined(POWERMANGA_LOG_ENABLED)
  log_initialize (LOG_INFO);
#endif

  /* load config file */
  if (!configfile_load ())
    {
#if defined (USE_MALLOC_WRAPPER)
      memory_releases_all ();
#endif
      exit (0);
    }
#ifdef _WIN32_WCE
  power_conf->verbose = 1;
  display_windows_ce_infos ();
#endif
  if (configfile_scan_arguments (args_count, arguments))
    {
#if defined(POWERMANGA_LOG_ENABLED)
      switch (power_conf->verbose)
        {
        case 1:
          log_level = LOG_WARNING;
          break;
        case 2:
          log_level = LOG_DEBUG;
          break;
        default:
          log_level = LOG_ERROR;
          break;
        }
      log_set_level (log_level);
#endif
#if defined(POWERMANGA_HANDHELD_CONSOLE) || defined(_WIN32_WCE)
      /* We require a 320x200 output size to fit on
       * the GP2X or PSP's display */
      power_conf->scale_x = 1;
      power_conf->resolution = 320;
      power_conf->fullscreen = 1;
      pixel_size = 1;
#endif
      if (power_conf->extract_to_png)
        {
          power_conf->scale_x = 1;
          power_conf->resolution = 320;
          power_conf->fullscreen = 0;
          power_conf->nosound = TRUE;
          pixel_size = 1;
        }
      if (power_conf->resolution == 320)
        {
          vmode = 0;
        }
      else
        {
          if (power_conf->scale_x > 1)
            {
              vmode = 2;
            }
          else
            {
              vmode = 1;
            }
        }
      initialize_and_run ();
    }
  release_game ();

#if defined(POWERMANGA_LOG_ENABLED)
  log_close ();
#endif

  /* releases all memory allocated */
#if defined (USE_MALLOC_WRAPPER)
  memory_releases_all ();
#endif

  /* launch html donation page before leaving */
#if !defined(_WIN32_WCE) && defined(_WIN32)
  ShellExecute (0, "open", ".\\html\\ar01s06s02.html", 0, 0, SW_SHOWNORMAL);
#endif
  return 0;
}
Пример #5
0
int main(int argc, char **argv) {
	char *optstring = "c:t:b:";
	int copt;
	char bnlspecified = 0;
	int r;
	char *rptr;
	newtimestamp = time(NULL);
	argv0 = argv[0];
	if(argc < 2) {
		printUsage(argv[0]);
		return 1;
	}
	for(;;) {
		copt = getopt(argc, argv, optstring);
		if(copt == -1) break;
		if(copt == '?') {
			fprintf(stderr, "Invalid option.");
			return 1;
		}
		switch(copt) {
			case 'c':
				strcpy(configfile_dir, optarg);
				break;
			case 't':
				newtimestamp = atoi(optarg);
				break;
			case 'b':
				strcpy(bnl_filename, optarg);
				bnlspecified = 1;
				break;
		}
	}
	// Get orig directory
	rptr = getcwd(configfile_origdir, CONFIGFILE_FILENAME_LEN);
	// cd to the new directory
	r = chdir(configfile_dir);
	if(r != 0) {
		fprintf(stderr, "Error changing to configfile dir");
		return 1;
	}
	// Load config file
	if(configfile_load() != CONFIGFILE_OK) { fprintf(stderr, "Error loading config file.\n"); return 1; }
	// Load SSL error strings
	SSL_load_error_strings();
	// Initialize signatures
	if(sig_init() != SIG_OK) { fprintf(stderr, "Error initializing signatures.\n"); return 1; }
	// Command
	if(argc - optind < 1) {
		printUsage(argv[0]);
		return 1;
	}
	if(bnlspecified) r = chdir(configfile_origdir);
	if(strcmp(argv[optind], "print") == 0) {
		if(argc - optind != 1) {
			printUsage(argv[0]);
			return 1;
		}
		return doPrintBNL();
	}
	if(strcmp(argv[optind], "new") == 0) {
		if(argc - optind != 1) {
			printUsage(argv[0]);
			return 1;
		}
		return doNew(newtimestamp);
	}
	if(strcmp(argv[optind], "add") == 0) {
		return doAdd(argc - optind - 1, &argv[optind + 1], newtimestamp);
	}
	if(strcmp(argv[optind], "modify") == 0) {
		return doModify(argc - optind - 1, &argv[optind + 1], newtimestamp);
	}
	if(strcmp(argv[optind], "remove") == 0) {
		if(argc - optind != 2) {
			printUsage(argv[0]);
			return 1;
		}
		return doRemove(argv[optind + 1], newtimestamp);
	}
	if(strcmp(argv[optind], "addsubnet") == 0) {
		if(argc - optind != 3) {
			printUsage(argv[0]);
			return 1;
		}
		return doAddSubnet(argv[optind + 1], argv[optind + 2], newtimestamp);
	}
	if(strcmp(argv[optind], "delsubnet") == 0) {
		if(argc - optind != 3) {
			printUsage(argv[0]);
			return 1;
		}
		return doDelSubnet(argv[optind + 1], argv[optind + 2], newtimestamp);
	}
	printUsage(argv[0]);
	return 1;
}