-fixed wii savegame emulation (derp)

-fixed wii games were unable to get online
-automatically update the internal nand save if the wiiflow.ini
got changed
This commit is contained in:
fix94.1 2012-12-27 01:08:16 +00:00
parent 45441ded06
commit ef9ebea794
7 changed files with 21 additions and 18 deletions

View File

@ -83,6 +83,8 @@ void WiiFlow_ExternalBooter(u8 vidMode, bool vipatch, bool countryString, u8 pat
/* Copy in booter */
memcpy(EXT_ADDR, booter, booter_size);
DCFlushRange(EXT_ADDR, booter_size);
/* Wii Games will need it */
net_wc24cleanup();
/* Boot it */
JumpToEntry(EXT_ENTRY);
}
@ -111,6 +113,7 @@ void ShutdownBeforeExit(bool KeepPatches)
DeviceHandle.UnMountAll();
NandHandle.DeInit_ISFS(KeepPatches);
WDVD_Close();
Close_Inputs();
/* Deinit network */
if(networkInit == true)
{

View File

@ -169,10 +169,13 @@ void NandSave::LoadIOS()
free(file);
}
void NandSave::SaveIOS(const ios_settings_t settings)
void NandSave::SaveIOS(u8 ios, bool use_ios)
{
if(loaded == false)
return;
memset(&ios_settings, 0, sizeof(ios_settings_t));
ios_settings.cios = ios;
ios_settings.use_cios = use_ios;
gprintf("Saving IOS Settings to NAND\n");
memset(&ISFS_Path, 0, ISFS_MAXPATH);
strcpy(ISFS_Path, IOS_SAVE_PATH);
@ -180,7 +183,7 @@ void NandSave::SaveIOS(const ios_settings_t settings)
fd = ISFS_Open(ISFS_Path, ISFS_OPEN_WRITE);
if(fd < 0)
return;
ret = ISFS_Write(fd, &settings, sizeof(ios_settings_t));
ret = ISFS_Write(fd, &ios_settings, sizeof(ios_settings_t));
ISFS_Close(fd);
if(ret < 0)
ISFS_Delete(ISFS_Path);

View File

@ -31,12 +31,13 @@ public:
NandSave();
bool CheckSave();
void LoadIOS();
void SaveIOS(const ios_settings_t settings);
void SaveIOS(u8 ios, bool use_ios);
private:
s32 fd;
s32 ret;
bool loaded;
char ISFS_Path[ISFS_MAXPATH];
ios_settings_t ios_settings;
};
extern NandSave InternalSave;

View File

@ -80,7 +80,6 @@ bool loadIOS(int ios, bool MountDevices)
if(ios != CurIOS && IOS_GetType(ios) != IOS_TYPE_STUB)
{
WDVD_Close();
Close_Inputs();
NandHandle.Patch_AHB(); //No AHBPROT for the next IOS
gprintf("Reloading into IOS %i from %i...\n", ios, CurIOS);
ShutdownBeforeExit();

View File

@ -12,6 +12,7 @@
#include "fonts.h"
#include "banner/BannerWindow.hpp"
#include "channel/nand.hpp"
#include "channel/nand_save.hpp"
#include "fileOps/fileOps.h"
#include "gc/gc.hpp"
#include "gui/Gekko.h"
@ -216,6 +217,8 @@ void CMenu::init()
init_network = (m_cfg.getBool("GENERAL", "async_network") || has_enabled_providers() || m_use_wifi_gecko);
_netInit();
/* Check if we want a cIOS loaded */
u8 prevCios = mainIOS;
bool prevForceCIOS = useMainIOS;
int ForceIOS = min(m_cfg.getInt("GENERAL", "force_cios_rev", 0), 254);
if(ForceIOS > 0)
{
@ -223,6 +226,8 @@ void CMenu::init()
mainIOS = ForceIOS;
}
useMainIOS = m_cfg.getBool("GENERAL", "force_cios_load", false);
if(prevCios != mainIOS || prevForceCIOS != useMainIOS)
InternalSave.SaveIOS(mainIOS, useMainIOS);
/* Do our USB HDD Checks */
bool onUSB = m_cfg.getBool("GENERAL", "data_on_usb", strncmp(drive, "usb", 3) == 0);
drive = check; //reset the drive variable for the check
@ -527,8 +532,6 @@ void CMenu::cleanup()
CoverFlow.shutdown();
wiiLightOff();
Close_Inputs();
LWP_MutexDestroy(m_mutex);
m_mutex = 0;

View File

@ -28,8 +28,6 @@ s16 m_bootLblCurCIOSrev;
s16 m_bootLblCIOSrevM;
s16 m_bootLblCIOSrevP;
ios_settings_t settings;
static void showBoot(void)
{
m_btnMgr.show(m_bootLblTitle);
@ -98,12 +96,7 @@ void CMenu::_Boot(void)
bool cur_load = m_cfg.getBool("GENERAL", "force_cios_load", false);
u8 cur_ios = min(m_cfg.getInt("GENERAL", "force_cios_rev", 0), 254);
if(prev_load != cur_load || prev_ios != cur_ios)
{
memset(&settings, 0, sizeof(ios_settings_t));
settings.cios = min(m_cfg.getInt("GENERAL", "force_cios_rev", 0), 254);
settings.use_cios = m_cfg.getBool("GENERAL", "force_cios_load", false);
InternalSave.SaveIOS(settings);
}
InternalSave.SaveIOS(cur_ios, cur_load);
hideBoot(false);
}

View File

@ -1263,9 +1263,13 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
NandHandle.CreatePath("%s:/wiiflow/nandemu", DeviceName[emuPartition]);
}
}
/* Init NAND Emu Settings */
NANDemuView = true;
NandHandle.SetNANDEmu(emuPartition);
NandHandle.SetPaths(emuPath.c_str(), DeviceName[emuPartition]);
/* Set them */
m_cfg.setInt(WII_DOMAIN, "savepartition", emuPartition);
m_cfg.setString(WII_DOMAIN, "savepath", emuPath);
if(emulate_mode == 2 || emulate_mode > 3)
{
if(emulate_mode == 2)
@ -1332,9 +1336,6 @@ 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.UnMountAll();
if(emulate_mode == 3)