From 65abbfbb4b46921ea521175b47278fdd5825c6a4 Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Sat, 1 Sep 2012 09:34:18 +0000 Subject: [PATCH] -auto reload to cIOS on disc game boot for backup disc support -cleaned up this and that --- source/channel/nand.cpp | 7 ++++--- source/loader/disc.c | 6 ------ source/loader/disc.h | 1 - source/loader/external_booter.cpp | 2 ++ source/main.cpp | 6 ++++-- source/menu/menu.cpp | 14 ++++++------- source/menu/menu_game.cpp | 34 +++++++++++++++++-------------- source/menu/menu_wbfs.cpp | 30 ++++++++++----------------- 8 files changed, 47 insertions(+), 53 deletions(-) diff --git a/source/channel/nand.cpp b/source/channel/nand.cpp index 724795df..27c1ab64 100644 --- a/source/channel/nand.cpp +++ b/source/channel/nand.cpp @@ -95,7 +95,7 @@ s32 Nand::Nand_Mount(NandDevice *Device) return fd; static ioctlv vector[1] ATTRIBUTE_ALIGN(32); - + vector[0].data = &Partition; vector[0].len = sizeof(u32); @@ -108,7 +108,8 @@ s32 Nand::Nand_Mount(NandDevice *Device) s32 Nand::Nand_Unmount(NandDevice *Device) { s32 fd = IOS_Open("fat", 0); - if (fd < 0) return fd; + if(fd < 0) + return fd; s32 ret = IOS_Ioctlv(fd, Device->Unmount, 0, 0, NULL); IOS_Close(fd); @@ -120,7 +121,7 @@ s32 Nand::Nand_Enable(NandDevice *Device) { gprintf("Enabling NAND Emulator\n"); s32 fd = IOS_Open("/dev/fs", 0); - if (fd < 0) + if(fd < 0) return fd; int NandPathlen = strlen(NandPath) + 1; diff --git a/source/loader/disc.c b/source/loader/disc.c index 09a9e1c2..e591f680 100644 --- a/source/loader/disc.c +++ b/source/loader/disc.c @@ -33,12 +33,6 @@ u32 appentrypoint; static u32 *buffer = (u32 *)0x93000000; static u8 *diskid = (u8 *)0x80000000; -s32 Disc_Init(void) -{ - /* Init DVD subsystem */ - return WDVD_Init(); -} - s32 Disc_Open(bool boot_disc) { /* Reset drive */ diff --git a/source/loader/disc.h b/source/loader/disc.h index bab43867..9fa4b29a 100644 --- a/source/loader/disc.h +++ b/source/loader/disc.h @@ -94,7 +94,6 @@ extern "C" { #endif /* __cplusplus */ /* Prototypes */ -s32 Disc_Init(void); s32 Disc_Open(bool); s32 Disc_Wait(void); s32 Disc_SetUSB(const u8 *id, bool frag); diff --git a/source/loader/external_booter.cpp b/source/loader/external_booter.cpp index bbc4245d..c3b57f09 100644 --- a/source/loader/external_booter.cpp +++ b/source/loader/external_booter.cpp @@ -19,6 +19,7 @@ #include "external_booter.hpp" #include "cios.h" #include "fst.h" +#include "wdvd.h" #include "channel/nand.hpp" #include "devicemounter/sdhc.h" #include "devicemounter/usbstorage.h" @@ -98,6 +99,7 @@ void WiiFlow_ExternalBooter(u8 vidMode, bool vipatch, bool countryString, u8 pat SDHC_Close(); #endif Nand::Instance()->DeInit_ISFS(true); //cIOS loves magic :P + WDVD_Close(); //We init that in the booter anyways memcpy(EXECUTE_ADDR, wii_game_booter_dol, wii_game_booter_dol_size); DCFlushRange(EXECUTE_ADDR, wii_game_booter_dol_size); diff --git a/source/main.cpp b/source/main.cpp index e9db8e87..246beeae 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -12,7 +12,7 @@ #include "gui/video.hpp" #include "gui/text.hpp" #include "homebrew/homebrew.h" -#include "loader/disc.h" +#include "loader/wdvd.h" #include "loader/alt_ios.h" #include "loader/sys.h" #include "loader/wbfs.h" @@ -104,7 +104,7 @@ int main(int argc, char **argv) #endif DeviceHandler::Instance()->MountAll(); vid.waitMessage(0.15f); - bool dipOK = Disc_Init() >= 0; + bool dipOK = WDVD_Init() >= 0; mainMenu = new CMenu(vid); Open_Inputs(); @@ -136,6 +136,8 @@ int main(int argc, char **argv) mainMenu->cleanup(); DeviceHandler::Instance()->UnMountAll(); Nand::Instance()->DeInit_ISFS(); + WDVD_Close(); + Sys_Exit(); exit(1); return 0; diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index fdb595fa..207b51d3 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -2061,7 +2061,7 @@ const wstringEx CMenu::_fmt(const char *key, const wchar_t *def) bool CMenu::_loadChannelList(void) { string emuPath; - + m_partRequest = m_cfg.getInt("NAND", "partition", 0); int emuPartition = _FindEmuPart(&emuPath, m_partRequest, false); @@ -2070,24 +2070,24 @@ bool CMenu::_loadChannelList(void) if(emuPartition < 0) emuPartition = _FindEmuPart(&emuPath, m_partRequest, true); - + if(emuPartition < 0) return false; - else + else currentPartition = emuPartition; - + static u8 lastPartition = currentPartition; static bool first = true; static bool failed = false; bool changed = lastPartition != currentPartition || last_emu_state != disable_emu || first || failed; - + gprintf("%s, which is %s\n", disable_emu ? "NAND" : DeviceName[emuPartition], changed ? "refreshing." : "cached."); if(first && !disable_emu) { - char basepath[64]; + char basepath[64]; snprintf(basepath, sizeof(basepath), "%s:%s", DeviceName[currentPartition], emuPath.c_str()); Nand::Instance()->PreNandCfg(basepath, m_cfg.getBool("NAND", "real_nand_miis", false), m_cfg.getBool("NAND", "real_nand_config", false)); first = false; @@ -2097,7 +2097,7 @@ bool CMenu::_loadChannelList(void) Nand::Instance()->Disable_Emu(); if(!disable_emu) { - if(CurrentIOS.Type == IOS_TYPE_NORMAL_IOS) + if(CurrentIOS.Version != mainIOS) { loadIOS(mainIOS, true); Open_Inputs(); diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index a9f12a9f..6e0a16b5 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -868,11 +868,7 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc) DML_Old_SetOptions(newPath.c_str()); if(!nodisc || !m_new_dml) - { - WDVD_Init(); WDVD_StopMotor(); - WDVD_Close(); - } } else if(loader == 2 || (loader == 0 && m_devo_installed && strcasestr(path.c_str(), "boot.bin") == NULL)) { @@ -907,17 +903,19 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc) SDHC_Close(); #endif Nand::Instance()->DeInit_ISFS(); - if(loader == 2) - { - writeStub(); - DEVO_Boot(); - } - else + WDVD_Close(); + + if(loader == 1 || disc) { DML_New_WriteOptions(); WII_Initialize(); WII_LaunchTitle(0x100000100LL); } + else if(loader == 2) + { + writeStub(); + DEVO_Boot(); + } Sys_LoadMenu(); } @@ -943,6 +941,8 @@ void CMenu::_launchHomebrew(const char *filepath, vector arguments) SDHC_Close(); #endif Nand::Instance()->DeInit_ISFS(); + WDVD_Close(); + writeStub(); BootHomebrew(); } @@ -1153,6 +1153,7 @@ void CMenu::_launchChannel(dir_discHdr *hdr) if(forwarder) { Nand::Instance()->DeInit_ISFS(); + WDVD_Close(); WII_Initialize(); if(WII_LaunchTitle(gameTitle) < 0) Sys_LoadMenu(); @@ -1186,23 +1187,26 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) { u32 cover = 0; #ifndef DOLPHIN - Disc_Init(); if(!neek2o()) { Disc_SetUSB(NULL, false); - if (WDVD_GetCoverStatus(&cover) < 0) + if(WDVD_GetCoverStatus(&cover) < 0) { error(_t("errgame7", L"WDVDGetCoverStatus Failed!")); if (BTN_B_PRESSED) return; } - if (!(cover & 0x2)) + if(!(cover & 0x2)) { error(_t("errgame8", L"Please insert a game disc.")); - do { + do + { WDVD_GetCoverStatus(&cover); - if (BTN_B_PRESSED) return; + if(BTN_B_PRESSED) + return; } while(!(cover & 0x2)); } + if(CurrentIOS.Version != mainIOS) + loadIOS(mainIOS, true); } #endif /* Open Disc */ diff --git a/source/menu/menu_wbfs.cpp b/source/menu/menu_wbfs.cpp index 9301dc37..7b55c862 100644 --- a/source/menu/menu_wbfs.cpp +++ b/source/menu/menu_wbfs.cpp @@ -288,26 +288,22 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op) } m_thrdStop = false; m_thrdMessageAdded = false; - while (true) + while(true) { _mainLoopCommon(false, m_thrdWorking); - if ((BTN_HOME_PRESSED || BTN_B_PRESSED) && !m_thrdWorking) - { + if((BTN_HOME_PRESSED || BTN_B_PRESSED) && !m_thrdWorking) 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_A_PRESSED && !m_thrdWorking) + if(BTN_A_PRESSED && !m_thrdWorking) { - if (m_btnMgr.selected(m_wbfsBtnBack)) - { + if(m_btnMgr.selected(m_wbfsBtnBack)) break; - } - else if (m_btnMgr.selected(m_wbfsBtnGo)) + else if(m_btnMgr.selected(m_wbfsBtnGo)) { - switch (op) + switch(op) { case CMenu::WO_ADD_GAME: m_btnMgr.show(m_wbfsPBar); @@ -317,7 +313,6 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op) m_btnMgr.show(m_wbfsLblMessage); m_btnMgr.setText(m_wbfsLblMessage, L""); Disc_SetUSB(NULL, false); - Disc_Init(); if (Disc_Wait() < 0) { error(_t("wbfsoperr1", L"Disc_Wait failed")); @@ -447,12 +442,12 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op) LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_GCcopyGame, (void *)this, 0, 8 * 1024, 64); break; } - if (out) + if(out) break; } } - if (m_thrdMessageAdded) + if(m_thrdMessageAdded) { LockMutex lock(m_mutex); m_thrdMessageAdded = false; @@ -460,13 +455,10 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op) m_btnMgr.setText(m_wbfsLblDialog, m_thrdMessage); m_btnMgr.setProgress(m_wbfsPBar, m_thrdProgress); m_btnMgr.setText(m_wbfsLblMessage, wfmt( L"%i%%", (int)(m_thrdProgress * 100.f))); - if (!m_thrdWorking) + if(!m_thrdWorking) { if(op == CMenu::WO_ADD_GAME) - { WDVD_StopMotor(); - WDVD_Close(); - } m_btnMgr.show(m_wbfsBtnBack); } }