diff --git a/out/bins/ext_booter.bin b/out/bins/ext_booter.bin index 8377de74..3df3a7fe 100644 Binary files a/out/bins/ext_booter.bin and b/out/bins/ext_booter.bin differ diff --git a/out/boot.dol b/out/boot.dol index d1781302..75f277b6 100644 Binary files a/out/boot.dol and b/out/boot.dol differ diff --git a/source/channel/nand.cpp b/source/channel/nand.cpp index 61cca9a6..48f83d95 100644 --- a/source/channel/nand.cpp +++ b/source/channel/nand.cpp @@ -77,15 +77,6 @@ void Nand::Init() isfs_inited = false; } -bool Nand::LoadDefaultIOS(void) -{ - Patch_AHB();//apply a patch so the new IOS will also have AHBPROT disabled - s32 ret = IOS_ReloadIOS(IOS_GetPreferredVersion());// reload to preferred IOS. not sure what wiiflows preferred IOS is. - loadIOS(IOS_GetVersion(), false);// this basically does nothing (well very little). definetly doesn't load a IOS or shutdown anything. - Init_ISFS(); - return (ret == 0); -} - void Nand::SetNANDEmu(u32 partition) { EmuDevice = partition == 0 ? EMU_SD : EMU_USB; diff --git a/source/channel/nand.hpp b/source/channel/nand.hpp index 1a5deb21..e31d5cdb 100644 --- a/source/channel/nand.hpp +++ b/source/channel/nand.hpp @@ -65,7 +65,6 @@ class Nand { public: void Init(); - bool LoadDefaultIOS(void); /* Prototypes */ void SetNANDEmu(u32 partition); diff --git a/source/defines.h b/source/defines.h index dcb95ab5..a7d46bee 100644 --- a/source/defines.h +++ b/source/defines.h @@ -1,6 +1,6 @@ #define APP_NAME "WiiFlow WFL" -#define APP_VERSION "5.4.4" +#define APP_VERSION "5.4.5" #define APP_DATA_DIR "wiiflow" #define APPS_DIR "apps/wiiflow" diff --git a/source/devicemounter/DeviceHandler.cpp b/source/devicemounter/DeviceHandler.cpp index adeafcd1..5ca29bd2 100644 --- a/source/devicemounter/DeviceHandler.cpp +++ b/source/devicemounter/DeviceHandler.cpp @@ -149,9 +149,10 @@ bool DeviceHandler::MountAllUSB() return false; /* Kill possible USB thread */ - KillUSBKeepAliveThread(); - /* Wait for our slowass HDD */ - WaitForDevice(GetUSBInterface()); + //KillUSBKeepAliveThread(); + /* usb spinup - Wait for our slowass HDD */ + if(WaitForDevice(GetUSBInterface()) == false) + return false; /* Get Partitions and Mount them */ if(!usb.IsInserted() || !usb.IsMounted(0)) usb.SetDevice(GetUSBInterface()); @@ -162,6 +163,7 @@ bool DeviceHandler::MountAllUSB() if(MountUSB(i)) result = true; } + // why force FAT? why not just return result? if(!result) result = usb.Mount(0, DeviceName[USB1], true); /* Force FAT */ //if(result && usb_libogc_mode) @@ -260,17 +262,19 @@ s32 DeviceHandler::OpenWBFS(int dev) return WBFS_Init(GetWbfsHandle(dev), part_fs, part_idx, part_lba, partition); } -void DeviceHandler::WaitForDevice(const DISC_INTERFACE *Handle) +/* usb spinup wait for 20 seconds */ +bool DeviceHandler::WaitForDevice(const DISC_INTERFACE *Handle) { - if(Handle == NULL) - return; + if(Handle == NULL)// apparently this never happens + return false; time_t timeout = time(NULL); while(time(NULL) - timeout < 20) { if(Handle->startup() && Handle->isInserted()) - break; + return true; usleep(50000); } + return false; } bool DeviceHandler::MountDevolution() diff --git a/source/devicemounter/DeviceHandler.hpp b/source/devicemounter/DeviceHandler.hpp index 32b54a06..15a23403 100644 --- a/source/devicemounter/DeviceHandler.hpp +++ b/source/devicemounter/DeviceHandler.hpp @@ -82,7 +82,7 @@ public: bool USB_Inserted() { return usb.IsInserted(); } bool UsablePartitionMounted(); bool PartitionUsableForNandEmu(int Partition); - void WaitForDevice(const DISC_INTERFACE *Handle); + bool WaitForDevice(const DISC_INTERFACE *Handle); void UnMountSD() { sd.UnMountAll(); } void UnMountUSB(int pos); diff --git a/source/loader/alt_ios.cpp b/source/loader/alt_ios.cpp index 12359198..3f7cd3ce 100644 --- a/source/loader/alt_ios.cpp +++ b/source/loader/alt_ios.cpp @@ -24,7 +24,7 @@ #include "dip_plugin_249.h" #include "mload_modules.h" -static int load_ehc_module_ex(void) +void load_ehc_module_ex(void) { u8 *ehc_cfg = search_for_ehcmodule_cfg((u8 *)ehcmodule_5, size_ehcmodule_5); if(ehc_cfg) @@ -35,7 +35,6 @@ static int load_ehc_module_ex(void) DCFlushRange((void *) (((u32)ehc_cfg[0]) & ~31), 32); } load_ehc_module(); - return 0; } void load_dip_249() diff --git a/source/loader/alt_ios.h b/source/loader/alt_ios.h index eb8c32bf..9205ed5f 100644 --- a/source/loader/alt_ios.h +++ b/source/loader/alt_ios.h @@ -8,6 +8,8 @@ extern "C" { #endif bool loadIOS(int ios, bool MountDevices); +void load_ehc_module_ex(void); +void load_dip_249(); #ifdef __cplusplus } diff --git a/source/main.cpp b/source/main.cpp index 4352ff8a..be1831bb 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -160,23 +160,33 @@ int main(int argc, char **argv) } else { - NandHandle.LoadDefaultIOS(); /* safe reload to preferred IOS */ - + NandHandle.Init_ISFS(); + /* load and check wiiflow save for possible new IOS and Port settings */ if(InternalSave.CheckSave()) InternalSave.LoadSettings(); /* Handle (c)IOS Loading */ - if(useMainIOS && CustomIOS(IOS_GetType(mainIOS))) /* Requested */ - iosOK = loadIOS(mainIOS, false) && CustomIOS(CurrentIOS.Type);// reload to cIOS (249 by default) + if(useMainIOS && CustomIOS(IOS_GetType(mainIOS)))// load cios + { + NandHandle.DeInit_ISFS(); + NandHandle.Patch_AHB(); + iosOK = IOS_ReloadIOS(mainIOS) == 0; + gprintf("AHBPROT disabled after IOS Reload: %s\n", AHBPROT_Patched() ? "yes" : "no"); + NandHandle.Init_ISFS(); + } else gprintf("Using IOS58\n");// stay on IOS58. no reload to cIOS + + IOS_GetCurrentIOSInfo(); + if(CurrentIOS.Type == IOS_TYPE_HERMES) + load_ehc_module_ex(); + else if(CurrentIOS.Type == IOS_TYPE_WANIN && CurrentIOS.Revision >= 18) + load_dip_249(); + DeviceHandle.SetModes(); + WDVD_Init(); } - /* sys inits */ - Sys_Init();// set reset and power button callbacks - Sys_ExitTo(EXIT_TO_HBC);// set exit to in case of failed launch - /* mount SD */ DeviceHandle.MountSD();// mount SD before calling isUsingUSB() duh! @@ -190,21 +200,14 @@ int main(int argc, char **argv) /* init controllers for input */ Open_Inputs();// WPAD_SetVRes() is called later in mainMenu.init() during cursor init which gets the theme pointer images + + /* sys inits */ + Sys_Init();// set reset and power button callbacks + bool startup_successful = false; /* init configs, folders, coverflow, gui and more */ if(mainMenu.init(usb_mounted)) { - if(CurrentIOS.Version != mainIOS) - { - if(useMainIOS || !DeviceHandle.UsablePartitionMounted())// if useMainIOS or there's isn't a FAT or NTFS partition - { - useMainIOS = false; - mainMenu.TempLoadIOS();// switch to cIOS - iosOK = CustomIOS(CurrentIOS.Type); - } - } - if(CurrentIOS.Version == mainIOS) - useMainIOS = true; //Needed for later checks if(!iosOK) mainMenu.terror("errboot1", L"No cIOS found!\ncIOS d2x 249 base 56 and 250 base 57 are enough for all your games."); else if(!DeviceHandle.UsablePartitionMounted()) @@ -213,6 +216,7 @@ int main(int argc, char **argv) mainMenu.terror("errboot3", L"Could not initialize the DIP module!"); else // alls good lets start wiiflow { + startup_successful = true; if(!isWiiVC) writeStub();// copy return stub to memory if(gameid != NULL && strlen(gameid) == 6)// if argv game ID then launch it @@ -224,6 +228,7 @@ int main(int argc, char **argv) mainMenu.cleanup();// removes all sounds, fonts, images, coverflow, plugin stuff, source menu and clear memory } ShutdownBeforeExit();// unmount devices and close inputs - Sys_Exit(); + if(startup_successful)// use wiiflow's exit choice otherwise just exit to loader (system menu or hbc) + Sys_Exit(); return 0; } diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index b731a273..e8689e6f 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -1109,6 +1109,7 @@ private: bool _gameinfo(void); void _gameSettings(const dir_discHdr *GameHdr, bool disc = false); void _CoverBanner(void); + int _sfCacheCoversNeeded(); int _cacheCovers(void); void _Explorer(void); const char *_FolderExplorer(const char *startPath); diff --git a/source/menu/menu_home.cpp b/source/menu/menu_home.cpp index 6a169ab4..eecf875d 100644 --- a/source/menu/menu_home.cpp +++ b/source/menu/menu_home.cpp @@ -466,6 +466,57 @@ void CMenu::_textShutdown(void) } /*******************************************************************************/ +int CMenu::_sfCacheCoversNeeded()// for sourceflow +{ + CoverFlow.stopCoverLoader(true); + + string coverPath; + string wfcPath; + string cachePath = m_cacheDir + "/sourceflow/"; + string gameNameOrID; + + bool smallBox = m_cfg.getBool(SOURCEFLOW_DOMAIN, "smallbox", false); + int missing = 0; + + for(vector::iterator hdr = m_gameList.begin(); hdr != m_gameList.end(); ++hdr) + { + /* get cover png path */ + bool blankCover = false; + bool fullCover = true; + coverPath.assign(getBoxPath(&(*hdr))); + if(!fsop_FileExist(coverPath.c_str()) || smallBox) + { + fullCover = false; + coverPath.assign(getFrontPath(&(*hdr))); + if(!fsop_FileExist(coverPath.c_str()) && !smallBox) + { + fullCover = true; + coverPath.assign(getBlankCoverPath(&(*hdr))); + blankCover = true; + if(!fsop_FileExist(coverPath.c_str())) + continue; + } + } + + /* get game name or ID */ + if(!blankCover) + gameNameOrID.assign(CoverFlow.getFilenameId(&(*hdr))); + else + gameNameOrID.assign(coverPath.substr(coverPath.find_last_of("/") + 1)); + + /* get cover wfc path */ + if(smallBox) + wfcPath.assign(cachePath + gameNameOrID + "_small.wfc"); + else + wfcPath.assign(cachePath + gameNameOrID); + + /* if wfc doesn't exist or is flat and have full cover */ + if(!fsop_FileExist(wfcPath.c_str()) || (!CoverFlow.fullCoverCached(wfcPath.c_str()) && fullCover)) + missing++; + } + return missing; +} + int CMenu::_cacheCovers() { CoverFlow.stopCoverLoader(true); diff --git a/source/menu/menu_input.cpp b/source/menu/menu_input.cpp index d6e6a41e..ff3d057f 100644 --- a/source/menu/menu_input.cpp +++ b/source/menu/menu_input.cpp @@ -54,18 +54,6 @@ static int CalculateRepeatSpeed(float magnitude, int current_value) void CMenu::ScanInput() { - /*for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--) - { - wd[chan] = WPAD_Data(chan); - if(wd[chan]->err < 0) - { - Close_Inputs(); - Open_Inputs(); - for(int chn = WPAD_MAX_WIIMOTES-1; chn >= 0; chn--) - WPAD_SetVRes(chn, m_vid.width() + m_cursor[chn].width(), m_vid.height() + m_cursor[chn].height()); - break; - } - }*/ m_show_zone_main = false; m_show_zone_main2 = false; m_show_zone_main3 = false; diff --git a/source/menu/menu_main.cpp b/source/menu/menu_main.cpp index cc27922b..e7b25c0a 100644 --- a/source/menu/menu_main.cpp +++ b/source/menu/menu_main.cpp @@ -240,31 +240,33 @@ void CMenu::_showCF(bool refreshList) if(cacheCovers) { cacheCovers = false; - m_btnMgr.setProgress(m_wbfsPBar, 0.f, true); - m_btnMgr.setText(m_wbfsLblMessage, L"0%"); - m_btnMgr.setText(m_wbfsLblDialog, L""); - m_btnMgr.show(m_wbfsPBar); - m_btnMgr.show(m_wbfsLblMessage); - m_btnMgr.show(m_wbfsLblDialog); - - _start_pThread(); - _cacheCovers(); - _stop_pThread(); - m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg14", L"Done.")); - u8 pause = 150; - if(m_sourceflow) - pause = 1; - while(!m_exit) + if(!m_sourceflow || _sfCacheCoversNeeded() > 0) { - _mainLoopCommon(); - pause--; - if(pause == 0) + m_btnMgr.setProgress(m_wbfsPBar, 0.f, true); + m_btnMgr.setText(m_wbfsLblMessage, L"0%"); + m_btnMgr.setText(m_wbfsLblDialog, L""); + m_btnMgr.show(m_wbfsPBar); + m_btnMgr.show(m_wbfsLblMessage); + m_btnMgr.show(m_wbfsLblDialog); + + _start_pThread(); + _cacheCovers(); + _stop_pThread(); + m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg14", L"Done.")); + u8 pause = 150; + if(m_sourceflow) + pause = 1; + do { - m_btnMgr.hide(m_wbfsPBar); - m_btnMgr.hide(m_wbfsLblMessage); - m_btnMgr.hide(m_wbfsLblDialog); - break; - } + _mainLoopCommon(); + pause--; + if(pause == 0) + { + m_btnMgr.hide(m_wbfsPBar); + m_btnMgr.hide(m_wbfsLblMessage); + m_btnMgr.hide(m_wbfsLblDialog); + } + }while(!m_exit && pause > 0); } } /* setup categories and favorites for filtering the game list below */ @@ -416,9 +418,7 @@ int CMenu::main(void) _setMainBg(); _showCF(true); } - else - _hideWaitMessage(); - + if(show_mem) { m_btnMgr.show(m_mem1FreeSize); diff --git a/source/menu/menu_source.cpp b/source/menu/menu_source.cpp index ddc4b8dc..d799fa2b 100644 --- a/source/menu/menu_source.cpp +++ b/source/menu/menu_source.cpp @@ -343,6 +343,7 @@ bool CMenu::_Source() SetupInput(); _showSource(); _updateSourceBtns(); + _hideWaitMessage();// needed for source menu on start while(!m_exit) {