- added "auto" cios selection based on the games' IOS and d2x cios installed. only works for d2x cios. if you wish to use a hermes cios you can still manually choose 222 - 225. note if more than one cios have the same base the higher slot will be chosen.

This commit is contained in:
Fledge68 2023-03-15 13:50:47 -05:00
parent aceb49ceb8
commit 7d4db44456
4 changed files with 45 additions and 26 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 MiB

After

Width:  |  Height:  |  Size: 4.4 MiB

View File

@ -2682,7 +2682,7 @@ void CMenu::_stopSounds(void)
m_gameSound.Stop();
}
/* wiiflow creates a map<u8, u8> _installed_cios list for slots 200 to 253 and slot 0
/* wiiflow creates a map<u8 slot, u8 base > _installed_cios list for slots 200 to 253 and slot 0
the first u8 is the slot and the second u8 is the base if its a d2x cios otherwise the slot number again.
slot 0 is set to 1 - first = 0 and second = 1
game config only shows the first (slot) or auto if first = 0 */
@ -2700,11 +2700,12 @@ void CMenu::_load_installed_cioses()
{
gprintf("Found d2x base %u in slot %u\n", base, slot);
_installed_cios[slot] = base;
_cios_base[base] = slot;// these are sorted low to high. no duplicates. higher slot will replace lower slot if same base.
}
else if(CustomIOS(IOS_GetType(slot)))
{
gprintf("Found cIOS in slot %u\n", slot);
_installed_cios[slot] = slot;
_installed_cios[slot] = slot;// we don't add the base for non d2x cios. only keep this if a user wants to try a hermies cios for example.
}
}
}

View File

@ -994,7 +994,8 @@ private:
wstringEx _optBoolToString(int b);
void _load_installed_cioses();
std::map<u8, u8> _installed_cios;
typedef std::map<u8, u8>::iterator CIOSItr;
typedef std::map<u8, u8>::iterator CIOSItr;// we can use this for both maps.
std::map<u8, u8> _cios_base;
//game boot functions
void _launch(const dir_discHdr *hdr);
@ -1005,7 +1006,7 @@ private:
void _launchPlugin(dir_discHdr *hdr);
void _launchShutdown();
vector<string> _getMetaXML(const char *bootpath);
int _loadGameIOS(u8 ios, int userIOS, string id, bool RealNAND_Channels = false);
int _loadGameIOS(u8 ios, int userIOS, const char *id, bool RealNAND_Channels = false);
bool _loadFile(u8 * &buffer, u32 &size, const char *path, const char *file);// gameconfig.txt and cheats.gct
//

View File

@ -731,9 +731,13 @@ bool CMenu::_loadFile(u8 * &buffer, u32 &size, const char *path, const char *fil
/* used by wii and channel games to load the cIOS to use for the game */
/* plugins, apps, and gamecube games don't use cIOS */
int CMenu::_loadGameIOS(u8 gameIOS, int userIOS, string id, bool RealNAND_Channels)
int CMenu::_loadGameIOS(u8 gameIOS, int userIOS, const char *id, bool RealNAND_Channels)
{
gprintf("Game ID %s requested IOS %d.\nUser selected %d\n", id.c_str(), gameIOS, userIOS);
gprintf("Game ID %s requested IOS %d.\n", id, gameIOS);
if(!userIOS)
gprintf("User selected %d\n", userIOS);
else
gprintf("User selected AUTO\n");
// this if seems to have been used if wiiflow was in neek2o mode
// or cios 249 is a stub and wiiflow runs on ios58
@ -751,36 +755,49 @@ int CMenu::_loadGameIOS(u8 gameIOS, int userIOS, string id, bool RealNAND_Channe
return LOAD_IOS_SUCCEEDED;
}
if(userIOS)// if IOS is not 'auto' and set to a specific cIOS then set gameIOS to that cIOS if it's installed
u8 slot = 0;
// check if the user wants to use a specific cios and if it's installed.
if(userIOS && _installed_cios.find(userIOS) != _installed_cios.end())
slot = userIOS;
else // auto find a cios base match
{
// we need to find it just in case the gameconfig has been manually edited or that cios deleted.
bool found = false;
for(CIOSItr itr = _installed_cios.begin(); itr != _installed_cios.end(); itr++)
// Workaround for SpongeBobs Boating Bash
if(strncasecmp(id, "SBV", 3) == 0)
{
if(itr->second == userIOS || itr->first == userIOS)
slot = _cios_base[gameIOS];// try the games'IOS 53
if(!slot)
slot = _cios_base[58];
if(!slot && !IsOnWiiU())
slot = _cios_base[38];
}
else
slot = _cios_base[gameIOS];
if(!slot)// no direct match so we get the first cios with a greater base
{
for(CIOSItr itr = _cios_base.begin(); itr != _cios_base.end(); itr++)
{
found = true;
gameIOS = itr->first;
break;
if(itr->first > gameIOS)//compare bases
{
slot = itr->second;// set to cios slot
break;
}
}
}
if(!found)
gameIOS = mainIOS;
}
else
gameIOS = mainIOS;// mainIOS is usually 249 unless changed by boot args or changed on startup settings menu
gprintf("Changed requested IOS to %d.\n", gameIOS);
if(!slot)// shouldn't happen but just in case
slot = mainIOS;// set to wiiflow's cios
gprintf("cIOS slot %d chosen.\n", slot);
/* at this point gameIOS is a cIOS */
if(gameIOS != CurrentIOS.Version)
// now we reload to this cios slot if we need to
if(slot != CurrentIOS.Version)
{
gprintf("Reloading IOS into %d\n", gameIOS);
bool ret = loadIOS(gameIOS, true);//load cIOS requested and then remount sd and USB devices
bool ret = loadIOS(slot, true);//load cIOS requested and then remount sd and USB devices
if(has_enabled_providers() || m_use_wifi_gecko)
_initAsyncNetwork();// always seem to do netinit after changing IOS
if(ret == false)
{
_error(wfmt(_fmt("errgame4", L"Couldn't load IOS %i"), gameIOS));
_error(wfmt(_fmt("errgame4", L"Couldn't load IOS %i"), slot));
return LOAD_IOS_FAILED;
}
return LOAD_IOS_SUCCEEDED;
@ -940,7 +957,7 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
}
/* load selected cIOS if necessary */
if(_loadGameIOS(gameIOS, userIOS, id, !NANDemuView) == LOAD_IOS_FAILED)
if(_loadGameIOS(gameIOS, userIOS, id.c_str(), !NANDemuView) == LOAD_IOS_FAILED)
{
/* error message already shown */
return;
@ -1242,7 +1259,7 @@ void CMenu::_launchWii(dir_discHdr *hdr, bool dvd, bool disc_cfg)
/* load selected cIOS if necessary */
if(!dvd)
{
if(_loadGameIOS(gameIOS, userIOS, id) == LOAD_IOS_FAILED)
if(_loadGameIOS(gameIOS, userIOS, id.c_str()) == LOAD_IOS_FAILED)
{
/* error message already shown */
return;