diff --git a/out/boot.dol b/out/boot.dol index 1e282446..7f07a863 100644 Binary files a/out/boot.dol and b/out/boot.dol differ diff --git a/source/defines.h b/source/defines.h index fd94f524..0633072e 100644 --- a/source/defines.h +++ b/source/defines.h @@ -24,6 +24,12 @@ #define HOMEBREW_DOMAIN "HOMEBREW" #define SOURCEFLOW_DOMAIN "SOURCEFLOW" +#define WII_PMAGIC "4E574949" +#define GC_PMAGIC "4E47434D" +#define ENAND_PMAGIC "454E414E" +#define NAND_PMAGIC "4E414E44" +#define HB_PMAGIC "48425257" + #define DEVELOPERS "Fledge68" #define PAST_DEVELOPERS "FIX94, OverjoY, Hibernatus, Narolez, Hulk, Miigotu, r-win" #define LOADER_AUTHOR "Kwiirk, Waninkoko, Hermes" diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index f997bacc..ad8c73a0 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -2226,7 +2226,7 @@ void CMenu::_initCF(void) { if(enabledPluginsCount == 1)// only one plugin enabled { - if(m_plugin.GetEnabledStatus(m_plugin.GetPluginPosition(strtoul("48425257", NULL, 16))))// homebrew plugin + if(m_plugin.GetEnabledStatus(HB_PMAGIC))// homebrew plugin { CoverFlow.setBoxMode(m_cfg.getBool(HOMEBREW_DOMAIN, "box_mode", true)); CoverFlow.setSmallBoxMode(m_cfg.getBool(HOMEBREW_DOMAIN, "smallbox", false)); @@ -2309,7 +2309,7 @@ void CMenu::_initCF(void) u32 sourceNumber = 0; if(m_current_view == COVERFLOW_PLUGIN && !m_sourceflow) { - if(!m_plugin.GetEnabledStatus(m_plugin.GetPluginPosition(strtoul(m_cfg.getString(PLUGIN_DOMAIN, "cur_magic", "00000000").c_str(), NULL, 16)))) + if(!m_plugin.GetEnabledStatus(m_cfg.getString(PLUGIN_DOMAIN, "cur_magic", "00000000").c_str())) { for(u8 i = 0; m_plugin.PluginExist(i); ++i) { @@ -2323,13 +2323,13 @@ void CMenu::_initCF(void) strncpy(m_plugin.PluginMagicWord, m_cfg.getString(PLUGIN_DOMAIN, "cur_magic").c_str(), 8); - if(strncasecmp(m_plugin.PluginMagicWord, "4E47434D", 8) == 0)//NGCM + if(strncasecmp(m_plugin.PluginMagicWord, GC_PMAGIC, 8) == 0)//NGCM ID = m_cfg.getString("plugin_item", m_plugin.PluginMagicWord, ""); - else if(strncasecmp(m_plugin.PluginMagicWord, "4E574949", 8) == 0)//NWII + else if(strncasecmp(m_plugin.PluginMagicWord, WII_PMAGIC, 8) == 0)//NWII ID = m_cfg.getString("plugin_item", m_plugin.PluginMagicWord, ""); - else if(strncasecmp(m_plugin.PluginMagicWord, "4E414E44", 8) == 0)//NAND + else if(strncasecmp(m_plugin.PluginMagicWord, NAND_PMAGIC, 8) == 0)//NAND ID = m_cfg.getString("plugin_item", m_plugin.PluginMagicWord, ""); - else if(strncasecmp(m_plugin.PluginMagicWord, "454E414E", 8) == 0)//EMUNAND + else if(strncasecmp(m_plugin.PluginMagicWord, ENAND_PMAGIC, 8) == 0)//EMUNAND ID = m_cfg.getString("plugin_item", m_plugin.PluginMagicWord, ""); else filename = m_cfg.getString("plugin_item", m_plugin.PluginMagicWord, "");// homebrew and plugins @@ -2394,23 +2394,34 @@ bool CMenu::_loadList(void) bool CMenu::_loadWiiList(void) { - currentPartition = m_cfg.getInt(WII_DOMAIN, "partition", USB1); - if(!DeviceHandle.IsInserted(currentPartition)) - return false; - gprintf("Adding wii list\n"); - DeviceHandle.OpenWBFS(currentPartition); - string gameDir(fmt(wii_games_dir, DeviceName[currentPartition])); - string cacheDir(fmt("%s/%s_wii.db", m_listCacheDir.c_str(), DeviceName[currentPartition])); + bool updateCache = m_cfg.getBool(WII_DOMAIN, "update_cache"); - bool preCachedList = fsop_FileExist(cacheDir.c_str()); - m_cacheList.CreateList(COVERFLOW_WII, gameDir, stringToVector(".wbfs|.iso", '|'), cacheDir, updateCache); - WBFS_Close(); - m_cfg.remove(WII_DOMAIN, "update_cache"); - for(vector::iterator tmp_itr = m_cacheList.begin(); tmp_itr != m_cacheList.end(); tmp_itr++) - m_gameList.push_back(*tmp_itr); - if(updateCache || (!preCachedList && fsop_FileExist(cacheDir.c_str()))) + if(updateCache) cacheCovers = true; + m_cfg.remove(WII_DOMAIN, "update_cache"); + for(u8 i = 0; i < 2; ++i) + { + currentPartition = m_cfg.getInt(WII_DOMAIN, "partition", USB1); + if(currentPartition == 8) + currentPartition = i; + else if(i == 1) + continue; + + if(!DeviceHandle.IsInserted(currentPartition)) + continue; + + DeviceHandle.OpenWBFS(currentPartition); + string gameDir(fmt(wii_games_dir, DeviceName[currentPartition])); + string cacheDir(fmt("%s/%s_wii.db", m_listCacheDir.c_str(), DeviceName[currentPartition])); + bool preCachedList = fsop_FileExist(cacheDir.c_str()); + m_cacheList.CreateList(COVERFLOW_WII, gameDir, stringToVector(".wbfs|.iso", '|'), cacheDir, updateCache); + WBFS_Close(); + for(vector::iterator tmp_itr = m_cacheList.begin(); tmp_itr != m_cacheList.end(); tmp_itr++) + m_gameList.push_back(*tmp_itr); + if(!preCachedList && fsop_FileExist(cacheDir.c_str())) + cacheCovers = true; + } return true; } @@ -2436,25 +2447,36 @@ bool CMenu::_loadHomebrewList(const char *HB_Dir) bool CMenu::_loadGamecubeList() { - currentPartition = m_cfg.getInt(GC_DOMAIN, "partition", USB1); - if(!DeviceHandle.IsInserted(currentPartition)) - return false; - gprintf("Adding gamecube list\n"); - string gameDir(fmt(gc_games_dir, DeviceName[currentPartition])); - string cacheDir(fmt("%s/%s_gamecube.db", m_listCacheDir.c_str(), DeviceName[currentPartition])); + bool updateCache = m_cfg.getBool(GC_DOMAIN, "update_cache"); - bool preCachedList = fsop_FileExist(cacheDir.c_str()); - m_cacheList.CreateList(COVERFLOW_GAMECUBE, gameDir, stringToVector(".iso|.gcm|.ciso|root", '|'), cacheDir, updateCache); - m_cfg.remove(GC_DOMAIN, "update_cache"); - for(vector::iterator tmp_itr = m_cacheList.begin(); tmp_itr != m_cacheList.end(); tmp_itr++) - { - if(tmp_itr->settings[0] == 1) /* disc 2 */ - continue;// skip gc disc 2 if its still part of the cached list - m_gameList.push_back(*tmp_itr); - } - if(updateCache || (!preCachedList && fsop_FileExist(cacheDir.c_str()))) + if(updateCache) cacheCovers = true; + m_cfg.remove(GC_DOMAIN, "update_cache"); + for(u8 i = 0; i < 2; ++i) + { + currentPartition = m_cfg.getInt(GC_DOMAIN, "partition", USB1); + if(currentPartition == 8) + currentPartition = i; + else if(i == 1) + continue; + + if(!DeviceHandle.IsInserted(currentPartition)) + continue; + + string gameDir(fmt(gc_games_dir, DeviceName[currentPartition])); + string cacheDir(fmt("%s/%s_gamecube.db", m_listCacheDir.c_str(), DeviceName[currentPartition])); + bool preCachedList = fsop_FileExist(cacheDir.c_str()); + m_cacheList.CreateList(COVERFLOW_GAMECUBE, gameDir, stringToVector(".iso|.gcm|.ciso|root", '|'), cacheDir, updateCache); + for(vector::iterator tmp_itr = m_cacheList.begin(); tmp_itr != m_cacheList.end(); tmp_itr++) + { + if(tmp_itr->settings[0] == 1) /* disc 2 */ + continue;// skip gc disc 2 if its still part of the cached list + m_gameList.push_back(*tmp_itr); + } + if(!preCachedList && fsop_FileExist(cacheDir.c_str())) + cacheCovers = true; + } return true; } @@ -2518,32 +2540,32 @@ bool CMenu::_loadPluginList() const char *romDir = m_plugin.GetRomDir(i); if(strstr(romDir, "scummvm.ini") == NULL) { - if(strncasecmp(m_plugin.PluginMagicWord, "484252", 6) == 0)//HBRW + if(strncasecmp(m_plugin.PluginMagicWord, HB_PMAGIC, 6) == 0)//HBRW { if(updateCache) m_cfg.setBool(HOMEBREW_DOMAIN, "update_cache", true); _loadHomebrewList(romDir); } - else if(strncasecmp(m_plugin.PluginMagicWord, "4E47434D", 8) == 0)//NGCM + else if(strncasecmp(m_plugin.PluginMagicWord, GC_PMAGIC, 8) == 0)//NGCM { if(updateCache) m_cfg.setBool(GC_DOMAIN, "update_cache", true); _loadGamecubeList(); } - else if(strncasecmp(m_plugin.PluginMagicWord, "4E574949", 8) == 0)//NWII + else if(strncasecmp(m_plugin.PluginMagicWord, WII_PMAGIC, 8) == 0)//NWII { if(updateCache) m_cfg.setBool(WII_DOMAIN, "update_cache", true); _loadWiiList(); } - else if(strncasecmp(m_plugin.PluginMagicWord, "4E414E44", 8) == 0)//NAND + else if(strncasecmp(m_plugin.PluginMagicWord, NAND_PMAGIC, 8) == 0)//NAND { if(updateCache) m_cfg.setBool(CHANNEL_DOMAIN, "update_cache", true); m_cfg.setInt(CHANNEL_DOMAIN, "channels_type", CHANNELS_REAL); _loadChannelList(); } - else if(strncasecmp(m_plugin.PluginMagicWord, "454E414E", 8) == 0)//ENAN + else if(strncasecmp(m_plugin.PluginMagicWord, ENAND_PMAGIC, 8) == 0)//ENAN { if(updateCache) m_cfg.setBool(CHANNEL_DOMAIN, "update_cache", true); @@ -2808,22 +2830,22 @@ const char *CMenu::getBlankCoverPath(const dir_discHdr *element) switch(element->type) { case TYPE_CHANNEL: - strncpy(m_plugin.PluginMagicWord, "4E414E44", 9); + strncpy(m_plugin.PluginMagicWord, NAND_PMAGIC, 9); break; case TYPE_EMUCHANNEL: - strncpy(m_plugin.PluginMagicWord, "454E414E", 9); + strncpy(m_plugin.PluginMagicWord, ENAND_PMAGIC, 9); break; case TYPE_HOMEBREW: - strncpy(m_plugin.PluginMagicWord, "48425257", 9); + strncpy(m_plugin.PluginMagicWord, HB_PMAGIC, 9); break; case TYPE_GC_GAME: - strncpy(m_plugin.PluginMagicWord, "4E47434D", 9); + strncpy(m_plugin.PluginMagicWord, GC_PMAGIC, 9); break; case TYPE_PLUGIN: strncpy(m_plugin.PluginMagicWord, fmt("%08x", element->settings[0]), 8); break; default:// wii - strncpy(m_plugin.PluginMagicWord, "4E574949", 9); + strncpy(m_plugin.PluginMagicWord, WII_PMAGIC, 9); } blankCoverTitle = m_platform.getString("PLUGINS", m_plugin.PluginMagicWord, "wii"); } diff --git a/source/menu/menu_categories.cpp b/source/menu/menu_categories.cpp index 9c19bc50..6e2ce430 100644 --- a/source/menu/menu_categories.cpp +++ b/source/menu/menu_categories.cpp @@ -69,15 +69,15 @@ void CMenu::_setCatGenDomain() if(m_plugin.GetEnabledStatus(i)) { strncpy(m_plugin.PluginMagicWord, fmt("%08x", m_plugin.GetPluginMagic(i)), 8); - if(strncasecmp(m_plugin.PluginMagicWord, "4E47434D", 8) == 0)//NGCM + if(strncasecmp(m_plugin.PluginMagicWord, GC_PMAGIC, 8) == 0)//NGCM continue; - else if(strncasecmp(m_plugin.PluginMagicWord, "4E574949", 8) == 0)//NWII + else if(strncasecmp(m_plugin.PluginMagicWord, WII_PMAGIC, 8) == 0)//NWII continue; - else if(strncasecmp(m_plugin.PluginMagicWord, "4E414E44", 8) == 0)//NAND + else if(strncasecmp(m_plugin.PluginMagicWord, NAND_PMAGIC, 8) == 0)//NAND continue; - else if(strncasecmp(m_plugin.PluginMagicWord, "454E414E", 8) == 0)//EMUNAND + else if(strncasecmp(m_plugin.PluginMagicWord, ENAND_PMAGIC, 8) == 0)//EMUNAND continue; - else if(strncasecmp(m_plugin.PluginMagicWord, "48425257", 8) == 0)//HBRW + else if(strncasecmp(m_plugin.PluginMagicWord, HB_PMAGIC, 8) == 0)//HBRW continue; else { diff --git a/source/menu/menu_config_game.cpp b/source/menu/menu_config_game.cpp index c2d324b9..a6840e9f 100644 --- a/source/menu/menu_config_game.cpp +++ b/source/menu/menu_config_game.cpp @@ -524,7 +524,7 @@ void CMenu::_configGame(const dir_discHdr *hdr, bool disc) // smallBox = m_cfg.getBool(SOURCEFLOW_DOMAIN, "smallbox", false); else if(m_current_view == COVERFLOW_PLUGIN && !m_sourceflow) { - if(enabledPluginsCount == 1 && m_plugin.GetEnabledStatus(m_plugin.GetPluginPosition(strtoul("48425257", NULL, 16)))) + if(enabledPluginsCount == 1 && m_plugin.GetEnabledStatus(HB_PMAGIC)) smallBox = m_cfg.getBool(HOMEBREW_DOMAIN, "smallbox", false); } diff --git a/source/menu/menu_config_hb.cpp b/source/menu/menu_config_hb.cpp index 3a4e6dc4..db6914f7 100644 --- a/source/menu/menu_config_hb.cpp +++ b/source/menu/menu_config_hb.cpp @@ -36,9 +36,8 @@ void CMenu::_showConfigHB(void) m_btnMgr.setText(m_configBtn2, m_cfg.getBool(HOMEBREW_DOMAIN, "smallbox") ? _t("on", L"On") : _t("off", L"Off")); m_btnMgr.setText(m_configBtn3, m_cfg.getBool(HOMEBREW_DOMAIN, "box_mode") ? _t("on", L"On") : _t("off", L"Off")); - currentPartition = m_cfg.getInt(HOMEBREW_DOMAIN, "partition", 0); - const char *partitionname = DeviceName[currentPartition]; - m_btnMgr.setText(m_configLbl4Val, upperCase(partitionname)); + currentPartition = m_cfg.getInt(HOMEBREW_DOMAIN, "partition", SD); + m_btnMgr.setText(m_configLbl4Val, upperCase(DeviceName[currentPartition])); m_btnMgr.show(m_configLbl1); m_btnMgr.show(m_configBtn1); @@ -95,10 +94,10 @@ void CMenu::_ConfigHB(void) { s8 direction = m_btnMgr.selected(m_configBtn4P) ? 1 : -1; _setPartition(direction, m_cfg.getInt(HOMEBREW_DOMAIN, "partition"), COVERFLOW_HOMEBREW); - const char *partitionname = DeviceName[currentPartition]; - m_btnMgr.setText(m_configLbl4Val, upperCase(partitionname)); + m_cfg.setInt(HOMEBREW_DOMAIN, "partition", currentPartition); + m_btnMgr.setText(m_configLbl4Val, upperCase(DeviceName[currentPartition])); if(m_current_view & COVERFLOW_HOMEBREW || - (m_current_view & COVERFLOW_PLUGIN && m_plugin.GetEnabledStatus(m_plugin.GetPluginPosition(strtoul("48425257", NULL, 16))))) + (m_current_view & COVERFLOW_PLUGIN && m_plugin.GetEnabledStatus(HB_PMAGIC))) { m_refreshGameList = true; //m_cfg.setBool(HOMEBREW_DOMAIN, "update_cache", true); diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index 03ddb721..d5f9e2b5 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -49,15 +49,15 @@ void CMenu::_setCurrentItem(const dir_discHdr *hdr) else { if(hdr->type == TYPE_WII_GAME) - strncpy(m_plugin.PluginMagicWord, "4E574949", 9); + strncpy(m_plugin.PluginMagicWord, WII_PMAGIC, 9); else if(hdr->type == TYPE_GC_GAME) - strncpy(m_plugin.PluginMagicWord, "4E47434D", 9); + strncpy(m_plugin.PluginMagicWord, GC_PMAGIC, 9); else if(hdr->type == TYPE_CHANNEL) - strncpy(m_plugin.PluginMagicWord, "4E414E44", 9); + strncpy(m_plugin.PluginMagicWord, NAND_PMAGIC, 9); else if(hdr->type == TYPE_EMUCHANNEL) - strncpy(m_plugin.PluginMagicWord, "454E414E", 9); + strncpy(m_plugin.PluginMagicWord, ENAND_PMAGIC, 9); else //HOMEBREW - strncpy(m_plugin.PluginMagicWord, "48425257", 9); + strncpy(m_plugin.PluginMagicWord, HB_PMAGIC, 9); } m_cfg.setString(PLUGIN_DOMAIN, "cur_magic", m_plugin.PluginMagicWord); m_cfg.setString("plugin_item", m_plugin.PluginMagicWord, fn_id); diff --git a/source/menu/menu_home.cpp b/source/menu/menu_home.cpp index f4a4c6ec..893ecad3 100644 --- a/source/menu/menu_home.cpp +++ b/source/menu/menu_home.cpp @@ -541,7 +541,7 @@ int CMenu::_cacheCovers() smallBox = m_cfg.getBool(SOURCEFLOW_DOMAIN, "smallbox", false); else if(m_current_view == COVERFLOW_PLUGIN && !m_sourceflow) { - if(enabledPluginsCount == 1 && m_plugin.GetEnabledStatus(m_plugin.GetPluginPosition(strtoul("48425257", NULL, 16)))) + if(enabledPluginsCount == 1 && m_plugin.GetEnabledStatus(HB_PMAGIC)) smallBox = m_cfg.getBool(HOMEBREW_DOMAIN, "smallbox", false); } diff --git a/source/menu/menu_main.cpp b/source/menu/menu_main.cpp index 4f46bb87..7049b6e6 100644 --- a/source/menu/menu_main.cpp +++ b/source/menu/menu_main.cpp @@ -58,15 +58,15 @@ void CMenu::_getCustomBgTex() { case COVERFLOW_CHANNEL: if(m_cfg.getInt(CHANNEL_DOMAIN, "channels_type") & CHANNELS_REAL) - strncpy(m_plugin.PluginMagicWord, "4E414E44", 9); + strncpy(m_plugin.PluginMagicWord, NAND_PMAGIC, 9); else - strncpy(m_plugin.PluginMagicWord, "454E414E", 9); + strncpy(m_plugin.PluginMagicWord, ENAND_PMAGIC, 9); break; case COVERFLOW_HOMEBREW: - strncpy(m_plugin.PluginMagicWord, "48425257", 9); + strncpy(m_plugin.PluginMagicWord, HB_PMAGIC, 9); break; case COVERFLOW_GAMECUBE: - strncpy(m_plugin.PluginMagicWord, "4E47434D", 9); + strncpy(m_plugin.PluginMagicWord, GC_PMAGIC, 9); break; case COVERFLOW_PLUGIN: while(m_plugin.PluginExist(i) && !m_plugin.GetEnabledStatus(i)) { ++i; } @@ -74,7 +74,7 @@ void CMenu::_getCustomBgTex() strncpy(m_plugin.PluginMagicWord, fmt("%08x", m_plugin.GetPluginMagic(i)), 8); break; default:// wii - strncpy(m_plugin.PluginMagicWord, "4E574949", 9); + strncpy(m_plugin.PluginMagicWord, WII_PMAGIC, 9); } if(strlen(m_plugin.PluginMagicWord) == 8) fn = m_platform.getString("PLUGINS", m_plugin.PluginMagicWord, ""); @@ -305,7 +305,7 @@ void CMenu::_showCF(bool refreshList) if(m_current_view == COVERFLOW_PLUGIN && !m_sourceflow) { /* check if homebrew plugin */ - if(enabledPluginsCount == 1 && m_plugin.GetEnabledStatus(m_plugin.GetPluginPosition(strtoul("48425257", NULL, 16))) && m_cfg.getBool(HOMEBREW_DOMAIN, "smallbox")) + if(enabledPluginsCount == 1 && m_plugin.GetEnabledStatus(HB_PMAGIC) && m_cfg.getBool(HOMEBREW_DOMAIN, "smallbox")) strcpy(cf_domain, "_SMALLFLOW"); else if(enabledPluginsCount > 0 && m_platform.loaded()) { @@ -1215,42 +1215,6 @@ wstringEx CMenu::_getNoticeTranslation(int sorting, wstringEx curLetter) return curLetter; } -void CMenu::_setPartition(s8 direction, u8 partition, u8 coverflow)// COVERFLOW_NONE is for emu saves nand -{ - if(m_source_cnt > 1 && coverflow > 0)// changing partition not allowed when more than one source is selected - return; - - currentPartition = partition; - u8 prev_view = m_current_view; - m_current_view = coverflow; - int FS_Type = 0; - bool NeedFAT = m_current_view == COVERFLOW_CHANNEL || m_current_view == COVERFLOW_GAMECUBE || m_current_view == COVERFLOW_NONE; - u8 limiter = 0; - - if(direction != 0)// change partition if direction is not zero - { - do - { - currentPartition = loopNum(currentPartition + direction, 9); - FS_Type = DeviceHandle.GetFSType(currentPartition); - limiter++; - } - while(limiter < 9 && (!DeviceHandle.IsInserted(currentPartition) || - (m_current_view != COVERFLOW_WII && FS_Type == PART_FS_WBFS) || - (NeedFAT && FS_Type != PART_FS_FAT))); - } - - /* set partition to currentPartition */ - if(limiter < 9) - { - if(coverflow == COVERFLOW_NONE)// saves emu nand - m_cfg.setInt(WII_DOMAIN, "savepartition", currentPartition); - else if(m_current_view != COVERFLOW_CHANNEL || (FS_Type != -1 && DeviceHandle.IsInserted(currentPartition))) - m_cfg.setInt(_domainFromView(), "partition", currentPartition); - } - m_current_view = prev_view; -} - void CMenu::exitHandler(int ExitTo) { m_exit = true; diff --git a/source/menu/menu_nandemu.cpp b/source/menu/menu_nandemu.cpp index 4e69b98f..d76fd026 100644 --- a/source/menu/menu_nandemu.cpp +++ b/source/menu/menu_nandemu.cpp @@ -132,14 +132,13 @@ void CMenu::_showNandEmu(void) else { m_btnMgr.setText(m_configLbl1, _t("cfgne38", L"Saves NAND Partition")); + currentPartition = m_cfg.getInt(WII_DOMAIN, "savepartition"); + m_btnMgr.setText(m_configLbl1Val, upperCase(DeviceName[currentPartition])); m_btnMgr.setText(m_configLbl2, _t("cfgne40", L"Use Real NAND Config")); - m_btnMgr.setText(m_configLbl3, _t("cfgne41", L"Use Real NAND Miis")); - - const char *partitionname = DeviceName[m_cfg.getInt(WII_DOMAIN, "savepartition")]; - m_btnMgr.setText(m_configLbl1Val, upperCase(partitionname)); - m_btnMgr.setText(m_configBtn2, m_cfg.getBool(CHANNEL_DOMAIN, "real_nand_config", false) ? _t("on", L"On") : _t("off", L"Off")); + + m_btnMgr.setText(m_configLbl3, _t("cfgne41", L"Use Real NAND Miis")); m_btnMgr.setText(m_configBtn3, m_cfg.getBool(CHANNEL_DOMAIN, "real_nand_miis", false) ? _t("on", L"On") : _t("off", L"Off")); m_btnMgr.show(m_configLbl1); @@ -298,9 +297,9 @@ int CMenu::_NandEmuCfg(void) { direction = m_btnMgr.selected(m_configBtn1P) ? 1 : -1; _setPartition(direction, m_cfg.getInt(WII_DOMAIN, "savepartition"), COVERFLOW_NONE); + m_cfg.setInt(WII_DOMAIN, "savepartition", currentPartition); + m_btnMgr.setText(m_configLbl1Val, upperCase(DeviceName[currentPartition])); _getEmuNands();// refresh emunands in case the partition was changed - const char *partitionname = DeviceName[m_cfg.getInt(WII_DOMAIN, "savepartition")]; - m_btnMgr.setText(m_configLbl1Val, upperCase(partitionname)); } else if(m_btnMgr.selected(m_configBtn2)) { diff --git a/source/menu/menu_partitions.cpp b/source/menu/menu_partitions.cpp index e35adfa1..b2059fea 100644 --- a/source/menu/menu_partitions.cpp +++ b/source/menu/menu_partitions.cpp @@ -7,6 +7,11 @@ s16 m_partitionsLblUser[4]; TexData m_partitionsBg; +static inline int loopNum(int i, int s) +{ + return (i + s) % s; +} + void CMenu::_hidePartitionsCfg(bool instant) { m_btnMgr.hide(m_partitionsLblTitle, instant); @@ -32,17 +37,17 @@ void CMenu::_showPartitionsCfg(void) m_btnMgr.setText(m_configLbl3, _t("part3", L"Emu NANDS Partition")); m_btnMgr.setText(m_configLbl4, _t("part4", L"Plugins Default Partition")); - const char *partitionname = DeviceName[m_cfg.getInt(WII_DOMAIN, "partition", 0)]; - m_btnMgr.setText(m_configLbl1Val, upperCase(partitionname)); + currentPartition = m_cfg.getInt(WII_DOMAIN, "partition", USB1); + m_btnMgr.setText(m_configLbl1Val, currentPartition == 8 ? "SD/USB" : upperCase(DeviceName[currentPartition])); - partitionname = DeviceName[m_cfg.getInt(GC_DOMAIN, "partition", 0)]; - m_btnMgr.setText(m_configLbl2Val, upperCase(partitionname)); + currentPartition = m_cfg.getInt(GC_DOMAIN, "partition", USB1); + m_btnMgr.setText(m_configLbl2Val, currentPartition == 8 ? "SD/USB" : upperCase(DeviceName[currentPartition])); - partitionname = DeviceName[m_cfg.getInt(CHANNEL_DOMAIN, "partition", 0)]; - m_btnMgr.setText(m_configLbl3Val, upperCase(partitionname)); + currentPartition = m_cfg.getInt(CHANNEL_DOMAIN, "partition", USB1); + m_btnMgr.setText(m_configLbl3Val, upperCase(DeviceName[currentPartition])); - partitionname = DeviceName[m_cfg.getInt(PLUGIN_DOMAIN, "partition", 0)]; - m_btnMgr.setText(m_configLbl4Val, upperCase(partitionname)); + currentPartition = m_cfg.getInt(PLUGIN_DOMAIN, "partition", SD); + m_btnMgr.setText(m_configLbl4Val, upperCase(DeviceName[currentPartition])); m_btnMgr.show(m_configLbl1); m_btnMgr.show(m_configLbl1Val); @@ -64,7 +69,6 @@ void CMenu::_showPartitionsCfg(void) void CMenu::_partitionsCfg(void) { - //int prevPartition = currentPartition; SetupInput(); _showPartitionsCfg(); while(!m_exit) @@ -84,55 +88,41 @@ void CMenu::_partitionsCfg(void) { s8 direction = m_btnMgr.selected(m_configBtn1P) ? 1 : -1; _setPartition(direction, m_cfg.getInt(WII_DOMAIN, "partition"), COVERFLOW_WII); + m_cfg.setInt(WII_DOMAIN, "partition", currentPartition); _showPartitionsCfg(); - if(m_current_view & COVERFLOW_WII || - (m_current_view & COVERFLOW_PLUGIN && m_plugin.GetEnabledStatus(m_plugin.GetPluginPosition(strtoul("4E574949", NULL, 16))))) - { + if(m_current_view & COVERFLOW_WII || (m_current_view & COVERFLOW_PLUGIN && m_plugin.GetEnabledStatus(WII_PMAGIC))) m_refreshGameList = true; - //prevPartition = currentPartition; - } } else if(m_btnMgr.selected(m_configBtn2P) || m_btnMgr.selected(m_configBtn2M)) { s8 direction = m_btnMgr.selected(m_configBtn2P) ? 1 : -1; _setPartition(direction, m_cfg.getInt(GC_DOMAIN, "partition"), COVERFLOW_GAMECUBE); + m_cfg.setInt(GC_DOMAIN, "partition", currentPartition); _showPartitionsCfg(); - if(m_current_view & COVERFLOW_GAMECUBE || - (m_current_view & COVERFLOW_PLUGIN && m_plugin.GetEnabledStatus(m_plugin.GetPluginPosition(strtoul("4E47434D", NULL, 16))))) - { + if(m_current_view & COVERFLOW_GAMECUBE || (m_current_view & COVERFLOW_PLUGIN && m_plugin.GetEnabledStatus(GC_PMAGIC))) m_refreshGameList = true; - //prevPartition = currentPartition; - } } else if(m_btnMgr.selected(m_configBtn3P) || m_btnMgr.selected(m_configBtn3M)) { s8 direction = m_btnMgr.selected(m_configBtn3P) ? 1 : -1; _setPartition(direction, m_cfg.getInt(CHANNEL_DOMAIN, "partition"), COVERFLOW_CHANNEL); + m_cfg.setInt(CHANNEL_DOMAIN, "partition", currentPartition); _showPartitionsCfg(); // partition only for emu nands - if(m_current_view & COVERFLOW_CHANNEL || - (m_current_view & COVERFLOW_PLUGIN && m_plugin.GetEnabledStatus(m_plugin.GetPluginPosition(strtoul("454E414E", NULL, 16))))) - { + if(m_current_view & COVERFLOW_CHANNEL || (m_current_view & COVERFLOW_PLUGIN && m_plugin.GetEnabledStatus(ENAND_PMAGIC))) m_refreshGameList = true; - //prevPartition = currentPartition; - } } else if(m_btnMgr.selected(m_configBtn4P) || m_btnMgr.selected(m_configBtn4M)) { s8 direction = m_btnMgr.selected(m_configBtn4P) ? 1 : -1; _setPartition(direction, m_cfg.getInt(PLUGIN_DOMAIN, "partition"), COVERFLOW_PLUGIN); + m_cfg.setInt(PLUGIN_DOMAIN, "partition", currentPartition); _showPartitionsCfg(); if(m_current_view & COVERFLOW_PLUGIN) - { m_refreshGameList = true; - //prevPartition = currentPartition; - } } } } - //m_current_view = m_prev_view; - //m_prev_view = 0; - //currentPartition = prevPartition; _hidePartitionsCfg(); } @@ -156,3 +146,29 @@ void CMenu::_textPartitionsCfg(void) m_btnMgr.setText(m_partitionsLblTitle, _t("part5", L"Partition Settings")); m_btnMgr.setText(m_partitionsBtnBack, _t("cfg10", L"Back")); } + +void CMenu::_setPartition(s8 direction, u8 partition, u8 coverflow)// COVERFLOW_NONE is for emu saves nand +{ + currentPartition = partition; + u8 prev_view = m_current_view;// save and restore later + m_current_view = coverflow; + int FS_Type = 0; + bool NeedFAT = m_current_view == COVERFLOW_CHANNEL || m_current_view == COVERFLOW_GAMECUBE || m_current_view == COVERFLOW_NONE; + u8 limiter = 0; + + if(direction != 0)// change partition if direction is not zero + { + do + { + currentPartition = loopNum(currentPartition + direction, 9); + if(currentPartition == 8 && (m_current_view == COVERFLOW_WII || m_current_view == COVERFLOW_GAMECUBE)) + break; + FS_Type = DeviceHandle.GetFSType(currentPartition); + limiter++; + } + while(limiter < 9 && (!DeviceHandle.IsInserted(currentPartition) || + (m_current_view != COVERFLOW_WII && FS_Type == PART_FS_WBFS) || + (NeedFAT && FS_Type != PART_FS_FAT))); + } + m_current_view = prev_view; +} diff --git a/source/menu/menu_plugin.cpp b/source/menu/menu_plugin.cpp index 50ac44f7..053c7a8c 100644 --- a/source/menu/menu_plugin.cpp +++ b/source/menu/menu_plugin.cpp @@ -173,9 +173,9 @@ void CMenu::_PluginSettings() else enabledMagics.append(',' + magic); - if(magic == "454e414e") + if(magic == ENAND_PMAGIC) channels_type |= CHANNELS_EMU; - else if(magic == "4e414e44") + else if(magic == NAND_PMAGIC) channels_type |= CHANNELS_REAL; } } diff --git a/source/menu/menu_sm_editor.cpp b/source/menu/menu_sm_editor.cpp index 0083ffad..305b383c 100644 --- a/source/menu/menu_sm_editor.cpp +++ b/source/menu/menu_sm_editor.cpp @@ -296,15 +296,15 @@ void CMenu::_checkboxesMenu(u8 md) u8 pos = firstCheckbox + i - 1; bool plugin_ok = true; strncpy(m_plugin.PluginMagicWord, fmt("%08x", m_plugin.GetPluginMagic(pos)), 8); - if(strncasecmp(m_plugin.PluginMagicWord, "484252", 6) == 0)//HBRW + if(strncasecmp(m_plugin.PluginMagicWord, HB_PMAGIC, 6) == 0)//HBRW plugin_ok = false; - else if(strncasecmp(m_plugin.PluginMagicWord, "4E47434D", 8) == 0)//NGCM + else if(strncasecmp(m_plugin.PluginMagicWord, GC_PMAGIC, 8) == 0)//NGCM plugin_ok = false; - else if(strncasecmp(m_plugin.PluginMagicWord, "4E574949", 8) == 0)//NWII + else if(strncasecmp(m_plugin.PluginMagicWord, WII_PMAGIC, 8) == 0)//NWII plugin_ok = false; - else if(strncasecmp(m_plugin.PluginMagicWord, "4E414E44", 8) == 0)//NAND + else if(strncasecmp(m_plugin.PluginMagicWord, NAND_PMAGIC, 8) == 0)//NAND plugin_ok = false; - else if(strncasecmp(m_plugin.PluginMagicWord, "454E414E", 8) == 0)//ENAN + else if(strncasecmp(m_plugin.PluginMagicWord, ENAND_PMAGIC, 8) == 0)//ENAN plugin_ok = false; else if(strncasecmp(m_plugin.PluginMagicWord, "5343564D", 8) == 0)//scummvm plugin_ok = false; diff --git a/source/plugin/plugin.cpp b/source/plugin/plugin.cpp index d7d424c8..bfaa9eee 100644 --- a/source/plugin/plugin.cpp +++ b/source/plugin/plugin.cpp @@ -237,6 +237,11 @@ bool Plugin::GetEnabledStatus(u8 pos) return false; } +bool Plugin::GetEnabledStatus(const char *magic) +{ + return GetEnabledStatus(GetPluginPosition(strtoul(magic, NULL, 16))); +} + const vector &Plugin::GetEnabledPlugins(u8 *num) { enabledPlugins.clear(); diff --git a/source/plugin/plugin.hpp b/source/plugin/plugin.hpp index 4828e117..3a09d92c 100644 --- a/source/plugin/plugin.hpp +++ b/source/plugin/plugin.hpp @@ -86,6 +86,7 @@ public: void AddPlugin(Config &plugin, const string &iniPath); void Cleanup(); bool GetEnabledStatus(u8 pos); + bool GetEnabledStatus(const char *magic); void SetEnablePlugin(u8 pos, u8 ForceMode = 0); const vector &GetEnabledPlugins(u8 *num); bool PluginExist(u8 pos);