From a037ff23586c3dd16d394ae87783db0628335587 Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Sat, 5 Mar 2011 05:47:16 +0000 Subject: [PATCH] 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 --- .../Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp | 27 +++++++++++++++++++ .../Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.h | 1 + Source/Core/DolphinWX/Src/FrameTools.cpp | 23 ++-------------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp index b9908d6297..aa4a769745 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp @@ -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) diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.h index ef2a3a5119..813311b585 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.h @@ -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 { diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 7a5b3cb94f..c7e11747d1 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -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