Ejemplo n.º 1
0
Archivo: mcard.c Proyecto: 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;
}
Ejemplo n.º 2
0
void SD_Manage(int mode, int slot){

	sd_file *handle;
	char path[1024];
	char msg[128];
	int offset = 0;
	int filesize = 0;
	int len = 0;
	
	//sprintf (filepath, "dev%d:\\%s\\%08x.fcs", slot, SAVEDIR, iNESGameCRC32);
	sprintf (path, "dev%d:\\%08x.fcs", slot, iNESGameCRC32);
	
	if (mode == 0) ShowAction ("Saving STATE to SD...");
	else ShowAction ("Loading STATE from SD...");
	
	handle = (mode == 0) ? SDCARD_OpenFile (path, "wb") : SDCARD_OpenFile (path, "rb");
	
	if (handle == NULL){        
        sprintf(msg, "Couldn't open %s", path);
        WaitPrompt(msg);
        return;
    }
	
	if (mode == 0){ //Save
		filesize = GCFCEUSS_Save();

		len = SDCARD_WriteFile (handle, statebuffer, filesize);
		SDCARD_CloseFile (handle);

		if (len != filesize){
			sprintf (msg, "Error writing %s", path);
			WaitPrompt (msg);
			return;			
		}

		sprintf (msg, "Saved %d bytes successfully", filesize);
		WaitPrompt (msg);
	}
	else{ //Load
	
		memopen();
		while ((len = SDCARD_ReadFile (handle, &statebuffer[offset], 1024)) > 0) offset += len;
		SDCARD_CloseFile (handle);
		
		sprintf (msg, "Loaded %d bytes successfully", offset);
		WaitPrompt(msg);

		GCFCEUSS_Load();
		return ;
	}
}
Ejemplo n.º 3
0
/****************************************************************************
* autoSaveMethod()
* Auto-determines and sets the save device
* Returns device set
****************************************************************************/
int autoSaveMethod(bool silent)
{
	if(!silent)
		ShowAction ("Attempting to determine save device...");

	int device = DEVICE_AUTO;

	if(ChangeInterface(DEVICE_SD, SILENT))
		device = DEVICE_SD;
	else if(ChangeInterface(DEVICE_USB, SILENT))
		device = DEVICE_USB;
	else if(ChangeInterface(DEVICE_SD_SLOTA, SILENT))
		device = DEVICE_SD_SLOTA;
	else if(ChangeInterface(DEVICE_SD_SLOTB, SILENT))
		device = DEVICE_SD_SLOTB;
	else if(ChangeInterface(DEVICE_SMB, SILENT))
		device = DEVICE_SMB;
	else if(!silent)
		ErrorPrompt("Unable to locate a save device!");

	if(GCSettings.SaveMethod == DEVICE_AUTO)
		GCSettings.SaveMethod = device; // save device found for later use

	CancelAction();
	return device;
}
Ejemplo n.º 4
0
/****************************************************************************
 * Load Preferences from SD Card
 ****************************************************************************/
void
LoadPrefsFromSD (int slot, bool silent)
{
    char filepath[1024];
    int offset = 0;
    
    ShowAction ((char*) "Loading prefs from SD...");
    
#ifdef SDUSE_LFN
    sprintf (filepath, "%s/%s/%s", rootSDdir, SNESSAVEDIR, PREFS_FILE_NAME);
#else
    sprintf (filepath, "%s/%s/%s", rootSDdir, SNESSAVEDIR, PREFS_FILE_NAME);
#endif
    
    offset = LoadBufferFromSD (filepath, silent);
    
    if (offset > 0)
    {
        decodePrefsData ();
        if ( !silent )
        {
            sprintf (filepath, "Loaded %d bytes", offset);
            WaitPrompt(filepath);
        }
    }
}
Ejemplo n.º 5
0
/****************************************************************************
 * Save SRAM to SD Card
 ****************************************************************************/
