void st_abort(const std::string& reason, const std::string& details)
{
  fprintf(stderr, "\nError: %s\n%s\n\n", reason.c_str(), details.c_str());
  st_shutdown();
  abort();
}
int main(int argc, char * argv[])
{

#ifdef _WII_
  IO::SD OurSD;
  OurSD.Mount();
  IO::USB OurUSB;
  OurUSB.Startup();
  OurUSB.Mount();
#endif

  st_directory_setup();

#ifndef _WII_
  parseargs(argc, argv);
  ////
#endif



  st_audio_setup();
  st_video_setup();


  clearscreen(0, 0, 0);
  loading_surf = new Surface(datadir + "/images/title/loading.png", USE_ALPHA);
  loading_surf->draw( 160, 30);
  updatescreen();


  st_joystick_setup();
  st_general_setup();
  st_menu();
  loadshared();

  if (launch_leveleditor_mode && level_startup_file)
    {
    leveleditor(level_startup_file);
    }
  else if (level_startup_file)
    {
      GameSession session(level_startup_file, 1, ST_GL_LOAD_LEVEL_FILE);
      session.run();
    }
  else
    {
      title();
    }

  clearscreen(0, 0, 0);
  updatescreen();

  unloadshared();
  st_general_free();
  TileManager::destroy_instance();
#ifdef DEBUG
  Surface::debug_check();
#endif
  st_shutdown();

  delete loading_surf;

  return 0;
}