Exemplo n.º 1
0
int main(int argc, char *argv[]) 
{
	/* INITIALIZE */
#ifdef HW_RVL
	DI_UseCache(false);
	if (!__di_check_ahbprot()) {
		s32 preferred = IOS_GetPreferredVersion();
		if (preferred == 58 || preferred == 61)
			IOS_ReloadIOS(preferred);
		else DI_LoadDVDX(true);
	}
	
	DI_Init();    // first
#endif
	
	loadSettings(argc, argv);
	MenuContext *menu = new MenuContext(vmode);
	VIDEO_SetPostRetraceCallback (ScanPADSandReset);

#ifndef WII
	DVD_Init();
#endif

#ifdef DEBUGON
	//DEBUG_Init(GDBSTUB_DEVICE_TCP,GDBSTUB_DEF_TCPPORT); //Default port is 2828
	DEBUG_Init(GDBSTUB_DEVICE_USB, 1);
	_break();
#endif

	control_info_init(); //Perform controller auto assignment at least once at startup.

	// Start up AESND (inited here because its used in SPU and CD)
	AESND_Init();

#ifdef HW_RVL
	// Initialize the network if the user has specified something in their SMB settings
	if(strlen(&smbShareName[0]) && strlen(&smbIpAddr[0])) {
	  init_network_thread();
  }
#endif
	
	while (menu->isRunning()) {}
	
	// Shut down AESND
	AESND_Reset();

	delete menu;

	return 0;
}
Exemplo n.º 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;
}
Exemplo n.º 3
0
int main(int argc, char* argv[]){
	/* INITIALIZE */
#ifdef DEBUGON
	//DEBUG_Init(GDBSTUB_DEVICE_TCP,GDBSTUB_DEF_TCPPORT); //Default port is 2828
	DEBUG_Init(GDBSTUB_DEVICE_USB, 1);
	_break();
#endif

	Initialise(); // Stock OGC initialization
//	vmode = VIDEO_GetPreferredMode(NULL);
#ifndef WII
	DVD_Init();
#endif
//	menuInit();
#ifdef DEBUGON
	//DEBUG_Init(GDBSTUB_DEVICE_TCP,GDBSTUB_DEF_TCPPORT); //Default port is 2828
//	DEBUG_Init(GDBSTUB_DEVICE_USB, 1);
//	_break();
#endif

	// Default Settings
	audioEnabled     = 1; // Audio
	scalePitch       = 1;
#ifdef RELEASE
	showFPSonScreen  = 0; // Show FPS on Screen
#else
	showFPSonScreen  = 1; // Show FPS on Screen
#endif
	printToScreen    = 1; // Show DEBUG text on screen
	printToSD        = 0; // Disable SD logging
	Timers.limitVIs  = 1;
	autoSave         = 1; // Auto Save Game
	dynacore         = 1; // Dynarec
#ifndef HW_RVL
	screenMode		 = 0; // Stretch FB horizontally
#else
	screenMode		 = CONF_GetAspectRatio() == CONF_ASPECT_16_9 ? SCREENMODE_16x9_PILLARBOX : SCREENMODE_4x3;
#endif
	videoMode		 = VIDEOMODE_AUTO;
	trapFilter		 = TRAPFILTER_DISABLE;
	padAutoAssign	 = PADAUTOASSIGN_AUTOMATIC;
	padType[0]		 = PADTYPE_NONE;
	padType[1]		 = PADTYPE_NONE;
	padType[2]		 = PADTYPE_NONE;
	padType[3]		 = PADTYPE_NONE;
	padAssign[0]	 = PADASSIGN_INPUT0;
	padAssign[1]	 = PADASSIGN_INPUT1;
	padAssign[2]	 = PADASSIGN_INPUT2;
	padAssign[3]	 = PADASSIGN_INPUT3;
	pakMode[0]		 = PAKMODE_MEMPAK; // memPak plugged into controller 1
	pakMode[1]		 = PAKMODE_MEMPAK;
	pakMode[2]		 = PAKMODE_MEMPAK;
	pakMode[3]		 = PAKMODE_MEMPAK;
	loadButtonSlot	 = LOADBUTTON_DEFAULT;
#ifdef GLN64_GX
// glN64 specific  settings
 	glN64_useFrameBufferTextures = 0; // Disable FrameBuffer textures
	glN64_use2xSaiTextures = 0;	// Disable 2xSai textures
	renderCpuFramebuffer = 0; // Disable CPU Framebuffer Rendering
#endif //GLN64_GX
	menuActive = 1;

	//config stuff
	fileBrowser_file* configFile_file;
	int (*configFile_init)(fileBrowser_file*) = fileBrowser_libfat_init;
#ifdef HW_RVL
	if(argc > 0 && argv[0][0] == 'u') {  //assume USB
		nativeSaveDevice = NATIVESAVEDEVICE_USB;
		saveStateDevice = SAVESTATEDEVICE_USB;
		configFile_file = &saveDir_libfat_USB;
		if(configFile_init(configFile_file)) {                //only if device initialized ok
			FILE* f = fopen( "usb:/not64/settings.cfg", "r" );  //attempt to open file
			if(f) {        //open ok, read it
				readConfig(f);
				fclose(f);
			}
			f = fopen( "usb:/not64/controlG.cfg", "r" );  //attempt to open file
			if(f) {
				load_configurations(f, &controller_GC);					//write out GC controller mappings
				fclose(f);
			}
#ifdef HW_RVL
			f = fopen( "usb:/not64/controlC.cfg", "r" );  //attempt to open file
			if(f) {
				load_configurations(f, &controller_Classic);			//write out Classic controller mappings
				fclose(f);
			}
			f = fopen( "usb:/not64/controlN.cfg", "r" );  //attempt to open file
			if(f) {
				load_configurations(f, &controller_WiimoteNunchuk);	//write out WM+NC controller mappings
				fclose(f);
			}
			f = fopen( "usb:/not64/controlW.cfg", "r" );  //attempt to open file
			if(f) {
				load_configurations(f, &controller_Wiimote);			//write out Wiimote controller mappings
				fclose(f);
			}
#endif //HW_RVL
		}
	}
	else /*if((argv[0][0]=='s') || (argv[0][0]=='/'))*/
#endif
	{ //assume SD
		nativeSaveDevice = NATIVESAVEDEVICE_SD;
		saveStateDevice = SAVESTATEDEVICE_SD;
		configFile_file = &saveDir_libfat_Default;
		if(configFile_init(configFile_file)) {                //only if device initialized ok
			FILE* f = fopen( "sd:/not64/settings.cfg", "r" );  //attempt to open file
			if(f) {        //open ok, read it
				readConfig(f);
				fclose(f);
			}
			f = fopen( "sd:/not64/controlG.cfg", "r" );  //attempt to open file
			if(f) {
				load_configurations(f, &controller_GC);					//write out GC controller mappings
				fclose(f);
			}
#ifdef HW_RVL
			f = fopen( "sd:/not64/controlC.cfg", "r" );  //attempt to open file
			if(f) {
				load_configurations(f, &controller_Classic);			//write out Classic controller mappings
				fclose(f);
			}
			f = fopen( "sd:/not64/controlN.cfg", "r" );  //attempt to open file
			if(f) {
				load_configurations(f, &controller_WiimoteNunchuk);	//write out WM+NC controller mappings
				fclose(f);
			}
			f = fopen( "sd:/not64/controlW.cfg", "r" );  //attempt to open file
			if(f) {
				load_configurations(f, &controller_Wiimote);			//write out Wiimote controller mappings
				fclose(f);
			}
#endif //HW_RVL
		}
	}
	// Handle options passed in through arguments
	int i;
	for(i=1; i<argc; ++i){
		handleConfigPair(argv[i]);
	}

	MenuContext *menu = new MenuContext(vmode);

	// Initialize the network if the user has specified something in their SMB settings
	if(strlen(&smbShareName[0]) && strlen(&smbIpAddr[0])) {
		init_network_thread();
	}

	while (menu->isRunning()) {}

	delete menu;

	return 0;
}