Move the cdb.vff file creation out of the wx code

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7293 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99 2011-03-05 05:47:16 +00:00
parent 278cb45eb9
commit a037ff2358
3 changed files with 30 additions and 21 deletions

View File

@ -49,6 +49,33 @@ std::string HLE_IPC_BuildFilename(const char* _pFilename, int _size)
return path_full;
}
void HLE_IPC_CreateVirtualFATFilesystem()
{
const std::string cdbPath = Common::CreateTitleDataPath(TITLEID_SYSMENU) + "/cdb.vff";
if (!File::Exists(cdbPath))
{
// cdb.vff is a virtual Fat filesystem created on first launch of sysmenu
// we create it here as it is faster ~3 minutes for me when sysmenu does it ~1 second created here
u8 cdbHDR[0x20] = {'V', 'F', 'F', 0x20, 0xfe, 0xff, 1, 0, 1, 0x40, 0, 0, 0, 0x20};
u8 cdbFAT[4] = {0xf0, 0xff, 0xff, 0xff};
FILE * cdbFile = fopen(cdbPath.c_str(), "wb");
if (cdbFile)
{
bool success = true;
if (fwrite(cdbHDR, 0x20, 1, cdbFile) != 1) success = false;
if (fwrite(cdbFAT, 0x4, 1, cdbFile) != 1) success = false;
fseeko(cdbFile, 0x14020, SEEK_SET);
if (fwrite(cdbFAT, 0x4, 1, cdbFile) != 1)success = false;
// 20 MiB file
fseeko(cdbFile, 0x01400000 - 1, SEEK_SET);
// write the final 0 to 0 file from the second FAT to 20 MiB
if (fwrite(cdbHDR+14, 1, 1, cdbFile) != 1) success = false;
fclose(cdbFile);
if (!success) File::Delete(cdbPath);
}
}
}
CWII_IPC_HLE_Device_FileIO::CWII_IPC_HLE_Device_FileIO(u32 _DeviceID, const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName, false) // not a real hardware
, m_pFileHandle(NULL)

View File

@ -21,6 +21,7 @@
#include "WII_IPC_HLE_Device.h"
std::string HLE_IPC_BuildFilename(const char* _pFilename, int _size);
void HLE_IPC_CreateVirtualFATFilesystem();
class CWII_IPC_HLE_Device_FileIO : public IWII_IPC_HLE_Device
{

View File

@ -63,6 +63,7 @@ Core::GetWindowHandle().
#include "HW/GCPad.h"
#include "HW/Wiimote.h"
#include "IPC_HLE/WII_IPC_HLE_Device_usb.h"
#include "IPC_HLE/WII_IPC_HLE_Device_FileIO.h"
#include "State.h"
#include "VolumeHandler.h"
#include "NANDContentLoader.h"
@ -1310,27 +1311,7 @@ void CFrame::OnLoadWiiMenu(wxCommandEvent& event)
{
if (event.GetId() == IDM_LOAD_WII_MENU)
{
const std::string cdbPath = Common::CreateTitleDataPath(TITLEID_SYSMENU) + "/cdb.vff";
if (!File::Exists(cdbPath))
{
// cdb.vff is a virtual Fat filesystem created on first launch of sysmenu
// we create it here as it is faster ~3 minutes for me when sysmenu does it ~1 second created here
u8 cdbHDR[0x20] = {'V', 'F', 'F', 0x20, 0xfe, 0xff, 1, 0, 1, 0x40, 0, 0, 0, 0x20};
u8 cdbFAT[4] = {0xf0, 0xff, 0xff, 0xff};
FILE * cdbFile = fopen(cdbPath.c_str(), "wb");
if (cdbFile)
{
bool success = true;
if (fwrite(cdbHDR, 0x20, 1, cdbFile) != 1) success = false;
if (fwrite(cdbFAT, 0x4, 1, cdbFile) != 1) success = false;
fseeko(cdbFile, 0x14020, SEEK_SET);
if (fwrite(cdbFAT, 0x4, 1, cdbFile) != 1)success = false;
fseeko(cdbFile, 0x01400000 - 1, SEEK_SET); // 20 MiB file
if (fwrite(cdbHDR+14, 1, 1, cdbFile) != 1) success = false; // write the final 0 to 0 file from the second FAT to 20 MiB
fclose(cdbFile);
if (!success) File::Delete(cdbPath);
}
}
HLE_IPC_CreateVirtualFATFilesystem();
BootGame(Common::CreateTitleContentPath(TITLEID_SYSMENU));
}
else