Exemple #1
0
	static char* restartGame_func(){
		if(hasLoadedROM){
			cpu_deinit();
			romClosed_RSP();
			romClosed_input();
			romClosed_audio();
			romClosed_gfx();
			free_memory();
			
			init_memory();
			romOpen_gfx();
			romOpen_audio();
			romOpen_input();
			cpu_init();
			return "Game restarted";
		} else	return "Please load a ROM first";
	}
Exemple #2
0
static void *main_thread(void *p)
{
   if (GTK_TOGGLE_BUTTON(dynam)->active == 1) dynacore = 1;
   else if (GTK_TOGGLE_BUTTON(pure_interp)->active == 1) dynacore = 2;
   else dynacore = 0;
   
   SDL_Init(SDL_INIT_VIDEO);
   SDL_SetVideoMode(10, 10, 16, 0);
   SDL_SetEventFilter(filter);
   SDL_ShowCursor(0);
   SDL_EnableKeyRepeat(0, 0);
   
   init_memory();
   plugin_load_plugins(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo_gfx)->entry)),
		       gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo_audio)->entry)),
		       gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo_input)->entry)),
		       gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo_RSP)->entry)));
   romOpen_gfx();
   romOpen_audio();
   romOpen_input();
   go();
   romClosed_RSP();
   romClosed_input();
   romClosed_audio();
   romClosed_gfx();
   closeDLL_RSP();
   closeDLL_input();
   closeDLL_audio();
   closeDLL_gfx();
   free(rom);
   rom = NULL;
   free(ROM_HEADER);
   ROM_HEADER = NULL;
   free_memory();
   file_selection_launched = 0;
   return 0;
}
Exemple #3
0
void Func_ResetROM()
{
	if(hasLoadedROM)
	{
		cpu_deinit();
		romClosed_RSP();
		romClosed_input();
		romClosed_audio();
		romClosed_gfx();
		free_memory();
		
		init_memory();
		romOpen_gfx();
		romOpen_audio();
		romOpen_input();
		cpu_init();
		menu::MessageBox::getInstance().setMessage("Game restarted");
		Func_SetPlayGame();
	}
	else	
	{
		menu::MessageBox::getInstance().setMessage("Please load a ROM first");
	}
}
Exemple #4
0
/*********************************************************************************************************
* emulation thread - runs the core
*/
m64p_error main_run(void)
{
    VILimit = (float) GetVILimit();
    VILimitMilliseconds = (double) 1000.0/VILimit; 

    /* take the r4300 emulator mode from the config file at this point and cache it in a global variable */
    r4300emu = ConfigGetParamInt(g_CoreConfig, "R4300Emulator");

    /* set some other core parameters based on the config file values */
    savestates_set_autoinc_slot(ConfigGetParamBool(g_CoreConfig, "AutoStateSlotIncrement"));
    savestates_select_slot(ConfigGetParamInt(g_CoreConfig, "CurrentStateSlot"));
    no_compiled_jump = ConfigGetParamBool(g_CoreConfig, "NoCompiledJump");

    /* set up the SDL key repeat and event filter to catch keyboard/joystick commands for the core */
    event_initialize();

    // initialize memory, and do byte-swapping if it's not been done yet
    if (g_MemHasBeenBSwapped == 0)
    {
        init_memory(1);
        g_MemHasBeenBSwapped = 1;
    }
    else
    {
        init_memory(0);
    }

    // Attach rom to plugins
    if (!romOpen_gfx())
    {
        free_memory(); SDL_Quit(); return M64ERR_PLUGIN_FAIL;
    }
    if (!romOpen_audio())
    {
        romClosed_gfx(); free_memory(); SDL_Quit(); return M64ERR_PLUGIN_FAIL;
    }
    if (!romOpen_input())
    {
        romClosed_audio(); romClosed_gfx(); free_memory(); SDL_Quit(); return M64ERR_PLUGIN_FAIL;
    }

    if (ConfigGetParamBool(g_CoreConfig, "OnScreenDisplay"))
    {
        // init on-screen display
        int width = 640, height = 480;
        readScreen(NULL, &width, &height, 0); // read screen to get width and height
        osd_init(width, height);
    }

    // setup rendering callback from video plugin to the core, for screenshots and On-Screen-Display
    setRenderingCallback(video_plugin_render_callback);

#ifdef WITH_LIRC
    lircStart();
#endif // WITH_LIRC

#ifdef DBG
    if (ConfigGetParamBool(g_CoreConfig, "EnableDebugger"))
        init_debugger();
#endif

    /* Startup message on the OSD */
    osd_new_message(OSD_MIDDLE_CENTER, "Mupen64Plus Started...");

    g_EmulatorRunning = 1;
    StateChanged(M64CORE_EMU_STATE, M64EMU_RUNNING);

    /* call r4300 CPU core and run the game */
    r4300_reset_hard();
    r4300_reset_soft();
    r4300_execute();

#ifdef WITH_LIRC
    lircStop();
#endif // WITH_LIRC

#ifdef DBG
    if (g_DebuggerActive)
        destroy_debugger();
#endif

    if (ConfigGetParamBool(g_CoreConfig, "OnScreenDisplay"))
    {
        osd_exit();
    }

    romClosed_RSP();
    romClosed_input();
    romClosed_audio();
    romClosed_gfx();
    free_memory();

    // clean up
    g_EmulatorRunning = 0;
    StateChanged(M64CORE_EMU_STATE, M64EMU_STOPPED);

    SDL_Quit();

    return M64ERR_SUCCESS;
}
int loadROM(fileBrowser_file* rom){
  int ret = 0;
  savestates_job = 0; //clear all pending save states
	// First, if there's already a loaded ROM
	if(hasLoadedROM){
		// Unload it, and deinit everything
		cpu_deinit();
		eepromWritten = FALSE;
		mempakWritten = FALSE;
		sramWritten = FALSE;
		flashramWritten = FALSE;
		romClosed_RSP();
		romClosed_input();
		romClosed_audio();
		romClosed_gfx();
		closeDLL_RSP();
		closeDLL_input();
		closeDLL_audio();
		closeDLL_gfx();

		ROMCache_deinit();
		free_memory();
#ifndef HW_RVL
		ARAM_manager_deinit();
#endif
	}
	format_mempacks();
	reset_flashram();
	init_eeprom();
	hasLoadedROM = TRUE;
#ifndef HW_RVL
	ARAM_manager_init();
#endif
#ifdef USE_TLB_CACHE
	TLBCache_init();
#else
	tlb_mem2_init();
#endif
	//romFile_init(rom);
	ret = rom_read(rom);
	if(ret){	// Something failed while trying to read the ROM.
		hasLoadedROM = FALSE;
		return ret;
	}

	// Init everything for this ROM
	init_memory();

	gfx_set_fb(xfb[0], xfb[1]);
	if (screenMode == SCREENMODE_16x9_PILLARBOX)
		gfx_set_window( 78, 0, 483, 480);
	else
		gfx_set_window( 0, 0, 640, 480);

	gfx_info_init();
	audio_info_init();
//	control_info_init();
	rsp_info_init();

	romOpen_gfx();
//	gfx_set_fb(xfb[0], xfb[1]);
	romOpen_audio();
	romOpen_input();

	cpu_init();

  if(autoSave==AUTOSAVE_ENABLE) {
    switch (nativeSaveDevice)
    {
    	case NATIVESAVEDEVICE_SD:
    	case NATIVESAVEDEVICE_USB:
    		// Adjust saveFile pointers
    		saveFile_dir = (nativeSaveDevice==NATIVESAVEDEVICE_SD) ? &saveDir_libfat_Default:&saveDir_libfat_USB;
    		saveFile_readFile  = fileBrowser_libfat_readFile;
    		saveFile_writeFile = fileBrowser_libfat_writeFile;
    		saveFile_init      = fileBrowser_libfat_init;
    		saveFile_deinit    = fileBrowser_libfat_deinit;
    		break;
    	case NATIVESAVEDEVICE_CARDA:
    	case NATIVESAVEDEVICE_CARDB:
    		// Adjust saveFile pointers
    		saveFile_dir       = (nativeSaveDevice==NATIVESAVEDEVICE_CARDA) ? &saveDir_CARD_SlotA:&saveDir_CARD_SlotB;
    		saveFile_readFile  = fileBrowser_CARD_readFile;
    		saveFile_writeFile = fileBrowser_CARD_writeFile;
    		saveFile_init      = fileBrowser_CARD_init;
    		saveFile_deinit    = fileBrowser_CARD_deinit;
    		break;
    }
    // Try loading everything
  	int result = 0;
  	saveFile_init(saveFile_dir);
  	result += loadEeprom(saveFile_dir);
  	result += loadSram(saveFile_dir);
  	result += loadMempak(saveFile_dir);
  	result += loadFlashram(saveFile_dir);
  	saveFile_deinit(saveFile_dir);

  	switch (nativeSaveDevice)
  	{
  		case NATIVESAVEDEVICE_SD:
//			if (result) menu::MessageBox::getInstance().setMessage("Found & loaded save from SD card");
  			if (result) autoSaveLoaded = NATIVESAVEDEVICE_SD;
  			break;
  		case NATIVESAVEDEVICE_USB:
//			if (result) menu::MessageBox::getInstance().setMessage("Found & loaded save from USB device");
  			if (result) autoSaveLoaded = NATIVESAVEDEVICE_USB;
  			break;
  		case NATIVESAVEDEVICE_CARDA:
//			if (result) menu::MessageBox::getInstance().setMessage("Found & loaded save from memcard in slot A");
  			if (result) autoSaveLoaded = NATIVESAVEDEVICE_CARDA;
  			break;
  		case NATIVESAVEDEVICE_CARDB:
 //			if (result) menu::MessageBox::getInstance().setMessage("Found & loaded save from memcard in slot B");
  			if (result) autoSaveLoaded = NATIVESAVEDEVICE_CARDB;
  			break;
  	}
  }
	return 0;
}
Exemple #6
0
/*********************************************************************************************************
* emulation thread - runs the core
*/
m64p_error main_run(void)
{
	DebugMessage(M64MSG_STATUS, "Main Run!");
    VILimit = (float) GetVILimit();
    VILimitMilliseconds = (double) 1000.0/VILimit; 

    /* take the r4300 emulator mode from the config file at this point and cache it in a global variable */
    r4300emu = ConfigGetParamInt(g_CoreConfig, "R4300Emulator");

    /* set some other core parameters based on the config file values */
    savestates_set_autoinc_slot(ConfigGetParamBool(g_CoreConfig, "AutoStateSlotIncrement"));
    savestates_select_slot(ConfigGetParamInt(g_CoreConfig, "CurrentStateSlot"));
    no_compiled_jump = ConfigGetParamBool(g_CoreConfig, "NoCompiledJump");

    /* set up the SDL key repeat and event filter to catch keyboard/joystick commands for the core */
    event_initialize();

    // initialize memory, and do byte-swapping if it's not been done yet
    if (g_MemHasBeenBSwapped == 0)
    {
        init_memory(1);
        g_MemHasBeenBSwapped = 1;
    }
    else
    {
        init_memory(0);
    }

    // Attach rom to plugins
    if (!romOpen_gfx())
    {
        free_memory(); return M64ERR_PLUGIN_FAIL;
    }
    DebugMessage(M64MSG_STATUS, "Graphics Plugin Opened!");
    if (!romOpen_audio())
    {
        romClosed_gfx(); free_memory(); return M64ERR_PLUGIN_FAIL;
    }
    DebugMessage(M64MSG_STATUS, "Audio Plugin Opened!");
    if (!romOpen_input())
    {
        romClosed_audio(); romClosed_gfx(); free_memory(); return M64ERR_PLUGIN_FAIL;
    }
    DebugMessage(M64MSG_STATUS, "Input Plugin Opened!");
    printf("Plugins opened!\n");fflush(stdout);

#ifdef WITH_LIRC
    lircStart();
#endif // WITH_LIRC

#ifdef DBG
    if (ConfigGetParamBool(g_CoreConfig, "EnableDebugger"))
        init_debugger();
#endif

    //PumpEvents();


    g_EmulatorRunning = 1;
    StateChanged(M64CORE_EMU_STATE, M64EMU_RUNNING);
    DebugMessage(M64MSG_STATUS, "Starting to reset r4300!");fflush(stdout);
    /* call r4300 CPU core and run the game */
    r4300_reset_hard();
    r4300_reset_soft();
    DebugMessage(M64MSG_STATUS, "About to execute!");
    fflush(stdout);
    r4300_execute();

#ifdef WITH_LIRC
    lircStop();
#endif // WITH_LIRC

#ifdef DBG
    if (g_DebuggerActive)
        destroy_debugger();
#endif

    romClosed_RSP();
    romClosed_input();
    romClosed_audio();
    romClosed_gfx();
    free_memory();

    // clean up
    g_EmulatorRunning = 0;
    StateChanged(M64CORE_EMU_STATE, M64EMU_STOPPED);

    //PDL_Quit();
    SDL_Quit();

    return M64ERR_SUCCESS;
}
Exemple #7
0
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;
}