コード例 #1
0
ファイル: graphics.c プロジェクト: sundargates/qed-examples
void draw_message (void) {
/* Draw the current message in the text area at the screen bottom. */

 int len, width, savefontsize, savecolor;
 float ylow;

 if (disp_type == SCREEN) {
    XClearWindow (display, textarea);
    len = strlen (message);
    width = XTextWidth(font_info[menu_font_size], message, len);

    XSetForeground(display, gc_menus,colors[BLACK]);
    XDrawString(display, textarea, gc_menus, 
       (top_width - MWIDTH - width)/2, 
       (T_AREA_HEIGHT - 4)/2 + (font_info[menu_font_size]->ascent - 
        font_info[menu_font_size]->descent)/2, message, len);
 }

 else {
/* Draw the message in the bottom margin.  Printer's generally can't  *
 * print on the bottom 1/4" (area with y < 18 in PostScript coords.)  */

    savecolor = currentcolor;
    setcolor (BLACK);
    savefontsize = currentfontsize;
    setfontsize (menu_font_size - 2);  /* Smaller OK on paper */
    ylow = ps_bot - 8.; 
    fprintf(ps,"(%s) %.2f %.2f censhow\n",message,(ps_left+ps_right)/2.,
        ylow);
    setcolor (savecolor);
    setfontsize (savefontsize);
 }
}
コード例 #2
0
ファイル: filesel.cpp プロジェクト: feraligatr/snes9xgx
/**
 * Showfile screen
 *
 * Display the file selection to the user
 */
