Ejemplo n.º 1
0
/*
 * Bootstrap our UI, get our buffers, etc.
 */
int main( int argc, char* argv[] )
{
    extern int nes_psg_quality; /* FIXME: cheap hack, copied from nes_psg.h */
    
  translation_buffer_16 = NULL;
  vid_pre_xlat = NULL;

  timeslice = NULL;
  timeslice_data = NULL;
  nes_psg_quality = 2;

  image_1 = image_2 = NULL;
  video_buffer_1 = video_buffer_2 = NULL;

  /* Get Gtk up and running. */
  gtk_init( &argc, &argv );

  nes_gtk_window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
  gtk_window_set_title( GTK_WINDOW( nes_gtk_window ), "DarcNES" );
  gtk_widget_set_usize( nes_gtk_window, 256, 240 );
  gtk_signal_connect( GTK_OBJECT( nes_gtk_window ), "destroy",
		      GTK_SIGNAL_FUNC( destroy ), NULL );
  gtk_signal_connect( GTK_OBJECT( nes_gtk_window ), "key_press_event",
		      GTK_SIGNAL_FUNC( key_press ), NULL );
  gtk_signal_connect( GTK_OBJECT( nes_gtk_window ), "key_release_event",
		      GTK_SIGNAL_FUNC( key_release ), NULL );
  gtk_widget_set_events( nes_gtk_window, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK );
  gtk_widget_show( nes_gtk_window );

  visual = gdk_window_get_visual( nes_gtk_window->window );
  gc = gdk_gc_new( nes_gtk_window->window );
  color_map = gdk_window_get_colormap( nes_gtk_window->window );

  if( argc > 1 )
  {
      int system_type;
      rom_file romfile;
      
      strncpy( rom_name, argv[1], 127 );
      romfile = read_romimage(rom_name);
      system_type = guess_system(romfile);
      activate_system(system_type, romfile);
  }
  else
  {
    show_open_dialog( NULL, NULL );
  }

  /* Using GTK_PRIORITY_HIGH causes Gtk events to not occur. */
  gtk_idle_add( (GtkFunction) emulate_timeslice, NULL );

  gtk_main( );

  return 0;
}
Ejemplo n.º 2
0
void file_selected( GtkWidget* w, GtkFileSelection* fs )
{
    rom_file romfile;
    int system_type;
    
    strncpy( rom_name, gtk_file_selection_get_filename( GTK_FILE_SELECTION( fs ) ), 127 );
    gtk_widget_destroy( GTK_WIDGET( fs ) );
    romfile = read_romimage(rom_name);
    system_type = guess_system(romfile);
    activate_system( system_type, romfile);
}
Ejemplo n.º 3
0
int main(int argc, char *argv[])
{
    /* Declarations */
    int c, option_index = 0;
    struct option long_options[] =
    {
        {"old-manifest", required_argument, 0, 'o'},
        {"coordinator-profile-path", required_argument, 0, 'P'},
        {"profile", required_argument, 0, 'p'},
        {"no-upgrade", no_argument, 0, 'u'},
        {"no-rollback", no_argument, 0, 'r'},
        {"dry-run", no_argument, 0, 'd'},
        {"help", no_argument, 0, 'h'},
        {"version", no_argument, 0, 'v'},
        {0, 0, 0, 0}
    };
    char *old_manifest = NULL;
    char *profile = NULL;
    char *coordinator_profile_path = NULL;
    int no_upgrade = FALSE;
    int no_rollback = FALSE;
    int dry_run = FALSE;
    
    /* Parse command-line options */
    while((c = getopt_long(argc, argv, "o:p:hv", long_options, &option_index)) != -1)
    {
        switch(c)
        {
            case 'o':
                old_manifest = optarg;
                break;
            case 'p':
                profile = optarg;
                break;
            case 'P':
                coordinator_profile_path = optarg;
                break;
            case 'r':
                no_rollback = TRUE;
                break;
            case 'u':
                no_upgrade = TRUE;
                break;
            case 'd':
                dry_run = TRUE;
                break;
            case 'h':
            case '?':
                print_usage(argv[0]);
                return 0;
            case 'v':
                print_version(argv[0]);
                return 0;
        }
    }

    /* Validate options */
    
    profile = check_profile_option(profile);
    
    if(optind >= argc)
    {
        fprintf(stderr, "A manifest file has to be specified!\n");
        return 1;
    }
    else
        return activate_system(argv[optind], old_manifest, coordinator_profile_path, profile, no_upgrade, no_rollback, dry_run); /* Execute activation operation */
}