From 4e345b651f037dbf952001792410770bae63250e Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Sun, 9 Sep 2012 18:35:15 +0000 Subject: [PATCH] -cleaned up that exit to code --- source/channel/nand.cpp | 4 +- source/gui/video.hpp | 2 +- source/loader/sys.c | 28 ++++--------- source/loader/sys.h | 4 +- source/main.cpp | 1 - source/menu/menu.cpp | 17 ++------ source/menu/menu.hpp | 6 +-- source/menu/menu_about.cpp | 8 +--- source/menu/menu_categories.cpp | 5 +-- source/menu/menu_cftheme.cpp | 14 +++---- source/menu/menu_cheat.cpp | 8 ++-- source/menu/menu_code.cpp | 3 +- source/menu/menu_config.cpp | 16 ++++---- source/menu/menu_config3.cpp | 2 +- source/menu/menu_config4.cpp | 6 +-- source/menu/menu_config_adv.cpp | 2 +- source/menu/menu_config_game.cpp | 64 +++++++++++++++--------------- source/menu/menu_config_screen.cpp | 2 +- source/menu/menu_configsnd.cpp | 2 +- source/menu/menu_download.cpp | 4 +- source/menu/menu_game.cpp | 46 ++++++++------------- source/menu/menu_home.cpp | 25 ++++++------ source/menu/menu_main.cpp | 46 ++++++--------------- source/menu/menu_nandemu.cpp | 16 ++++---- source/menu/menu_plugin.cpp | 4 +- source/menu/menu_source.cpp | 8 ++-- source/menu/menu_system.cpp | 10 ++--- source/menu/menu_wbfs.cpp | 4 +- 28 files changed, 142 insertions(+), 215 deletions(-) diff --git a/source/channel/nand.cpp b/source/channel/nand.cpp index 6b59aa1f..71d8ecbb 100644 --- a/source/channel/nand.cpp +++ b/source/channel/nand.cpp @@ -1045,7 +1045,7 @@ extern "C" { extern s32 MagicPatches(s32); } void Nand::Init_ISFS() { - gprintf("Init ISFS\n"); + //gprintf("Init ISFS\n"); ISFS_Initialize(); if(AHBRPOT_Patched()) { @@ -1061,7 +1061,7 @@ void Nand::Init_ISFS() void Nand::DeInit_ISFS(bool KeepPatches) { - gprintf("Deinit ISFS\n"); + //gprintf("Deinit ISFS\n"); if(AHBRPOT_Patched()) { // Disable memory protection diff --git a/source/gui/video.hpp b/source/gui/video.hpp index e6c84768..8f4f3f0e 100644 --- a/source/gui/video.hpp +++ b/source/gui/video.hpp @@ -100,7 +100,7 @@ private: float m_vpW; float m_vpH; float m_waitMessageDelay; - bool m_showWaitMessage; + volatile bool m_showWaitMessage; volatile bool m_showingWaitMessages; vector m_waitMessages; // diff --git a/source/loader/sys.c b/source/loader/sys.c index 62bd8ac0..0de39bdb 100644 --- a/source/loader/sys.c +++ b/source/loader/sys.c @@ -52,7 +52,7 @@ void Close_Inputs(void) u32 cnt; /* Disconnect Wiimotes */ - for (cnt = 0; cnt < 4; cnt++) + for(cnt = 0; cnt < 4; cnt++) WPAD_Disconnect(cnt); /* Shutdown Wiimote subsystem */ @@ -68,22 +68,11 @@ void Sys_Shutdown(void) { /* via hollywood registers first */ *HW_GPIO_OUT |= (1<<1); + usleep(50000); /* If it failed just do the libogc way */ SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); } -void Sys_Test(void) -{ - if(reset || shutdown) - { - Close_Inputs(); - if(reset) - SYS_ResetSystem(SYS_RESTART, 0, 0); - else - Sys_Shutdown(); - } -} - int Sys_GetExitTo(void) { return ExitOption; @@ -129,8 +118,11 @@ void Sys_Exit(void) WII_LaunchTitle(HBC_JODI); WII_LaunchTitle(HBC_HAXX); } - //else boot system menu - Sys_LoadMenu(); + else if(ExitOption == BUTTON_CALLBACK) + Sys_Shutdown(); + /* else Return to Menu */ + SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); + exit(1); } void __Sys_ResetCallback(void) @@ -150,12 +142,6 @@ void Sys_Init(void) SYS_SetPowerCallback(__Sys_PowerCallback); } -void Sys_LoadMenu(void) -{ - /* Return to the Wii system menu */ - SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); -} - bool AHBRPOT_Patched(void) { return (*HW_AHBPROT == 0xFFFFFFFF); diff --git a/source/loader/sys.h b/source/loader/sys.h index dcc6a91e..477bf84f 100644 --- a/source/loader/sys.h +++ b/source/loader/sys.h @@ -23,13 +23,13 @@ enum EXIT_TO_DISABLE, EXIT_TO_BOOTMII, EXIT_TO_NEEK2O, + BUTTON_CALLBACK, }; /* Prototypes */ void Sys_Init(void); -void Sys_LoadMenu(void); +void Sys_Shutdown(void); bool Sys_Exiting(void); -void Sys_Test(void); void Sys_Exit(void); void Sys_ExitTo(int); int Sys_GetExitTo(void); diff --git a/source/main.cpp b/source/main.cpp index bdd135bb..a9ed2594 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -131,6 +131,5 @@ int main(int argc, char **argv) mainMenu->cleanup(); ShutdownBeforeExit(); Sys_Exit(); - exit(1); return 0; } diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 3ba2bf88..b7d2eba1 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -446,8 +446,6 @@ void CMenu::init(void) m_btnMgr.setRumble(m_cfg.getBool("GENERAL", "rumble", true)); int exit_to = m_cfg.getInt("GENERAL", "exit_to", 0); - m_disable_exit = exit_to == EXIT_TO_DISABLE; - if(exit_to == EXIT_TO_BOOTMII && (!DeviceHandler::Instance()->IsInserted(SD) || stat(fmt("%s:/bootmii/armboot.bin",DeviceName[SD]), &dummy) != 0 || stat(fmt("%s:/bootmii/ppcboot.elf", DeviceName[SD]), &dummy) != 0)) @@ -1786,7 +1784,7 @@ void CMenu::_initCF(void) m_cf.startCoverLoader(); } -void CMenu::_mainLoopCommon(bool withCF, bool blockReboot, bool adjusting) +void CMenu::_mainLoopCommon(bool withCF, bool adjusting) { if(withCF) m_cf.tick(); @@ -1846,17 +1844,8 @@ void CMenu::_mainLoopCommon(bool withCF, bool blockReboot, bool adjusting) if(!m_vid.showingWaitMessage()) m_vid.render(); - if(!blockReboot) - { - if(withCF && Sys_Exiting()) - m_cf.clear(); - if(Sys_Exiting()) - { - m_cat.save(); - m_cfg.save(); - } - Sys_Test(); - } + if(Sys_Exiting()) + exitHandler(BUTTON_CALLBACK); if(withCF && m_gameSelected && m_gamesound_changed && (m_gameSoundHdr == NULL) && !m_gameSound.IsPlaying() && m_music.GetVolume() == 0) { diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index 300195d1..33440c6a 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -648,8 +648,6 @@ private: bool m_show_zone_game; volatile bool m_exit; - volatile bool m_disable_exit; - volatile bool m_networkInit; volatile bool m_thrdStop; volatile bool m_thrdWorking; @@ -968,7 +966,7 @@ private: bool _Home(); bool _ExitTo(); // - void _mainLoopCommon(bool withCF = false, bool blockReboot = false, bool adjusting = false); + void _mainLoopCommon(bool withCF = false, bool adjusting = false); // vector _searchGamesByID(const char *gameId); /* vector _searchGamesByTitle(wchar_t letter); @@ -1097,7 +1095,7 @@ private: static const SOption _GCLoader[3]; static const SOption _vidModePatch[4]; static const SOption _hooktype[8]; - static const SOption _exitTo[6]; + static const SOption _exitTo[5]; static map _installed_cios; typedef map::iterator CIOSItr; static int _version[9]; diff --git a/source/menu/menu_about.cpp b/source/menu/menu_about.cpp index 01581e99..7c7b2198 100644 --- a/source/menu/menu_about.cpp +++ b/source/menu/menu_about.cpp @@ -32,15 +32,11 @@ void CMenu::_about(bool help) SetupInput(); _showAbout(); - while(1) + while(!m_exit) { _mainLoopCommon(); - - if (amount_of_skips == 0) - { - // Check dimensions in the loop, because the animation can have an effect + if(amount_of_skips == 0) // Check dimensions in the loop, because the animation can have an effect m_btnMgr.getDimensions(m_aboutLblInfo, thanks_x, thanks_y, thanks_w, thanks_h); // Get original dimensions - } if(first) { m_btnMgr.moveBy(m_aboutLblInfo, 0, -1); diff --git a/source/menu/menu_categories.cpp b/source/menu/menu_categories.cpp index ff0a0b17..106ee7d6 100644 --- a/source/menu/menu_categories.cpp +++ b/source/menu/menu_categories.cpp @@ -145,19 +145,17 @@ void CMenu::_CategorySettings(bool fromGameSet) memset(&m_categories, '0', m_max_categories); memcpy(&m_categories, catSettings, m_max_categories); _showCategorySettings(); - while(true) + while(!m_exit) { _mainLoopCommon(); m_cf.tick(); if(!m_btnMgr.selected(lastBtn)) m_btnMgr.noHover(false); - if(BTN_HOME_PRESSED || BTN_B_PRESSED || (BTN_A_PRESSED && m_btnMgr.selected(m_categoryBtnBack))) { char newCatSettings[m_max_categories + 1]; memset(&newCatSettings, 0, sizeof(newCatSettings)); memcpy(&newCatSettings, &m_categories, sizeof(m_categories)); - if(!fromGameSet) { newCatSettings[0] = '1'; @@ -173,7 +171,6 @@ void CMenu::_CategorySettings(bool fromGameSet) } else m_cat.setString(_domainFromView(), id, newCatSettings); - //m_cat.save(); break; } diff --git a/source/menu/menu_cftheme.cpp b/source/menu/menu_cftheme.cpp index db990e91..cf653620 100644 --- a/source/menu/menu_cftheme.cpp +++ b/source/menu/menu_cftheme.cpp @@ -321,27 +321,27 @@ void CMenu::_cfTheme(void) _showCFTheme(curParam, cfVersion, wide); _loadCFLayout(cfVersion, true, wide != m_vid.wide()); m_cf.applySettings(); - while (true) + while(!m_exit) { - _mainLoopCommon(true, false, curParam == 5 || curParam == 6 || curParam == 7); - if (BTN_HOME_PRESSED) + _mainLoopCommon(true); + if(BTN_HOME_PRESSED) { m_theme.clear(); m_theme.unload(); m_theme.load(fmt("%s/%s.ini", m_themeDir.c_str(), m_cfg.getString("GENERAL", "theme", "default").c_str())); break; } - else if (BTN_UP_PRESSED) + else if(BTN_UP_PRESSED) m_btnMgr.up(); - else if (BTN_DOWN_PRESSED) + else if(BTN_DOWN_PRESSED) m_btnMgr.down(); - if (BTN_B_HELD && BTN_1_PRESSED) + if(BTN_B_HELD && BTN_1_PRESSED) { copyVersion = cfVersion; copySelected = m_cf.selected(); copyWide = wide; } - else if (copyVersion > 0 && BTN_B_HELD && BTN_2_PRESSED) + else if(copyVersion > 0 && BTN_B_HELD && BTN_2_PRESSED) { string domSrc(sfmt(_cfDomain(copySelected), copyVersion)); string domDst(sfmt(_cfDomain(m_cf.selected()), cfVersion)); diff --git a/source/menu/menu_cheat.cpp b/source/menu/menu_cheat.cpp index 75c350d1..e87f2a4b 100644 --- a/source/menu/menu_cheat.cpp +++ b/source/menu/menu_cheat.cpp @@ -92,10 +92,10 @@ void CMenu::_CheatSettings() else m_btnMgr.setText(m_cheatLblTitle,L""); - while (true) + while(!m_exit) { _mainLoopCommon(); - if (BTN_HOME_PRESSED || BTN_B_PRESSED) + if(BTN_HOME_PRESSED || BTN_B_PRESSED) break; else if (BTN_UP_PRESSED) m_btnMgr.up(); @@ -185,9 +185,9 @@ void CMenu::_CheatSettings() m_thrdWorking = true; lwp_t thread = LWP_THREAD_NULL; LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_downloadCheatFileAsync, (void *)this, 0, 8192, 40); - while (m_thrdWorking) + while(m_thrdWorking) { - _mainLoopCommon(false, m_thrdWorking); + _mainLoopCommon(); if ((BTN_HOME_PRESSED || BTN_B_PRESSED) && !m_thrdWorking) break; if (BTN_A_PRESSED && !(m_thrdWorking && m_thrdStop)) diff --git a/source/menu/menu_code.cpp b/source/menu/menu_code.cpp index 1258e7b2..c2995c84 100644 --- a/source/menu/menu_code.cpp +++ b/source/menu/menu_code.cpp @@ -53,13 +53,12 @@ void CMenu::_code(void) m_btnMgr.show(m_codeBtnAge); m_btnMgr.show(m_codeBtnErase); } - while (true) + while(!m_exit) { int c = -1; _mainLoopCommon(); if (BTN_HOME_PRESSED) goBack = true; - if (WPadIR_ANY()) { if (BTN_B_PRESSED) diff --git a/source/menu/menu_config.cpp b/source/menu/menu_config.cpp index f4308cc6..0d4613bb 100644 --- a/source/menu/menu_config.cpp +++ b/source/menu/menu_config.cpp @@ -91,9 +91,9 @@ void CMenu::_config(int page) m_curGameId = m_cf.getId(); m_cfNeedsUpdate = false; int change = CONFIG_PAGE_NO_CHANGE; - while (true) + while(!m_exit) { - switch (page) + switch(page) { case 1: change = _config1(); @@ -114,9 +114,9 @@ void CMenu::_config(int page) change = _configScreen(); break; } - if (change == CONFIG_PAGE_BACK) + if(change == CONFIG_PAGE_BACK) break; - if (!m_locked) + if(!m_locked) { // assumes change is in the range of CONFIG_PAGE_DEC to CONFIG_PAGE_INC page += change; @@ -126,10 +126,10 @@ void CMenu::_config(int page) page = _nbCfgPages; } } - if (m_cfNeedsUpdate) + if(m_cfNeedsUpdate) { - m_cfg.save(); - _initCF(); + m_cfg.save(); + _initCF(); } } @@ -167,7 +167,7 @@ int CMenu::_config1(void) _showConfig(); _textConfig(); - while (true) + while(!m_exit) { change = _configCommon(); if (change != CONFIG_PAGE_NO_CHANGE) diff --git a/source/menu/menu_config3.cpp b/source/menu/menu_config3.cpp index c096de5e..213fc42e 100644 --- a/source/menu/menu_config3.cpp +++ b/source/menu/menu_config3.cpp @@ -107,7 +107,7 @@ int CMenu::_config3(void) int change = CONFIG_PAGE_NO_CHANGE; _showConfig3(); - while (true) + while(!m_exit) { change = _configCommon(); if (change != CONFIG_PAGE_NO_CHANGE) diff --git a/source/menu/menu_config4.cpp b/source/menu/menu_config4.cpp index 1d52d9fd..4fae476f 100644 --- a/source/menu/menu_config4.cpp +++ b/source/menu/menu_config4.cpp @@ -20,12 +20,11 @@ int amountOfChannels = -1; Channels m_channels; -const CMenu::SOption CMenu::_exitTo[6] = { +const CMenu::SOption CMenu::_exitTo[5] = { { "def", L"Default" }, { "menu", L"System Menu" }, { "hbc", L"HBC" }, { "prii", L"Priiloader" }, - { "disabled", L"Disabled" }, { "bootmii", L"BootMii" } }; @@ -110,7 +109,7 @@ int CMenu::_config4(void) int change = CONFIG_PAGE_NO_CHANGE; _showConfig4(); - while (true) + while(!m_exit) { change = _configCommon(); if (change != CONFIG_PAGE_NO_CHANGE) @@ -122,7 +121,6 @@ int CMenu::_config4(void) int exit_to = (int)loopNum((u32)m_cfg.getInt("GENERAL", "exit_to", 0) + 1, ARRAY_SIZE(CMenu::_exitTo)); m_cfg.setInt("GENERAL", "exit_to", exit_to); Sys_ExitTo(exit_to); - m_disable_exit = exit_to == EXIT_TO_DISABLE; _showConfig4(); } else if (m_btnMgr.selected(m_config4BtnSaveFavMode)) diff --git a/source/menu/menu_config_adv.cpp b/source/menu/menu_config_adv.cpp index 2b4efaf6..1777c2cd 100644 --- a/source/menu/menu_config_adv.cpp +++ b/source/menu/menu_config_adv.cpp @@ -107,7 +107,7 @@ int CMenu::_configAdv(void) break; } _showConfigAdv(); - while (true) + while(!m_exit) { change = _configCommon(); if (change != CONFIG_PAGE_NO_CHANGE) diff --git a/source/menu/menu_config_game.cpp b/source/menu/menu_config_game.cpp index 4a1c46ee..2f71f874 100644 --- a/source/menu/menu_config_game.cpp +++ b/source/menu/menu_config_game.cpp @@ -475,16 +475,16 @@ void CMenu::_gameSettings(void) m_gameSettingsPage = 1; _showGameSettings(); - while (true) + while(!m_exit) { _mainLoopCommon(); - if (BTN_HOME_PRESSED || BTN_B_PRESSED) + if(BTN_HOME_PRESSED || BTN_B_PRESSED) break; - else if (BTN_UP_PRESSED) + else if(BTN_UP_PRESSED) m_btnMgr.up(); - else if (BTN_DOWN_PRESSED) + else if(BTN_DOWN_PRESSED) m_btnMgr.down(); - if ((BTN_MINUS_PRESSED || BTN_LEFT_PRESSED || (BTN_A_PRESSED && m_btnMgr.selected(m_gameSettingsBtnPageM))) && !m_locked) + if((BTN_MINUS_PRESSED || BTN_LEFT_PRESSED || (BTN_A_PRESSED && m_btnMgr.selected(m_gameSettingsBtnPageM))) && !m_locked) { if (m_gameSettingsPage == 1) m_gameSettingsPage = g_numGCfPages; @@ -492,67 +492,69 @@ void CMenu::_gameSettings(void) if(BTN_LEFT_PRESSED || BTN_MINUS_PRESSED) m_btnMgr.click(m_gameSettingsBtnPageM); _showGameSettings(); } - else if ((BTN_PLUS_PRESSED || BTN_RIGHT_PRESSED || (BTN_A_PRESSED && m_btnMgr.selected(m_gameSettingsBtnPageP))) && !m_locked) + else if((BTN_PLUS_PRESSED || BTN_RIGHT_PRESSED || (BTN_A_PRESSED && m_btnMgr.selected(m_gameSettingsBtnPageP))) && !m_locked) { - if (m_gameSettingsPage == g_numGCfPages) + if(m_gameSettingsPage == g_numGCfPages) m_gameSettingsPage = 1; - else ++m_gameSettingsPage; - if(BTN_RIGHT_PRESSED || BTN_PLUS_PRESSED) m_btnMgr.click(m_gameSettingsBtnPageP); + else + ++m_gameSettingsPage; + if(BTN_RIGHT_PRESSED || BTN_PLUS_PRESSED) + m_btnMgr.click(m_gameSettingsBtnPageP); _showGameSettings(); } - else if (BTN_A_PRESSED) + else if(BTN_A_PRESSED) { - if (m_btnMgr.selected(m_gameSettingsBtnBack)) + if(m_btnMgr.selected(m_gameSettingsBtnBack)) break; - else if (m_btnMgr.selected(m_gameSettingsBtnOcarina)) + else if(m_btnMgr.selected(m_gameSettingsBtnOcarina)) { int intoption = loopNum(m_gcfg2.getBool(id, "cheat") + 1, 3); - if (intoption > 1) + if(intoption > 1) m_gcfg2.remove(id, "cheat"); else m_gcfg2.setOptBool(id, "cheat", intoption); _showGameSettings(); } - else if (m_btnMgr.selected(m_gameSettingsBtnVipatch)) + else if(m_btnMgr.selected(m_gameSettingsBtnVipatch)) { bool booloption = m_gcfg2.getBool(id, "vipatch"); - if (booloption != false) + if(booloption != false) m_gcfg2.remove(id, "vipatch"); else m_gcfg2.setBool(id, "vipatch", true); _showGameSettings(); } - else if (m_btnMgr.selected(m_gameSettingsBtnCountryPatch)) + else if(m_btnMgr.selected(m_gameSettingsBtnCountryPatch)) { bool booloption = m_gcfg2.getBool(id, "country_patch"); - if (booloption != false) + if(booloption != false) m_gcfg2.remove(id, "country_patch"); else m_gcfg2.setBool(id, "country_patch", true); _showGameSettings(); } - else if (m_btnMgr.selected(m_gameSettingsBtnIOSreloadBlock)) + else if(m_btnMgr.selected(m_gameSettingsBtnIOSreloadBlock)) { bool booloption = m_gcfg2.getBool(id, "reload_block"); - if (booloption != false) + if(booloption != false) m_gcfg2.remove(id, "reload_block"); else m_gcfg2.setBool(id, "reload_block", true); _showGameSettings(); } - else if (m_btnMgr.selected(m_gameSettingsBtnCustom)) + else if(m_btnMgr.selected(m_gameSettingsBtnCustom)) { bool booloption = m_gcfg2.getBool(id, "custom"); - if (booloption != false) + if(booloption != false) m_gcfg2.remove(id, "custom"); else m_gcfg2.setBool(id, "custom", true); _showGameSettings(); } - else if (m_btnMgr.selected(m_gameSettingsBtnLaunchNK)) + else if(m_btnMgr.selected(m_gameSettingsBtnLaunchNK)) { bool booloption = m_gcfg2.getBool(id, "useneek"); - if (booloption != false) + if(booloption != false) m_gcfg2.remove(id, "useneek"); else m_gcfg2.setBool(id, "useneek", true); @@ -576,43 +578,43 @@ void CMenu::_gameSettings(void) m_gcfg2.setBool(id, "dm_widescreen", true); _showGameSettings(); } - else if (m_btnMgr.selected(m_gameSettingsBtnLanguageP) || m_btnMgr.selected(m_gameSettingsBtnLanguageM)) + else if(m_btnMgr.selected(m_gameSettingsBtnLanguageP) || m_btnMgr.selected(m_gameSettingsBtnLanguageM)) { s8 direction = m_btnMgr.selected(m_gameSettingsBtnLanguageP) ? 1 : -1; m_gcfg2.setInt(id, "language", (int)loopNum((u32)m_gcfg2.getInt(id, "language", 0) + direction, ARRAY_SIZE(CMenu::_languages))); _showGameSettings(); } - else if (m_btnMgr.selected(m_gameSettingsBtnVideoP) || m_btnMgr.selected(m_gameSettingsBtnVideoM)) + else if(m_btnMgr.selected(m_gameSettingsBtnVideoP) || m_btnMgr.selected(m_gameSettingsBtnVideoM)) { s8 direction = m_btnMgr.selected(m_gameSettingsBtnVideoP) ? 1 : -1; m_gcfg2.setInt(id, "video_mode", (int)loopNum((u32)m_gcfg2.getInt(id, "video_mode", 0) + direction, ARRAY_SIZE(CMenu::_VideoModes))); _showGameSettings(); } - else if (m_btnMgr.selected(m_gameSettingsBtnDMLVideoP) || m_btnMgr.selected(m_gameSettingsBtnDMLVideoM)) + else if(m_btnMgr.selected(m_gameSettingsBtnDMLVideoP) || m_btnMgr.selected(m_gameSettingsBtnDMLVideoM)) { s8 direction = m_btnMgr.selected(m_gameSettingsBtnDMLVideoP) ? 1 : -1; m_gcfg2.setInt(id, "dml_video_mode", (int)loopNum((u32)m_gcfg2.getInt(id, "dml_video_mode", 0) + direction, ARRAY_SIZE(CMenu::_DMLvideoModes))); _showGameSettings(); } - else if (m_btnMgr.selected(m_gameSettingsBtnGClanguageP) || m_btnMgr.selected(m_gameSettingsBtnGClanguageM)) + else if(m_btnMgr.selected(m_gameSettingsBtnGClanguageP) || m_btnMgr.selected(m_gameSettingsBtnGClanguageM)) { s8 direction = m_btnMgr.selected(m_gameSettingsBtnGClanguageP) ? 1 : -1; m_gcfg2.setInt(id, "gc_language", (int)loopNum((u32)m_gcfg2.getInt(id, "gc_language", 0) + direction, ARRAY_SIZE(CMenu::_GClanguages))); _showGameSettings(); } - else if (m_btnMgr.selected(m_gameSettingsBtnAspectRatioP) || m_btnMgr.selected(m_gameSettingsBtnAspectRatioM)) + else if(m_btnMgr.selected(m_gameSettingsBtnAspectRatioP) || m_btnMgr.selected(m_gameSettingsBtnAspectRatioM)) { s8 direction = m_btnMgr.selected(m_gameSettingsBtnAspectRatioP) ? 1 : -1; m_gcfg2.setInt(id, "aspect_ratio", (int)loopNum((u32)m_gcfg2.getInt(id, "aspect_ratio", 0) + direction, ARRAY_SIZE(CMenu::_AspectRatio))); _showGameSettings(); } - else if (m_btnMgr.selected(m_gameSettingsBtnNMM_P) || m_btnMgr.selected(m_gameSettingsBtnNMM_M)) + else if(m_btnMgr.selected(m_gameSettingsBtnNMM_P) || m_btnMgr.selected(m_gameSettingsBtnNMM_M)) { s8 direction = m_btnMgr.selected(m_gameSettingsBtnNMM_P) ? 1 : -1; m_gcfg2.setInt(id, "dml_nmm", (int)loopNum((u32)m_gcfg2.getInt(id, "dml_nmm", 0) + direction, ARRAY_SIZE(CMenu::_NMM))); _showGameSettings(); } - else if (m_btnMgr.selected(m_gameSettingsBtnNoDVD_P) || m_btnMgr.selected(m_gameSettingsBtnNoDVD_M)) + else if(m_btnMgr.selected(m_gameSettingsBtnNoDVD_P) || m_btnMgr.selected(m_gameSettingsBtnNoDVD_M)) { s8 direction = m_btnMgr.selected(m_gameSettingsBtnNoDVD_P) ? 1 : -1; m_gcfg2.setInt(id, "no_disc_patch", (int)loopNum((u32)m_gcfg2.getInt(id, "no_disc_patch", 0) + direction, ARRAY_SIZE(CMenu::_NoDVD))); @@ -624,7 +626,7 @@ void CMenu::_gameSettings(void) m_gcfg2.setInt(id, "gc_loader", (int)loopNum((u32)m_gcfg2.getInt(id, "gc_loader", 0) + direction, ARRAY_SIZE(CMenu::_GCLoader))); _showGameSettings(); } - else if (m_btnMgr.selected(m_gameSettingsBtnIOSM) || m_btnMgr.selected(m_gameSettingsBtnIOSP)) + else if(m_btnMgr.selected(m_gameSettingsBtnIOSM) || m_btnMgr.selected(m_gameSettingsBtnIOSP)) { if( _installed_cios.size() > 0) { diff --git a/source/menu/menu_config_screen.cpp b/source/menu/menu_config_screen.cpp index 418cfc5e..980aea92 100644 --- a/source/menu/menu_config_screen.cpp +++ b/source/menu/menu_config_screen.cpp @@ -64,7 +64,7 @@ int CMenu::_configScreen(void) SetupInput(); _showConfigScreen(); - while (true) + while(!m_exit) { change = _configCommon(); if (change != CONFIG_PAGE_NO_CHANGE) diff --git a/source/menu/menu_configsnd.cpp b/source/menu/menu_configsnd.cpp index 26406f84..5b930375 100644 --- a/source/menu/menu_configsnd.cpp +++ b/source/menu/menu_configsnd.cpp @@ -65,7 +65,7 @@ int CMenu::_configSnd(void) int step = 1; _showConfigSnd(); - while (true) + while(!m_exit) { change = _configCommon(); if (change != CONFIG_PAGE_NO_CHANGE) diff --git a/source/menu/menu_download.cpp b/source/menu/menu_download.cpp index e55b8890..50259b42 100644 --- a/source/menu/menu_download.cpp +++ b/source/menu/menu_download.cpp @@ -1222,9 +1222,9 @@ void CMenu::_download(string gameId) else m_coverDLGameId = gameId; - while(true) + while(!m_exit) { - _mainLoopCommon(false, m_thrdWorking); + _mainLoopCommon(); if ((BTN_HOME_PRESSED || BTN_B_PRESSED) && !m_thrdWorking) { if(settingsmenu) diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index 9c18302b..7102cc85 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -393,7 +393,7 @@ void CMenu::_game(bool launch) m_banner->ToogleZoom(); s8 startGameSound = 1; - while(true) + while(!m_exit) { if(startGameSound < 1) startGameSound++; @@ -594,7 +594,7 @@ void CMenu::_game(bool launch) m_cf.clear(); _showWaitMessage(); - exitHandler(0); //Making wiiflow ready to boot something + exitHandler(PRIILOADER_DEF); //Making wiiflow ready to boot something if(hdr->type != TYPE_HOMEBREW && hdr->type != TYPE_PLUGIN) { @@ -903,7 +903,7 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc) WII_Initialize(); WII_LaunchTitle(0x100000100LL); } - Sys_LoadMenu(); + Sys_Exit(); } void CMenu::_launchHomebrew(const char *filepath, vector arguments) @@ -962,7 +962,7 @@ int CMenu::_loadIOS(u8 gameIOS, int userIOS, string id) if(_installed_cios.size() <= 0) { error(sfmt("errgame2", L"No cIOS found!")); - Sys_LoadMenu(); + Sys_Exit(); } u8 IOS[3]; IOS[0] = gameIOS; @@ -1081,7 +1081,7 @@ void CMenu::_launchChannel(dir_discHdr *hdr) if(!Load_Neek2o_Kernel()) { error(_t("errneek1", L"Cannot launch neek2o. Verify your neek2o setup")); - Sys_LoadMenu(); + Sys_Exit(); } ShutdownBeforeExit(); Launch_nk(gameTitle, emuPath.size() > 1 ? emuPath.c_str() : NULL); @@ -1097,7 +1097,7 @@ void CMenu::_launchChannel(dir_discHdr *hdr) if(!emu_disabled) Nand::Instance()->Disable_Emu(); if(_loadIOS(gameIOS, userIOS, id) == LOAD_IOS_FAILED) - return; + Sys_Exit(); } if(CurrentIOS.Type == IOS_TYPE_D2X && rtrn != NULL && strlen(rtrn) == 4) { @@ -1125,15 +1125,14 @@ void CMenu::_launchChannel(dir_discHdr *hdr) { Nand::Instance()->Disable_Emu(); error(_t("errgame5", L"Enabling emu failed!")); - return; + Sys_Exit(); } } if(forwarder) { ShutdownBeforeExit(); WII_Initialize(); - if(WII_LaunchTitle(gameTitle) < 0) - Sys_LoadMenu(); + WII_LaunchTitle(gameTitle); } else { @@ -1143,6 +1142,7 @@ void CMenu::_launchChannel(dir_discHdr *hdr) ExternalBooter_ChannelSetup(gameTitle); BootChannel(gameTitle, gameIOS, videoMode, vipatch, countryPatch, patchVidMode, aspectRatio); } + Sys_Exit(); } void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) @@ -1167,7 +1167,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) if(WDVD_GetCoverStatus(&cover) < 0) { error(_t("errgame7", L"WDVDGetCoverStatus Failed!")); - if (BTN_B_PRESSED) return; + Sys_Exit(); } if(!(cover & 0x2)) { @@ -1186,8 +1186,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) if(Disc_Open(true) < 0) { error(_t("wbfsoperr2", L"Disc_Open failed")); - if(BTN_B_PRESSED) - return; + Sys_Exit(); } /* Check disc */ if(Disc_IsWii() < 0) @@ -1195,8 +1194,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) if (Disc_IsGC() < 0) { error(_t("errgame9", L"This is not a Wii or GC disc")); - if(BTN_B_PRESSED) - return; + Sys_Exit(); } else { @@ -1296,23 +1294,18 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) } } #ifndef DOLPHIN - bool iosLoaded = false; if(!dvd || neek2o()) { int result = _loadIOS(GetRequestedGameIOS(hdr), m_gcfg2.getInt(id, "ios"), id); if(result == LOAD_IOS_FAILED) - return; - if(result == LOAD_IOS_SUCCEEDED) - iosLoaded = true; + Sys_Exit(); } -#else - bool iosLoaded = true; #endif DeviceHandler::Instance()->Open_WBFS(currentPartition); bool wbfs_partition = (DeviceHandler::Instance()->GetFSType(currentPartition) == PART_FS_WBFS); if(!dvd && !wbfs_partition && get_frag_list((u8 *)id.c_str(), (char*)path.c_str(), currentPartition == 0 ? 0x200 : USBStorage2_GetSectorSize()) < 0) - return; + Sys_Exit(); u8 patchVidMode = min((u32)m_gcfg2.getInt(id, "patch_video_modes", 0), ARRAY_SIZE(CMenu::_vidModePatch) - 1u); hooktype = (u32) m_gcfg2.getInt(id, "hooktype", 0); // hooktype is defined in patchcode.h @@ -1394,8 +1387,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) { Nand::Instance()->Disable_Emu(); error(_t("errgame6", L"Enabling emu after reload failed!")); - Sys_LoadMenu(); - return; + Sys_Exit(); } if(!DeviceHandler::Instance()->IsInserted(currentPartition)) DeviceHandler::Instance()->Mount(currentPartition); @@ -1408,16 +1400,12 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) { gprintf("Set USB failed: %d\n", ret); error(wfmt(_fmt("errgame10", L"Set USB failed: %d"), ret)); - if(iosLoaded) - Sys_LoadMenu(); - return; + Sys_Exit(); } if(Disc_Open(false) < 0) { error(_t("wbfsoperr2", L"Disc_Open failed")); - if(iosLoaded) - Sys_LoadMenu(); - return; + Sys_Exit(); } } if(CurrentIOS.Type == IOS_TYPE_HERMES) diff --git a/source/menu/menu_home.cpp b/source/menu/menu_home.cpp index bcf5b629..28aff30d 100644 --- a/source/menu/menu_home.cpp +++ b/source/menu/menu_home.cpp @@ -3,6 +3,7 @@ #include "svnrev.h" #include "loader/cios.h" #include "loader/nk.h" +#include "loader/sys.h" u32 m_homeLblTitle; u32 m_exittoLblTitle; @@ -28,7 +29,7 @@ bool CMenu::_Home(void) _showHome(); string prevTheme = m_cfg.getString("GENERAL", "theme", "default"); - while(1) + while(!m_exit) { _mainLoopCommon(); if(BTN_A_PRESSED) @@ -86,7 +87,7 @@ bool CMenu::_Home(void) { _hideHome(); if(m_locked) - exitHandler(0); + exitHandler(PRIILOADER_DEF); else _ExitTo(); if(m_exit) @@ -96,12 +97,12 @@ bool CMenu::_Home(void) } else if(BTN_HOME_PRESSED) { - exitHandler(0); + exitHandler(PRIILOADER_DEF); break; } else if(BTN_B_PRESSED) break; - } + } _hideHome(); return m_exit; @@ -112,29 +113,29 @@ bool CMenu::_ExitTo(void) SetupInput(); _showExitTo(); - while(1) + while(!m_exit) { _mainLoopCommon(); if(BTN_A_PRESSED) { if(m_btnMgr.selected(m_homeBtnExitToHBC)) { - exitHandler(1); + exitHandler(EXIT_TO_HBC); break; } else if(m_btnMgr.selected(m_homeBtnExitToMenu)) { - exitHandler(2); + exitHandler(EXIT_TO_MENU); break; } else if(m_btnMgr.selected(m_homeBtnExitToPriiloader)) { - exitHandler(3); + exitHandler(EXIT_TO_PRIILOADER); break; } else if(m_btnMgr.selected(m_homeBtnExitToBootmii)) { - exitHandler(4); + exitHandler(EXIT_TO_BOOTMII); break; } else if(m_btnMgr.selected(m_homeBtnExitToNeek)) @@ -142,16 +143,16 @@ bool CMenu::_ExitTo(void) if(!Load_Neek2o_Kernel()) { error(sfmt("errneek1", L"Cannot launch neek2o. Verify your neek2o setup")); - exitHandler(2); + exitHandler(PRIILOADER_DEF); } else - exitHandler(5); + exitHandler(EXIT_TO_BOOTMII); break; } } else if(BTN_HOME_PRESSED) { - exitHandler(0); + exitHandler(PRIILOADER_DEF); break; } else if(BTN_B_PRESSED) diff --git a/source/menu/menu_main.cpp b/source/menu/menu_main.cpp index 5d5f7b21..bfc68211 100644 --- a/source/menu/menu_main.cpp +++ b/source/menu/menu_main.cpp @@ -210,39 +210,19 @@ void CMenu::LoadView(void) void CMenu::exitHandler(int ExitTo) { - gprintf("Exit WiiFlow called\n"); - Nand::Instance()->Disable_Emu(); - if(!m_disable_exit || ExitTo == 0) + m_exit = true; + if(ExitTo == EXIT_TO_BOOTMII) //Bootmii, check that the files are there, or ios will hang. { - m_exit = true; - if(ExitTo == 1) // HBC - Sys_ExitTo(EXIT_TO_HBC); - else if(ExitTo == 2) // System Menu - Sys_ExitTo(EXIT_TO_MENU); - else if(ExitTo == 3) // Priiloader - Sys_ExitTo(EXIT_TO_PRIILOADER); - else if(ExitTo == 4) //Bootmii, check that the files are there, or ios will hang. - { - struct stat dummy; - if(DeviceHandler::Instance()->IsInserted(SD) && - stat(fmt("%s:/bootmii/armboot.bin", DeviceName[SD]), &dummy) == 0 && - stat(fmt("%s:/bootmii/ppcboot.elf", DeviceName[SD]), &dummy) == 0) - { - Sys_ExitTo(EXIT_TO_BOOTMII); - } - else - Sys_ExitTo(EXIT_TO_HBC); - } - else if(ExitTo == 5) //Neek2o kernel - Sys_ExitTo(EXIT_TO_NEEK2O); - } - m_reload = (BTN_B_HELD || m_disable_exit); - if(m_exit) - { - // Mark exiting to prevent soundhandler from restarting - extern bool exiting; - exiting = true; + struct stat dummy; + if(!DeviceHandler::Instance()->IsInserted(SD) || + stat("sd:/bootmii/armboot.bin", &dummy) != 0 || + stat("sd:/bootmii/ppcboot.elf", &dummy) != 0) + ExitTo = EXIT_TO_HBC; } + Sys_ExitTo(ExitTo); + // Mark exiting to prevent soundhandler from restarting + extern bool exiting; + exiting = true; } int CMenu::main(void) @@ -297,7 +277,7 @@ int CMenu::main(void) bUsed = true; } - while(true) + while(!m_exit) { /* IMPORTANT check if a disc is inserted */ WDVD_GetCoverStatus(&disc_check); @@ -838,7 +818,7 @@ int CMenu::main(void) { m_cf.clear(); _showWaitMessage(); - exitHandler(0); //Making wiiflow ready to boot something + exitHandler(PRIILOADER_DEF); //Making wiiflow ready to boot something _launchHomebrew(fmt("%s/boot.dol", m_appDir.c_str()), m_homebrewArgs); return 0; } diff --git a/source/menu/menu_nandemu.cpp b/source/menu/menu_nandemu.cpp index 1ccae1e8..8019e8fc 100644 --- a/source/menu/menu_nandemu.cpp +++ b/source/menu/menu_nandemu.cpp @@ -325,9 +325,9 @@ int CMenu::_NandEmuCfg(void) m_thrdMessageAdded = false; m_nandext = false; - while(true) + while(!m_exit) { - _mainLoopCommon(false, m_thrdWorking); + _mainLoopCommon(); if((BTN_HOME_PRESSED || BTN_B_PRESSED) && !m_thrdWorking) break; else if(BTN_UP_PRESSED) @@ -428,9 +428,9 @@ int CMenu::_FlashSave(string gameId) m_saveExtGameId = gameId; - while(true) + while(!m_exit) { - _mainLoopCommon(false, m_thrdWorking); + _mainLoopCommon(); if(m_forceext) { m_forceext = false; @@ -523,9 +523,9 @@ int CMenu::_AutoExtractSave(string gameId) m_saveExtGameId = gameId; - while(true) + while(!m_exit) { - _mainLoopCommon(false, m_thrdWorking); + _mainLoopCommon(); if((BTN_A_PRESSED && (m_btnMgr.selected(m_nandemuBtnExtract))) || m_forceext) { m_forceext = false; @@ -618,9 +618,9 @@ int CMenu::_AutoCreateNand(void) m_btnMgr.show(m_nandemuBtnPartition); m_btnMgr.show(m_nandemuLblInit); - while(true) + while(!m_exit) { - _mainLoopCommon(false, m_thrdWorking); + _mainLoopCommon(); if(BTN_A_PRESSED && (m_btnMgr.selected(m_nandemuBtnExtract))) { m_fulldump = true; diff --git a/source/menu/menu_plugin.cpp b/source/menu/menu_plugin.cpp index 23744d4c..2f3f551a 100644 --- a/source/menu/menu_plugin.cpp +++ b/source/menu/menu_plugin.cpp @@ -101,7 +101,7 @@ void CMenu::_PluginSettings() Plugin_curPage = 1; _textPluginSettings(); _showPluginSettings(); - while(true) + while(!m_exit) { _mainLoopCommon(); if(!m_btnMgr.selected(Plugin_lastBtn)) @@ -222,7 +222,7 @@ void CMenu::_textPluginSettings(void) m_btnMgr.setText(m_pluginLblTitle, _t("cfgpl1", L"Select Plugins")); m_btnMgr.setText(m_pluginBtnBack, _t("cd1", L"Back")); u8 i = 0; - while(true) + while(!m_exit) { if(i == 0) m_btnMgr.setText(m_pluginLblCat[i], _t("dl25", L"All")); diff --git a/source/menu/menu_source.cpp b/source/menu/menu_source.cpp index e612276a..88e23820 100644 --- a/source/menu/menu_source.cpp +++ b/source/menu/menu_source.cpp @@ -189,14 +189,12 @@ bool CMenu::_Source() m_btnMgr.show(m_sourceBtnEmu); } else - { _updateSourceBtns(); - } - - while(true) + + while(!m_exit) { _mainLoopCommon(); - if (BTN_HOME_PRESSED || BTN_B_PRESSED) + if(BTN_HOME_PRESSED || BTN_B_PRESSED) { back = true; break; diff --git a/source/menu/menu_system.cpp b/source/menu/menu_system.cpp index 16343198..ef47a58b 100644 --- a/source/menu/menu_system.cpp +++ b/source/menu/menu_system.cpp @@ -29,15 +29,11 @@ void CMenu::_system() m_thrdStop = false; m_thrdMessageAdded = false; m_showtimer = -1; - while (true) + while(!m_exit) { - _mainLoopCommon(false, m_thrdWorking); - - if (amount_of_skips == 0) - { - // Check dimensions in the loop, because the animation can have an effect + _mainLoopCommon(); + if(amount_of_skips == 0) // Check dimensions in the loop, because the animation can have an effect m_btnMgr.getDimensions(m_systemLblInfo, update_x, update_y, update_w, update_h); // Get original dimensions - } if(first) { m_btnMgr.moveBy(m_systemLblInfo, 0, -(pixels_to_skip * 10)); diff --git a/source/menu/menu_wbfs.cpp b/source/menu/menu_wbfs.cpp index 2854f1a9..a70ffc52 100644 --- a/source/menu/menu_wbfs.cpp +++ b/source/menu/menu_wbfs.cpp @@ -288,9 +288,9 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op) } m_thrdStop = false; m_thrdMessageAdded = false; - while(true) + while(!m_exit) { - _mainLoopCommon(false, m_thrdWorking); + _mainLoopCommon(); if((BTN_HOME_PRESSED || BTN_B_PRESSED) && !m_thrdWorking) break; else if(BTN_UP_PRESSED)