void SaveSRAMToSD (int slot, bool silent)
{
    char filepath[1024];
    int datasize;
    int offset;

    ShowAction ((char*) "Saving SRAM to SD...");
    
#ifdef SDUSE_LFN
    sprintf (filepath, "%s/%s/%s.srm", rootSDdir, SNESSAVEDIR, Memory.ROMName);
#else
    sprintf (filepath, "%s/SNESSAVE/%08x.srm", rootSDdir, Memory.ROMCRC32);
#endif
    
    datasize = prepareEXPORTsavedata ();

    if ( datasize )
    {
        offset = SaveBufferToSD (filepath, datasize, silent);
        
        if ( (offset > 0) && (!silent) )
        {
            sprintf (filepath, "Wrote %d bytes", offset);
            WaitPrompt (filepath);
        }
    }
}
Ejemplo n.º 6
0
void LandscapeEditorBase::Toggle()
{
    if(ELE_ACTIVE == state)
    {
        state = ELE_CLOSING;
        
        SaveTexture();
    }
    else if(ELE_NONE == state)
    {
        touchID = INVALID_TOUCH_ID;
        
        SafeRelease(heightmapNode);
        heightmapNode = new HeightmapNode(workingScene, workingLandscape);
        workingScene->AddNode(heightmapNode);
                
        state = ELE_ACTIVE;
        
        SetTool(toolsPanel->CurrentTool());
        
        if(delegate)
        {
            delegate->LandscapeEditorStarted();
        }
        
        ShowAction();
    }
}
Ejemplo n.º 7
0
bool SavePalettes(bool silent)
{
	char filepath[1024];
	int datasize;
	int offset = 0;

	if(prefpath[0] == 0)
		return false;

	sprintf(filepath, "%s/%s", prefpath, PAL_FILE_NAME);

	// Now create the XML palette file

	if (!silent)
		ShowAction("Saving palette...");

	AllocSaveBuffer();
	datasize = preparePalData(palettes, loadedPalettes);

	offset = SaveFile(filepath, datasize, silent);

	FreeSaveBuffer();

	CancelAction();

	if (offset > 0)
	{
		if (!silent)
			InfoPrompt("Palette saved");
		return true;
	}
	return false;
}
void LandscapeEditorBase::Toggle()
{
    if(ELE_ACTIVE == state)
    {
        state = ELE_CLOSING;
        
        SaveTexture();
    }
    else if(ELE_NONE == state)
    {
        touchID = INVALID_TOUCH_ID;
        
        state = ELE_ACTIVE;
        
        SetTool(toolsPanel->CurrentTool());
        
        if(delegate)
        {
            delegate->LandscapeEditorStarted();
        }
        
        ShowAction();
        
        RecreateHeightmapNode();
    }
}
Ejemplo n.º 9
0
bool InitializeNetwork(bool silent)
{
	ShowAction ((char*) "Initializing network...");
	s32 result;

	while ((result = net_init()) == -EAGAIN);

	if (result >= 0)
	{
		char myIP[16];

		if (if_config(myIP, NULL, NULL, true) < 0)
		{
			if(!silent)
				WaitPrompt((char*) "Error reading IP address.");
			return false;
		}
		else
		{
			return true;
		}
	}

	if(!silent)
		WaitPrompt((char*) "Unable to initialize network.");
	return false;
}
Ejemplo n.º 10
0
/****************************************************************************
* autoLoadMethod()
* Auto-determines and sets the load device
* Returns device set
****************************************************************************/
int autoLoadMethod()
{
	ShowAction ("Attempting to determine load device...");

	int device = DEVICE_AUTO;

	if(ChangeInterface(DEVICE_SD, SILENT))
		device = DEVICE_SD;
	else if(ChangeInterface(DEVICE_USB, SILENT))
		device = DEVICE_USB;
	else if(ChangeInterface(DEVICE_SD_SLOTA, SILENT))
		device = DEVICE_SD_SLOTA;
	else if(ChangeInterface(DEVICE_SD_SLOTB, SILENT))
		device = DEVICE_SD_SLOTB;
	else if(ChangeInterface(DEVICE_DVD, SILENT))
		device = DEVICE_DVD;
	else if(ChangeInterface(DEVICE_SMB, SILENT))
		device = DEVICE_SMB;
	else
		ErrorPrompt("Unable to locate a load device!");

	if(GCSettings.LoadMethod == DEVICE_AUTO)
		GCSettings.LoadMethod = device; // save device found for later use
	CancelAction();
	return device;
}
Ejemplo n.º 11
0
bool ActionBar::onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *unused_event)
{
	//log("ActionBar touch began:(%d,%d)", touch->getLocation().x, touch->getLocation().y);
	bool bHitted = false;
	if (isVisible())
	{
		Vec2 pos = convertTouchToNodeSpace(touch);
		Size sz = getContentSize();
		Rect rc(0, 0, sz.width, sz.height);
		if (rc.containsPoint(pos))
		{
			bHitted = true;
		}

		if (m_pMenuItemSlideRaise->isVisible())
		{
			rc.size = m_pSpriteBgSlider->getContentSize();
			rc.origin = m_pSpriteBgSlider->getPosition() - Vec2(rc.size.width / 2, rc.size.height / 2);
			if (rc.containsPoint(pos))
			{
				bHitted = true;
			}
		}

		if (!bHitted)
		{
			if (m_pMenuItemSlideRaise->isVisible())
			{
				ShowAction(true);
			}
		}
	}

	return false;
}
Ejemplo n.º 12
0
/****************************************************************************
 * Load SRAM From SD Card
 ****************************************************************************/
