-auto reload to cIOS on disc game boot for backup disc support

-cleaned up this and that
This commit is contained in:
fix94.1 2012-09-01 09:34:18 +00:00
parent 14b0db2dc1
commit 65abbfbb4b
8 changed files with 47 additions and 53 deletions

View File

@ -108,7 +108,8 @@ s32 Nand::Nand_Mount(NandDevice *Device)
s32 Nand::Nand_Unmount(NandDevice *Device) s32 Nand::Nand_Unmount(NandDevice *Device)
{ {
s32 fd = IOS_Open("fat", 0); 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); s32 ret = IOS_Ioctlv(fd, Device->Unmount, 0, 0, NULL);
IOS_Close(fd); IOS_Close(fd);
@ -120,7 +121,7 @@ s32 Nand::Nand_Enable(NandDevice *Device)
{ {
gprintf("Enabling NAND Emulator\n"); gprintf("Enabling NAND Emulator\n");
s32 fd = IOS_Open("/dev/fs", 0); s32 fd = IOS_Open("/dev/fs", 0);
if (fd < 0) if(fd < 0)
return fd; return fd;
int NandPathlen = strlen(NandPath) + 1; int NandPathlen = strlen(NandPath) + 1;

View File

@ -33,12 +33,6 @@ u32 appentrypoint;
static u32 *buffer = (u32 *)0x93000000; static u32 *buffer = (u32 *)0x93000000;
static u8 *diskid = (u8 *)0x80000000; static u8 *diskid = (u8 *)0x80000000;
s32 Disc_Init(void)
{
/* Init DVD subsystem */
return WDVD_Init();
}
s32 Disc_Open(bool boot_disc) s32 Disc_Open(bool boot_disc)
{ {
/* Reset drive */ /* Reset drive */

View File

@ -94,7 +94,6 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
/* Prototypes */ /* Prototypes */
s32 Disc_Init(void);
s32 Disc_Open(bool); s32 Disc_Open(bool);
s32 Disc_Wait(void); s32 Disc_Wait(void);
s32 Disc_SetUSB(const u8 *id, bool frag); s32 Disc_SetUSB(const u8 *id, bool frag);

View File

@ -19,6 +19,7 @@
#include "external_booter.hpp" #include "external_booter.hpp"
#include "cios.h" #include "cios.h"
#include "fst.h" #include "fst.h"
#include "wdvd.h"
#include "channel/nand.hpp" #include "channel/nand.hpp"
#include "devicemounter/sdhc.h" #include "devicemounter/sdhc.h"
#include "devicemounter/usbstorage.h" #include "devicemounter/usbstorage.h"
@ -98,6 +99,7 @@ void WiiFlow_ExternalBooter(u8 vidMode, bool vipatch, bool countryString, u8 pat
SDHC_Close(); SDHC_Close();
#endif #endif
Nand::Instance()->DeInit_ISFS(true); //cIOS loves magic :P 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); memcpy(EXECUTE_ADDR, wii_game_booter_dol, wii_game_booter_dol_size);
DCFlushRange(EXECUTE_ADDR, wii_game_booter_dol_size); DCFlushRange(EXECUTE_ADDR, wii_game_booter_dol_size);

View File

@ -12,7 +12,7 @@
#include "gui/video.hpp" #include "gui/video.hpp"
#include "gui/text.hpp" #include "gui/text.hpp"
#include "homebrew/homebrew.h" #include "homebrew/homebrew.h"
#include "loader/disc.h" #include "loader/wdvd.h"
#include "loader/alt_ios.h" #include "loader/alt_ios.h"
#include "loader/sys.h" #include "loader/sys.h"
#include "loader/wbfs.h" #include "loader/wbfs.h"
@ -104,7 +104,7 @@ int main(int argc, char **argv)
#endif #endif
DeviceHandler::Instance()->MountAll(); DeviceHandler::Instance()->MountAll();
vid.waitMessage(0.15f); vid.waitMessage(0.15f);
bool dipOK = Disc_Init() >= 0; bool dipOK = WDVD_Init() >= 0;
mainMenu = new CMenu(vid); mainMenu = new CMenu(vid);
Open_Inputs(); Open_Inputs();
@ -136,6 +136,8 @@ int main(int argc, char **argv)
mainMenu->cleanup(); mainMenu->cleanup();
DeviceHandler::Instance()->UnMountAll(); DeviceHandler::Instance()->UnMountAll();
Nand::Instance()->DeInit_ISFS(); Nand::Instance()->DeInit_ISFS();
WDVD_Close();
Sys_Exit(); Sys_Exit();
exit(1); exit(1);
return 0; return 0;

View File

@ -2097,7 +2097,7 @@ bool CMenu::_loadChannelList(void)
Nand::Instance()->Disable_Emu(); Nand::Instance()->Disable_Emu();
if(!disable_emu) if(!disable_emu)
{ {
if(CurrentIOS.Type == IOS_TYPE_NORMAL_IOS) if(CurrentIOS.Version != mainIOS)
{ {
loadIOS(mainIOS, true); loadIOS(mainIOS, true);
Open_Inputs(); Open_Inputs();

View File

@ -868,11 +868,7 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc)
DML_Old_SetOptions(newPath.c_str()); DML_Old_SetOptions(newPath.c_str());
if(!nodisc || !m_new_dml) if(!nodisc || !m_new_dml)
{
WDVD_Init();
WDVD_StopMotor(); WDVD_StopMotor();
WDVD_Close();
}
} }
else if(loader == 2 || (loader == 0 && m_devo_installed && strcasestr(path.c_str(), "boot.bin") == NULL)) 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(); SDHC_Close();
#endif #endif
Nand::Instance()->DeInit_ISFS(); Nand::Instance()->DeInit_ISFS();
if(loader == 2) WDVD_Close();
{
writeStub(); if(loader == 1 || disc)
DEVO_Boot();
}
else
{ {
DML_New_WriteOptions(); DML_New_WriteOptions();
WII_Initialize(); WII_Initialize();
WII_LaunchTitle(0x100000100LL); WII_LaunchTitle(0x100000100LL);
} }
else if(loader == 2)
{
writeStub();
DEVO_Boot();
}
Sys_LoadMenu(); Sys_LoadMenu();
} }
@ -943,6 +941,8 @@ void CMenu::_launchHomebrew(const char *filepath, vector<string> arguments)
SDHC_Close(); SDHC_Close();
#endif #endif
Nand::Instance()->DeInit_ISFS(); Nand::Instance()->DeInit_ISFS();
WDVD_Close();
writeStub(); writeStub();
BootHomebrew(); BootHomebrew();
} }
@ -1153,6 +1153,7 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
if(forwarder) if(forwarder)
{ {
Nand::Instance()->DeInit_ISFS(); Nand::Instance()->DeInit_ISFS();
WDVD_Close();
WII_Initialize(); WII_Initialize();
if(WII_LaunchTitle(gameTitle) < 0) if(WII_LaunchTitle(gameTitle) < 0)
Sys_LoadMenu(); Sys_LoadMenu();
@ -1186,23 +1187,26 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
{ {
u32 cover = 0; u32 cover = 0;
#ifndef DOLPHIN #ifndef DOLPHIN
Disc_Init();
if(!neek2o()) if(!neek2o())
{ {
Disc_SetUSB(NULL, false); Disc_SetUSB(NULL, false);
if (WDVD_GetCoverStatus(&cover) < 0) if(WDVD_GetCoverStatus(&cover) < 0)
{ {
error(_t("errgame7", L"WDVDGetCoverStatus Failed!")); error(_t("errgame7", L"WDVDGetCoverStatus Failed!"));
if (BTN_B_PRESSED) return; if (BTN_B_PRESSED) return;
} }
if (!(cover & 0x2)) if(!(cover & 0x2))
{ {
error(_t("errgame8", L"Please insert a game disc.")); error(_t("errgame8", L"Please insert a game disc."));
do { do
{
WDVD_GetCoverStatus(&cover); WDVD_GetCoverStatus(&cover);
if (BTN_B_PRESSED) return; if(BTN_B_PRESSED)
return;
} while(!(cover & 0x2)); } while(!(cover & 0x2));
} }
if(CurrentIOS.Version != mainIOS)
loadIOS(mainIOS, true);
} }
#endif #endif
/* Open Disc */ /* Open Disc */

View File

@ -288,26 +288,22 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
} }
m_thrdStop = false; m_thrdStop = false;
m_thrdMessageAdded = false; m_thrdMessageAdded = false;
while (true) while(true)
{ {
_mainLoopCommon(false, m_thrdWorking); _mainLoopCommon(false, m_thrdWorking);
if ((BTN_HOME_PRESSED || BTN_B_PRESSED) && !m_thrdWorking) if((BTN_HOME_PRESSED || BTN_B_PRESSED) && !m_thrdWorking)
{
break; break;
} else if(BTN_UP_PRESSED)
else if (BTN_UP_PRESSED)
m_btnMgr.up(); m_btnMgr.up();
else if (BTN_DOWN_PRESSED) else if(BTN_DOWN_PRESSED)
m_btnMgr.down(); 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; break;
} else if(m_btnMgr.selected(m_wbfsBtnGo))
else if (m_btnMgr.selected(m_wbfsBtnGo))
{ {
switch (op) switch(op)
{ {
case CMenu::WO_ADD_GAME: case CMenu::WO_ADD_GAME:
m_btnMgr.show(m_wbfsPBar); m_btnMgr.show(m_wbfsPBar);
@ -317,7 +313,6 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
m_btnMgr.show(m_wbfsLblMessage); m_btnMgr.show(m_wbfsLblMessage);
m_btnMgr.setText(m_wbfsLblMessage, L""); m_btnMgr.setText(m_wbfsLblMessage, L"");
Disc_SetUSB(NULL, false); Disc_SetUSB(NULL, false);
Disc_Init();
if (Disc_Wait() < 0) if (Disc_Wait() < 0)
{ {
error(_t("wbfsoperr1", L"Disc_Wait failed")); 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); LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_GCcopyGame, (void *)this, 0, 8 * 1024, 64);
break; break;
} }
if (out) if(out)
break; break;
} }
} }
if (m_thrdMessageAdded) if(m_thrdMessageAdded)
{ {
LockMutex lock(m_mutex); LockMutex lock(m_mutex);
m_thrdMessageAdded = false; m_thrdMessageAdded = false;
@ -460,13 +455,10 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
m_btnMgr.setText(m_wbfsLblDialog, m_thrdMessage); m_btnMgr.setText(m_wbfsLblDialog, m_thrdMessage);
m_btnMgr.setProgress(m_wbfsPBar, m_thrdProgress); m_btnMgr.setProgress(m_wbfsPBar, m_thrdProgress);
m_btnMgr.setText(m_wbfsLblMessage, wfmt( L"%i%%", (int)(m_thrdProgress * 100.f))); 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) if(op == CMenu::WO_ADD_GAME)
{
WDVD_StopMotor(); WDVD_StopMotor();
WDVD_Close();
}
m_btnMgr.show(m_wbfsBtnBack); m_btnMgr.show(m_wbfsBtnBack);
} }
} }