-fixed savegame emu bug from r818

-more and longer wifi gecko messages
This commit is contained in:
fix94.1 2012-12-22 20:57:23 +00:00
parent aeee973e08
commit 4dbef7ab4d
8 changed files with 34 additions and 30 deletions

View File

@ -24,12 +24,15 @@
#include "Config.h"
#include "channel/nand.hpp"
#include "devicemounter/DeviceHandler.hpp"
#include "gecko/wifi_gecko.hpp"
#include "gui/text.hpp"
#include "loader/fst.h"
#include "loader/mload.h"
#include "loader/wdvd.h"
#include "loader/sys.h"
#include "homebrew/homebrew.h"
#include "memory/mem2.hpp"
#include "network/http.h"
#include "plugin/crc32.h"
/* External WiiFlow Game Booter */
@ -108,4 +111,13 @@ void ShutdownBeforeExit(bool KeepPatches)
DeviceHandle.UnMountAll();
NandHandle.DeInit_ISFS(KeepPatches);
WDVD_Close();
/* Deinit network */
if(networkInit == true)
{
while(net_get_status() == -EBUSY)
usleep(50);
WiFiDebugger.Close();
net_deinit();
networkInit = false;
}
}

View File

@ -77,13 +77,13 @@ bool loadIOS(int ios, bool MountDevices)
int CurIOS = IOS_GetVersion();
bool ret = true;
if(ios != CurIOS)
if(ios != CurIOS && IOS_GetType(ios) != IOS_TYPE_STUB)
{
WDVD_Close();
Close_Inputs();
NandHandle.Patch_AHB(); //No AHBPROT for the next IOS
ShutdownBeforeExit();
gprintf("Reloading into IOS %i from %i...\n", ios, CurIOS);
ShutdownBeforeExit();
ret = IOS_ReloadIOS(ios) == 0;
gprintf("AHBPROT after IOS Reload: %u\n", AHBRPOT_Patched());
NandHandle.Init_ISFS();

View File

@ -48,6 +48,7 @@ extern void __exception_setreload(int t);
extern int mainIOS;
extern bool useMainIOS;
extern volatile bool NANDemuView;
extern volatile bool networkInit;
extern u8 currentPartition;
#ifdef __cplusplus

View File

@ -23,6 +23,7 @@
CMenu mainMenu;
bool useMainIOS = false;
volatile bool NANDemuView = false;
volatile bool networkInit = false;
int main(int argc, char **argv)
{

View File

@ -121,7 +121,6 @@ CMenu::CMenu()
m_thrdStepLen = 0.f;
m_locked = false;
m_favorites = false;
m_networkInit = false;
m_thrdNetwork = false;
m_mutex = 0;
m_showtimer = 0;
@ -536,9 +535,6 @@ void CMenu::cleanup()
cleaned_up = true;
//gprintf(" \nMemory cleaned up\n");
gprintf("MEM1_freesize(): %i\nMEM2_freesize(): %i\n", MEM1_freesize(), MEM2_freesize());
/* Lets deinit our possible wifi gecko here */
_deinitNetwork();
net_wc24cleanup();
}
void CMenu::_Theme_Cleanup(void)
@ -644,7 +640,7 @@ void CMenu::_Theme_Cleanup(void)
void CMenu::_netInit(void)
{
if(m_networkInit || !init_network || m_exit)
if(networkInit || !init_network || m_exit)
return;
_initAsyncNetwork();
while(net_get_status() == -EBUSY)
@ -2706,7 +2702,6 @@ void CMenu::TempLoadIOS(int IOS)
if(CurrentIOS.Version != IOS)
{
_deinitNetwork();
loadIOS(IOS, true);
Open_Inputs();
for(int chan = WPAD_MAX_WIIMOTES-2; chan >= 0; chan--)

View File

@ -644,7 +644,6 @@ private:
bool m_show_zone_game;
volatile bool m_exit;
volatile bool m_networkInit;
volatile bool m_thrdStop;
volatile bool m_thrdWorking;
volatile bool m_thrdNetwork;
@ -1039,7 +1038,6 @@ private:
void _initAsyncNetwork();
bool _isNetworkAvailable();
int _initNetwork();
void _deinitNetwork();
void LoadView(void);
void _getGrabStatus(void);
static void _addDiscProgress(int status, int total, void *user_data);

View File

@ -409,7 +409,7 @@ s32 CMenu::_networkComplete(s32 ok, void *usrData)
{
CMenu *m = (CMenu *) usrData;
m->m_networkInit = ok == 0;
networkInit = ok == 0;
m->m_thrdNetwork = false;
bool wifigecko = m->m_cfg.getBool("DEBUG", "wifi_gecko", false);
@ -428,25 +428,16 @@ s32 CMenu::_networkComplete(s32 ok, void *usrData)
int CMenu::_initNetwork()
{
while (net_get_status() == -EBUSY || m_thrdNetwork) {}; // Async initialization may be busy, wait to see if it succeeds.
if (m_networkInit) return 0;
if (networkInit) return 0;
if (!_isNetworkAvailable()) return -2;
char ip[16];
int val = if_config(ip, NULL, NULL, true);
m_networkInit = !val;
networkInit = !val;
return val;
}
void CMenu::_deinitNetwork()
{
while(net_get_status() == -EBUSY)
usleep(100);
WiFiDebugger.Close();
net_deinit();
m_networkInit = false;
}
int CMenu::_coverDownloader(bool missingOnly)
{
string path;

View File

@ -947,9 +947,10 @@ int CMenu::_loadIOS(u8 gameIOS, int userIOS, string id, bool RealNAND_Channels)
gprintf("Game ID# %s requested IOS %d. User selected %d\n", id.c_str(), gameIOS, userIOS);
if(neek2o() || (RealNAND_Channels && IOS_GetType(mainIOS) == IOS_TYPE_STUB))
{
if(!loadIOS(gameIOS, false))
bool ret = loadIOS(gameIOS, false);
_netInit();
if(ret == false)
{
_netInit();
error(sfmt("errgame4", L"Couldn't load IOS %i", gameIOS));
return LOAD_IOS_FAILED;
}
@ -1007,9 +1008,10 @@ int CMenu::_loadIOS(u8 gameIOS, int userIOS, string id, bool RealNAND_Channels)
if(gameIOS != CurrentIOS.Version)
{
gprintf("Reloading IOS into %d\n", gameIOS);
if(!loadIOS(gameIOS, true))
bool ret = loadIOS(gameIOS, true);
_netInit();
if(ret == false)
{
_netInit();
error(sfmt("errgame4", L"Couldn't load IOS %i", gameIOS));
return LOAD_IOS_FAILED;
}
@ -1090,8 +1092,9 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
returnTo ? (((u64)(0x00010001) << 32) | (returnTo & 0xFFFFFFFF)) : 0);
while(1) usleep(500);
}
NandHandle.SetPaths(emuPath.c_str(), DeviceName[emuPartition]);
NANDemuView = true;
NandHandle.SetNANDEmu(emuPartition); /* Init NAND Emu */
NandHandle.SetPaths(emuPath.c_str(), DeviceName[emuPartition]);
}
gameIOS = ChannelHandle.GetRequestedIOS(gameTitle);
if(_loadIOS(gameIOS, userIOS, id, !NAND_Emu) == LOAD_IOS_FAILED)
@ -1103,6 +1106,8 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
}
if(NAND_Emu && !neek2o())
{
/* Enable our Emu NAND */
DeviceHandle.UnMount(emuPartition);
if(emulate_mode == 1)
NandHandle.Set_FullMode(true);
else
@ -1113,8 +1118,8 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
error(_t("errgame5", L"Enabling emu failed!"));
Sys_Exit();
}
DeviceHandle.Mount(emuPartition);
}
if(WII_Launch)
{
ShutdownBeforeExit();
@ -1245,7 +1250,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
if(_TestEmuNand(m_cfg.getInt(WII_DOMAIN, "savepartition", 0), emuPath.c_str(), true))
{
emuPartition = m_cfg.getInt(WII_DOMAIN, "savepartition", -1);
string emuPath = m_cfg.getString(WII_DOMAIN, "savepath", m_cfg.getString(CHANNEL_DOMAIN, "path", ""));
emuPath = m_cfg.getString(WII_DOMAIN, "savepath", m_cfg.getString(CHANNEL_DOMAIN, "path", ""));
break;
}
}
@ -1260,7 +1265,6 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
}
m_cfg.setInt(WII_DOMAIN, "savepartition", emuPartition);
m_cfg.setString(WII_DOMAIN, "savepath", emuPath);
m_cfg.save();
if(emulate_mode == 2 || emulate_mode > 3)
{
@ -1329,7 +1333,9 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
if(emulate_mode && !neek2o() && CurrentIOS.Type == IOS_TYPE_D2X)
{
NANDemuView = true;
NandHandle.SetNANDEmu(emuPartition); /* Init NAND Emu */
NandHandle.SetPaths(emuPath.c_str(), DeviceName[emuPartition]);
/* Enable our Emu NAND */
DeviceHandle.UnMount(emuPartition);
if(emulate_mode == 3)
NandHandle.Set_RCMode(true);