static void
ShowFiles (int offset, int selection)
{
  int i, j;
  char text[MAXPATHLEN];
  int ypos;
  int w;
  
  setfontsize(18);
  clearscreen ();

  ypos = (screenheight - ((PAGESIZE - 1) * 20)) >> 1;

  if (screenheight == 480)
    ypos += 24;
  else
    ypos += 10;


  j = 0;
  for (i = offset; i < (offset + PAGESIZE) && (i < maxfiles); i++)

    {
      if (filelist[i].flags)	// if a dir

        {
          strcpy (text, "[");
          strcat (text, filelist[i].displayname);
          strcat (text, "]");
        }

      else
        strcpy (text, filelist[i].displayname);
      if (j == (selection - offset))

        {

            /*** Highlighted text entry ***/
          for ( w = 0; w < 20; w++ )
                DrawLineFast( 30, 610, ( j * 20 ) + (ypos-16) + w, 0x80, 0x80, 0x80 );

          setfontcolour (0x00, 0x00, 0xe0);
          DrawText (-1, (j * 20) + ypos, text);
          setfontcolour (0x00, 0x00, 0x00);
        }

      else

        {
                        /*** Normal entry ***/
          DrawText (-1, (j * 20) + ypos, text);
        }
      j++;
    }
  showscreen ();

}
コード例 #3
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!");
			}
		}
	}
}
コード例 #4
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!");
	}
}
コード例 #5
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!");
	}

}
コード例 #6
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;
		}
	}
}
コード例 #7
0
ファイル: m3.cpp プロジェクト: guipaiqigong/mapper
void GetPathInstructions(vector<unsigned> Path){
    
    
    
    
    // First, draw a box in the graphics window, on which the path instructions 
    // will be displayed. 
    float tempXCenter = get_visible_world().get_xcenter();
    float tempYCenter = get_visible_world().get_ycenter();
    float BoxLeft = tempXCenter + 0.18 * get_visible_world().get_width();
    float BoxRight = tempXCenter + 0.48 * get_visible_world().get_width();
    float BoxBottom = tempYCenter - 0.48 * get_visible_world().get_height();
    float BoxTop = tempYCenter + 0.12 * get_visible_world().get_height();
    t_bound_box HelpBox(BoxLeft, BoxBottom, BoxRight, BoxTop);
    
    // string intro = "Welcome to Map-2-Go"; 
    
    setcolor(246, 246, 246);

    fillrect(HelpBox);

    
    // Draw the borders of the box. 
    setcolor(200, 200, 200);
    setlinewidth(6);

    t_point border[6];
    border[5].x = BoxRight;
    border[5].y = BoxTop;

    
    // Add depth to the box, making the user feel as if he or she is looking 
    // in 3D perspective at the box. 
    border[2].x = BoxLeft + 0.02 * HelpBox.get_width();
    border[2].y = BoxBottom - 0.02 * HelpBox.get_width();

    border[3].x = BoxRight + 0.02 * HelpBox.get_width();
    border[3].y = BoxBottom - 0.02 * HelpBox.get_width();

    border[4].x = BoxRight + 0.02 * HelpBox.get_width();
    border[4].y = BoxTop - 0.02 * HelpBox.get_width();

    border[0].x = BoxRight;
    border[0].y = BoxBottom;

    border[1].x = BoxLeft;
    border[1].y = BoxBottom;

    fillpoly(border, 6);
    setcolor(20, 20, 20);
    setlinewidth(1);

    drawrect(border[1], border[5]);

    drawline(border[1], border[2]);
    drawline(border[2], border[3]);
    drawline(border[3], border[0]);
    drawline(border[4], border[5]);
    drawline(border[4], border[3]);
    
    // From now on, start displaying the path instructions. 
    
    settextrotation(0); 
    setcolor(20,20,20); 
    setfontsize(12); 
    
    string InstructionLabel = "Path Instructions"; 
    
    // Write "Path Instructions" onto the box in the graphics window. 
    drawtext(HelpBox.left() + 0.5 * HelpBox.get_width(), HelpBox.top() - 0.03 * HelpBox.get_height(), InstructionLabel, HelpBox.get_width(), HelpBox.get_height());

    // Draw a line separating the header above from the instructions later on. 
    setlinewidth(2);
    drawline(HelpBox.left() + 0.05 * HelpBox.get_width(), HelpBox.top() - 0.06 * HelpBox.get_height(), HelpBox.right() - 0.05 * HelpBox.get_width(), HelpBox.top() - 0.06 * HelpBox.get_height()); //splitline 

    settextrotation(0); 
    setcolor(20,20,20); 
    setfontsize(10); 
   
    
    /////////////////////////////////////////////////////////
   
    bool differentStreet; // Bool flag to determine if two street segments belong to different streets. 
    bool needExtraLine; // Bool flag to determine if obtained path instruction has too many characters 
    // to fit in the width of the box. 
    
    int numLines = 0; // This counter determines how far down the box each subsequent instruction will be displayed at. 
    int displayStraightInstruction = 0; // When this integer counter is zero, a path instruction that has "Go Straight" 
    // will be displayed once, but if the subsequent instruction is still "Go Straight", the integer counter will have 
    // incremented by one already - thus preventing the redundant instruction rom being displayed. 
    
    // Traverse the vector of street segments, and access the current and current+1 street segment with each iteration. 
    for (unsigned i = 0; i < Path.size()-1; i++){
        
 
        
        int LeftOrRight = 3; // This integer determines whether to turn right, left, or go straight. It is initialized 
        // to 3 for each iteration, so as not to match any of the above cases initially. 
        
        string tempString; // This will store the path instruction. 
        string tempString2; // This will store the remainder of the path instruction, if the instruction is longer than 
        // 50 characters and will potentially be cut off. 
        
        // The bool flags are initially set to false, for each iteration. 
        differentStreet = false; 
        needExtraLine = false; 
        
        // Obtain street name of the first street segment. 
        string StreetName1 = getStreetName(getStreetSegmentStreetID(Path[i])); 
        // Obtain street name of the second street segment. 
        string StreetName2 = getStreetName(getStreetSegmentStreetID(Path[i+1])); 
        
        // If the second segment's street name is "(unknown)" or " ", then do not go and create 
        // a proper path instruction for it. 
        if ((StreetName2 != "(unknown)") && (StreetName2 != " ")){
            
            // If the second segment's street name WAS ACTUALLY a valid name...
            
            // If the two street names are different, the user will then go onto a different street, so 
            // set the flag to true. 
            if (StreetName2!=StreetName1){
                differentStreet = true; 
            }

            // Call TurnLeftOrRight function to determine which way to turn. 
            // If the returned value is 2, turn right; if the value is 0, turn left; 
            // else if the value is 1, go straight. 
            LeftOrRight = TurnLeftOrRight(Path[i],Path[i+1]); 
            if (LeftOrRight==2){
                tempString.append("Turn right");
                //displayStraightInstruction = 0; // If turning right, automatically enable the instruction to be 
                // displayed again, regardless of whether or not the street name remains the same. 
            } 
            else if (LeftOrRight==1){
                tempString.append("Go straight"); 
            } 
            else if (LeftOrRight==0){
                tempString.append("Turn left"); 
                //displayStraightInstruction = 0; // If turning left, automatically enable the instruction to be 
                // displayed again, regardless of whether or not the street name remains the same. 
            } 

            /////////////////////////////////////////////////////////
            
            // If the user does go onto a different street, add " onto " into the instruction. 
            if (differentStreet){
                tempString.append(" onto "); 
                tempString.append(StreetName2);
                displayStraightInstruction = 0; // If different street names, set the displayStraightInstruction counter 
                // back to zero, so that subsequent "Go Straight" instructions can be displayed at least once. 
            }
            else{ // If the user does NOT go onto a different street, add " along " into the instruction. 
                tempString.append(" along "); 
                tempString.append(StreetName2); 
            }
            
            /////////////////////////////////////////////////////////

            // If the string length is two wide to fit onto the box (max 50 characters), 
            // store the remainder of the string into a second string, and print it on the next line. 
            if (tempString.length()>=50){
                needExtraLine = true; 
                size_t pos = tempString.find_last_of(' ',string::npos); // Find the last occurrence of whitespace in the string.  
                tempString2 = tempString.substr(pos+1,30);
                tempString.erase(pos,string::npos); 
            }
            
            /////////////////////////////////////////////////////////
            
            // The following if case only applies to an instruction if it tells the user to "Go Straight". 
            // For the first occurrence of "Go Straight", the instruction will be displayed, but if it appears 
            // consecutively many times afterwards, the instructions will be disabled by incrementing the 
            // displayStraightInstruction counter. 
            if (displayStraightInstruction < 1){
                // Draw the text onto the box. 
                drawtext(HelpBox.left() + 0.5 * HelpBox.get_width(), HelpBox.top() - (0.10 +0.04*numLines) * HelpBox.get_height(), tempString, HelpBox.get_width(), HelpBox.get_height());
                numLines++; // Increment the numLines counter so set the subsequent line further down the box. 
                if (needExtraLine){ // If an extra line is needed, display this instruction too. 
                    drawtext(HelpBox.left() + 0.5 * HelpBox.get_width(), HelpBox.top() - (0.10 +0.04*numLines) * HelpBox.get_height(), tempString2, HelpBox.get_width(), HelpBox.get_height());
                    numLines++; 
                }
            }
            
            // Before iterating the overall for loop again and checking the next two segments, check if 
            // the instruction this time was 
            if (!differentStreet)
                displayStraightInstruction++; 

        }
        
    }
    
    // After exiting the for loop and displaying all instructions, display this message for users to 
    // know how to clear the screen of any displayed path or path instructions. 
    string endMessage = "Press 'Esc' to clear the path instructions. "; 
    drawtext(HelpBox.left() + 0.5 * HelpBox.get_width(), HelpBox.top() - (0.10 +0.04*numLines + 0.015) * HelpBox.get_height(), endMessage, HelpBox.get_width(), HelpBox.get_height());
    // DisplayPathInstructions(InstructionVector); 
    
} 
コード例 #8
0
ファイル: main.c プロジェクト: LPFaint99/gcmm
/****************************************************************************
* 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;
}
コード例 #9
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;
}
コード例 #10
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;
}