Пример #1
0
	static char* dvd_stop_func(){
		if((hasLoadedROM) && (dvdInitialized)){
			dvdInitialized = 0;
			if (rom_length<15728640){
				dvd_motor_off();
				dvd_read_id();
				return "Motor stopped";
			}
			else 
				return "Game still needs DVD";
		}
		dvd_motor_off();
		dvd_read_id();
		dvdInitialized = 0;
		return "Motor Stopped";
	}
Пример #2
0
/****************************************************************************
* Main
****************************************************************************/
int main () 
{
	// Setup defaults (if no config is found)
	memset(&swissSettings, 0 , sizeof(SwissSettings));
	
	void *fb;
	fb = Initialise();
	if(!fb) {
		return -1;
	}

	// Sane defaults
	refreshSRAM();
	swissSettings.debugUSB = 1;
	swissSettings.gameVMode = 0;	// Auto video mode
	swissSettings.exiSpeed = 1;		// 32MHz
	swissSettings.uiVMode = 0; 		// Auto UI mode
	swissSettings.enableFileManagement = 0;

	config_copy_swiss_settings(&swissSettings);
	needsDeviceChange = 1;
	needsRefresh = 1;
	

	//debugging stuff
	if(swissSettings.debugUSB) {
		if(usb_isgeckoalive(1)) {
			usb_flush(1);
		}
		print_gecko("Arena Size: %iKb\r\n",(SYS_GetArena1Hi()-SYS_GetArena1Lo())/1024);
		print_gecko("DVD Drive Present? %s\r\n",swissSettings.hasDVDDrive?"Yes":"No");
		print_gecko("GIT Commit: %s\r\n", GITREVISION);
		print_gecko("GIT Revision: %s\r\n", GITVERSION);
	}
	
	// Detect devices
	populateDeviceAvailability();
	
	curDevice = -1;
	// Are we working with a Wiikey Fusion?
	if(__wkfSpiReadId() != 0 && __wkfSpiReadId() != 0xFFFFFFFF) {
		print_gecko("Detected Wiikey Fusion with SPI Flash ID: %08X\r\n",__wkfSpiReadId());

		// Set real device back
		curDevice = WKF;

		// SlotB hack
		trySlotB();
	}
	else {
		deviceHandler_setStatEnabled(0);
		// Try to init SD cards here and load config
		deviceHandler_initial = &initial_SD0;
		deviceHandler_init		=  deviceHandler_FAT_init;
		deviceHandler_deinit	=  deviceHandler_FAT_deinit;
		if(deviceHandler_init(deviceHandler_initial)) {
			print_gecko("Detected SDGecko in Slot A\r\n");
			load_auto_dol();
			curDevice = SD_CARD;
		}
		else {
			deviceHandler_deinit(deviceHandler_initial);
			deviceHandler_initial = &initial_SD1;
			if(deviceHandler_init(deviceHandler_initial)) {
				print_gecko("Detected SDGecko in Slot B\r\n");
				load_auto_dol();
				curDevice = SD_CARD;
			}
		}
		deviceHandler_setStatEnabled(1);
	}
	
	// If no device has been selected yet to browse ..
	if(curDevice < 0) {
		print_gecko("No default boot device detected, trying DVD!\r\n");
		// Do we have a DVD drive with a ready medium we can perhaps browse then?
		u8 driveReallyExists[8];
		drive_version(&driveReallyExists[0]);
		if(*(u32*)&driveReallyExists[0]) {
			dvd_read_id();
			if(!dvd_get_error()) {
				print_gecko("DVD Medium is up, using it as default device\r\n");
				curDevice = DVD_DISC;
				
				// If we have a GameCube (single image) bootable disc, show the banner screen here
				dvdDiscTypeInt = gettype_disc();
				if(dvdDiscTypeInt == GAMECUBE_DISC) {
					select_device(1);
					// Setup curFile and load it
					memset(&curFile, 0, sizeof(file_handle));
					strcpy(&curFile.name[0], "game.gcm");
					curFile.size = DISC_SIZE;
					curFile.fileAttrib = IS_FILE;
					populate_meta(&curFile);
					load_file();
					curDevice = -1;
					deviceHandler_initial = NULL;
				}
			}
		}
	}
	if(curDevice) {
		needsDeviceChange = 0;
		select_device(1); // to setup deviceHandler_ ptrs
		load_config(forceSlot);
	}

	// Start up the BBA if it exists
	init_network_thread();
	init_httpd_thread();
	
	// DVD Motor off
	if(swissSettings.stopMotor && swissSettings.hasDVDDrive) {
		dvd_motor_off();
	}

	// Swiss video mode force
	GXRModeObj *forcedMode = getModeFromSwissSetting(swissSettings.uiVMode);
	
	if((forcedMode != NULL) && (forcedMode != vmode)) {
		initialise_video(forcedMode);
		vmode = forcedMode;
	}

	while(1) {
		main_loop();
	}
	return 0;
}
Пример #3
0
void
mainmenu ()
{
	int quit = 0;
	int ret;
	int *psoid = (int *) 0x80001800;
	void (*PSOReload) () = (void (*)()) 0x80001800;
	
	if ( isWii )
    	sprintf (menuitems[8],"Reset Wii");
	else
    	sprintf (menuitems[8],"Reset Gamecube");
	
	VIDEO_WaitVSync ();
	
	while (quit == 0)
	{
		ret = RunMenu (menuitems, menucount, (char*)"Main Menu");
		
		switch (ret)
		{
			case 0:
				/*** Load ROM Menu ***/
				quit = LoadManager ();
				break;
			
			case 1:
				/*** SRAM Manager Menu ***/
				if ( ARAM_ROMSIZE > 0 )
                    SaveManager ();
                else
                    WaitPrompt((char*) "No ROM is loaded!");
                break;
			
			case 2:
				/*** Do Freeze / Thaw Menu ***/
				if ( ARAM_ROMSIZE > 0 )
                    quit = FreezeManager ();
                else
                    WaitPrompt((char*) "No ROM is loaded!");
                break;
			
			case 3:
				/*** Configure Controllers ***/
				ConfigureControllers ();
				break;
			
			case 4:
				/*** Emulator Options ***/
				EmulatorOptions ();
				break;
			
			case 5:
				/*** Soft reset ***/
				S9xSoftReset ();
				quit = 1;
				break;
			
			case 6:
				/*** Turn off DVD motor ***/
				dvd_motor_off();
				break;
			
			case 7:
				/*** Exit to Loader ***/
				#ifdef __wii__
				exit(0);
				#else	// gamecube
				if (psoid[0] == PSOSDLOADID)
				PSOReload ();
				#endif
				break;
				
		    case 8:
		        /*** Reset the Gamecube/Wii ***/
                Reboot();
                break;
			
			case -1: /*** Button B ***/
			case 9:
				/*** Return to Game ***/
				quit = 1;
				break;
			
		}
		
	}
	
	/*** Remove any still held buttons ***/
#ifdef HW_RVL
	while( PAD_ButtonsHeld(0) || WPAD_ButtonsHeld(0) )
	    VIDEO_WaitVSync();
#else
	while( PAD_ButtonsHeld(0) )
	    VIDEO_WaitVSync();
#endif
	
}
Пример #4
0
int loadmenu ()
{
  int prevmenu = menu;
  int ret,count,size;
  int quit = 0;
#ifdef HW_RVL
  count = 7;
  char item[7][20] = {
    {"Load Recent"},
    {"Load from SD"},
    {"Load from USB"},
    {"Load from IDE-EXI"},
    {"Load from DVD"},
    {"Stop DVD Motor"},
    {"Return to previous"}
  };
#else
  count = 7;
  char item[7][20] = {
    {"Load Recent"},
    {"Load from SD"},
    {"Load from IDE-EXI"},
    {"Load from WKF"},
    {"Load from DVD"},
    {"Stop DVD Motor"},
    {"Return to previous"}
  };
#endif

  menu = load_menu;
  
  while (quit == 0)
  {
    strcpy (menutitle, "");
    ret = DoMenu (&item[0], count);
    switch (ret)
    {
      // Load from DVD

      case 4:
        load_menu = menu;
        size = DVD_Open(gbrom);
        if (size)
        {
          dvd_on = 1;
          gbromsize = size;
          memfile_autosave();
          reload_rom();
          memfile_autoload();
          return 1;
        }
        break;

      // Stop DVD Disc
      case 5:
        dvd_motor_off();
        dvd_on = 0;
        menu = load_menu;
        break;


      // Button B - Return to Previous
      case -1:
      case 6:
        quit = 1;
        break;

      // Load from SD, USB, IDE-EXI, or WKF device
      default:
        load_menu = menu;
        size = FAT_Open(ret,gbrom);
        if (size)
        {
          gbromsize = size;
          memfile_autosave();
          reload_rom();
          memfile_autoload(); 
          return 1;
        }
        break;
    }
  }

  menu = prevmenu;
  return 0;
}
Пример #5
0
void
MainMenu (int selectedMenu)
{
	tb_t start,end;
	mftb(&start);

	int quit = 0;
	int ret;

	#ifdef HW_RVL
	// don't show dvd motor off on the wii
	menuitems[5][0] = 0;
	// rename reset/exit items
	sprintf (menuitems[6], "Return to Wii Menu");
	sprintf (menuitems[7], "Return to Homebrew Channel");
	#endif

	// disable game-specific menu items if a ROM isn't loaded
	if (!ROMLoaded)
    	menuitems[3][0] = '\0';
	else
		sprintf (menuitems[3], "Game Menu");

	VIDEO_WaitVSync ();

	while (quit == 0)
	{
		if(selectedMenu >= 0)
		{
			ret = selectedMenu;
			selectedMenu = -1; // default back to main menu
		}
		else
		{
			ret = RunMenu (menuitems, menucount, (char*)"Main Menu");
		}

		switch (ret)
		{
			case 0:
				// Load ROM Menu
				quit = LoadManager ();
				break;

			case 1:
				// Configure Controllers
				ConfigureControllers ();
				break;

			case 2:
				// Preferences
				PreferencesMenu ();
				break;

			case 3:
				// Game Options
				quit = GameMenu ();
				break;

			case 4:
				// Credits
				Credits ();
				WaitButtonA ();
                break;

			case 5:
				// turn the dvd motor off (GC only)
				#ifdef HW_DOL
				dvd_motor_off ();
				#endif

			case 6:
				// Reset the Gamecube/Wii
			    Reboot();
                break;

			case 7:
				ExitToLoader();
				break;

			case -1: // Button B
				// Return to Game
				if(ROMLoaded)
					quit = 1;
				break;
		}
	}

	// Wait for buttons to be released
	int count = 0; // how long we've been waiting for the user to release the button
	while(count < 50 && (
		PAD_ButtonsHeld(0)
		#ifdef HW_RVL
		|| WPAD_ButtonsHeld(0)
		#endif
	))
	{
		VIDEO_WaitVSync();
		count++;
	}

	mftb(&end);
	loadtimeradjust += tb_diff_msec(&end, &start);
}
Пример #6
0
/* "Swap DVD" menu item */
	static char* dvd_swap_func(){
		dvd_motor_off();
		dvd_read_id();
		return "Swap disc now";
	}
