Example #1
0
static int initFAT(){

	int slotagecko = 0;
	int i =0;
	s32 ret, memsize, sectsize;


	for(i=0;i<10;i++){
		ret = CARD_ProbeEx(CARD_SLOTA, &memsize, &sectsize);
		//printf("Ret: %d", ret);
		if (ret == CARD_ERROR_WRONGDEVICE){
			slotagecko = 1;
			break;
		}
	}

	if (slotagecko)
	{//Memcard in SLOT B, SD gecko in SLOT A
		//This will ensure SD gecko is recognized if inserted or changed to another slot after GCMM is executed
		for(i=0;i<10;i++){
			ret = CARD_Probe(CARD_SLOTA);
			if (ret == CARD_ERROR_WRONGDEVICE)
				//printf ("SDGecko detected...\n\n");
				break;
		}
		__io_gcsda.startup();
		if (!__io_gcsda.isInserted())
		{
			//printf ("No SD Gecko inserted! Using embedded config.\n\n");
			return 0;
		}
		if (!fatMountSimple ("fat", &__io_gcsda))
		{
			//printf("Error Mounting SD fat! Using embedded config.\n\n");
			return 0;
		}
	}else //Memcard in SLOT A, SD gecko in SLOT B
	{
		//This will ensure SD gecko is recognized if inserted or changed to another slot after GCMM is executed
		for(i=0;i<10;i++){
			ret = CARD_Probe(CARD_SLOTB);
			if (ret == CARD_ERROR_WRONGDEVICE)
				break;
		}	
		__io_gcsdb.startup();
		if (!__io_gcsdb.isInserted())
		{
			//printf ("No SD Gecko inserted! Using default config.\n\n");
			return 0;
		}
		if (!fatMountSimple ("fat", &__io_gcsdb))
		{
			//printf("Error Mounting SD fat! Using default config.\n\n");
			return 0;
		}
	}

	return 1;
}
Example #2
0
/****************************************************************************
* Main
****************************************************************************/
int main ()
{

	int have_sd = 0;


#ifdef HW_DOL
	int *psoid = (int *) 0x80001800;
	void (*PSOReload) () = (void (*)()) 0x80001800;
#endif

	Initialise ();	/*** Start video ***/
	FT_Init ();		/*** Start FreeType ***/
	ClearScreen();
	ShowScreen();
#ifdef HW_RVL
	initialise_power();
	have_sd = initFAT(WaitPromptChoice ("Use internal SD or FAT32 USB device?", "USB", "SD"));
#else
	//Returns 1 (memory card in slot B, sd gecko in slot A) if A button was pressed and 0 if B button was pressed
	MEM_CARD = WaitPromptChoice ("Please select the slot where SD Gecko is inserted", "SLOT B", "SLOT A");
	have_sd = initFAT(MEM_CARD);
#endif


	for (;;)
	{
		/*** Select Mode ***/
		ClearScreen();
		setfontsize (FONT_SIZE);
		freecardbuf();
		cancel = 0;/******a global value to track action aborted by user pressing button B********/
		doall = 0;
		mode = SelectMode ();
#ifdef HW_RVL
		if ((mode != 500 ) && (mode != 100) && (mode != 600)){
			if (WaitPromptChoice ("Please select a memory card slot", "Slot B", "Slot A") == 1)
			{
				MEM_CARD = CARD_SLOTA;
			}else
			{
				MEM_CARD = CARD_SLOTB;
			}
		}
#endif
		/*** Mode == 100 for backup, 200 for restore ***/
		switch (mode)
		{
		case 100 : //User pressed A so keep looping
			//SMB_BackupMode();
			//WaitPrompt ("Inactive");
			break;
		case 200 : //User wants to delete
			MC_DeleteMode(MEM_CARD);
			break;
		case 300 : //User wants to backup
			if (have_sd) SD_BackupMode();
			else WaitPrompt("Reboot aplication with a FAT device");
			break;
		case 400 : //User wants to restore
			if (have_sd) SD_RestoreMode();
			else WaitPrompt("Reboot aplication with a FAT device");
			break;
		case 500 ://exit
			ShowAction ("Exiting...");
			deinitFAT();
#ifdef HW_RVL
			//if there's a loader stub load it, if not return to wii menu.
			if (!!*(u32*)0x80001800) exit(1);
			else SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
#else
			if (psoid[0] == PSOSDLOADID) PSOReload ();
			else SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
#endif
			break; //PSO_Reload
		case 600 : //User wants to backup full card
			/*
			if (have_sd) SD_BackupModeAllFiles();
			else WaitPrompt("Reboot aplication with an SD card");
			*/
			break;
		case 700 : //Raw backup mode
			if (have_sd)
			{
				SD_RawBackupMode();
			}else
			{
				WaitPrompt("Reboot aplication with a FAT device");
			}
			break;
		case 800 : //Raw restore mode
			//These two lines are a work around for the second call of CARD_Probe to detect a newly inserted memory card
			CARD_Probe(MEM_CARD);
			VIDEO_WaitVSync ();
			if (CARD_Probe(MEM_CARD) > 0)
			{
				if (have_sd) SD_RawRestoreMode();
				else WaitPrompt("Reboot aplication with a FAT device");

			}else if (MEM_CARD)
			{
				WaitPrompt("Please insert a memory card in slot B");
			}else
			{
				WaitPrompt("Please insert a memory card in slot A");
			}
			break;
		case 900 : //Format card mode
			//These two lines are a work around for the second call of CARD_Probe to detect a newly inserted memory card
			CARD_Probe(MEM_CARD);
			VIDEO_WaitVSync ();
			if (CARD_Probe(MEM_CARD) > 0)
			{
				clearRightPane();
				DrawText(390,224,"____________________");
				DrawText(390,248,"F o r m a t  C a r d");
				DrawText(460,268,"M o d e");
				DrawText(390,272,"____________________");				
				MC_FormatMode(MEM_CARD);

			}else if (MEM_CARD)
			{
				WaitPrompt("Please insert a memory card in slot B");
			}else
			{
				WaitPrompt("Please insert a memory card in slot A");
			}
			break;
		}

		offsetchanged = true;
	}
	while (1);
	return 0;
}
Example #3
0
// 1 for Internal SD, 0 for fat32 usb
static int initFAT(int device)
{
	ShowAction("Mounting device...");
#ifdef	HW_RVL
	if (device){//try SD card first
		__io_wiisd.startup();
		if (!__io_wiisd.isInserted())
		{
			ShowAction ("No SD card inserted! Trying USB storage.");
			sleep(2);
				__io_usbstorage.startup();
			if (!__io_usbstorage.isInserted())
			{
				WaitPrompt ("No USB device inserted either!");
				return 0;
			}
			else if (!fatMountSimple ("fat", &__io_usbstorage)){
				WaitPrompt("Error Mounting USB fat!");
				return 0;
			}
			return 1;//usb mounted
		}
		if (!fatMountSimple ("fat", &__io_wiisd))
		{
			WaitPrompt("Error Mounting SD fat!");
			return 0;
		}
	}else if (!device)//try USB first
	{
		__io_usbstorage.startup();
		if (!__io_usbstorage.isInserted())
		{
			ShowAction ("No usb device inserted! Trying internal SD.");
			sleep(2);
				__io_wiisd.startup();
			if (!__io_wiisd.isInserted())
			{
				WaitPrompt ("No SD card inserted either!");
				return 0;
			}
			else if (!fatMountSimple ("fat", &__io_wiisd)){
				WaitPrompt("Error Mounting SD fat!");
				return 0;
			}
			return 1;//SD mounted
		}
		if (!fatMountSimple ("fat", &__io_usbstorage))
		{
			WaitPrompt("Error Mounting USB fat!");
			return 0;
		}
	}
#else
	int i =0;
	s32 ret;
	if (device)
	{//Memcard in SLOT B, SD gecko in SLOT A
		//This will ensure SD gecko is recognized if inserted or changed to another slot after GCMM is executed
		for(i=0;i<10;i++){
			ret = CARD_Probe(CARD_SLOTA);
			if (ret == CARD_ERROR_WRONGDEVICE)
				break;
		}
		__io_gcsda.startup();
		if (!__io_gcsda.isInserted())
		{
			WaitPrompt ("No SD Gecko inserted! Insert it in slot A and restart");
			return 0;
		}
		if (!fatMountSimple ("fat", &__io_gcsda))
		{
			WaitPrompt("Error Mounting SD fat!");
			return 0;
		}
	}else //Memcard in SLOT A, SD gecko in SLOT B
	{
		//This will ensure SD gecko is recognized if inserted or changed to another slot after GCMM is executed
		for(i=0;i<10;i++){
			ret = CARD_Probe(CARD_SLOTB);
			if (ret == CARD_ERROR_WRONGDEVICE)
				break;
		}	
		__io_gcsdb.startup();
		if (!__io_gcsdb.isInserted())
		{
			WaitPrompt ("No SD Gecko inserted! Insert it in slot B and restart");
			return 0;
		}
		if (!fatMountSimple ("fat", &__io_gcsdb))
		{
			WaitPrompt("Error Mounting SD fat!");
			return 0;
		}
	}
#endif
	return 1;
}
Example #4
0
static bool IsGCCardAvailable (void)
	{
	CARD_Init (NULL, NULL);
    return (CARD_Probe (CARD_SLOTA) <= 0) ? false : true;
	}