示例#1
0
文件: main.c 项目: LPFaint99/gcmm
/****************************************************************************
* RawRestoreMode
*
* Restore a full raw backup to Memory Card from SD Card
****************************************************************************/
void SD_RawRestoreMode ()
{
	int files;
	int selected;
	char msg[64];
	s32 writen = 0;
	int i;

	clearRightPane();
	DrawText(380,130,"R A W   R e s t o r e");
	DrawText(450,150,"M o d e");
	DrawText(380,154,"_____________________");

	writeStatusBar("Reading files... ", "");
	
	files = SDGetFileList (0);

	setfontsize (14);
	writeStatusBar("Pick a file using UP or DOWN", "Press A to restore to Memory Card ");

	if (!files)
	{
		WaitPrompt ("No raw backups in FAT device to restore !");
	}else
	{
		selected = ShowSelector (0);

		if (cancel)
		{
			WaitPrompt ("Restore action cancelled !");
			return;
		}
		else
		{
		#ifdef FLASHIDCHECK
			//Now imageserial and sramex.flash_id[MEM_CARD] variables should hold the proper information
			for (i=0;i<12;i++){
				if (imageserial[i] != sramex->flash_id[MEM_CARD][i]){
					WaitPrompt ("Card and image flash ID don't match !");
					return;
				}
			}
		#endif
			ShowAction ("Reading from FAT device...");
			if (RestoreRawImage(MEM_CARD, (char*)filelist[selected], &writen) == 1)
			{
				sprintf(msg, "Restore complete! Wrote %d bytes to card",writen);
				WaitPrompt(msg);
			}else
			{
				WaitPrompt("Restore failed!");
			}
		}
	}
}
示例#2
0
文件: mcard.c 项目: suloku/gcmm
u16 FreeBlocks(s32 chn)
{
	s32 err;
	static u8 noinserted = 0;
	u16 freeblocks = 0;
	/*** Try to mount the card ***/
	err = MountCard(chn);
	if (err < 0)
	{
		//We want to allow browsing saves in sd even with no card
		if (err == CARD_ERROR_NOCARD)
		{
			noinserted = 1;
			if(chn) ShowAction("No card inserted in slot B!");
			else ShowAction("No card inserted in slot A!");
			return 0;
		}else
		{
			WaitCardError("CardMount", err);
			return 0;			/*** Unable to mount the card ***/
		}
	}else{
		err = CARD_GetFreeBlocks(chn, &freeblocks);
		if (err < 0)
		{
			CARD_Unmount(chn);
            //We want to allow browsing saves in sd even with no card
            if (err == CARD_ERROR_NOCARD)
            {
				noinserted = 1;
                if(chn) ShowAction("No card inserted in slot B!");
                else ShowAction("No card inserted in slot A!");
                return 0;
            }else
            {
				WaitCardError("FreeBlocks", err);
				return 0;
            }
		}
	}
	if (noinserted)
	{
		if (mode == 300)//Backup mode
			writeStatusBar("Pick a file using UP or DOWN ", "Press A to backup savegame");
		else if (mode == 400)//Restore mode
			writeStatusBar("Pick a file using UP or DOWN", "Press A to restore to Memory Card ");
		else
			writeStatusBar("","");
	}
	CARD_Unmount(chn);
	return freeblocks;
}
示例#3
0
文件: main.c 项目: LPFaint99/gcmm
/****************************************************************************
* BackupModeAllFiles - SD Mode
* Copy all files on the Memory Card to the SD card
****************************************************************************/
void SD_BackupModeAllFiles ()
{
	int memitems;
	int selected = 0;
	int bytestodo;

	char buffer[128];

	clearRightPane();
	DrawText(386,130," B a c k u p   A l l ");
	DrawText(386,134,"_____________________");

	setfontsize (14);
	writeStatusBar("Backing up all files.", "This may take a while.");
	/*** Get the directory listing from the memory card ***/
	memitems = CardGetDirectory (MEM_CARD);

	/*** If it's a blank card, get out of here ***/
	if (!memitems)
	{
		WaitPrompt ("No saved games to backup!");
	}
	else
	{
		for ( selected = 0; selected < memitems; selected++ ) {
			/*** Backup files ***/
			sprintf(buffer, "[%d/%d] Reading from MC slot B", selected+1, memitems);
			ShowAction(buffer);
			bytestodo = CardReadFile(MEM_CARD, selected);
			if (bytestodo)
			{
				sprintf(buffer, "[%d/%d] Saving to FAT device", selected+1, memitems);
				ShowAction(buffer);
				SDSaveMCImage();
			}
			else
			{
				WaitPrompt ("Error reading MC file");
				return;
			}
		}

		WaitPrompt("Full card backup done!");
	}
}
示例#4
0
文件: main.c 项目: LPFaint99/gcmm
/****************************************************************************
* RawBackupMode -SD Mode
*
* Perform backup of full memory card (in raw format) to a SD Card.
****************************************************************************/
void SD_RawBackupMode ()
{
	s32 writen = 0;
	char msg[64];
	clearRightPane();

	DrawText(394,224,"___________________");	
	DrawText(394,248,"R A W   B a c k u p");
	DrawText(454,268,"M o d e");
	DrawText(394,272,"___________________");
	
	setfontsize (14);	
	writeStatusBar("Reading memory card... ", "");

	if (BackupRawImage(MEM_CARD, &writen) == 1)
	{
		sprintf(msg, "Backup complete! Wrote %d bytes to FAT device",writen);
		WaitPrompt(msg);
	}else{

		WaitPrompt("Backup failed!");
	}

}
示例#5
0
文件: mcard.c 项目: suloku/gcmm
void MC_DeleteMode(int slot)
{
	int memitems, err;
	int selected = 0;
	int erase;
	
	displaypath = 0;
	
	clearRightPane();
	DrawText(386,130,"D e l e t e   M o d e");
	DrawText(386,134,"_____________________");
	char msg[1024];

	writeStatusBar("Reading memory card... ", "");
	/*** Get the directory listing from the memory card ***/
	memitems = CardGetDirectory (slot);

	setfontsize (14);
	writeStatusBar("Choose a file with UP button or DOWN button ", "Press A button to delete ") ;

	/*** If it's a blank card, get out of here ***/
	if (!memitems)
	{
		WaitPrompt ("No saved games to delete !");
	}
	else
	{
		while(1)
		{
			// TODO: implement showselector
			selected = ShowSelector(1);
			if (cancel)
			{
				WaitPrompt ("Delete action cancelled !");
				return;
			}

			//0 = Z or 2 was pressed -> delete the file
			erase = WaitPromptChoiceAZ("Are you sure you want to delete the file?", "Delete", "Cancel");
			if (!erase)
			{
				// selected = 1;

				/*** Delete the file ***/
				sprintf(msg, "Deleting \"%s\"", CardList[selected].filename);
				writeStatusBar(msg,"");
				//WaitPrompt(msg);
				
				/*** Try to mount the card ***/
				err = MountCard(slot);
				if (err < 0)
				{
					WaitCardError("MCDel Mount", err);
					return; /*** Unable to mount the card ***/
				}

				/*** Initialise for this company & gamecode ***/
				CARD_SetCompany(CardList[selected].company);
				CARD_SetGamecode(CardList[selected].gamecode);

				err = CARD_Delete(slot, (char *) &CardList[selected].filename);
				if (err < 0)
				{
					WaitCardError("MCDel", err);
				}
				else
				{
					WaitPrompt("Delete complete");
				}

				CARD_Unmount(slot);
				return;
			}
			offsetchanged = true;
		}
	}
}
示例#6
0
文件: main.c 项目: LPFaint99/gcmm
/****************************************************************************
* RestoreMode
*
* Restore a file to Memory Card from SD Card
****************************************************************************/
void SD_RestoreMode ()
{
	int files;
	int selected;
	char buffer[256], text[64];

	clearRightPane();
	DrawText(380,130,"R e s t o r e  M o d e");
	DrawText(380,134,"______________________");
	writeStatusBar("Reading files... ", "");

	files = SDGetFileList (1);

	setfontsize (14);
	writeStatusBar("Pick a file using UP or DOWN", "Press A to restore to Memory Card ") ;
#ifdef HW_RVL
	DrawText(40, 60, "Press R/1 to restore ALL savegames");
#else
	DrawText(40, 60, "Press R to restore ALL savegames");
#endif

	if (!files)
	{
		WaitPrompt ("No saved games in FAT device to restore !");
	}
    else
	{
		selected = ShowSelector (1);

		if (cancel)
		{
			WaitPrompt ("Restore action cancelled !");
			return;
		}
        else if (doall)
        {
            doall = WaitPromptChoice("Are you sure you want to restore -ALL- files?", "Yes", "No");
            if (!doall)
            {
                //Restore All files
                for ( selected = 0; selected < files; selected++ ) {
                    /*** Restore files ***/
                    sprintf(buffer, "[%d/%d] Reading from FAT device", selected+1, files);
                    ShowAction(buffer);
                    if (SDLoadMCImage ((char*)filelist[selected]))
                    {
                        sprintf(buffer, "[%d/%d] Saving to MC slot %s", selected+1, files, (MEM_CARD) ? "B" : "A");
                        ShowAction(buffer);
                        if (!CardWriteFile (MEM_CARD))
                        {
                            strncpy(text, (char*)filelist[selected], 32);
                            text[32]='\0';
                            sprintf(buffer, "Error during restore (%s). Continue?", text);
                            doall = WaitPromptChoice(buffer, "Yes", "No");
                            if (doall)
                            {
                                WaitPrompt ("Restore action cancelled due to error!");
                                return;
                            }
                        }
                    }
                    else
                    {
                        WaitPrompt ("Error reading image");
                        return;
                    }
                }

                WaitPrompt("Full card restore done!");
                return;
            }
        }
		else
		{
			ShowAction ("Reading from FAT device");
			if (SDLoadMCImage ((char*)filelist[selected]))
			{
				ShowAction ("Updating Memory Card");
				if (CardWriteFile (MEM_CARD))
				{
					WaitPrompt ("Restore Complete");
					return;
				}
				else
				{
					WaitPrompt ("Error during restore");
					return;
				}
			}
			else
			{
				WaitPrompt ("Error reading image");
				return;
			}
		}

	}
    return;
}
示例#7
0
文件: main.c 项目: LPFaint99/gcmm
/****************************************************************************
* BackupMode -SD Mode
*
* Perform backup of a memory card file to a SD Card.
****************************************************************************/
void SD_BackupMode ()
{
	int memitems;
	int selected = 0;
	int bytestodo;
	char buffer[256], text[64];

	clearRightPane();
	DrawText(386,130,"B a c k u p   M o d e");
	DrawText(386,134,"_____________________");
	writeStatusBar("Reading memory card... ", "");
	/*** Get the directory listing from the memory card ***/
	memitems = CardGetDirectory (MEM_CARD);

	setfontsize (14);
	writeStatusBar("Pick a file using UP or DOWN ", "Press A to backup savegame") ;
#ifdef HW_RVL
	DrawText(40, 60, "Press R/1 to backup ALL savegames");
#else
	DrawText(40, 60, "Press R to backup ALL savegames");
#endif

	/*** If it's a blank card, get out of here ***/
	if (!memitems)
	{
		WaitPrompt ("No saved games to backup!");
	}
	else
	{
		selected = ShowSelector (1);
		if (cancel)
		{
			WaitPrompt ("Backup action cancelled!");
		}
		else if(doall)
		{
			doall = WaitPromptChoice("Are you sure you want to backup all files?", "No", "Yes");
			if (doall)
			{
				//Backup All files
				for ( selected = 0; selected < memitems; selected++ ) {
					/*** Backup files ***/
					sprintf(buffer, "[%d/%d] Reading from MC slot %s", selected+1, memitems, (MEM_CARD) ? "B" : "A");
					ShowAction(buffer);
					bytestodo = CardReadFile(MEM_CARD, selected);
					if (bytestodo)
					{
						sprintf(buffer, "[%d/%d] Saving to FAT device", selected+1, memitems);
						ShowAction(buffer);
						if (!SDSaveMCImage())
						{
							strncpy(text, (char*)filelist[selected], 32);
							text[32]='\0';
							sprintf(buffer, "Error during backup (%s). Continue?", text);
							doall = WaitPromptChoice(buffer, "Yes", "No");
							if (doall)
							{
								WaitPrompt ("Backup action cancelled due to error!");
								return;
							}
						}

					}
					else
					{
						WaitPrompt ("Error reading MC file");
						return;
					}
				}

				WaitPrompt("Full card backup done!");
				return;
			}

		}
		else
		{
			/*** Backup the file ***/
			ShowAction ("Reading File From MC SLOT B");
			bytestodo = CardReadFile (MEM_CARD, selected);
			if (bytestodo)
			{
				ShowAction ("Saving to FAT device");
				if (SDSaveMCImage())
				{
					WaitPrompt ("Backup complete");
					return;
				}
				else
				{
					WaitPrompt ("Backup failed");
					return;
				}
			}
			else
			{
				WaitPrompt ("Error reading MC file");
				return;
			}

		}
	}
    return;
}
示例#8
0
void vwriteStatusBarf(const char format[], va_list ap)
{
	vsprintf(fileBuffer, format, ap);
	writeStatusBar(fileBuffer);
}