diff --git a/source/booter/external_booter.cpp b/source/booter/external_booter.cpp index 70a628a0..267b357b 100644 --- a/source/booter/external_booter.cpp +++ b/source/booter/external_booter.cpp @@ -83,6 +83,8 @@ void WiiFlow_ExternalBooter(u8 vidMode, bool vipatch, bool countryString, u8 pat /* Copy in booter */ memcpy(EXT_ADDR, booter, booter_size); DCFlushRange(EXT_ADDR, booter_size); + /* Wii Games will need it */ + net_wc24cleanup(); /* Boot it */ JumpToEntry(EXT_ENTRY); } @@ -111,6 +113,7 @@ void ShutdownBeforeExit(bool KeepPatches) DeviceHandle.UnMountAll(); NandHandle.DeInit_ISFS(KeepPatches); WDVD_Close(); + Close_Inputs(); /* Deinit network */ if(networkInit == true) { diff --git a/source/channel/nand_save.cpp b/source/channel/nand_save.cpp index 86aeef08..0a9ee74f 100644 --- a/source/channel/nand_save.cpp +++ b/source/channel/nand_save.cpp @@ -169,10 +169,13 @@ void NandSave::LoadIOS() free(file); } -void NandSave::SaveIOS(const ios_settings_t settings) +void NandSave::SaveIOS(u8 ios, bool use_ios) { if(loaded == false) return; + memset(&ios_settings, 0, sizeof(ios_settings_t)); + ios_settings.cios = ios; + ios_settings.use_cios = use_ios; gprintf("Saving IOS Settings to NAND\n"); memset(&ISFS_Path, 0, ISFS_MAXPATH); strcpy(ISFS_Path, IOS_SAVE_PATH); @@ -180,7 +183,7 @@ void NandSave::SaveIOS(const ios_settings_t settings) fd = ISFS_Open(ISFS_Path, ISFS_OPEN_WRITE); if(fd < 0) return; - ret = ISFS_Write(fd, &settings, sizeof(ios_settings_t)); + ret = ISFS_Write(fd, &ios_settings, sizeof(ios_settings_t)); ISFS_Close(fd); if(ret < 0) ISFS_Delete(ISFS_Path); diff --git a/source/channel/nand_save.hpp b/source/channel/nand_save.hpp index 5d76e0af..0f7bff05 100644 --- a/source/channel/nand_save.hpp +++ b/source/channel/nand_save.hpp @@ -31,12 +31,13 @@ public: NandSave(); bool CheckSave(); void LoadIOS(); - void SaveIOS(const ios_settings_t settings); + void SaveIOS(u8 ios, bool use_ios); private: s32 fd; s32 ret; bool loaded; char ISFS_Path[ISFS_MAXPATH]; + ios_settings_t ios_settings; }; extern NandSave InternalSave; diff --git a/source/loader/alt_ios.cpp b/source/loader/alt_ios.cpp index 4b0d6465..10b86782 100644 --- a/source/loader/alt_ios.cpp +++ b/source/loader/alt_ios.cpp @@ -80,7 +80,6 @@ bool loadIOS(int ios, bool MountDevices) if(ios != CurIOS && IOS_GetType(ios) != IOS_TYPE_STUB) { WDVD_Close(); - Close_Inputs(); NandHandle.Patch_AHB(); //No AHBPROT for the next IOS gprintf("Reloading into IOS %i from %i...\n", ios, CurIOS); ShutdownBeforeExit(); diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index e1213904..83ee033f 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -12,6 +12,7 @@ #include "fonts.h" #include "banner/BannerWindow.hpp" #include "channel/nand.hpp" +#include "channel/nand_save.hpp" #include "fileOps/fileOps.h" #include "gc/gc.hpp" #include "gui/Gekko.h" @@ -216,6 +217,8 @@ void CMenu::init() init_network = (m_cfg.getBool("GENERAL", "async_network") || has_enabled_providers() || m_use_wifi_gecko); _netInit(); /* Check if we want a cIOS loaded */ + u8 prevCios = mainIOS; + bool prevForceCIOS = useMainIOS; int ForceIOS = min(m_cfg.getInt("GENERAL", "force_cios_rev", 0), 254); if(ForceIOS > 0) { @@ -223,6 +226,8 @@ void CMenu::init() mainIOS = ForceIOS; } useMainIOS = m_cfg.getBool("GENERAL", "force_cios_load", false); + if(prevCios != mainIOS || prevForceCIOS != useMainIOS) + InternalSave.SaveIOS(mainIOS, useMainIOS); /* Do our USB HDD Checks */ bool onUSB = m_cfg.getBool("GENERAL", "data_on_usb", strncmp(drive, "usb", 3) == 0); drive = check; //reset the drive variable for the check @@ -527,8 +532,6 @@ void CMenu::cleanup() CoverFlow.shutdown(); wiiLightOff(); - Close_Inputs(); - LWP_MutexDestroy(m_mutex); m_mutex = 0; diff --git a/source/menu/menu_boot.cpp b/source/menu/menu_boot.cpp index 92491e9e..6b761cd1 100644 --- a/source/menu/menu_boot.cpp +++ b/source/menu/menu_boot.cpp @@ -28,8 +28,6 @@ s16 m_bootLblCurCIOSrev; s16 m_bootLblCIOSrevM; s16 m_bootLblCIOSrevP; -ios_settings_t settings; - static void showBoot(void) { m_btnMgr.show(m_bootLblTitle); @@ -98,12 +96,7 @@ void CMenu::_Boot(void) bool cur_load = m_cfg.getBool("GENERAL", "force_cios_load", false); u8 cur_ios = min(m_cfg.getInt("GENERAL", "force_cios_rev", 0), 254); if(prev_load != cur_load || prev_ios != cur_ios) - { - memset(&settings, 0, sizeof(ios_settings_t)); - settings.cios = min(m_cfg.getInt("GENERAL", "force_cios_rev", 0), 254); - settings.use_cios = m_cfg.getBool("GENERAL", "force_cios_load", false); - InternalSave.SaveIOS(settings); - } + InternalSave.SaveIOS(cur_ios, cur_load); hideBoot(false); } diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index 3299981e..3928388e 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -1263,9 +1263,13 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) NandHandle.CreatePath("%s:/wiiflow/nandemu", DeviceName[emuPartition]); } } + /* Init NAND Emu Settings */ + NANDemuView = true; + NandHandle.SetNANDEmu(emuPartition); + NandHandle.SetPaths(emuPath.c_str(), DeviceName[emuPartition]); + /* Set them */ m_cfg.setInt(WII_DOMAIN, "savepartition", emuPartition); m_cfg.setString(WII_DOMAIN, "savepath", emuPath); - if(emulate_mode == 2 || emulate_mode > 3) { if(emulate_mode == 2) @@ -1332,9 +1336,6 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) } if(emulate_mode && !neek2o() && CurrentIOS.Type == IOS_TYPE_D2X) { - NANDemuView = true; - NandHandle.SetNANDEmu(emuPartition); /* Init NAND Emu */ - NandHandle.SetPaths(emuPath.c_str(), DeviceName[emuPartition]); /* Enable our Emu NAND */ DeviceHandle.UnMountAll(); if(emulate_mode == 3)