diff --git a/out/boot.dol b/out/boot.dol index 1ca14fdb..33978ee2 100644 Binary files a/out/boot.dol and b/out/boot.dol differ diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index c0cba2db..09ec7ba8 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -2682,7 +2682,7 @@ void CMenu::_stopSounds(void) m_gameSound.Stop(); } -/* wiiflow creates a map _installed_cios list for slots 200 to 253 and slot 0 +/* wiiflow creates a map _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. } } } diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index be79a2ee..1462fc09 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -994,7 +994,8 @@ private: wstringEx _optBoolToString(int b); void _load_installed_cioses(); std::map _installed_cios; - typedef std::map::iterator CIOSItr; + typedef std::map::iterator CIOSItr;// we can use this for both maps. + std::map _cios_base; //game boot functions void _launch(const dir_discHdr *hdr); @@ -1005,7 +1006,7 @@ private: void _launchPlugin(dir_discHdr *hdr); void _launchShutdown(); vector _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 // diff --git a/source/menu/menu_game_boot.cpp b/source/menu/menu_game_boot.cpp index 6a25ad54..5f49a031 100644 --- a/source/menu/menu_game_boot.cpp +++ b/source/menu/menu_game_boot.cpp @@ -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;