void
LoadSRAMFromSD (int slot, bool silent)
{
    char filepath[1024];
    int offset = 0;
    
    ShowAction ((char*) "Loading SRAM from SD...");
    
#ifdef SDUSE_LFN
    sprintf (filepath, "%s/%s/%s.srm", rootSDdir, SNESSAVEDIR, Memory.ROMName);
#else
    sprintf (filepath, "%s/%s/%08x.srm", rootSDdir, SNESSAVEDIR, Memory.ROMCRC32);
#endif
    
    offset = LoadBufferFromSD (filepath, silent);
    
    if (offset > 0)
    {
        decodesavedata (offset);
        if ( !silent )
        {
            sprintf (filepath, "Loaded %d bytes", offset);
            WaitPrompt(filepath);
        }
        S9xSoftReset();
    }
}
Ejemplo n.º 13
0
void InitializeNetwork(bool silent)
{
	// stop if we're already initialized, or if auto-init has failed before
	// in which case, manual initialization is required
	if(networkInit || !autoNetworkInit)
		return;

	if(!silent)
		ShowAction ("Initializing network...");

	char ip[16];
	s32 initResult = if_config(ip, NULL, NULL, true);

	if(initResult == 0)
	{
		networkInit = true;
	}
	else
	{
		// do not automatically attempt a reconnection
		autoNetworkInit = false;

		if(!silent)
		{
			char msg[150];
			sprintf(msg, "Unable to initialize network (Error #: %i)", initResult);
			WaitPrompt(msg);
		}
	}
}
Ejemplo n.º 14
0
bool UpdateCheck()
{
	bool ret = 0;

	// we only check for an update if we have internet
	if(!networkInit)
		return 0;

	ShowAction("Checking for updates...");
	class twitCurl twitterObj;
	std::string tmp("392315277"); // @WiiTwiity userid
	if( twitterObj.userGet(tmp, 1) ){
		tmp.clear();
		twitterObj.getLastWebResponse(tmp);
	}else{
		CancelAction();
		return 0;
	}
	mxml_node_t *xml;
	mxml_node_t *item;

	xml = mxmlLoadString(NULL, tmp.c_str(), MXML_OPAQUE_CALLBACK);

	if(!xml){
		CancelAction();
		return 0;
	}

	item = mxmlFindElement(xml, xml, "text", NULL, NULL, MXML_DESCEND);
	if(item) // Tweet found!
	{
		const char * tweet = item->child->value.opaque;
		int verMajor, verMinor, verPoint;

		if(sscanf(tweet, "WiiTweet %d.%d.%d released! SHA-1: %s", &verMajor, &verMinor, &verPoint, updateHash) == 4)
		{
			int curMajor = APPVERSION[0] - '0';
			int curMinor = APPVERSION[2] - '0';
			int curPoint = APPVERSION[4] - '0';

			// check that the versioning is valid and is a newer version
			if((verMajor >= 0 && verMajor <= 9 &&
				verMinor >= 0 && verMinor <= 9 &&
				verPoint >= 0 && verPoint <= 9) &&
				(verMajor > curMajor ||
				(verMajor == curMajor && verMinor > curMinor) ||
				(verMajor == curMajor && verMinor == curMinor && verPoint > curPoint)))
			{
				snprintf(updateURL, 128, "http://wiitweet.googlecode.com/files/wiitweet%%20%d.%d.%d.zip", verMajor, verMinor, verPoint);
				ret = 1;
			}
		}
	}

	mxmlDelete(xml);
	CancelAction();
	return ret;
}
Ejemplo n.º 15
0
/****************************************************************************
* 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!");
	}
}
Ejemplo n.º 16
0
bool SaveRAM (int method, bool silent)
{
	ShowAction ((char*) "Saving...");

	if(method == METHOD_AUTO)
		method = autoSaveMethod();

	bool retval = false;
	char filepath[1024];
	int datasize = 0;
	int offset = 0;

	// save game save to savebuffer
	if(nesGameType == 1)
		datasize = NGCFCEU_GameSave(&iNESCart, 0);
	else if(nesGameType == 2)
		datasize = NGCFCEU_GameSave(&UNIFCart, 0);

	if ( datasize )
	{
		if(method == METHOD_SD || method == METHOD_USB)
		{
			if(ChangeFATInterface(method, NOTSILENT))
			{
				sprintf (filepath, "%s/%s/%s.sav", ROOTFATDIR, GCSettings.SaveFolder, romFilename);
				offset = SaveBufferToFAT (filepath, datasize, silent);
			}
		}
		else if(method == METHOD_SMB)
		{
			sprintf (filepath, "%s/%s.sav", GCSettings.SaveFolder, romFilename);
			offset = SaveBufferToSMB (filepath, datasize, silent);
		}
		else if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
		{
			sprintf (filepath, "%08x.sav", iNESGameCRC32);

			if(method == METHOD_MC_SLOTA)
				offset = SaveBufferToMC (savebuffer, CARD_SLOTA, filepath, datasize, silent);
			else
				offset = SaveBufferToMC (savebuffer, CARD_SLOTB, filepath, datasize, silent);
		}

		if (offset > 0)
		{
			if ( !silent )
				WaitPrompt((char *)"Save successful");
			retval = true;
		}
	}
	else
	{
		if ( !silent )
			WaitPrompt((char *)"No data to save!");
	}
	return retval;
}
Ejemplo n.º 17
0
/****************************************************************************
* 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!");
			}
		}
	}
}
Ejemplo n.º 18
0
void ActionBar::onMenuItemSelected(cocos2d::Ref *pItem,cocos2d::ui::TouchEventType type)
{
	if (type == TouchEventType::TOUCH_EVENT_ENDED)
	{
		if (pItem == m_pMenuItemRaise)
		{
			ShowAction(false);
		}
	}

}
Ejemplo n.º 19
0
Archivo: mcard.c Proyecto: suloku/gcmm
void MC_FormatMode(s32 slot)
{
	int erase = 1;
	int err;

	//0 = B wass pressed -> ask again
	if (!slot){
		erase = WaitPromptChoice("Are you sure you want to format memory card in slot A?", "Format", "Cancel");
	}else{
		erase = WaitPromptChoice("Are you sure you want to format memory card in slot B?", "Format", "Cancel");
	}

	if (!erase){
		if (!slot){
			erase = WaitPromptChoiceAZ("All contents of memory card in slot A will be erased!", "Format", "Cancel");
		}else{
			erase = WaitPromptChoiceAZ("All contents of memory card in slot B will be erased!", "Format", "Cancel");
		}

		if (!erase)
		{

			/*** Try to mount the card ***/
			err = MountCard(slot);
			if (err < 0)
			{
				WaitCardError("MCFormat Mount", err);
				return; /*** Unable to mount the card ***/
			}
			ShowAction("Formatting card...");
			/*** Format the card ***/
			CARD_Format(slot);
			usleep(1000*1000);

			/*** Try to mount the card ***/
			err = MountCard(slot);
			if (err < 0)
			{
				WaitCardError("MCFormat Mount", err);
				return; /*** Unable to mount the card ***/
			}else
			{
				WaitPrompt("Format completed successfully");
			}

				CARD_Unmount(slot);
				return;
		}
	}

	WaitPrompt("Format operation cancelled");
	return;
}
Ejemplo n.º 20
0
bool
ConnectShare (bool silent)
{
	if(!InitializeNetwork(silent))
		return false;

	if(networkShareInit)
		return true;

	int retry = 1;
	int chkS = (strlen(GCSettings.smbshare) > 0) ? 0:1;
	int chkI = (strlen(GCSettings.smbip) > 0) ? 0:1;

	// check that all parameters have been set
	if(chkS + chkI > 0)
	{
		if(!silent)
		{
			char msg[50];
			char msg2[100];
			if(chkS + chkI > 1) // more than one thing is wrong
				sprintf(msg, "Check settings.xml.");
			else if(chkS)
				sprintf(msg, "Share name is blank.");
			else if(chkI)
				sprintf(msg, "Share IP is blank.");

			sprintf(msg2, "Invalid network settings - %s", msg);
			ErrorPrompt(msg2);
		}
		return false;
	}

	while(retry)
	{
		if(!silent)
			ShowAction ("Connecting to network share...");
		
		if(smbInit(GCSettings.smbuser, GCSettings.smbpwd, GCSettings.smbshare, GCSettings.smbip))
			networkShareInit = true;

		if(networkShareInit || silent)
			break;

		retry = ErrorPromptRetry("Failed to connect to network share.");
	}

	if(!silent)
		CancelAction();

	return networkShareInit;
}
Ejemplo n.º 21
0
bool LoadRAM (int method, bool silent)
{
	ShowAction ((char*) "Loading...");

	if(method == METHOD_AUTO)
		method = autoSaveMethod(); // we use 'Save' because we need R/W

	char filepath[1024];
	int offset = 0;

	if(method == METHOD_SD || method == METHOD_USB)
	{
		if(ChangeFATInterface(method, NOTSILENT))
		{
			sprintf (filepath, "%s/%s/%s.sav", ROOTFATDIR, GCSettings.SaveFolder, romFilename);
			offset = LoadSaveBufferFromFAT (filepath, silent);
		}
	}
	else if(method == METHOD_SMB)
	{
		sprintf (filepath, "%s/%s.sav", GCSettings.SaveFolder, romFilename);
		offset = LoadSaveBufferFromSMB (filepath, silent);
	}
	else if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
	{
		sprintf (filepath, "%08x.sav", iNESGameCRC32);

		if(method == METHOD_MC_SLOTA)
			offset = LoadBufferFromMC (savebuffer, CARD_SLOTA, filepath, silent);
		else
			offset = LoadBufferFromMC (savebuffer, CARD_SLOTB, filepath, silent);
	}

	if (offset > 0)
	{
		if(nesGameType == 1)
			NGCFCEU_GameSave(&iNESCart, 1);
		else if(nesGameType == 2)
			NGCFCEU_GameSave(&UNIFCart, 1);

		ResetNES();
		return 1;
	}

	// if we reached here, nothing was done!
	if(!silent)
		WaitPrompt ((char*) "Save file not found");

	return 0;
}
Ejemplo n.º 22
0
bool InitializeNetwork(bool silent)
{
#ifdef HW_RVL
	StopNetworkThread();

	if(networkInit && net_gethostip() > 0)
		return true;

	networkInit = false;
#else
	if(networkInit)
		return true;
#endif

	int retry = 1;

	while(retry)
	{
		ShowAction("Initializing network...");

#ifdef HW_RVL
		u64 start = gettime();
		StartNetworkThread();

		while (!LWP_ThreadIsSuspended(networkthread))
		{
			usleep(50 * 1000);

			if(diff_sec(start, gettime()) > 10) // wait for 10 seconds max for net init
				break;
		}
#else
		networkInit = !(if_config(wiiIP, NULL, NULL, true) < 0);
#endif

		CancelAction();

		if(networkInit || silent)
			break;

		retry = ErrorPromptRetry("Unable to initialize network!");
#ifdef HW_RVL  	
		if(networkInit && net_gethostip() > 0)
#else
		if(networkInit)
#endif
			return true;
	}
	return networkInit;
}
Ejemplo n.º 23
0
bool LoadState (int method, bool silent)
{
	ShowAction ((char*) "Loading...");

	if(method == METHOD_AUTO)
		method = autoSaveMethod(); // we use 'Save' because we need R/W

	char filepath[1024];
	int offset = 0;

	if(method == METHOD_SD || method == METHOD_USB)
	{
		ChangeFATInterface(method, NOTSILENT);
		sprintf (filepath, "%s/%s/%s.fcs", ROOTFATDIR, GCSettings.SaveFolder, romFilename);
		offset = LoadSaveBufferFromFAT (filepath, silent);

		if(offset == 0) // file not found
		{
			// look for CRC save
			sprintf (filepath, "%08x.fcs", iNESGameCRC32);
			offset = LoadSaveBufferFromFAT (filepath, silent);
		}
	}
	else if(method == METHOD_SMB)
	{
		sprintf (filepath, "%s/%s.fcs", GCSettings.SaveFolder, romFilename);
		offset = LoadSaveBufferFromSMB (filepath, silent);
	}
	else if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
	{
		sprintf (filepath, "%08x.fcs", iNESGameCRC32);

		if(method == METHOD_MC_SLOTA)
			offset = LoadBufferFromMC (savebuffer, CARD_SLOTA, filepath, silent);
		else
			offset = LoadBufferFromMC (savebuffer, CARD_SLOTB, filepath, silent);
	}

	if (offset > 0)
	{
		GCFCEUSS_Load();
		return 1;
	}

	// if we reached here, nothing was done!
	if(!silent)
		WaitPrompt ((char*) "State file not found");

	return 0;
}
Ejemplo n.º 24
0
/**
 * LoadDVDFile
 *
 * This function will load a file from DVD, in BIN, SMD or ZIP format.
 * The values for offset and length are inherited from rootdir and 
 * rootdirlength.
 *
 * The buffer parameter should re-use the initial ROM buffer.
 */
