Replace install wii menu option tools to install wad

Add the option to clear a title from the NANDContentLoader and attempt to reload it
This allows the using the system menu immediately after installing rather than requiring a relaunch

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7290 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99 2011-03-05 05:07:44 +00:00
parent 15ca7b72e6
commit 708f6f7299
11 changed files with 65 additions and 41 deletions

View File

@ -33,7 +33,7 @@ public:
static std::string GenerateMapFilename();
static bool Install_WiiWAD(const char *filename);
static u64 Install_WiiWAD(const char *filename);
private:
static void RunFunction(u32 _iAddr);

View File

@ -86,13 +86,13 @@ bool CBoot::Boot_WiiWAD(const char* _pFilename)
}
bool CBoot::Install_WiiWAD(const char* _pFilename)
u64 CBoot::Install_WiiWAD(const char* _pFilename)
{
if (!IsWiiWAD(_pFilename))
return false;
return 0;
const DiscIO::INANDContentLoader& ContentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(_pFilename);
if (ContentLoader.IsValid() == false)
return false;
return 0;
u64 TitleID = ContentLoader.GetTitleID();
u32 TitleID_HI = (u32)(TitleID >> 32);
@ -111,7 +111,7 @@ bool CBoot::Install_WiiWAD(const char* _pFilename)
FILE* pTMDFile = fopen(TMDFileName.c_str(), "wb");
if (pTMDFile == NULL) {
PanicAlertT("WAD installation failed: error creating %s", TMDFileName.c_str());
return false;
return 0;
}
fwrite(ContentLoader.GetTmdHeader(), DiscIO::INANDContentLoader::TMD_HEADER_SIZE, 1, pTMDFile);
@ -140,7 +140,7 @@ bool CBoot::Install_WiiWAD(const char* _pFilename)
if (pAPPFile == NULL)
{
PanicAlertT("WAD installation failed: error creating %s", APPFileName);
return false;
return 0;
}
fwrite(Content.m_pData, Content.m_Size, 1, pAPPFile);
@ -167,14 +167,14 @@ bool CBoot::Install_WiiWAD(const char* _pFilename)
FILE* pTicketFile = fopen(TicketFileName, "wb");
if (pTicketFile == NULL) {
PanicAlertT("WAD installation failed: error creating %s", TicketFileName);
return false;
return 0;
}
DiscIO::WiiWAD Wad(_pFilename);
if (!Wad.IsValid())
{
fclose(pTicketFile);
return false;
return 0;
}
fwrite(Wad.GetTicket(), Wad.GetTicketSize(), 1, pTicketFile);
@ -186,7 +186,7 @@ bool CBoot::Install_WiiWAD(const char* _pFilename)
INFO_LOG(DISCIO, "Title %08x%08x, already exists in uid.sys", TitleID_HI, TitleID_LO);
}
return true;
return TitleID;
}

View File

@ -205,7 +205,7 @@ bool SCoreStartupParameter::AutoSetup(EBootBS2 _BootBS2)
if (ContentLoader.GetContentByIndex(ContentLoader.GetBootIndex()) == NULL)
{
//WAD is valid yet cannot be booted. Install instead.
bool installed = CBoot::Install_WiiWAD(m_strFilename.c_str());
u64 installed = CBoot::Install_WiiWAD(m_strFilename.c_str());
if (installed)
SuccessAlertT("The WAD has been installed successfully");
return false; //do not boot

View File

@ -824,14 +824,13 @@ u32 CWII_IPC_HLE_Device_es::ES_DIVerify(u8* _pTMD, u32 _sz)
{
return -1;
}
std::string contentPath,
dataPath,
tmdPath;
contentPath = Common::CreateTitleContentPath(tmdTitleID) + DIR_SEP;
dataPath = Common::CreateTitleDataPath(tmdTitleID) + DIR_SEP;
tmdPath = contentPath + "/title.tmd";
std::string tmdPath,
dataPath;
File::CreateFullPath(contentPath);
tmdPath = Common::CreateTitleContentPath(tmdTitleID) + DIR_SEP + "title.tmd";
dataPath = Common::CreateTitleDataPath(tmdTitleID) + DIR_SEP;
File::CreateFullPath(tmdPath);
File::CreateFullPath(dataPath);
if(!File::Exists(tmdPath))
{

View File

@ -97,6 +97,7 @@ private:
IOCTL_ES_GETSTOREDTMD = 0x35,
IOCTL_ES_GETSHAREDCONTENTCNT = 0x36,
IOCTL_ES_GETSHAREDCONTENTS = 0x37,
IOCTL_ES_DELETESHAREDCONTENT = 0x38,
IOCTL_ES_CHECKKOREAREGION = 0x45,
};

View File

@ -366,20 +366,29 @@ CNANDContentManager::~CNANDContentManager()
m_Map.clear();
}
const INANDContentLoader& CNANDContentManager::GetNANDLoader(const std::string& _rName)
const INANDContentLoader& CNANDContentManager::GetNANDLoader(const std::string& _rName, bool forceReload)
{
CNANDContentMap::iterator lb = m_Map.lower_bound(_rName);
if(lb == m_Map.end() || (m_Map.key_comp()(_rName, lb->first)))
{
m_Map.insert(lb, CNANDContentMap::value_type(_rName, new CNANDContentLoader(_rName)));
}
else
{
if (!lb->second->IsValid() || forceReload)
{
delete lb->second;
lb->second = new CNANDContentLoader(_rName);
}
}
return *m_Map[_rName];
}
const INANDContentLoader& CNANDContentManager::GetNANDLoader(u64 _titleId)
const INANDContentLoader& CNANDContentManager::GetNANDLoader(u64 _titleId, bool forceReload)
{
std::string _rName = Common::CreateTitleContentPath(_titleId);
return GetNANDLoader(_rName);
return GetNANDLoader(_rName, forceReload);
}
cUIDsys::cUIDsys()
@ -411,7 +420,7 @@ cUIDsys::cUIDsys()
if (pFile)
{
if (fwrite(&Element, sizeof(SElement), 1, pFile) != 1)
ERROR_LOG(DISCIO, "fwrite failed");
ERROR_LOG(DISCIO, "Failed to write to %s", uidSys);
fclose(pFile);
}
}

