コード例 #1
0
ファイル: bca.c プロジェクト: Jeremy-D-Miller/usbloader-gui
u32 do_bca_code(const char *BCAFilepath, u8 *gameid)
{
	if (!BCAFilepath || !gameid) return 0;

	if (IOS_GetVersion() == 222 || IOS_GetVersion() == 223)
	{
		FILE *fp;
		u32 filesize;
		char filepath[150];
		memset(filepath, 0, 150);
		u8 bcaCode[64] ATTRIBUTE_ALIGN( 32 );

		// Attempt to open the BCA file using the full game ID.
		snprintf(filepath, sizeof(filepath), "%s%.6s.bca", BCAFilepath, gameid);

		fp = fopen(filepath, "rb");
		if (!fp)
		{
			// Not found. Try again without the system code or company code.
			snprintf(filepath, sizeof(filepath), "%s%.3s.bca", BCAFilepath, gameid+1);

			fp = fopen(filepath, "rb");
			if (!fp)
			{
				// Not found. Use the default BCA.
				memset(bcaCode, 0, 64);
				bcaCode[0x33] = 1;
			}
		}

		if (fp)
		{
			// BCA file opened.
			u32 ret = 0;

			fseek(fp, 0, SEEK_END);
			filesize = ftell(fp);

			if (filesize == 64)
			{
				fseek(fp, 0, SEEK_SET);
				ret = fread(bcaCode, 1, 64, fp);
			}
			fclose(fp);

			if (ret != 64)
			{
				// Error reading the BCA file.
				// Use the default BCA.
				memset(bcaCode, 0, 64);
				bcaCode[0x33] = 1;
			}
		}

		Set_DIP_BCA_Datas(bcaCode);
	}
	return 0;
}
コード例 #2
0
bool loadIOS(int ios, bool MountDevices)
{
	int CurIOS = IOS_GetVersion();
	bool ret = true;

	if(ios != CurIOS && IOS_GetType(ios) != IOS_TYPE_STUB)
	{
		WDVD_Close();
		gprintf("Reloading into IOS %i from %i...\n", ios, CurIOS);
		ShutdownBeforeExit();
		NandHandle.Patch_AHB(); //No AHBPROT for the next IOS
		ret = IOS_ReloadIOS(ios) == 0;
		gprintf("AHBPROT after IOS Reload: %u\n", AHBRPOT_Patched());
		NandHandle.Init_ISFS();
		WDVD_Init();
	}

	IOS_GetCurrentIOSInfo();
	if(CurrentIOS.Type == IOS_TYPE_HERMES)
		load_ehc_module_ex();
	else if(CurrentIOS.Type == IOS_TYPE_WANIN && CurrentIOS.Revision >= 18)
		load_dip_249();
	DeviceHandle.SetModes();
	if(MountDevices && ios != CurIOS)
		DeviceHandle.MountAll();

	return ret;
}
コード例 #3
0
ファイル: cios.c プロジェクト: CHASECAREY123456789/wiiflow
void IOS_GetCurrentIOSInfo()
{
	memset(&CurrentIOS, 0, sizeof(IOS_Info));
	CurrentIOS.Version = IOS_GetVersion();
	CurrentIOS.Base = CurrentIOS.Version;
	CurrentIOS.Revision = IOS_GetRevision();
	CurrentIOS.SubRevision = 0;
	CurrentIOS.Type = IOS_GetType(CurrentIOS.Version);
	if(CurrentIOS.Type == IOS_TYPE_D2X)
	{
		iosinfo_t *iosInfo = IOS_GetInfo(CurrentIOS.Version);
		CurrentIOS.Revision = iosInfo->version;
		CurrentIOS.Base = iosInfo->baseios;
		gprintf("D2X IOS%i[%i] v%i\n", CurrentIOS.Version, CurrentIOS.Base, 
			CurrentIOS.Revision);
		MEM2_free(iosInfo);
	}
	else if(CurrentIOS.Type == IOS_TYPE_WANIN)
	{
		if(CurrentIOS.Revision >= 18)
			CurrentIOS.Base = wanin_mload_get_IOS_base();
		gprintf("Waninkoko IOS%i[%i] v%i\n", CurrentIOS.Version, CurrentIOS.Base, 
			CurrentIOS.Revision);
	}
	else if(CurrentIOS.Type == IOS_TYPE_HERMES)
	{
		CurrentIOS.Base = mload_get_IOS_base();
		if(CurrentIOS.Revision > 4)
		{
			CurrentIOS.Revision = mload_get_version() >> 4;
			CurrentIOS.SubRevision = mload_get_version() & 0xF;
		}
コード例 #4
0
ファイル: main.c プロジェクト: PokeAcer549/GeckoStuff
void detectIOScapabilities()
{
	if (!(identifyworks = DIVerify_works()) || identify_SU() < 0 || !DIVerify_works())
	{
		if (identifyworks)
		{
			menu_generatechannellist(TRUE);	// DIVerify seems to be slightly broken, try to workaround the problem
			IOS_ReloadIOS(IOS_GetVersion()); // Reset IOS, needed for some buggy cIOS versions
			buggycIOS = 1;
			identifyworks = (channellist_menu_items > 0);
		}
	}
	if (IOS_GetVersion() == 249 && IOS_GetRevision() > 7 && IOS_GetRevision() < 14)
		disableRebooter = 1;
	else
		disableRebooter = 0;
}
コード例 #5
0
ファイル: tools.c プロジェクト: DarkMatterCore/bluedump-mod
void logfile_header()
{
	logfile("\r\n\r\n*---------------------------------------------------------------------------------------------------------------------------*\r\n");
	logfile("\r\n\r\nYet Another BlueDump MOD v%s - Logfile.\r\n", VERSION);
	logfile("SDmnt(%d), USBmnt(%d), isUSB2(%d), isSD(%d), vwii(%d), __wiilight(%d).\r\n", SDmnt, USBmnt, isUSB2, isSD, vwii, __wiilight);
	logfile("Using IOS%ld v%ld.\r\n", IOS_GetVersion(), IOS_GetRevision());
	logfile("Console language: %d (%s).\r\n\r\n", lang, languages[lang]);
}
コード例 #6
0
bool DeviceHandler::MountUSB(int pos)
{
	if(!usb0)
		usb0 = new PartitionHandle((IOS_GetVersion() > 200) ? &__io_usbstorage2_port0 : &__io_usbstorage);
	if(!usb1 && Settings.USBPort == 1 && IOS_GetVersion() > 200)
		usb1 = new PartitionHandle(&__io_usbstorage2_port1);

	int partCount = 0;
	if(usb0)
		partCount += usb0->GetPartitionCount();
	if(usb1)
		partCount += usb1->GetPartitionCount();

	if(pos >= partCount)
		return false;

	return GetUSBFromDev(USB1+pos)->Mount(PartToPortPart(pos), DeviceName[USB1+pos]);
}
コード例 #7
0
ファイル: main.cpp プロジェクト: AndrisLipenitis/priiloader
int main(int argc, char **argv)
{
    //DEBUG_Init(GDBSTUB_DEVICE_USB, 1);
    s8 ios_patched = 0;
    s32 ret = 0;

    CheckForGecko();
    VIDEO_Init();

    vmode = VIDEO_GetPreferredMode(NULL);
    xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));

    VIDEO_Configure(vmode);
    VIDEO_SetNextFramebuffer(xfb);
    VIDEO_SetBlack(false);
    VIDEO_Flush();

    VIDEO_WaitVSync();
    if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();

    int x = 20, y = 20, w, h;
    w = vmode->fbWidth - (x * 2);
    h = vmode->xfbHeight - (y + 20);

    // Initialize the console
    //Con_InitEX works better but for some odd reason doesn't show right when clearing screen...
    //CON_InitEx(vmode, x, y, w, h);
    CON_Init(xfb,x,y,w,h, vmode->fbWidth*VI_DISPLAY_PIX_SZ );
    printf("\n\n\n");
    VIDEO_ClearFrameBuffer(vmode, xfb, COLOR_BLACK);

    gprintf("resolution is %dx%d\n",vmode->viWidth,vmode->viHeight);
    //printf("\x1b[2J");
    /*sleep(3);
    gprintf("crashing...\n");
    free((void*)0x1);*/
    /*free((void*)0x1);
    free((void*)0x1);
    free((void*)0x1);
    memcpy((void*)0x0,(void*)0x1,5);*/
    //return 0;
    //reload ios so that IF the user started this with AHBPROT we lose everything from HBC. also, IOS36 is the most patched ios :')
    IOS_ReloadIOS(36);

    WPAD_Init();
    PAD_Init();

    printf("\nIOS %d rev %d\n\n",IOS_GetVersion(),IOS_GetRevision());
    if( (VERSION&0xFF) % 10 == 0 )
    {
#if BETAVERSION > 0
        printf("Priiloader v%d.%db%d(r0x%08x) Installation/Removal Tool\n\n\n\n\t",VERSION>>8, (VERSION&0xFF) / 10,BETAVERSION,GIT_REV);
#else
        printf("\t\tPriiloader v%d.%d(r0x%08x) Installation / Removal Tool\n\n\n\n\t",VERSION>>8, (VERSION&0xFF) / 10,GIT_REV);
#endif
    }
コード例 #8
0
ファイル: platform_gx.c プロジェクト: ChowZenki/RetroArch
static void frontend_gx_init(void *data)
{
   (void)data;
#ifdef HW_RVL
   IOS_ReloadIOS(IOS_GetVersion());
   L2Enhance();
#ifndef IS_SALAMANDER
   gx_init_mem2();
#endif
#endif

#if defined(DEBUG) && defined(IS_SALAMANDER)
   VIDEO_Init();
   GXRModeObj *rmode = VIDEO_GetPreferredMode(NULL);
   void *xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
   console_init(xfb, 20, 20, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * VI_DISPLAY_PIX_SZ);
   VIDEO_Configure(rmode);
   VIDEO_SetNextFramebuffer(xfb);
   VIDEO_SetBlack(FALSE);
   VIDEO_Flush();
   VIDEO_WaitVSync();
   VIDEO_WaitVSync();
#endif

#ifndef DEBUG
   __exception_setreload(8);
#endif

   fatInitDefault();

#ifdef HAVE_LOGGER
   devoptab_list[STD_OUT] = &dotab_stdout;
   devoptab_list[STD_ERR] = &dotab_stdout;
   dotab_stdout.write_r = gx_logger_net;
#elif defined(HAVE_FILE_LOGGER) && !defined(IS_SALAMANDER)
   devoptab_list[STD_OUT] = &dotab_stdout;
   devoptab_list[STD_ERR] = &dotab_stdout;
   dotab_stdout.write_r = gx_logger_file;
#endif

#if defined(HW_RVL) && !defined(IS_SALAMANDER)
   OSThread gx_device_thread;
   gx_devices[GX_DEVICE_SD].interface = &__io_wiisd;
   gx_devices[GX_DEVICE_SD].name = "sd";
   gx_devices[GX_DEVICE_SD].mounted = fatMountSimple(gx_devices[GX_DEVICE_SD].name, gx_devices[GX_DEVICE_SD].interface);
   gx_devices[GX_DEVICE_USB].interface = &__io_usbstorage;
   gx_devices[GX_DEVICE_USB].name = "usb";
   gx_devices[GX_DEVICE_USB].mounted = fatMountSimple(gx_devices[GX_DEVICE_USB].name, gx_devices[GX_DEVICE_USB].interface);

   OSInitMutex(&gx_device_cond_mutex);
   OSInitCond(&gx_device_cond);
   OSInitMutex(&gx_device_mutex);
   OSCreateThread(&gx_device_thread, gx_devthread, 0, NULL, NULL, 0, 66, 0);
#endif
}
コード例 #9
0
ファイル: tools.c プロジェクト: SmilingWolf/118-c-c-installer
void printheadline()
{
	int rows, cols;
	CON_GetMetrics(&cols, &rows);

	printf("118Channel and IOS118 Installer v1");
	
	char buf[64];
	sprintf(buf, "IOS%u (Rev %u)\n", IOS_GetVersion(), IOS_GetRevision());
	printf("\x1B[%d;%dH", 0, cols-strlen(buf)-1);	
	printf(buf);
}
コード例 #10
0
bool DeviceHandler::MountAllUSB()
{
	if(!usb0)
		usb0 = new PartitionHandle((IOS_GetVersion() > 200) ? &__io_usbstorage2_port0 : &__io_usbstorage);
	if(!usb1 && Settings.USBPort == 1 && IOS_GetVersion() > 200)
		usb1 = new PartitionHandle(&__io_usbstorage2_port1);

	bool result = false;
	int partCount = 0;
	if(usb0)
		partCount += usb0->GetPartitionCount();
	if(usb1)
		partCount += usb1->GetPartitionCount();

	for(int i = 0; i < partCount; i++)
	{
		if(MountUSB(i))
			result = true;
	}

	return result;
}
コード例 #11
0
bool shadow_mload()
{
	int ios = IOS_GetVersion();

	if(ios != 222 || ios != 223 || ios != 224)
		return false;

	int v51 = (5 << 4) & 1;
	if (IOS_GetRevision() >= 5 && mload_get_version() >= v51)
	{
		char fs[] ATTRIBUTE_ALIGN(32) = "/dev/mload/OFF";
		// shadow /dev/mload supported in hermes cios v5.1char fs[] ATTRIBUTE_ALIGN(32) = "/dev/usb2";
		IOS_Open(fs,0);
		return true;
	}
コード例 #12
0
ファイル: tools.c プロジェクト: DarkMatterCore/bluedump-mod
void KeepAccessRightsAndReload(s32 ios, bool verbose)
{
	s32 ret;
	
	if (AHBPROT_DISABLED)
	{
		/* There should be nothing to worry about if this fails, as long as the new IOS is patched */
		if (verbose) printf("\t- Patching IOS%ld to keep hardware access rights... ", IOS_GetVersion());
		ret = IosPatch_AHBPROT(false);
		if (verbose) printf("%s.\n", (ret < 0 ? "FAILED" : "OK"));
	}
	
	if (verbose) printf("\t- Reloading to IOS%ld... ", ios);
	WUPC_Shutdown();
	WPAD_Shutdown();
	IOS_ReloadIOS(ios);
	//sleep(2);
	PAD_Init();
	WUPC_Init();
	WPAD_Init();
	WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
	if (verbose) printf("done.");
	
	if (AHBPROT_DISABLED)
	{
		if (verbose) printf("\n\t- Applying runtime patches to IOS%ld... ", IOS_GetVersion());
		ret = IosPatch_RUNTIME(true, false, vwii, false);
		if (verbose) printf("%s.\n", (ret < 0 ? "FAILED" : "OK"));
	}
	
	if (IsHermesIOS(ios))
	{
		mload_Init();
		if (verbose) printf("\n\t- Hermes cIOS detected! ehcmodule loaded through mload.");
	}
}
コード例 #13
0
ファイル: tools.c プロジェクト: DarkMatterCore/bluedump-mod
void printheadline()
{
	int rows, cols;
	CON_GetMetrics(&cols, &rows);
	
	printf("Yet Another BlueDump MOD v%s.", VERSION);
	
	char buf[64];
	sprintf(buf, "IOS%ld (v%ld)", IOS_GetVersion(), IOS_GetRevision());
	printf("\x1b[%d;%dH", 0, cols-strlen(buf)-1);
	printf(buf);
	
	printf("\nOriginal code by nicksasa and WiiPower.");
	printf("\nUpdated by DarkMatterCore. Additional code by JoostinOnline.");
	printf("\nHacksDen.com, The Hacking Resource Community (2013-2017).\n\n");
}
コード例 #14
0
void GeneralSettingsMenu::SetOptionValues()
{
	int i = 0;

	if(strextcmp(Settings.LanguagePath, "lang", '.') != 0)
	{
		options.SetValue(i++, tr("Default"));
	}
	else
	{
		char * language = strrchr(Settings.LanguagePath, '/')+1;
		options.SetValue(i++, "%s", language);
	}

	if (Settings.ClockMode == 1)
		options.SetValue(i++, tr("12H"));
	else
		options.SetValue(i++, tr("24H"));

	options.SetValue(i++, "%0.2f", Settings.PDFLoadZoom);

	options.SetValue(i++, "%i", Settings.KeyboardDeleteDelay);

	options.SetValue(i++, "%s", Settings.Rumble ? tr("ON") : tr("OFF"));

	options.SetValue(i++, "%i", Settings.ScrollSpeed);

	options.SetValue(i++, "%i ms", Settings.TooltipDelay);

	options.SetValue(i++, "%i %s", Settings.CompressionLevel, CompressionSynonym(Settings.CompressionLevel));

	options.SetValue(i++, PrioritySynonym(Settings.CopyThreadPrio));

	options.SetValue(i++, PrioritySynonym(Settings.CopyThreadBackPrio));

	options.SetValue(i++, "%s", Settings.ShowFormatter ? tr("ON") : tr("OFF"));

	iosinfo_t *info = IosLoader::GetIOSInfo(IOS_GetVersion());
	if(info && (info->version >= 9)) {
		options.SetValue(i++, "%s", Settings.USBPort ? tr("ON") : tr("OFF"));
	}
	else {
		options.SetValue(i++, tr("requires d2x cIOS v9+"));
	}

	options.SetValue(i++, "%s", Settings.OverridePriiloader ? tr("ON") : tr("OFF"));
}
コード例 #15
0
s32 BlockIOSReload(void)
{
	/* Open ES Module */
	s32 ESHandle = IOS_Open("/dev/es", 0);
	/* IOS Reload Block */
	static ioctlv block_vector[2] ATTRIBUTE_ALIGN(32);
	static u32 mode ATTRIBUTE_ALIGN(32);
	static u32 ios ATTRIBUTE_ALIGN(32);
	mode = 2;
	block_vector[0].data = &mode;
	block_vector[0].len  = sizeof(u32);
	ios = IOS_GetVersion();
	block_vector[1].data = &ios;
	block_vector[1].len  = sizeof(u32);
	s32 ret = IOS_Ioctlv(ESHandle, 0xA0, 2, 0, block_vector);
	/* Close ES Module */
	IOS_Close(ESHandle);
	return ret;
}
コード例 #16
0
ファイル: menu.c プロジェクト: smurk-too/wodebrew
void Print_SYS_Info()
{
	FgColor(CFG.color_inactive);
	printf_("");
	Fat_print_sd_mode();
	printf_(gt("CFG base: %s"), USBLOADER_PATH);
	printf("\n");
	if (strcmp(LAST_CFG_PATH, USBLOADER_PATH)) {
		// if last cfg differs, print it out
		printf_(gt("Additional config:"));
		printf("\n");
		printf_("  %s/config.txt\n", LAST_CFG_PATH);
	}
	printf_(gt("Loader Version: %s"), CFG_VERSION);
	printf("\n");
	printf_("IOS%u (Rev %u)\n",
			IOS_GetVersion(), IOS_GetRevision());
	DefaultColor();
}
コード例 #17
0
ファイル: sys.cpp プロジェクト: gnils/usbloader-gx
int Sys_ChangeIos(int ios) {
	s32 prevIos = IOS_GetVersion();

	SDCard_deInit();
	USBDevice_deInit();

	WPAD_Flush(0);
	WPAD_Disconnect(0);
	WPAD_Shutdown();

	WDVD_Close();

	USBStorage2_Deinit();

	s32 ret = IOS_ReloadIOSsafe(ios);
	if (ret < 0) {
		ios = prevIos;
	}

	SDCard_Init();

	if (ios == 222 || ios == 223) {
		load_ehc_module();
	}
	USBDevice_Init();

    PAD_Init();
    Wpad_Init();
    WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
    WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);

	WBFS_Init(WBFS_DEVICE_USB);
	Disc_Init();

	if (Sys_IsHermes()) {
		WBFS_OpenNamed((char *) &game_partition);
	} else {
		WBFS_Open();
	}

	return ret;
}
コード例 #18
0
ファイル: platform_gx.c プロジェクト: Jalle19/RetroArch
static void system_init(void)
{
#ifdef HW_RVL
   IOS_ReloadIOS(IOS_GetVersion());
   L2Enhance();
#ifndef IS_SALAMANDER
   gx_init_mem2();
#endif
#endif

#ifndef DEBUG
   __exception_setreload(8);
#endif

   fatInitDefault();

#ifdef HAVE_LOGGER
   inl_logger_init();
   devoptab_list[STD_OUT] = &dotab_stdout;
   devoptab_list[STD_ERR] = &dotab_stdout;
   dotab_stdout.write_r = gx_logger_net;
#elif defined(HAVE_FILE_LOGGER)
   inl_logger_init();
#ifndef IS_SALAMANDER
   devoptab_list[STD_OUT] = &dotab_stdout;
   devoptab_list[STD_ERR] = &dotab_stdout;
   dotab_stdout.write_r = gx_logger_file;
#endif
#endif

#if defined(HW_RVL) && !defined(IS_SALAMANDER)
   lwp_t gx_device_thread;
   gx_devices[GX_DEVICE_SD].interface = &__io_wiisd;
   gx_devices[GX_DEVICE_SD].name = "sd";
   gx_devices[GX_DEVICE_SD].mounted = fatMountSimple(gx_devices[GX_DEVICE_SD].name, gx_devices[GX_DEVICE_SD].interface);
   gx_devices[GX_DEVICE_USB].interface = &__io_usbstorage;
   gx_devices[GX_DEVICE_USB].name = "usb";
   gx_devices[GX_DEVICE_USB].mounted = fatMountSimple(gx_devices[GX_DEVICE_USB].name, gx_devices[GX_DEVICE_USB].interface);
   LWP_MutexInit(&gx_device_mutex, false);
   LWP_CreateThread(&gx_device_thread, gx_devthread, NULL, NULL, 0, 66);
#endif
}
コード例 #19
0
void Menu_Loop(void)
{
	u8 iosVersion;

	/* Select IOS menu */
	Menu_SelectIOS();

	/* Retrieve IOS version */
	iosVersion = IOS_GetVersion();

	/* NAND device menu */
	if (iosVersion == CIOS_VERSION)
		Menu_NandDevice();

	for (;;) {
		/* FAT device menu */
		Menu_FatDevice();

		/* WAD list menu */
		Menu_WadList();
	}
}
コード例 #20
0
ファイル: main.c プロジェクト: PokeAcer549/GeckoStuff
void loadStartupIOS()
{
	if (!startupiosloaded)
	{
		sdio_Shutdown();
		if (IOS_GetVersion() != 36) IOS_ReloadIOS(36);
		detectIOScapabilities();
		
		if (!identifyworks && !isIOSstub(249) && IOS_ReloadIOS(249) >= 0)
			detectIOScapabilities();
		
		if (!identifyworks && IOS_ReloadIOS(35) >= 0)
			detectIOScapabilities();
		
		if (!identifyworks)
		{
			IOS_ReloadIOS(36);
			disableRebooter = 1;
		}
		
		sd_init();
		startupiosloaded = 1;
	}
}
コード例 #21
0
ファイル: tools.c プロジェクト: DarkMatterCore/bluedump-mod
void Init_USB()
{
	//Close_USB();
	
	printf("\n");
	if (AHBPROT_DISABLED && !USB_PORT_CONNECTED)
	{
		USBmnt = false;
	} else {
		bool started = false;
		isUSB2 = (IOS_GetVersion() >= 200);
		
		time_t tStart = time(0);
		while ((time(0) - tStart) < 10) // 10 seconds timeout
		{
			Con_ClearLine();
			printf("\t- USB drive: %.f...", difftime(time(0), tStart));
			
			if (isUSB2)
			{
				started = (__io_usbstorage2.startup() && __io_usbstorage2.isInserted());
			} else {
				started = (__io_usbstorage.startup() && __io_usbstorage.isInserted());
			}
			
			if (started) break;
			
			usleep(50000);
		}
		
		USBmnt = (started && fatMountSimple("usb", (isUSB2 ? &__io_usbstorage2 : &__io_usbstorage)));
		Con_ClearLine();
	}
	
	printf("\t- USB drive: %s.\n\n", (USBmnt ? "OK" : "FAILED"));
}
コード例 #22
0
ファイル: menu.c プロジェクト: Hitechcomputergeek/yawmm
void Menu_Loop(void)
{
	u8 iosVersion;
	/* Select IOS menu */
	Menu_SelectIOS();

	/* Retrieve IOS version */
	iosVersion = IOS_GetVersion();

	ndev = &ndevList[0];

	/* NAND device menu */
	if ((iosVersion == CIOS_VERSION || iosVersion == 250) && IOS_GetRevision() >13)
	{
		Menu_NandDevice();
	}
	for (;;) {
		/* FAT device menu */
		Menu_FatDevice();

		/* WAD list menu */
		Menu_WadList();
	}
}
コード例 #23
0
ファイル: tools.c プロジェクト: DarkMatterCore/bluedump-mod
int Device_Menu(bool swap)
{
	u32 pressed;
	int i, selection = 0;
	char *dev_opt[2] = { "SD Card", "USB Storage" };
	
	while(true)
	{
		resetscreen();
		printheadline();
		
		printf("Current device: %s.\n\n", DEVICE(1));
		printf("Select the new output device. ");
		printf("%s.\n\n", (swap ? "Press B to swap/remount the storage devices" : "Device swapping is not allowed"));
		
		for (i = 0; i <= 1; i++)
		{
			printf("%s %s %s\n", ((selection == i) ? ARROW : "  "), dev_opt[i], (((i == 0 && SDmnt) || (i == 1 && USBmnt)) ? "(available)" : "(not available)"));
		}
		
		pressed = DetectInput(DI_BUTTONS_DOWN);
		
		if (pressed == WPAD_BUTTON_UP)
		{
			if (selection > 0) selection--;
		}
		
		if (pressed == WPAD_BUTTON_DOWN)
		{
			if (selection < 1) selection++;
		}
		
		if (pressed == WPAD_BUTTON_A)
		{
			/* Do not exit this screen if the user attempts to select an unavailable storage device */
			if ((selection == 0 && SDmnt) || (selection == 1 && USBmnt))
			{
				/* Detect if the selected device is being already used */
				if ((selection == 0 && !isSD) || (selection == 1 && isSD))
				{
					/* Do the magic */
					isSD ^= 1;
					
					if (debug_file)
					{
						fclose(debug_file);
						logfile_header();
						logfile("Device changed from %s to %s.\r\n\r\n", (selection == 0 ? "USB" : "SD"), DEVICE(1));
					}
				}
				
				return 0;
			}
		}
		
		if (pressed == WPAD_BUTTON_B)
		{
			if (swap) break;
		}
	}
	
	resetscreen();
	printheadline();
	
	Unmount_Devices();
	
	printf("Swap the current storage devices if you want to use different ones.\n");
	printf("Press A when you're done to mount them.\n");
	printf("Otherwise, you can just remount the devices already connected.");
	
	while(true)
	{
		pressed = DetectInput(DI_BUTTONS_DOWN);
		if (pressed == WPAD_BUTTON_A) break;
	}
	
	/* If the currently running IOS is a Waninkoko/d2x cIOS, we have to reload it before we can retry the USB ports */
	s32 ios = IOS_GetVersion();
	if (ios >= 200 && !IsHermesIOS(ios))
	{
		/* Unmount NAND */
		ISFS_Deinitialize();
		
		/* Do our thing */
		KeepAccessRightsAndReload(ios, false);
		
		/* Remount NAND */
		ISFS_Initialize();
	}
	
	int ret = Mount_Devices();
	if (ret < 0) return ret;
	
	logfile_header();
	return 0;
}
コード例 #24
0
void Menu_SelectIOS(void)
{
	u8 *iosVersion = NULL;
	u32 iosCnt;
	u8 tmpVersion;

	u32 cnt;
	s32 ret, selected = 0;
	bool found = false;

	/* Get IOS versions */
	ret = Title_GetIOSVersions(&iosVersion, &iosCnt);
	if (ret < 0)
		return;

	/* Sort list */
	qsort(iosVersion, iosCnt, sizeof(u8), __Menu_IsGreater);

	if (gConfig.cIOSVersion < 0)
		tmpVersion = CIOS_VERSION;
	else
	{
		tmpVersion = (u8)gConfig.cIOSVersion;
		// For debugging only
		//printf ("User pre-selected cIOS: %i\n", tmpVersion);
		//WaitButtons();
	}

	/* Set default version */
	for (cnt = 0; cnt < iosCnt; cnt++) {
		u8 version = iosVersion[cnt];

		/* Custom IOS available */
		//if (version == CIOS_VERSION)
		if (version == tmpVersion)
		{
			selected = cnt;
			found = true;
			break;
		}

		/* Current IOS */
		if (version == IOS_GetVersion())
			selected = cnt;
	}

	/* Ask user for IOS version */
	if ((gConfig.cIOSVersion < 0) || (found == false))
	{
		for (;;)
		{
			/* Clear console */
			Con_Clear();

			printf("\t>> Select IOS version to use: < IOS%d >\n\n", iosVersion[selected]);

			printf("\t   Press LEFT/RIGHT to change IOS version.\n\n");

			printf("\t   Press A button to continue.\n");
			printf("\t   Press HOME button to restart.\n\n");

			u32 buttons = WaitButtons();

			/* LEFT/RIGHT buttons */
			if (buttons & WPAD_BUTTON_LEFT) {
				if ((--selected) <= -1)
					selected = (iosCnt - 1);
			}
			if (buttons & WPAD_BUTTON_RIGHT) {
				if ((++selected) >= iosCnt)
					selected = 0;
			}

			/* HOME button */
			if (buttons & WPAD_BUTTON_HOME)
				Restart();

			/* A button */
			if (buttons & WPAD_BUTTON_A)
				break;
		}
	}


	u8 version = iosVersion[selected];

	if (IOS_GetVersion() != version) {
		/* Shutdown subsystems */
		Wpad_Disconnect();

		/* Load IOS */
		ret = IOS_ReloadIOS(version);

		/* Initialize subsystems */
		Wpad_Init();
	}
}
コード例 #25
0
/****************************************************************************
 * WindowPrompt
 *
 * Displays a prompt window to user, with information, an error message, or
 * presenting a user with a choice
 ***************************************************************************/
void
infoPrompt()
{
	bool stop = false;

	GuiWindow promptWindow(520,360);
	promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	promptWindow.SetPosition(0, -10);
	GuiImageData btnOutline(Theme.button_tiny);
	GuiImageData btnOutlineOver(Theme.button_tiny_focus);
	GuiTrigger trigA;
	GuiTrigger trigB;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
	trigB.SetSimpleTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);

	GuiImageData dialogBox(Theme.dialog_background);
	GuiImage dialogBoxImg(&dialogBox);

    int i = 0;
    int x = 30;
    int y = 40;
	GuiText * Entrie[20];

    Entrie[i] = new GuiText(tr("About HomebrewFilter"), 28, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i]->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
    Entrie[i]->SetPosition(0, y);
    i++;
    y += 50;

    Entrie[i] = new GuiText(tr("Developers:"), 24, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    Entrie[i]->SetPosition(x, y);
    i++;

//    Entrie[i] = new GuiText("hamachi-mp / Christopher Roy Bratusek / obcd", 22, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i] = new GuiText("hamachi-mp   Nano   Obcd", 22, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    Entrie[i]->SetPosition(x+200, y);
    i++;
    y += 32;

    Entrie[i] = new GuiText(tr("Designer:"), 24, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    Entrie[i]->SetPosition(x, y);
    i++;

    Entrie[i] = new GuiText("Black.Pearl", 22, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    Entrie[i]->SetPosition(x+200, y);
    i++;
    y += 50;

    Entrie[i] = new GuiText(tr("Special thanks to:"), 22, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    Entrie[i]->SetPosition(x,y);
	i++;
	y += 32;

	Entrie[i] = new GuiText("- Dimok", 20, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    Entrie[i]->SetPosition(x+50,y);
    i++;
	y += 32;

	Entrie[i] = new GuiText("- ichfly ", 20, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    Entrie[i]->SetPosition(x+50,y);
    i++;
	y += 32;

	Entrie[i] = new GuiText("- all the translators", 20, (GXColor) {Theme.text_1, Theme.text_2, Theme.text_3, 255});
    Entrie[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    Entrie[i]->SetPosition(x+50,y);
    i++;


    int CreditEntries = i;

	char Rev[50];
#ifdef STBOOTVWII
	sprintf(Rev, "Rev. %i (vWii ST)", SvnRev());
#elif VWII
	sprintf(Rev, "Rev. %i (vWii Full)", SvnRev());
#elif STBOOT
	sprintf(Rev, "Rev. %i (Wii ST)", SvnRev());
#else
	sprintf(Rev, "Rev. %i (Wii Full)", SvnRev());
#endif
	GuiText RevTxt(Rev, 20, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	RevTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
	RevTxt.SetPosition(30,24);

	char RunsIos[50];
	if((*(volatile unsigned int*)HW_ARMIRQMASK)&&(*(volatile unsigned int*)HW_ARMIRQFLAG))
		sprintf(RunsIos, "IOS %i Rev. %i (HW_AHBPROT)", IOS_GetVersion(), IOS_GetRevision());
	else
		sprintf(RunsIos, "IOS %i Rev. %i", IOS_GetVersion(), IOS_GetRevision());

	GuiText RunsIosTxt(RunsIos, 14, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	RunsIosTxt.SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
	RunsIosTxt.SetPosition(-30,24);

	GuiText backTxt(tr("Back"), 24, (GXColor){Theme.button_tiny_text_1, Theme.button_tiny_text_2, Theme.button_tiny_text_3, 255});
	GuiImage backImg(&btnOutline);
	GuiImage backImgOver(&btnOutlineOver);
	GuiButton back(btnOutline.GetWidth(), btnOutline.GetHeight());
	back.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
	back.SetPosition(0, -15);
	back.SetLabel(&backTxt);
	back.SetImage(&backImg);
	back.SetImageOver(&backImgOver);
	back.SetTrigger(&trigA);
	back.SetTrigger(&trigB);

	promptWindow.Append(&dialogBoxImg);

	for(int i = 0; i < CreditEntries; i++)
        promptWindow.Append(Entrie[i]);

    promptWindow.Append(&RevTxt);
    promptWindow.Append(&RunsIosTxt);
	promptWindow.Append(&back);

	HaltGui();
	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&promptWindow);
	mainWindow->ChangeFocus(&promptWindow);
	ResumeGui();

	while(!stop)
	{
		usleep(100);

		if(back.GetState() == STATE_CLICKED)
			stop = true;
	}

	HaltGui();
	mainWindow->Remove(&promptWindow);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();
}
コード例 #26
0
ファイル: disc.c プロジェクト: Yardape8000/wiiflow-plus
s32 Disc_BootPartition(u64 offset, u8 vidMode, bool vipatch, bool countryString, u8 patchVidMode, int aspectRatio)
{
	entry_point p_entry;

	IOSReloadBlock(IOS_GetVersion());
	
	s32 ret = WDVD_OpenPartition(offset, 0, 0, 0, Tmd_Buffer);
	if (ret < 0) return ret;

	/* Select an appropriate video mode */
	__Disc_SelectVMode(vidMode, 0);

	/* Setup low memory */;
	__Disc_SetLowMem();

	/* Run apploader */
	ret = Apploader_Run(&p_entry, vidMode, vmode, vipatch, countryString, patchVidMode, aspectRatio);
	free_wip();
	if (ret < 0) return ret;

	if (hooktype != 0)
		ocarina_do_code();

	gprintf("\n\nEntry Point is: %0x8\n", p_entry);
//	gprintf("Lowmem:\n\n");
//	ghexdump((void*)0x80000000, 0x3f00);

	/* Set time */
	__Disc_SetTime();

	/* Set an appropriate video mode */
	__Disc_SetVMode();

	u8 temp_data[4];

	// fix for PeppaPig
	memcpy((char *) &temp_data, (void*)0x800000F4,4);

	usleep(100 * 1000);

	/* Shutdown IOS subsystems */
	SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);

	/* Originally from tueidj - taken from NeoGamma (thx) */
	*(vu32*)0xCC003024 = 1;
	
	// fix for PeppaPig
	memcpy((void*)0x800000F4,(char *) &temp_data, 4);

	appentrypoint = (u32) p_entry;
	
	gprintf("Jumping to entrypoint\n");
	
	if (hooktype != 0) //2x "nop\n" removed From Mod
	{
		__asm__(
			"lis %r3, appentrypoint@h\n"
			"ori %r3, %r3, appentrypoint@l\n"
			"lwz %r3, 0(%r3)\n"
			"mtlr %r3\n"
			"lis %r3, 0x8000\n"
			"ori %r3, %r3, 0x18A8\n"
			"nop\n"
			"mtctr %r3\n"
			"bctr\n"
		);
	}
	else
	{
		__asm__(
			"lis %r3, appentrypoint@h\n"
			"ori %r3, %r3, appentrypoint@l\n"
			"lwz %r3, 0(%r3)\n"
			"mtlr %r3\n"
			"blr\n"
		);
	}

	return 0;
}
コード例 #27
0
ファイル: tools.c プロジェクト: DarkMatterCore/bluedump-mod
s32 ios_selectionmenu(s32 default_ios)
{
	u32 pressed, i, ioscount, selection = 0;
	
	s32 *list = get_ioslist(&ioscount);
	if (list == 0) return -1;
	
	for (i = 0; i < ioscount; i++)
	{
		/* Default to default_ios if found, else the loaded IOS */
		if (list[i] == default_ios)
		{
			selection = i;
			break;
		}
		
		if (list[i] == IOS_GetVersion()) selection = i;
	}
	
	resetscreen();
	printheadline();
	
	s32 ios;
	
	while (true)
	{
		printf("\x1b[%d;%dH", 5, 0);	// move console cursor to y/x
		printf("Select the IOS version to use:       \b\b\b\b\b\b");
		
		set_highlight(true);
		printf("IOS%ld", list[selection]);
		set_highlight(false);
		
		printf("\n\nPress LEFT/RIGHT to change IOS version.");
		printf("\nPress A button to load the selected IOS.");
		printf("\nPress B to continue without IOS Reload.");
		printf("\nPress HOME or Start to exit.\n\n");
		
		pressed = DetectInput(DI_BUTTONS_DOWN);
		
		if (pressed == WPAD_BUTTON_LEFT)
		{	
			if (selection > 0)
			{
				selection--;
			} else {
				selection = ioscount - 1;
			}
		}
		
		if (pressed == WPAD_BUTTON_RIGHT)
		{
			if (selection < ioscount -1)
			{
				selection++;
			} else {
				selection = 0;
			}
		}
		
		if (pressed == WPAD_BUTTON_A)
		{
			ios = list[selection];
			break;
		}
		
		if (pressed == WPAD_BUTTON_B)
		{
			ios = 0;
			break;
		}
		
		if (pressed == WPAD_BUTTON_HOME)
		{
			ios = -2;
			break;
		}
	}
	
	free(list);
	return ios;
}
コード例 #28
0
ファイル: tools.c プロジェクト: DarkMatterCore/bluedump-mod
s32 Settings_Menu()
{
	s32 ret = 0;
	u32 pressed;
	int i, selection = 0;
	char *menu_opt[3] = { "Device menu", "Update application", "Reload to another IOS (device remount required)" };
	
	while(true)
	{
		resetscreen();
		printheadline();
		
		printf("Select an option. Press B to go back to the menu.\n\n");
		
		for (i = 0; i <= 2; i++)
		{
			printf("%s %s\n", ((selection == i) ? ARROW : "  "), menu_opt[i]);
		}
		
		pressed = DetectInput(DI_BUTTONS_DOWN);
		
		if (pressed == WPAD_BUTTON_UP)
		{
			if (selection > 0) selection--;
		}
		
		if (pressed == WPAD_BUTTON_DOWN)
		{
			if (selection < 2) selection++;
		}
		
		if (pressed == WPAD_BUTTON_A)
		{
			switch (selection)
			{
				case 0:
					/* Device menu */
					ret = Device_Menu(true);
					break;
				case 1:
					/* Update application */
					UpdateYABDM(launch_path);
					break;
				case 2:
					/* IOS reload */
					ret = ios_selectionmenu(249);
					if (ret > 0)
					{
						if (ret != IOS_GetVersion())
						{
							/* Unmount devices */
							ISFS_Deinitialize();
							Unmount_Devices();
							
							KeepAccessRightsAndReload(ret, true);
							
							/* Remount devices */
							ISFS_Initialize();
							ret = Mount_Devices();
							if (ret != -2) logfile_header();
						} else {
							printf("\t- IOS reload aborted (IOS%ld is already loaded).", ret);
							waitforbuttonpress();
						}
					} else
					if (ret == 0)
					{
						printf("\t- Proceeding without IOS reload...");
						waitforbuttonpress();
					}
					
					break;
				default:
					break;
			}
			
			break;
		}
		
		if (pressed == WPAD_BUTTON_B) break;
	}
	
	return ret;
}
コード例 #29
0
ファイル: tools.c プロジェクト: DarkMatterCore/bluedump-mod
s32 ahbprot_menu()
{
	s32 ret;
	u32 pressed;

	/* HW_AHBPROT check */
	if (AHBPROT_DISABLED)
	{
		printf("Hardware protection is disabled!\n");
		printf("Current IOS: %ld.\n\n", IOS_GetVersion());
		
		printf("Press A button to use full hardware access.\n");
		printf("Press B button to reload to another IOS.\n");
		printf("Press HOME or Start to exit.\n\n");
		
		for (;;)
		{
			pressed = DetectInput(DI_BUTTONS_DOWN);
			
			/* A button */
			if (pressed == WPAD_BUTTON_A)
			{
				printf("Initializing IOS patches... ");
				ret = IosPatch_RUNTIME(true, false, vwii, false);
				if (ret < 0)
				{
					/* This is a very, very weird error */
					printf("ERROR!\n\n");
					printf("\tUnable to load the initial patches. Maybe the loaded IOS isn't\n");
					printf("\tvulnerable for an unknown reason.\n");
					sleep(4);
					printf("\tThis error is very uncommon. I already checked if the hardware\n");
					printf("\tprotection was disabled. You should report this to me as soon as\n");
					printf("\tyou can.\n");
					sleep(4);
					printf("\tI'll let you reload to another IOS instead of kicking you out\n");
					printf("\tto the loader...");
					sleep(4);
				} else {
					printf("OK!");
				}
				
				break;
			}
			
			/* B button */
			if (pressed == WPAD_BUTTON_B)
			{
				ret = -1;
				break;
			}
			
			/* HOME/Start button */
			if (pressed == WPAD_BUTTON_HOME) return -1;
		}
	} else {
		ret = -1;
	}
	
	if (ret < 0)
	{
		ret = ios_selectionmenu(249);
		if (ret > 0)
		{
			if (ret != IOS_GetVersion())
			{
				KeepAccessRightsAndReload(ret, true);
			} else {
				printf("\t- IOS reload aborted (IOS%ld is already loaded).", ret);
			}
		} else
		if (ret == 0)
		{
			printf("\t- Proceeding without IOS reload...");
		} else {
			return ret;
		}
	}
	
	return 0;
}
コード例 #30
0
ファイル: main.c プロジェクト: mmodahl/RetroArch
int main(int argc, char *argv[])
{
#ifdef HW_RVL
   IOS_ReloadIOS(IOS_GetVersion());
   L2Enhance();
   gx_init_mem2();
#endif

   fatInitDefault();

#ifdef HAVE_LOGGER
   g_extern.verbose = true;
   logger_init();
   devoptab_list[STD_OUT] = &dotab_stdout;
   devoptab_list[STD_ERR] = &dotab_stdout;
   dotab_stdout.write_r = gx_logger_net;
#elif defined(HAVE_FILE_LOGGER)
   g_extern.verbose = true;
   log_fp = fopen("/retroarch-log.txt", "w");
   devoptab_list[STD_OUT] = &dotab_stdout;
   devoptab_list[STD_ERR] = &dotab_stdout;
   dotab_stdout.write_r = gx_logger_file;
#endif

#ifdef HW_RVL
   lwp_t gx_device_thread;
   gx_devices[GX_DEVICE_SD].interface = &__io_wiisd;
   gx_devices[GX_DEVICE_SD].name = "sd";
   gx_devices[GX_DEVICE_SD].mounted = fatMountSimple(gx_devices[GX_DEVICE_SD].name, gx_devices[GX_DEVICE_SD].interface);
   gx_devices[GX_DEVICE_USB].interface = &__io_usbstorage;
   gx_devices[GX_DEVICE_USB].name = "usb";
   gx_devices[GX_DEVICE_USB].mounted = fatMountSimple(gx_devices[GX_DEVICE_USB].name, gx_devices[GX_DEVICE_USB].interface);
   LWP_MutexInit(&gx_device_mutex, false);
   LWP_CreateThread(&gx_device_thread, gx_devthread, NULL, NULL, 0, 66);
#endif

   get_environment_settings();
   make_directories();
   config_set_defaults();
   input_gx.init();

   video_gx.start();
   driver.video = &video_gx;

   gx_video_t *gx = (gx_video_t*)driver.video_data;
   gx->menu_data = (uint32_t *) menu_framebuf;

   char tmp_path[PATH_MAX];
   const char *extension = default_paths.executable_extension;
   snprintf(tmp_path, sizeof(tmp_path), "%s/", default_paths.core_dir);
   const char *path_prefix = tmp_path; 

   char full_path[1024];
   snprintf(full_path, sizeof(full_path), "%sCORE%s", path_prefix, extension);

   bool find_libretro_file = rarch_configure_libretro_core(full_path, path_prefix, path_prefix, 
   default_paths.config_file, extension);

   rarch_settings_set_default(&input_gx);
   rarch_config_load(default_paths.config_file, path_prefix, extension, find_libretro_file);

   char core_name[64];
   rarch_console_name_from_id(core_name, sizeof(core_name));
   char input_path[1024];
   snprintf(input_path, sizeof(input_path), "%s/%s.cfg", default_paths.input_presets_dir, core_name);
   config_read_keybinds(input_path);

   init_libretro_sym();

   input_gx.post_init();

   menu_init();

   if (argc > 2 && argv[1] != NULL && argv[2] != NULL)
   {
      char rom[PATH_MAX];
      g_console.external_launcher_support = EXTERN_LAUNCHER_CHANNEL;
      snprintf(rom, sizeof(rom), "%s%s", argv[1], argv[2]);
      g_console.zip_extract_mode = ZIP_EXTRACT_TO_CURRENT_DIR_AND_LOAD_FIRST_FILE;
      rarch_console_load_game_wrap(rom, g_console.zip_extract_mode, S_DELAY_1);

      rgui_iterate(rgui, RGUI_ACTION_MESSAGE);
      gx->menu_render = true;
      rarch_render_cached_frame();
      gx->menu_render = false;

      rarch_startup(default_paths.config_file);
   }
   else
   {
      g_console.external_launcher_support = EXTERN_LAUNCHER_SALAMANDER;
   }

begin_loop:
   if(g_console.mode_switch == MODE_EMULATION)
   {
      bool repeat = false;

      input_gx.poll(NULL);

      video_set_aspect_ratio_func(g_console.aspect_ratio_index);

      audio_start_func();

      do{
         repeat = rarch_main_iterate();
      }while(repeat && !g_console.frame_advance_enable);

      audio_stop_func();
   }
   else if(g_console.mode_switch == MODE_MENU)
   {
      menu_loop();

      if (g_console.mode_switch != MODE_EXIT)
         rarch_startup(default_paths.config_file);
   }
   else
      goto begin_shutdown;
   goto begin_loop;

begin_shutdown:
   rarch_config_save(default_paths.config_file);
   config_save_keybinds(input_path);

   if(g_console.emulator_initialized)
      rarch_main_deinit();

   input_gx.free(NULL);

   video_gx.stop();
   menu_free();

#ifdef HAVE_LOGGER
   logger_shutdown();
#elif defined(HAVE_FILE_LOGGER)
   fclose(log_fp);
#endif

   if(g_console.return_to_launcher)
      rarch_console_exec(g_console.launch_app_on_exit);

   exit(0);
}