- changed emu nand settings so they don't change if you you remove a device.

This commit is contained in:
Fledge68 2021-11-10 17:56:44 -06:00
parent 85c0f05b6d
commit 7f4f6ea2fc
7 changed files with 93 additions and 77 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 MiB

After

Width:  |  Height:  |  Size: 4.4 MiB

View File

@ -1,6 +1,6 @@
#define APP_NAME "WiiFlow WFL" #define APP_NAME "WiiFlow WFL"
#define APP_VERSION "5.5.0 beta 10" #define APP_VERSION "5.5.0 beta 11"
#define APP_DATA_DIR "wiiflow" #define APP_DATA_DIR "wiiflow"
#define APPS_DIR "apps/wiiflow" #define APPS_DIR "apps/wiiflow"

View File

@ -190,9 +190,9 @@ bool CMenu::init(bool usb_mounted)
m_cfg.getBool("GENERAL", "sd_only", usb_mounted ? false : true);// will only set it if this doesn't already exist - very first boot up m_cfg.getBool("GENERAL", "sd_only", usb_mounted ? false : true);// will only set it if this doesn't already exist - very first boot up
/* set default wii games partition in case this is the first boot */ /* set default wii games partition in case this is the first boot */
if(!m_cfg.has(WII_DOMAIN, "partition")) int wp = m_cfg.getInt(WII_DOMAIN, "partition", -1);
if(wp < 0)
{ {
int wp = -1;
if(!m_cfg.getBool("GENERAL", "sd_only")) if(!m_cfg.getBool("GENERAL", "sd_only"))
{ {
for(int i = SD; i <= USB8; i++) // Find first wbfs folder or a partition of wbfs file system for(int i = SD; i <= USB8; i++) // Find first wbfs folder or a partition of wbfs file system
@ -215,15 +215,16 @@ bool CMenu::init(bool usb_mounted)
} }
/* preferred partition setting - negative 1 means not set by user so skip this */ /* preferred partition setting - negative 1 means not set by user so skip this */
int pp; int pp = m_cfg.getInt(WII_DOMAIN, "preferred_partition", -1);
if((pp = m_cfg.getInt(WII_DOMAIN, "preferred_partition", -1)) >= 0) if(pp >= 0)
{ {
if(usb_mounted && pp > 0) if(usb_mounted && pp > 0)
m_cfg.setInt(WII_DOMAIN, "partition", pp); m_cfg.setInt(WII_DOMAIN, "partition", pp);
else else
m_cfg.setInt(WII_DOMAIN, "partition", SD); m_cfg.setInt(WII_DOMAIN, "partition", SD);
} }
if((pp = m_cfg.getInt(GC_DOMAIN, "preferred_partition", -1)) >= 0) pp = m_cfg.getInt(GC_DOMAIN, "preferred_partition", -1);
if(pp >= 0)
{ {
if(usb_mounted && pp > 0) if(usb_mounted && pp > 0)
m_cfg.setInt(GC_DOMAIN, "partition", USB1); m_cfg.setInt(GC_DOMAIN, "partition", USB1);
@ -315,10 +316,52 @@ bool CMenu::init(bool usb_mounted)
fsop_MakeFolder(m_cartDir.c_str()); fsop_MakeFolder(m_cartDir.c_str());
fsop_MakeFolder(m_snapDir.c_str()); fsop_MakeFolder(m_snapDir.c_str());
/* Emu nands init even if not being used */ if(!isWiiVC)
memset(emu_nands_dir, 0, sizeof(emu_nands_dir)); {
strncpy(emu_nands_dir, IsOnWiiU() ? "vwiinands" : "nands", sizeof(emu_nands_dir) - 1); /* Emu nands init even if not being used */
_checkEmuNandSettings(); memset(emu_nands_dir, 0, sizeof(emu_nands_dir));
strncpy(emu_nands_dir, IsOnWiiU() ? "vwiinands" : "nands", sizeof(emu_nands_dir) - 1);
string emuNand = m_cfg.getString(CHANNEL_DOMAIN, "current_emunand", "default");// just to set to default on first boot
int emuPart = m_cfg.getInt(CHANNEL_DOMAIN, "partition", -1);
string savesNand = m_cfg.getString(WII_DOMAIN, "current_save_emunand", "default");
int savesPart = m_cfg.getInt(WII_DOMAIN, "savepartition", -1);
if(emuPart < 0)
{
u8 i;
for(i = SD; i < MAXDEVICES; i++)// find first usable partition
{
if(DeviceHandle.PartitionUsableForNandEmu(i))
{
emuPart = i;
break;
}
}
if(i == MAXDEVICES)// if no usable partitions found set to SD for now
emuPart = SD;// cfgne8=No valid FAT partition found for NAND Emulation!
m_cfg.setInt(CHANNEL_DOMAIN, "partition", emuPart);
}
gprintf("emunand = %s:/%s/%s\n", DeviceName[emuPart], emu_nands_dir, emuNand.c_str());
if(savesPart < 0)
{
u8 i;
for(i = SD; i < MAXDEVICES; i++)
{
if(DeviceHandle.PartitionUsableForNandEmu(i))
{
savesPart = i;
break;
}
}
if(i == MAXDEVICES)
savesPart = SD;
m_cfg.setInt(WII_DOMAIN, "savepartition", savesPart);
}
gprintf("savesnand = %s:/%s/%s\n", DeviceName[savesPart], emu_nands_dir, savesNand.c_str());
_FullNandCheck();
}
/* misc. setup */ /* misc. setup */
SoundHandle.Init(); SoundHandle.Init();

View File

@ -1288,9 +1288,9 @@ private:
int _FindEmuPart(bool savesnand, bool searchvalid); int _FindEmuPart(bool savesnand, bool searchvalid);
bool _checkSave(string id, int nand_type); bool _checkSave(string id, int nand_type);
bool _TestEmuNand(int epart, const char *path, bool indept); bool _TestEmuNand(int epart, const char *path, bool indept);
void _checkEmuNandSettings(void); void _getEmuNands(void);
void _FullNandCheck(void); void _FullNandCheck(void);
void _listEmuNands(const char *path, vector<string> &emuNands); void _listEmuNands(const char *path, vector<string> &nands);
int _downloadCheatFileAsync(); int _downloadCheatFileAsync();
static void * _downloadUrlAsync(void *obj); static void * _downloadUrlAsync(void *obj);

View File

@ -526,7 +526,7 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
//GameID for Video mode when booting a Disc //GameID for Video mode when booting a Disc
memcpy((u8*)Disc_ID, id, 6); memcpy((u8*)Disc_ID, id, 6);
DCFlushRange((u8*)Disc_ID, 32); DCFlushRange((u8*)Disc_ID, 6);
/* set nintendont conifg options */ /* set nintendont conifg options */
u32 n_config = 0; u32 n_config = 0;
@ -1043,7 +1043,7 @@ void CMenu::_launchWii(dir_discHdr *hdr, bool dvd, bool disc_cfg)
if(emulate_mode && !dvd) if(emulate_mode && !dvd)
{ {
int emuPart = _FindEmuPart(SAVES_NAND, true); int emuPart = _FindEmuPart(SAVES_NAND, true);
if(emuPart == -1)//if savepartition is unusable if(emuPart < 0)//if savepartition is unusable
{ {
_hideWaitMessage(); _hideWaitMessage();
error(_t("errgame13", L"EmuNAND for gamesave not found! Using real NAND.")); error(_t("errgame13", L"EmuNAND for gamesave not found! Using real NAND."));

View File

@ -77,11 +77,11 @@ static inline int loopNum(int i, int s)
return (i + s) % s; return (i + s) % s;
} }
void CMenu::_listEmuNands(const char *path, vector<string> &emuNands) void CMenu::_listEmuNands(const char *path, vector<string> &nands)
{ {
DIR *d; DIR *d;
struct dirent *dir; struct dirent *dir;
emuNands.clear(); nands.clear();
bool add_def = true; bool add_def = true;
d = opendir(path); d = opendir(path);
@ -93,57 +93,34 @@ void CMenu::_listEmuNands(const char *path, vector<string> &emuNands)
continue; continue;
if(dir->d_type == DT_DIR) if(dir->d_type == DT_DIR)
{ {
emuNands.push_back(dir->d_name); nands.push_back(dir->d_name);
if(strlen(dir->d_name) == 7 && strcasecmp(dir->d_name, "default") == 0) if(strlen(dir->d_name) == 7 && strcasecmp(dir->d_name, "default") == 0)
add_def = false; add_def = false;
} }
} }
closedir(d); closedir(d);
} }
else
return;
if(add_def) if(add_def)
emuNands.push_back("default"); nands.push_back("default");
sort(emuNands.begin(), emuNands.end()); sort(nands.begin(), nands.end());
} }
void CMenu::_checkEmuNandSettings(void) void CMenu::_getEmuNands(void)
{ {
if(isWiiVC)
return;
u8 i; u8 i;
string emuNand = m_cfg.getString(CHANNEL_DOMAIN, "current_emunand", "default"); string emuNand = m_cfg.getString(CHANNEL_DOMAIN, "current_emunand", "default");
int emuPart = m_cfg.getInt(CHANNEL_DOMAIN, "partition", 0); int emuPart = m_cfg.getInt(CHANNEL_DOMAIN, "partition", -1);
string savesNand = m_cfg.getString(WII_DOMAIN, "current_save_emunand", "default"); string savesNand = m_cfg.getString(WII_DOMAIN, "current_save_emunand", "default");
int savesPart = m_cfg.getInt(WII_DOMAIN, "savepartition", 0); int savesPart = m_cfg.getInt(WII_DOMAIN, "savepartition", -1);
if(!DeviceHandle.PartitionUsableForNandEmu(emuPart))// current partition no good /* emu Nands */
{
for(i = SD; i < MAXDEVICES; i++)// find first usable partition
{
if(DeviceHandle.PartitionUsableForNandEmu(i))
{
emuPart = i;
break;
}
}
if(i == MAXDEVICES)// if no usable partitions found set to SD for now
emuPart = SD;
}
if(!DeviceHandle.PartitionUsableForNandEmu(savesPart))// do same for savesnand partition
{
for(i = SD; i < MAXDEVICES; i++)
{
if(DeviceHandle.PartitionUsableForNandEmu(i))
{
savesPart = i;
break;
}
}
if(i == MAXDEVICES)
savesPart = SD;
}
//cfgne8=No valid FAT partition found for NAND Emulation!
_listEmuNands(fmt("%s:/%s", DeviceName[emuPart], emu_nands_dir), emuNands); _listEmuNands(fmt("%s:/%s", DeviceName[emuPart], emu_nands_dir), emuNands);
if(emuNands.empty())// in case device has been temporarily disconnected
emuNands.push_back(emuNand);
curEmuNand = 0; curEmuNand = 0;
for(i = 0; i < emuNands.size(); ++i)// find current emunand folder for(i = 0; i < emuNands.size(); ++i)// find current emunand folder
{ {
@ -164,9 +141,13 @@ void CMenu::_checkEmuNandSettings(void)
} }
} }
} }
gprintf("emu nand path = %s:/%s/%s\n", DeviceName[emuPart], emu_nands_dir, emuNands[curEmuNand].c_str());
/* saves Nands */
_listEmuNands(fmt("%s:/%s", DeviceName[savesPart], emu_nands_dir), savesNands); _listEmuNands(fmt("%s:/%s", DeviceName[savesPart], emu_nands_dir), savesNands);
if(savesNands.empty())
savesNands.push_back(savesNand);
curSavesNand = 0; curSavesNand = 0;
for(i = 0; i < savesNands.size(); ++i)// find current savesnand folder for(i = 0; i < savesNands.size(); ++i)// find current savesnand folder
{ {
@ -187,30 +168,24 @@ void CMenu::_checkEmuNandSettings(void)
} }
} }
} }
gprintf("saves nand path = %s:/%s/%s\n", DeviceName[savesPart], emu_nands_dir, savesNands[curSavesNand].c_str());
m_cfg.setString(WII_DOMAIN, "current_save_emunand", savesNands[curSavesNand]);
m_cfg.setInt(WII_DOMAIN, "savepartition", savesPart);
m_cfg.setString(CHANNEL_DOMAIN, "current_emunand", emuNands[curEmuNand]);
m_cfg.setInt(CHANNEL_DOMAIN, "partition", emuPart);
// add check if full emulation and if is then check for config and mii files
_FullNandCheck();
} }
/* This checks if nand emulation is set to Full */
/* if is then it copies SYSCONF, setting.txt, and RFL_DB.dat only if they don't already exist */
/* this is helpful if you use a modmii created nand, wiiflow dumped nand will already have these files */
/* if you wish to overwrite these files then use the real nand mii's and config options */
void CMenu::_FullNandCheck(void) void CMenu::_FullNandCheck(void)
{ {
if(isWiiVC)
return;
for(u8 i = 0; i < 2; i++) for(u8 i = 0; i < 2; i++)
{ {
int emulate_mode; int emulate_mode;
if(i == EMU_NAND) if(i == EMU_NAND)
emulate_mode = m_cfg.getInt(CHANNEL_DOMAIN, "emulation", 0); emulate_mode = m_cfg.getInt(CHANNEL_DOMAIN, "emulation", 1);// full by default
else else
emulate_mode = m_cfg.getInt(WII_DOMAIN, "save_emulation", 0); emulate_mode = m_cfg.getInt(WII_DOMAIN, "save_emulation", 2);// full by default
if((i == EMU_NAND && emulate_mode == 1) || (i == SAVES_NAND && emulate_mode == 2))//full if((i == EMU_NAND && emulate_mode == 1) || (i == SAVES_NAND && emulate_mode == 2))//full
{ {
int emuPart = _FindEmuPart(i, true); int emuPart = _FindEmuPart(i, false);
if(emuPart < 0) if(emuPart < 0)
continue; continue;
bool need_config = false; bool need_config = false;
@ -566,7 +541,7 @@ int CMenu::_NandEmuCfg(void)
string emuNand = m_cfg.getString(CHANNEL_DOMAIN, "current_emunand"); string emuNand = m_cfg.getString(CHANNEL_DOMAIN, "current_emunand");
lwp_t thread = 0; lwp_t thread = 0;
SetupInput(); SetupInput();
_checkEmuNandSettings(); _getEmuNands();
_showNandEmu(); _showNandEmu();
m_thrdStop = false; m_thrdStop = false;
@ -624,7 +599,7 @@ int CMenu::_NandEmuCfg(void)
m_emuSaveNand = true; m_emuSaveNand = true;
_setPartition(direction); _setPartition(direction);
m_emuSaveNand = false; m_emuSaveNand = false;
_checkEmuNandSettings();// refresh emunands in case the partition was changed _getEmuNands();// refresh emunands in case the partition was changed
_showNandEmu(); _showNandEmu();
} }
else if(m_btnMgr.selected(m_nandemuBtnNandDump) || m_btnMgr.selected(m_nandemuBtnAll) || m_btnMgr.selected(m_nandemuBtnMissing)) else if(m_btnMgr.selected(m_nandemuBtnNandDump) || m_btnMgr.selected(m_nandemuBtnAll) || m_btnMgr.selected(m_nandemuBtnMissing))
@ -689,12 +664,12 @@ int CMenu::_NandEmuCfg(void)
nandemuPage = 1; nandemuPage = 1;
_showNandEmu(); _showNandEmu();
} }
else if (m_btnMgr.selected(m_nandemuBtnRealConfig)) else if(m_btnMgr.selected(m_nandemuBtnRealConfig))
{ {
m_cfg.setBool(CHANNEL_DOMAIN, "real_nand_config", !m_cfg.getBool(CHANNEL_DOMAIN, "real_nand_config")); m_cfg.setBool(CHANNEL_DOMAIN, "real_nand_config", !m_cfg.getBool(CHANNEL_DOMAIN, "real_nand_config"));
_showNandEmu(); _showNandEmu();
} }
else if (m_btnMgr.selected(m_nandemuBtnRealMiis)) else if(m_btnMgr.selected(m_nandemuBtnRealMiis))
{ {
m_cfg.setBool(CHANNEL_DOMAIN, "real_nand_miis", !m_cfg.getBool(CHANNEL_DOMAIN, "real_nand_miis")); m_cfg.setBool(CHANNEL_DOMAIN, "real_nand_miis", !m_cfg.getBool(CHANNEL_DOMAIN, "real_nand_miis"));
_showNandEmu(); _showNandEmu();
@ -822,11 +797,12 @@ int CMenu::_FlashSave(string gameId)
int CMenu::_AutoExtractSave(string gameId)// called from game settings menu to extract a gamesave from real nand to savesnand int CMenu::_AutoExtractSave(string gameId)// called from game settings menu to extract a gamesave from real nand to savesnand
{ {
if(!_checkSave(gameId, REAL_NAND))//if save not on real nand
return 0;
int emuPart = _FindEmuPart(SAVES_NAND, false); int emuPart = _FindEmuPart(SAVES_NAND, false);
if(emuPart == -1)// if savesnand partition unusable if(emuPart == -1)// if savesnand partition unusable
{
return 0; return 0;
}
else if(emuPart == -2)// emunand folder not found so make it else if(emuPart == -2)// emunand folder not found so make it
{ {
emuPart = _FindEmuPart(SAVES_NAND, true); emuPart = _FindEmuPart(SAVES_NAND, true);
@ -843,9 +819,6 @@ int CMenu::_AutoExtractSave(string gameId)// called from game settings menu to e
NandHandle.CreatePath("%s/tmp", basepath); NandHandle.CreatePath("%s/tmp", basepath);
} }
if(!_checkSave(gameId, REAL_NAND))//if save not on real nand
return 0;
lwp_t thread = 0; lwp_t thread = 0;
m_thrdStop = false; m_thrdStop = false;
m_thrdMessageAdded = false; m_thrdMessageAdded = false;
@ -914,10 +887,10 @@ void * CMenu::_NandFlasher(void *obj)
char dest[ISFS_MAXPATH]; char dest[ISFS_MAXPATH];
int emuPartition = m._FindEmuPart(SAVES_NAND, true); int emuPartition = m._FindEmuPart(SAVES_NAND, true);
const char *emuPath = NandHandle.Get_NandPath();
const char *SaveGameID = m.m_saveExtGameId.c_str(); const char *SaveGameID = m.m_saveExtGameId.c_str();
int flashID = SaveGameID[0] << 24 | SaveGameID[1] << 16 | SaveGameID[2] << 8 | SaveGameID[3]; int flashID = SaveGameID[0] << 24 | SaveGameID[1] << 16 | SaveGameID[2] << 8 | SaveGameID[3];
const char *emuPath = NandHandle.Get_NandPath();
/* we know it exist on emunand just need to figure out which folder */ /* we know it exist on emunand just need to figure out which folder */
if(_saveExists(fmt("%s:%s/title/00010000/%08x", DeviceName[emuPartition], emuPath, flashID))) if(_saveExists(fmt("%s:%s/title/00010000/%08x", DeviceName[emuPartition], emuPath, flashID)))