View File

@ -81,8 +81,8 @@ public:
static CNANDContentManager& Access() { return m_Instance; }
const INANDContentLoader& GetNANDLoader(const std::string& _rName);
const INANDContentLoader& GetNANDLoader(u64 _titleId);
const INANDContentLoader& GetNANDLoader(const std::string& _rName, bool forceReload = false);
const INANDContentLoader& GetNANDLoader(u64 _titleId, bool forceReload = false);
private:
CNANDContentManager() {};

View File

@ -283,7 +283,7 @@ EVT_MENU(IDM_MEMCARD, CFrame::OnMemcard)
EVT_MENU(IDM_IMPORTSAVE, CFrame::OnImportSave)
EVT_MENU(IDM_CHEATS, CFrame::OnShow_CheatsWindow)
EVT_MENU(IDM_CHANGEDISC, CFrame::OnChangeDisc)
EVT_MENU(IDM_INSTALL_WII_MENU, CFrame::OnLoadWiiMenu)
EVT_MENU(IDM_INSTALLWAD, CFrame::OnLoadWiiMenu)
EVT_MENU(IDM_LOAD_WII_MENU, CFrame::OnLoadWiiMenu)
EVT_MENU(IDM_TOGGLE_FULLSCREEN, CFrame::OnToggleFullscreen)

View File

@ -202,17 +202,14 @@ void CFrame::CreateMenu()
toolsMenu->Append(IDM_NETPLAY, _("Start &NetPlay"));
if (DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU).IsValid())
{
toolsMenu->Append(IDM_INSTALLWAD, _("Install WAD"));
int sysmenuVersion = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU).GetTitleVersion();
char sysmenuRegion = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU).GetCountryChar();
toolsMenu->Append(IDM_LOAD_WII_MENU, wxString::Format(_("Load Wii System Menu (%d %c)"), sysmenuVersion, sysmenuRegion));
}
else
{
toolsMenu->Append(IDM_INSTALL_WII_MENU, _("Install Wii Menu"));
}
toolsMenu->Append(IDM_LOAD_WII_MENU, wxString::Format(_("Load Wii System Menu %d%c"), sysmenuVersion, sysmenuRegion));
toolsMenu->Enable(IDM_LOAD_WII_MENU, DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU).IsValid());
toolsMenu->AppendSeparator();
toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE1, GetMenuLabel(HK_WIIMOTE1_CONNECT));
toolsMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE2, GetMenuLabel(HK_WIIMOTE2_CONNECT));
@ -1319,15 +1316,33 @@ void CFrame::OnLoadWiiMenu(wxCommandEvent& event)
{
wxString path = wxFileSelector(
_("Select the System Menu wad extracted from the update partition of a disc"),
_("Select a Wii WAD file to install"),
wxEmptyString, wxEmptyString, wxEmptyString,
_T("System Menu (*.wad)|*.wad"),
_T("Wii WAD file (*.wad)|*.wad"),
wxFD_OPEN | wxFD_PREVIEW | wxFD_FILE_MUST_EXIST,
this);
if (CBoot::Install_WiiWAD(path.mb_str()))
wxProgressDialog dialog(_("Installing WAD..."),
_("Working..."),
1000, // range
this, // parent
wxPD_APP_MODAL |
wxPD_SMOOTH // - makes indeterminate mode bar on WinXP very small
);
dialog.CenterOnParent();
u64 titleID = CBoot::Install_WiiWAD(path.mb_str());
if (titleID == TITLEID_SYSMENU)
{
GetMenuBar()->FindItem(IDM_INSTALL_WII_MENU)->Enable(false);
const DiscIO::INANDContentLoader & _Loader = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU, true);
if (_Loader.IsValid())
{
int sysmenuVersion = _Loader.GetTitleVersion();
char sysmenuRegion = _Loader.GetCountryChar();
GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->Enable();
GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->SetText(wxString::Format(_("Load Wii System Menu %d%c"), sysmenuVersion, sysmenuRegion));
}
}
}
}

View File

@ -94,7 +94,6 @@ enum
IDM_PROPERTIES,
IDM_GAMEWIKI,
IDM_LOAD_WII_MENU,
IDM_INSTALL_WII_MENU,
IDM_CONNECT_WIIMOTE1,
IDM_CONNECT_WIIMOTE2,
IDM_CONNECT_WIIMOTE3,

View File

@ -7,6 +7,7 @@
#include <ws2tcpip.h>
#define sock_t SOCKET
#define ERRNO WSAGetLastError()
#undef EWOULDBLOCK
#define EWOULDBLOCK WSAEWOULDBLOCK
#define BAD_SOCK INVALID_SOCKET
#define close(x) closesocket(x)