Fixed NAND emulation stuff:

*Fixed NAND emulation itself
*Fixed creation of nandpath and title.tmd for some games
*Fixed extraction of game saves for some games
*Cleaned up some code for NAND emulation
*Cleaned up some more unused stuff

Todo: 

*Cleanup NAND emulation code much more 
*Move the last used function in savefile.c to a better place
*Add extraction and flash options to game config menu
This commit is contained in:
overjoy.psm 2012-05-08 00:59:53 +00:00
parent 615000728d
commit 26a1ca085c
4 changed files with 35 additions and 19 deletions

View File

@ -1826,7 +1826,7 @@ bool CMenu::_loadChannelList(void)
gprintf("%s, which is %s\n", disable_emu ? "NAND" : DeviceName[currentPartition], changed ? "refreshing." : "cached.");
string path = m_cfg.getString("NAND", "path", "");
string path = m_cfg.getString("NAND", "path", STDEMU_DIR);
if(first && !disable_emu)
{
@ -1839,7 +1839,7 @@ bool CMenu::_loadChannelList(void)
if(sysconf != NULL && sysconf_size > 0)
{
sprintf(filepath, "%s:%sshared2/sys/SYSCONF", DeviceName[currentPartition], path.c_str());
sprintf(filepath, "%s:%s/shared2/sys/SYSCONF", DeviceName[currentPartition], path.c_str());
FILE *file = fopen(filepath, "wb");
if(file)
{
@ -1856,7 +1856,7 @@ bool CMenu::_loadChannelList(void)
if(meez != NULL && meez_size > 0)
{
sprintf(filepath, "%s:%sshared2/menu/FaceLib/RFL_DB.dat", DeviceName[currentPartition], path.c_str());
sprintf(filepath, "%s:%s/shared2/menu/FaceLib/RFL_DB.dat", DeviceName[currentPartition], path.c_str());
FILE *file = fopen(filepath, "wb");
if(file)
{
@ -1890,7 +1890,7 @@ bool CMenu::_loadChannelList(void)
if(!DeviceHandler::Instance()->IsInserted(currentPartition))
DeviceHandler::Instance()->Mount(currentPartition);
string nandpath = sfmt("%s:%s", DeviceName[currentPartition], path.empty() ? "/" : path.c_str());
string nandpath = sfmt("%s:%s/", DeviceName[currentPartition], path.empty() ? "" : path.c_str());
gprintf("nandpath = %s\n", nandpath.c_str());
if(!failed)

View File

@ -1150,10 +1150,10 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
{
m_forceext = false;
_hideWaitMessage();
_AutoExtractSave(id);
if(!_AutoExtractSave(id))
CreateTitleTMD(basepath, hdr);
_showWaitMessage();
}
CreateSavePath(basepath, hdr);
}
if(emuSave > 2)
{

View File

@ -941,7 +941,6 @@ void CMenu::_textMain(void)
{
m_btnMgr.setText(m_mainBtnInit, _t("main1", L"Install Game"));
m_btnMgr.setText(m_mainBtnInit2, _t("main3", L"Select Partition"));
//m_btnMgr.setText(m_mainLblInit, _t("main2", L"Welcome to WiiFlow. I have not found any games. Click Install to install games, or Select partition to select your partition type."), true);
}
wstringEx CMenu::_getNoticeTranslation(int sorting, wstringEx curLetter)

View File

@ -259,11 +259,26 @@ int CMenu::_AutoExtractSave(string gameId)
{
int emuPartition = m_cfg.getInt("GAMES", "savepartition", m_cfg.getInt("NAND", "partition", 0));
int savePath = gameId.c_str()[0] << 24 | gameId.c_str()[1] << 16 | gameId.c_str()[2] << 8 | gameId.c_str()[3];
string npath = sfmt("/title/00010000/%x", savePath);
string path = sfmt("%s:%s/title/00010000/%x", DeviceName[emuPartition], m_cfg.getString("GAMES", "savepath", m_cfg.getString("NAND", "path", "")).c_str(), savePath);
if(!_nandSaveExists(npath.c_str()) || (!m_forceext && _saveExists(path.c_str())))
char basepath[MAX_FAT_PATH];
snprintf(basepath, sizeof(basepath), "%s:%s", DeviceName[emuPartition], m_cfg.getString("GAMES", "savepath", m_cfg.getString("NAND", "path", "")).c_str());
Nand::Instance()->CreatePath("%s/import", basepath);
Nand::Instance()->CreatePath("%s/meta", basepath);
Nand::Instance()->CreatePath("%s/shared1", basepath);
Nand::Instance()->CreatePath("%s/shared2", basepath);
Nand::Instance()->CreatePath("%s/sys", basepath);
Nand::Instance()->CreatePath("%s/title", basepath);
Nand::Instance()->CreatePath("%s/ticket", basepath);
Nand::Instance()->CreatePath("%s/tmp", basepath);
string npath = sfmt("/title/00010000/%08x", savePath);
string path = sfmt("%s/title/00010000/%08x", basepath, savePath);
if(!_nandSaveExists(sfmt("/title/00010000/%08x", savePath).c_str()) && !_nandSaveExists(sfmt("/title/00010004/%08x", savePath).c_str()))
return 0;
if(!m_forceext && (_saveExists(sfmt("%s/title/00010000/%08x", basepath, savePath).c_str()) || _saveExists(sfmt("%s/title/00010004/%08x", basepath, savePath).c_str())))
return 1;
lwp_t thread = 0;
SetupInput();
@ -509,7 +524,6 @@ int CMenu::_NandDumper(void *obj)
else
{
bool missingOnly = !m.m_saveall;
string path, npath;
vector<string> saveList;
m.m_sgdump = true;
@ -527,12 +541,9 @@ int CMenu::_NandDumper(void *obj)
int savePath = id.c_str()[0] << 24 | id.c_str()[1] << 16 | id.c_str()[2] << 8 | id.c_str()[3];
path = sfmt("%s/title/00010000/%x", basepath, savePath);
npath = sfmt("/title/00010000/%x", savePath);
if(!missingOnly || !_saveExists(path.c_str()))
if(!missingOnly || (!_saveExists(sfmt("%s/title/00010000/%08x", basepath, savePath).c_str()) && !_saveExists(sfmt("%s/title/00010004/%08x", basepath, savePath).c_str())))
{
if(_nandSaveExists(npath.c_str()))
if(_nandSaveExists(sfmt("/title/00010000/%08x", savePath).c_str()) || _nandSaveExists(sfmt("/title/00010004/%08x", savePath).c_str()))
{
m.m_nandexentry++;
saveList.push_back(id);
@ -547,14 +558,20 @@ int CMenu::_NandDumper(void *obj)
{
char source[ISFS_MAXPATH];
int savePath = saveList[i].c_str()[0] << 24 | saveList[i].c_str()[1] << 16 | saveList[i].c_str()[2] << 8 | saveList[i].c_str()[3];
snprintf(source, sizeof(source), "/title/00010000/%x", savePath);
snprintf(source, sizeof(source), "/title/00010000/%08x", savePath);
if(!_nandSaveExists(source))
snprintf(source, sizeof(source), "/title/00010004/%08x", savePath);
m.m_dumpsize = Nand::Instance()->CalcDumpSpace(source, false, CMenu::_ShowProgress, obj);
}
for(u32 i = 0; i < saveList.size() && !m.m_thrdStop; ++i)
{
char source[ISFS_MAXPATH];
int savePath = saveList[i].c_str()[0] << 24 | saveList[i].c_str()[1] << 16 | saveList[i].c_str()[2] << 8 | saveList[i].c_str()[3];
snprintf(source, sizeof(source), "/title/00010000/%x", savePath);
snprintf(source, sizeof(source), "/title/00010000/%08x", savePath);
if(!_nandSaveExists(source))
snprintf(source, sizeof(source), "/title/00010004/%08x", savePath);
m.m_nandext = true;
Nand::Instance()->DoNandDump(source, basepath, false, CMenu::_ShowProgress, obj);
}