Example #1
0
static void game_list_init(int argc)
{
	if (argc==1)
		game_list_init_nocache();
	else
		game_list_init_cache();
}
Example #2
0
int main (int argc, char **argv)
{
  char options[1000];
  int i;
  char gamename[255];

  //create options string for later passing to runtime
  options[0] = '\0';
  if(argc > 1) {
    for(i=1;i<argc;i++) {
      strcat(options, argv[i]);
      strcat(options, " ");
    }
  }

  frontend_init();

  /* Initialize list of available games */
  game_list_init_nocache();

  while(1)
  {
    fe_S9xInitInputDevices();

    //Initialise SDL input after each game run
    initSDL();

    if (game_num_avail==0)
    {
      /* Draw background image */
      draw_background();
      fe_gamelist_text_out(35, 110, "ERROR: NO AVAILABLE GAMES FOUND",color16(255,255,255));
      frontend_display();
      sleep(5);
      fe_exit();
    }

    /* Select Game */
    select_game(playgame);

    //Quit SDL input before starting Game
    SDL_Quit();

    //Run the actual game
    //Using system seems to work better with snes9x
    sprintf(gamename, "./snes9x %s \"roms/%s\"", options, playgame);
    system(gamename);

    usleep(500000);

  }

}
static void game_list_init_cache(void)
{
	FILE *f;
	int i;
	f=fopen("frontend/mame.lst","r");
	if (f)
	{
		for (i=0;i<NUMGAMES;i++)
		{
			drivers[i].available=fgetc(f);
			if (drivers[i].available)
				game_num_avail++;
		}
		fclose(f);
	}
	else
		game_list_init_nocache();
}