int
LoadDVDFile (unsigned char *buffer)
{
  int offset;
  int blocks;
  int i;
  u64 discoffset;
  char readbuffer[2048];

        /*** SDCard Addition ***/
  if (rootdirlength == 0)
    return 0;

        /*** How many 2k blocks to read ***/
  blocks = rootdirlength / 2048;
  offset = 0;
  discoffset = rootdir;
  ShowAction ((char*) "Loading ... Wait");
  dvd_read (readbuffer, 2048, discoffset);

  if (!IsZipFile (readbuffer))

    {
      for (i = 0; i < blocks; i++)

        {
          dvd_read (readbuffer, 2048, discoffset);
          memcpy (buffer + offset, readbuffer, 2048);
          offset += 2048;
          discoffset += 2048;
        }

                /*** And final cleanup ***/
      if (rootdirlength % 2048)

        {
          i = rootdirlength % 2048;
          dvd_read (readbuffer, 2048, discoffset);
          memcpy (buffer + offset, readbuffer, i);
        }
    }

  else

    {
      return UnZipBuffer (buffer, discoffset, rootdirlength);
    }
  return rootdirlength;
}
Ejemplo n.º 25
0
bool
ConnectShare (bool silent)
{
	// Crashes or stalls system in GameCube mode - so disable
	#ifndef HW_RVL
	return false;
	#endif

	// check that all parameter have been set
	if(strlen(GCSettings.smbuser) == 0 ||
		strlen(GCSettings.smbpwd) == 0 ||
		strlen(GCSettings.smbshare) == 0 ||
		strlen(GCSettings.smbip) == 0)
	{
		if(!silent)
			WaitPrompt((char*) "Invalid network settings. Check SNES9xGX.xml.");
		return false;
	}

	if(!networkInit)
		networkInit = InitializeNetwork(silent);

	if(networkInit)
	{
		// connection may have expired
		if (networkShareInit && SMBTimer > SMBTIMEOUT)
		{
			networkShareInit = false;
			SMBTimer = 0;
			SMB_Close(smbconn);
		}

		if(!networkShareInit)
		{
			if(!silent)
				ShowAction ((char*) "Connecting to network share...");

			if(SMB_Connect(&smbconn, GCSettings.smbuser, GCSettings.smbpwd,
			GCSettings.smbgcid, GCSettings.smbsvid, GCSettings.smbshare, GCSettings.smbip) == SMB_SUCCESS)
				networkShareInit = true;
		}

		if(!networkShareInit && !silent)
			WaitPrompt ((char*) "Failed to connect to network share.");
	}

	return networkShareInit;
}
Ejemplo n.º 26
0
bool SaveState (int method, bool silent)
{
	ShowAction ((char*) "Saving...");

	if(method == METHOD_AUTO)
		method = autoSaveMethod();

	bool retval = false;
	char filepath[1024];
	int datasize;
	int offset = 0;

	datasize = GCFCEUSS_Save();

	if ( datasize )
	{
		if(method == METHOD_SD || method == METHOD_USB)
		{
			if(ChangeFATInterface(method, NOTSILENT))
			{
				sprintf (filepath, "%s/%s/%s.fcs", ROOTFATDIR, GCSettings.SaveFolder, romFilename);
				offset = SaveBufferToFAT (filepath, datasize, silent);
			}
		}
		else if(method == METHOD_SMB)
		{
			sprintf (filepath, "%s/%s.fcs", GCSettings.SaveFolder, romFilename);
			offset = SaveBufferToSMB (filepath, datasize, silent);
		}
		else if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
		{
			sprintf (filepath, "%08x.fcs", iNESGameCRC32);

			if(method == METHOD_MC_SLOTA)
				offset = SaveBufferToMC (savebuffer, CARD_SLOTA, filepath, datasize, silent);
			else
				offset = SaveBufferToMC (savebuffer, CARD_SLOTB, filepath, datasize, silent);
		}

		if (offset > 0)
		{
			if ( !silent )
				WaitPrompt((char *)"Save successful");
			retval = true;
		}
	}
	return retval;
}
Ejemplo n.º 27
0
/****************************************************************************
* autoLoadMethod()
* Auto-determines and sets the load method
* Returns method set
****************************************************************************/
int autoLoadMethod()
{
	ShowAction ((char*) "Attempting to determine load method...");

	if(ChangeFATInterface(METHOD_SD, SILENT))
		return METHOD_SD;
	else if(ChangeFATInterface(METHOD_USB, SILENT))
		return METHOD_USB;
	else if(TestDVD())
		return METHOD_DVD;
	else if(ConnectShare (SILENT))
		return METHOD_SMB;
	else
	{
		WaitPrompt((char*) "Unable to auto-determine load method!");
		return 0; // no method found
	}
}
Ejemplo n.º 28
0
/****************************************************************************
 * OpenDVD
 *
 * Function to load a DVD directory and display to user.
****************************************************************************/
int
OpenDVD (int method)
{
	if (!getpvd())
	{
		ShowAction((char*) "Loading DVD...");
		#ifdef HW_DOL
		DVD_Mount(); // mount the DVD unit again
		#elif WII_DVD
		u32 val;
		DI_GetCoverRegister(&val);
		if(val & 0x1)	// True if no disc inside, use (val & 0x2) for true if disc inside.
		{
			WaitPrompt((char *)"No disc inserted!");
			return 0;
		}
		DI_Mount();
		while(DI_GetStatus() & DVD_INIT);
		#endif

		if (!getpvd())
		{
			WaitPrompt ((char *)"Invalid DVD.");
			return 0; // not a ISO9660 DVD
		}
	}

	maxfiles = ParseDVDdirectory(); // load root folder

	// switch to rom folder
	SwitchDVDFolder(GCSettings.LoadFolder);

	if (maxfiles > 0)
	{
		return FileSelector (method);
	}
	else
	{
		// no entries found
		WaitPrompt ((char *)"No Files Found!");
		return 0;
	}
}
Ejemplo n.º 29
0
/**
 * OpenDVD
 *
 * Function to load a DVD directory and display to user.
 */
