-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

@ -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;

View File

@ -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 */

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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();

View File

@ -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<string> 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 */

View File

@ -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);
}
}