Пример #7
0
/****************************************************************************
* Main
****************************************************************************/
int main () 
{
	// Setup defaults (if no config is found)
	memset(&swissSettings, 0 , sizeof(SwissSettings));

	// Register all devices supported (order matters for boot devices)
	int i = 0;
	for(i = 0; i < MAX_DEVICES; i++)
		allDevices[i] = NULL;
	i = 0;
	allDevices[i++] = &__device_wkf;
	allDevices[i++] = &__device_wode;
	allDevices[i++] = &__device_sd_a;
	allDevices[i++] = &__device_sd_b;
	allDevices[i++] = &__device_card_a;
	allDevices[i++] = &__device_card_b;
	allDevices[i++] = &__device_dvd;
	allDevices[i++] = &__device_ide_a;
	allDevices[i++] = &__device_ide_b;
	allDevices[i++] = &__device_qoob;
	allDevices[i++] = &__device_smb;
	allDevices[i++] = &__device_sys;
	allDevices[i++] = &__device_usbgecko;
	allDevices[i++] = &__device_ftp;
	allDevices[i++] = &__device_fsp;
	allDevices[i++] = NULL;
	
	// Set current devices
	devices[DEVICE_CUR] = NULL;
	devices[DEVICE_DEST] = NULL;
	devices[DEVICE_TEMP] = NULL;
	devices[DEVICE_CONFIG] = NULL;
	devices[DEVICE_PATCHES] = NULL;
	
	Initialise();
	
	// Sane defaults
	refreshSRAM(&swissSettings);
	swissSettings.debugUSB = 0;
	swissSettings.gameVMode = 0;	// Auto video mode
	swissSettings.exiSpeed = 1;		// 32MHz
	swissSettings.uiVMode = 0; 		// Auto UI mode
	swissSettings.aveCompat = 1;
	swissSettings.enableFileManagement = 0;

	needsDeviceChange = 1;
	needsRefresh = 1;
	
	//debugging stuff
	if(swissSettings.debugUSB) {
		if(usb_isgeckoalive(1)) {
			usb_flush(1);
		}
		print_gecko("Arena Size: %iKb\r\n",(SYS_GetArena1Hi()-SYS_GetArena1Lo())/1024);
		print_gecko("DVD Drive Present? %s\r\n",swissSettings.hasDVDDrive?"Yes":"No");
		print_gecko("GIT Commit: %s\r\n", GITREVISION);
		print_gecko("GIT Revision: %s\r\n", GITVERSION);
	}
	
	// Go through all devices with FEAT_BOOT_DEVICE feature and set it as current if one is available
	for(i = 0; i < MAX_DEVICES; i++) {
		if(allDevices[i] != NULL && (allDevices[i]->features & FEAT_BOOT_DEVICE)) {
			print_gecko("Testing device %s\r\n", allDevices[i]->deviceName);
			if(allDevices[i]->test()) {
				deviceHandler_setDeviceAvailable(allDevices[i], true);
				devices[DEVICE_CUR] = allDevices[i];
				break;
			}
		}
	}
	if(devices[DEVICE_CUR] != NULL) {
		print_gecko("Detected %s\r\n", devices[DEVICE_CUR]->deviceName);
		if(devices[DEVICE_CUR]->init(devices[DEVICE_CUR]->initial)) {
			if(devices[DEVICE_CUR]->features & FEAT_AUTOLOAD_DOL) {
				load_auto_dol();
			}
			memcpy(&curFile, devices[DEVICE_CUR]->initial, sizeof(file_handle));
			needsDeviceChange = 0;
		}
	}

	// Scan here since some devices would already be initialised (faster)
	populateDeviceAvailability();

	// If there's no default config device, set it to the first writable device available
	if(swissSettings.configDeviceId == DEVICE_ID_UNK) {
		for(int i = 0; i < MAX_DEVICES; i++) {
			if(allDevices[i] != NULL && (allDevices[i]->features & FEAT_WRITE) && deviceHandler_getDeviceAvailable(allDevices[i])) {
				swissSettings.configDeviceId = allDevices[i]->deviceUniqueId;
				print_gecko("No default config device found, using [%s]\r\n", allDevices[i]->deviceName);
				syssramex* sramex = __SYS_LockSramEx();
				sramex->__padding0 = swissSettings.configDeviceId;
				__SYS_UnlockSramEx(1);
				while(!__SYS_SyncSram());
				break;
			}
		}
	}
	
	// Try to open up the config .ini in case it hasn't been opened already
	if(config_init()) {
		// TODO notification area this
		print_gecko("Loaded %i entries from the config file\r\n",config_get_count());
	}
	
	if(swissSettings.initNetworkAtStart) {
		// Start up the BBA if it exists
		uiDrawObj_t *msgBox = DrawPublish(DrawProgressBar(true, 0, "Initialising Network"));
		init_network();
		init_httpd_thread();
		DrawDispose(msgBox);
	}
	
	// DVD Motor off setting; Always stop the drive if we only started it to read the ID out
	if((swissSettings.stopMotor && swissSettings.hasDVDDrive) || (swissSettings.hasDVDDrive == 2)) {
		dvd_motor_off();
	}

	// Swiss video mode force
	GXRModeObj *forcedMode = getVideoModeFromSwissSetting(swissSettings.uiVMode);
	
	if((forcedMode != NULL) && (forcedMode != getVideoMode())) {
		setVideoMode(forcedMode);
	}

	while(1) {
		menu_loop();
	}
	return 0;
}