int
OpenDVD ()
{
    int romsdiroffset = 0;
    
    loadtype = LOAD_DVD;
    
    if (!getpvd())
    {
        ShowAction((char*) "Mounting DVD ... Wait");
        DVD_Mount();             /* mount the DVD unit again */
        havedir = 0;             /* this may be a new DVD: content need to be parsed again */
        if (!getpvd())
            return 0; /* no correct ISO9660 DVD */
    }
    
    if (havedir == 0)
    {
        offset = selection = 0; /* reset file selector */
        haveSDdir = 0;  /* prevent conflicts with SDCARD, USB file selector */
		haveUSBdir = 0;
        
        if ((maxfiles = parsedirectory ()))
        {
            if ( romsdiroffset = SNESROMSOffset() )
            {
                rootdir = filelist[romsdiroffset].offset;
                rootdirlength = filelist[romsdiroffset].length;
                offset = selection = 0;
                maxfiles = parsedirectory ();
            }
            
            int ret = FileSelector ();
            havedir = 1;
            return ret;
        }
    }
    
    else
        return FileSelector ();
    
    return 0;
}
Ejemplo n.º 30
0
/****************************************************************************
* autoSaveMethod()
* Auto-determines and sets the save method
* Returns method set
****************************************************************************/
int autoSaveMethod()
{
	ShowAction ((char*) "Attempting to determine save method...");

	if(ChangeFATInterface(METHOD_SD, SILENT))
		return METHOD_SD;
	else if(ChangeFATInterface(METHOD_USB, SILENT))
		return METHOD_USB;
	else if(TestCard(CARD_SLOTA, SILENT))
		return METHOD_MC_SLOTA;
	else if(TestCard(CARD_SLOTB, SILENT))
		return METHOD_MC_SLOTB;
	else if(ConnectShare (SILENT))
		return METHOD_SMB;
	else
	{
		WaitPrompt((char*) "Unable to auto-determine save method!");
		return 0; // no method found
	}
}