int main (int argc, char *argv[]) { char c; char plugins[100][100], s[20]; char romfile[PATH_MAX]; int old_i, i, i1, i2, i3, i4; int p, p_fullscreen = 0, p_emumode = 0, p_gfx = 0, p_audio = 0, p_input = 0, p_rsp = 0, p_help = 0, p_error = 0; int p_emumode_value=1, fileloaded = 0, p_interactive = 0; int true = 1; char *buffer, *buffer2; #if defined (__linux__) if (signal(SIGTERM, sigterm_handler) == SIG_ERR) printf("Warning: Couldn't register SIGTERM signal handler!\n"); #endif //Set working dir #ifdef WITH_HOME { char temp[PATH_MAX], orig[PATH_MAX]; FILE *src, *dest; struct dirent *entry; DIR *dir; strcpy(g_WorkingDir, getenv("HOME")); strcat(g_WorkingDir, "/.mupen64/"); strcpy(cwd, g_WorkingDir); mkdir(g_WorkingDir, 0700); strcpy(temp, g_WorkingDir); strcat(temp, "mupen64.ini"); dest = fopen(temp, "rb"); if (dest == NULL) { unsigned char byte; dest = fopen(temp, "wb"); strcpy(orig, WITH_HOME); strcat(orig, "share/mupen64/mupen64.ini"); src = fopen(orig, "rb"); while(fread(&byte, 1, 1, src)) fwrite(&byte, 1, 1, dest); fclose(src); fclose(dest); } else fclose(dest); strcpy(temp, g_WorkingDir); strcat(temp, "lang"); strcpy(orig, WITH_HOME); strcat(orig, "share/mupen64/lang"); symlink(orig, temp); /*strcpy(temp, g_WorkingDir); strcat(temp, "plugins"); strcpy(orig, WITH_HOME); strcat(orig, "share/mupen64/plugins"); symlink(orig, temp);*/ strcpy(temp, g_WorkingDir); strcat(temp, "plugins"); mkdir(temp, 0700); strcpy(orig, WITH_HOME); strcat(orig, "share/mupen64/plugins"); dir = opendir(orig); while((entry = readdir(dir)) != NULL) { if(strcmp(entry->d_name + strlen(entry->d_name) - 3, ".so")) { strcpy(orig, WITH_HOME); strcat(orig, "share/mupen64/plugins/"); strcat(orig, entry->d_name); src = fopen(orig, "rb"); if(src == NULL) continue; strcpy(temp, g_WorkingDir); strcat(temp, "plugins/"); strcat(temp, entry->d_name); dest = fopen(temp, "rb"); if(dest == NULL) { unsigned char byte; dest = fopen(temp, "wb"); while(fread(&byte, 1, 1, src)) fwrite(&byte, 1, 1, dest); fclose(src); fclose(dest); } else fclose(dest); } else { strcpy(temp, g_WorkingDir); strcat(temp, "plugins/"); strcat(temp, entry->d_name); strcpy(orig, WITH_HOME); strcat(orig, "share/mupen64/plugins/"); strcat(orig, entry->d_name); symlink(orig, temp); } } strcpy(temp, g_WorkingDir); strcat(temp, "save/"); mkdir(temp, 0700); chdir(g_WorkingDir); } #else if (argv[0][0] != '/') { getcwd(cwd, 1024); strcat(cwd, "/"); strcat(cwd, argv[0]); } else strcpy(cwd, argv[0]); while(cwd[strlen(cwd)-1] != '/') cwd[strlen(cwd)-1] = '\0'; strcpy(g_WorkingDir, cwd); #endif //read config file, read plugins config_read(); plugin_scan_directory(cwd); //get config file settings buffer = (char*)config_get_string("Gfx Plugin", ""); buffer2= plugin_name_by_filename(buffer); if(buffer2) { strcpy(plugins[100], buffer2); p_gfx = true; } else if(buffer) printf("GFX Plugin from ini-file could not be loaded\n"); buffer = (char*)config_get_string("Audio Plugin", ""); buffer2= plugin_name_by_filename(buffer); if(buffer2) { strcpy(plugins[99], buffer2); p_audio = true; } else if(buffer) printf("Audio Plugin from ini-file could not be loaded\n"); buffer = (char*)config_get_string("Input Plugin", ""); buffer2= plugin_name_by_filename(buffer); if(buffer2) { strcpy(plugins[98], buffer2); p_input = true; } else if(buffer) printf("Input Plugin from ini-file could not be loaded\n"); buffer = (char*)config_get_string("RSP Plugin", ""); buffer2= plugin_name_by_filename(buffer); if(buffer2) { strcpy(plugins[97], buffer2); p_rsp = true; } else if(buffer) printf("RSP Plugin from ini-file could not be loaded\n"); buffer = (char*)config_get_string("Core", ""); if(strcmp(buffer,"")) { p_emumode = true; p_emumode_value = buffer[0]-'0'+1; } buffer = (char*)config_get_string("Fullscreen", ""); if(strcmp(buffer,"")) { if(!strcmp(buffer, "true")) p_fullscreen = true; } buffer = (char*)config_get_string("No Ask", ""); if(strcmp(buffer,"")) { if(!strcmp(buffer, "true")) p_noask = true; } // Command Line Parameter - Parsing for(p=1; p<argc; p++) { if(argv[p][0] == '-') { if(!strcmp(argv[p], "--fullscreen")) p_fullscreen = true; else if(!strcmp(argv[p], "--help")) p_help = true; else if(!strcmp(argv[p], "--noask")) p_noask = true; else if(!strcmp(argv[p], "--interactive")) p_interactive = true; else if(!strcmp(argv[p], "--emumode")) { p++; if(p < argc) { p_emumode_value = argv[p][0]; p_emumode = true; } } else if(!strcmp(argv[p], "--gfx")) { p++; if(p < argc) { buffer = plugin_name_by_filename(argv[p]); if(buffer) { strcpy(plugins[100], buffer); p_gfx = true; } else printf("specified GFX Plugin couldn't be loaded!\n"); } } else if(!strcmp(argv[p], "--audio")) { p++; if(p < argc) { buffer = plugin_name_by_filename(argv[p]); if(buffer) { strcpy(plugins[99], buffer); p_audio = true; } else printf("specified Audio Plugin couldn't be loaded!\n"); } } else if(!strcmp(argv[p], "--input")) { p++; if(p < argc) { buffer = plugin_name_by_filename(argv[p]); if(buffer) { strcpy(plugins[98], buffer); p_input = true; } else printf("specified Input Plugin couldn't be loaded!\n"); } } else if(!strcmp(argv[p], "--rsp")) { p++; if(p < argc) { buffer = plugin_name_by_filename(argv[p]); if(buffer) { strcpy(plugins[97], buffer); p_rsp = true; } else printf("specified RSP Plugin couldn't be loaded!\n"); } } } else { strcpy(romfile, argv[p]); fileloaded = true; } } if(p_interactive) { p_emumode = 0; p_gfx = 0; p_audio = 0; p_input = 0; p_rsp = 0; } printf("\nMupen64 version : %s\n", VERSION); if (argc < 2 || p_help || p_error || fileloaded != true) { printf("\n\n" "syntax: mupen64_nogui [parameter(s)] rom\n" "\n" "Parameters:\n" " --fullscreen : turn fullscreen mode on\n" " --gfx (plugin) : set gfx plugin to (plugin)\n" " --audio (plugin) : set audio plugin to (plugin)\n" " --input (plugin) : set input plugin to (plugin)\n" " --rsp (plugin) : set rsp plugin to (plugin)\n" " --emumode (number) : set emu mode to: 1=interp./2=recomp./3=pure interp\n" " --noask : don't ask to force load on bad dumps\n" " --interactive : ask interactively for all plugins\n" "\n" "You can also use the Config-File from the Gui-Version\n" "but there are aditional Parameters for the NO-GUI Version\n" "\n"); return 0; } if (rom_read(romfile)) { if(rom) free(rom); if(ROM_HEADER) free(ROM_HEADER); return 1; } printf("Goodname:%s\n", ROM_SETTINGS.goodname); printf("16kb eeprom=%d\n", ROM_SETTINGS.eeprom_16kb); printf ("emulation mode:\n" " 1. interpreter\n" " 2. dynamic recompiler (default)\n" " 3. pure interpreter\n"); if(p_emumode) c = p_emumode_value; else c = getchar(); if (c == '1') dynacore=0; else if (c == '3') dynacore=2; else dynacore=1; SDL_Init(SDL_INIT_VIDEO); SDL_SetVideoMode(10, 10, 16, 0); SDL_ShowCursor(0); SDL_EnableKeyRepeat(0, 0); SDL_EnableUNICODE(1); init_memory(); // --------------------- loading plugins ---------------------- i=1; i1=1; printf(" Choose your gfx plugin : \n"); while(plugin_type() != -1) { if (plugin_type() == PLUGIN_TYPE_GFX) { strcpy(plugins[i], plugin_next()); printf("%s (%s)\n", plugins[i], plugin_filename_by_name(plugins[i])); i++; } else plugin_next(); } if(p_gfx) i1 = 100; else { if(p_emumode) getchar(); /*c = getchar(); s[0] = c; s[1] = 0;*/ scanf("%10s", s); i1 = atoi(s); } plugin_rewind(); old_i = i; printf(" Choose your audio plugin : \n"); while(plugin_type() != -1) { if (plugin_type() == PLUGIN_TYPE_AUDIO) { strcpy(plugins[i], plugin_next()); printf("%s (%s)\n", plugins[i], plugin_filename_by_name(plugins[i])); i++; } else plugin_next(); } /*getchar(); c = getchar(); //getchar(); s[0] = c; s[1] = 0;*/ if(p_audio) i2 = 99; else { scanf("%10s", s); i2 = old_i + atoi(s) - 1; } plugin_rewind(); old_i = i; printf(" Choose your input plugin : \n"); while(plugin_type() != -1) { if (plugin_type() == PLUGIN_TYPE_CONTROLLER) { strcpy(plugins[i], plugin_next()); printf("%s (%s)\n", plugins[i], plugin_filename_by_name(plugins[i])); i++; } else plugin_next(); } /*getchar(); c = getchar(); //getchar(); s[0] = c; s[1] = 0;*/ if(p_input) i3 = 98; else { scanf("%10s", s); i3 = old_i + atoi(s) - 1; } plugin_rewind(); old_i = i; printf(" Choose your RSP plugin : \n"); while(plugin_type() != -1) { if (plugin_type() == PLUGIN_TYPE_RSP) { strcpy(plugins[i], plugin_next()); printf("%s (%s)\n", plugins[i], plugin_filename_by_name(plugins[i])); i++; } else plugin_next(); } /*getchar(); c = getchar(); getchar(); s[0] = c; s[1] = 0;*/ if(p_rsp) i4 = 97; else { scanf("%10s", s); i4 = old_i + atoi(s) - 1; } printf("\n\nSelected Plugins: %s, %s, %s, %s\n", plugins[i1], plugins[i2], plugins[3], plugins[i4]); plugin_load_plugins(plugins[i1], plugins[i2], plugins[i3], plugins[i4]); romOpen_gfx(); romOpen_audio(); romOpen_input(); // ------------------------------------------------------------ SDL_SetEventFilter(filter); if(p_fullscreen) changeWindow(); go(); romClosed_RSP(); romClosed_input(); romClosed_audio(); romClosed_gfx(); closeDLL_RSP(); closeDLL_input(); closeDLL_audio(); closeDLL_gfx(); free(rom); free(ROM_HEADER); free_memory(); return 0; }
int main (int argc, char *argv[]) { GtkWidget *load_button; GtkWidget *table; GtkWidget *pixmapwid; GtkStyle *style; GdkPixmap *pixmap; GdkBitmap *mask; GtkWidget *label_core; GList *glist_gfx = NULL; GtkWidget *label_gfx; GtkWidget *config_gfx_button; GtkWidget *test_gfx_button; GtkWidget *about_gfx_button; GList *glist_audio = NULL; GtkWidget *label_audio; GtkWidget *config_audio_button; GtkWidget *test_audio_button; GtkWidget *about_audio_button; GList *glist_input = NULL; GtkWidget *label_input; GtkWidget *config_input_button; GtkWidget *test_input_button; GtkWidget *about_input_button; GList *glist_RSP = NULL; GtkWidget *label_RSP; GtkWidget *config_RSP_button; GtkWidget *test_RSP_button; GtkWidget *about_RSP_button; #ifdef DBG if (!g_thread_supported()) g_thread_init(NULL); else { fprintf(stderr, "mupen64 will certainly have problems with GTK threads.\n"); fprintf(stderr, "Check your GLIB/GDK/GTK installation for thread support.\n"); } #endif gtk_init(&argc, &argv); if (argv[0][0] != '/') { getcwd(cwd, 1024); strcat(cwd, "/"); strcat(cwd, argv[0]); } else strcpy(cwd, argv[0]); while(cwd[strlen(cwd)-1] != '/') cwd[strlen(cwd)-1] = '\0'; // création de la fenêtre window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width(GTK_CONTAINER(window), 10); gtk_widget_show(window); // création du bouton Load rom load_button = gtk_button_new_with_label("Load rom..."); gtk_widget_show(load_button); // création du logo style = gtk_widget_get_style(window); pixmap = gdk_pixmap_create_from_xpm_d(window->window, &mask, &style->bg[GTK_STATE_NORMAL], (gchar **)logo_xpm); pixmapwid = gtk_pixmap_new(pixmap, mask); gtk_widget_show(pixmapwid); // création de la selection du mode d'émulation label_core = gtk_frame_new("cpu core : "); gtk_widget_show(label_core); interp = gtk_radio_button_new_with_label(NULL, "interpreter"); gtk_widget_show(interp); dynam = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(interp)), "dynamic compiler"); gtk_widget_show(dynam); pure_interp = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(interp)), "pure interpreter"); gtk_widget_show(pure_interp); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dynam), TRUE); // création de l'option 'debugger' #ifdef DBG button_debug = gtk_check_button_new_with_label("debugger mode"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_debug), FALSE); gtk_widget_show(button_debug); #endif // recherche des plugins plugin_scan_directory(cwd); while(plugin_type() != -1) switch (plugin_type()) { case PLUGIN_TYPE_GFX: glist_gfx = g_list_append(glist_gfx, plugin_next()); break; case PLUGIN_TYPE_AUDIO: glist_audio = g_list_append(glist_audio, plugin_next()); break; case PLUGIN_TYPE_CONTROLLER: glist_input = g_list_append(glist_input, plugin_next()); break; case PLUGIN_TYPE_RSP: glist_RSP = g_list_append(glist_RSP, plugin_next()); break; } label_gfx = gtk_frame_new("gfx plugin : "); gtk_widget_show(label_gfx); combo_gfx = gtk_combo_new(); gtk_combo_set_popdown_strings(GTK_COMBO(combo_gfx), glist_gfx); gtk_combo_set_value_in_list(GTK_COMBO(combo_gfx), TRUE, FALSE); gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(combo_gfx)->entry), FALSE); gtk_widget_show(combo_gfx); config_gfx_button = gtk_button_new_with_label("Config"); gtk_widget_show(config_gfx_button); test_gfx_button = gtk_button_new_with_label("Test"); gtk_widget_show(test_gfx_button); about_gfx_button = gtk_button_new_with_label("About"); gtk_widget_show(about_gfx_button); label_audio = gtk_frame_new("audio plugin : "); gtk_widget_show(label_audio); combo_audio = gtk_combo_new(); gtk_combo_set_popdown_strings(GTK_COMBO(combo_audio), glist_audio); gtk_combo_set_value_in_list(GTK_COMBO(combo_audio), TRUE, FALSE); gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(combo_audio)->entry), FALSE); gtk_widget_show(combo_audio); config_audio_button = gtk_button_new_with_label("Config"); gtk_widget_show(config_audio_button); test_audio_button = gtk_button_new_with_label("Test"); gtk_widget_show(test_audio_button); about_audio_button = gtk_button_new_with_label("About"); gtk_widget_show(about_audio_button); label_input = gtk_frame_new("input plugin : "); gtk_widget_show(label_input); combo_input = gtk_combo_new(); gtk_combo_set_popdown_strings(GTK_COMBO(combo_input), glist_input); gtk_combo_set_value_in_list(GTK_COMBO(combo_input), TRUE, FALSE); gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(combo_input)->entry), FALSE); gtk_widget_show(combo_input); config_input_button = gtk_button_new_with_label("Config"); gtk_widget_show(config_input_button); test_input_button = gtk_button_new_with_label("Test"); gtk_widget_show(test_input_button); about_input_button = gtk_button_new_with_label("About"); gtk_widget_show(about_input_button); label_RSP = gtk_frame_new("RSP plugin : "); gtk_widget_show(label_RSP); combo_RSP = gtk_combo_new(); gtk_combo_set_popdown_strings(GTK_COMBO(combo_RSP), glist_RSP); gtk_combo_set_value_in_list(GTK_COMBO(combo_RSP), TRUE, FALSE); gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(combo_RSP)->entry), FALSE); gtk_widget_show(combo_RSP); config_RSP_button = gtk_button_new_with_label("Config"); gtk_widget_show(config_RSP_button); test_RSP_button = gtk_button_new_with_label("Test"); gtk_widget_show(test_RSP_button); about_RSP_button = gtk_button_new_with_label("About"); gtk_widget_show(about_RSP_button); // mise en place des évenements gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(delete_event), NULL); gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(destroy), NULL); gtk_signal_connect(GTK_OBJECT(load_button), "clicked", GTK_SIGNAL_FUNC(load), NULL); gtk_signal_connect(GTK_OBJECT(config_gfx_button), "clicked", GTK_SIGNAL_FUNC(config_gfx), NULL); gtk_signal_connect(GTK_OBJECT(test_gfx_button), "clicked", GTK_SIGNAL_FUNC(test_gfx), NULL); gtk_signal_connect(GTK_OBJECT(about_gfx_button), "clicked", GTK_SIGNAL_FUNC(about_gfx), NULL); gtk_signal_connect(GTK_OBJECT(config_audio_button), "clicked", GTK_SIGNAL_FUNC(config_audio), NULL); gtk_signal_connect(GTK_OBJECT(test_audio_button), "clicked", GTK_SIGNAL_FUNC(test_audio), NULL); gtk_signal_connect(GTK_OBJECT(about_audio_button), "clicked", GTK_SIGNAL_FUNC(about_audio), NULL); gtk_signal_connect(GTK_OBJECT(config_input_button), "clicked", GTK_SIGNAL_FUNC(config_input), NULL); gtk_signal_connect(GTK_OBJECT(test_input_button), "clicked", GTK_SIGNAL_FUNC(test_input), NULL); gtk_signal_connect(GTK_OBJECT(about_input_button), "clicked", GTK_SIGNAL_FUNC(about_input), NULL); gtk_signal_connect(GTK_OBJECT(config_RSP_button), "clicked", GTK_SIGNAL_FUNC(config_RSP), NULL); gtk_signal_connect(GTK_OBJECT(test_RSP_button), "clicked", GTK_SIGNAL_FUNC(test_RSP), NULL); gtk_signal_connect(GTK_OBJECT(about_RSP_button), "clicked", GTK_SIGNAL_FUNC(about_RSP), NULL); // mise en page table = gtk_table_new(55, 30, TRUE); gtk_widget_show(table); gtk_container_add(GTK_CONTAINER(window), table); gtk_table_attach_defaults(GTK_TABLE(table), load_button, 0, 10, 0, 3); gtk_table_attach_defaults(GTK_TABLE(table), label_core, 0, 10, 5, 15); gtk_table_attach_defaults(GTK_TABLE(table), pixmapwid, 10, 30, 0, 10); gtk_table_attach_defaults(GTK_TABLE(table), interp, 1, 10, 6, 9); gtk_table_attach_defaults(GTK_TABLE(table), dynam, 1, 10, 9, 12); gtk_table_attach_defaults(GTK_TABLE(table), pure_interp, 1, 10, 12, 15); #ifdef DBG gtk_table_attach_defaults(GTK_TABLE(table), button_debug, 15, 25, 12, 15); #endif gtk_table_attach_defaults(GTK_TABLE(table), label_gfx, 0, 30, 15, 25); gtk_table_attach_defaults(GTK_TABLE(table), combo_gfx, 1, 29, 17, 22); gtk_table_attach_defaults(GTK_TABLE(table), config_gfx_button, 1, 10, 22, 24); gtk_table_attach_defaults(GTK_TABLE(table), test_gfx_button, 10, 20, 22, 24); gtk_table_attach_defaults(GTK_TABLE(table), about_gfx_button, 20, 29, 22, 24); gtk_table_attach_defaults(GTK_TABLE(table), label_audio, 0, 30, 25, 35); gtk_table_attach_defaults(GTK_TABLE(table), combo_audio, 1, 29, 27, 32); gtk_table_attach_defaults(GTK_TABLE(table), config_audio_button, 1, 10, 32, 34); gtk_table_attach_defaults(GTK_TABLE(table), test_audio_button, 10, 20, 32, 34); gtk_table_attach_defaults(GTK_TABLE(table), about_audio_button, 20, 29, 32, 34); gtk_table_attach_defaults(GTK_TABLE(table), label_input, 0, 30, 35, 45); gtk_table_attach_defaults(GTK_TABLE(table), combo_input, 1, 29, 37, 42); gtk_table_attach_defaults(GTK_TABLE(table), config_input_button, 1, 10, 42, 44); gtk_table_attach_defaults(GTK_TABLE(table), test_input_button, 10, 20, 42, 44); gtk_table_attach_defaults(GTK_TABLE(table), about_input_button, 20, 29, 42, 44); gtk_table_attach_defaults(GTK_TABLE(table), label_RSP, 0, 30, 45, 55); gtk_table_attach_defaults(GTK_TABLE(table), combo_RSP, 1, 29, 47, 52); gtk_table_attach_defaults(GTK_TABLE(table), config_RSP_button, 1, 10, 52, 54); gtk_table_attach_defaults(GTK_TABLE(table), test_RSP_button, 10, 20, 52, 54); gtk_table_attach_defaults(GTK_TABLE(table), about_RSP_button, 20, 29, 52, 54); gtk_main(); return 0; }